Skip to content

Integrate with spaCy

spaCy is a library for training advanced NLP models for use cases such as tagging, parsing, named entity recognition, text classification, and more.

Start Logging

Connect Comet to your existing code by using the spaCy Comet logger, here is an example configuration file:

@loggers = "comet_ml.spacy.logger.v1"

Log automatically

By default, Comet will log the following items:

  • Metrics
    • The metrics defined in the project .cfg file
  • Parameters
    • hyper-parameters defined in the project .cfg file
  • Model
    • the best-performing model

End-to-end example

Following is a basic example of using Comet with spaCy.

Install dependencies

pip install 'comet_ml>=3.31.19' spacy

Download example project

spacy project clone pipelines/tagger_parser_ud
spacy project assets tagger_parser_ud

Login to Comet

There are two ways to configure Comet

You can either set your credentials through environment variables

Environment Variables

export COMET_API_KEY=<Your Comet API Key>
export COMET_PROJECT_NAME=<Your Comet Project Name>

Or create a .comet.config file in your working directory and set your credentials there.

Comet Configuration File

api_key=<Your Comet API Key>
project_name=<Your Comet Project Name>

Configure Comet as your logger

Logging in spaCy is defined in the projects training.logger in the project configs/default.cfg file, replace the section [training.logger] with:

@loggers = "comet_ml.spacy.logger.v1"
workspace = "your_workspace"
project_name = "your_project_name"
tags = ["your_tags"]
remove_config_values = ["paths.train", "", "corpora.train.path", ""]

Run your spaCy Training Pipeline

spacy project run all tagger_parser_ud
Jun. 5, 2024