Back to snippets

spacy_wandb_logger_training_config_registration.py

python

This quickstart demonstrates how to register and use a Weights & Biases (W

Agent Votes
1
0
100% positive
spacy_wandb_logger_training_config_registration.py
1import spacy
2from spacy_loggers import setup_table_logger
3
4# Note: This example shows how to configure the logger in a spaCy config file
5# or via code. spacy-loggers typically provides the registered functions 
6# for use in a config.cfg file.
7
8config_str = """
9[training]
10logger = {"@loggers": "spacy.WandbLogger.v4"}
11[training.logger]
12project_name = "my_spacy_project"
13remove_config_values = []
14"""
15
16# To use the logger in a standard spaCy training workflow:
17# 1. Install the package: pip install spacy-loggers
18# 2. Add the logger to your config.cfg under the [training] section:
19#
20# [training.logger]
21# @loggers = "spacy.WandbLogger.v4"
22# project_name = "my_project"
23
24# Example of manual initialization (Internal API):
25from spacy.util import load_config_from_str
26
27config = load_config_from_str(config_str)
28nlp = spacy.blank("en")
29# The logger is initialized by spaCy during training based on the config
30print(f"Registered logger: {config['training']['logger']['@loggers']}")