Universe

Classy Classification

Have you ever struggled with needing a spaCy TextCategorizer but didn't have the time to train one from scratch? Classy Classification is the way to go!

spaCy v3

Have you ever struggled with needing a spaCy TextCategorizer but didn't have the time to train one from scratch? Classy Classification is the way to go! For few-shot classification using sentence-transformers or spaCy models, provide a dictionary with labels and examples, or just provide a list of labels for zero shot-classification with Huggingface zero-shot classifiers.

Example

import spacy import classy_classification data = { "furniture": ["This text is about chairs.", "Couches, benches and televisions.", "I really need to get a new sofa."], "kitchen": ["There also exist things like fridges.", "I hope to be getting a new stove today.", "Do you also have some ovens."] } # see github repo for examples on sentence-transformers and Huggingface nlp = spacy.load('en_core_web_md') nlp.add_pipe("text_categorizer", config={ "data": data, "model": "spacy" } ) print(nlp("I am looking for kitchen appliances.")._.cats) # Output: # # [{"label": "furniture", "score": 0.21}, {"label": "kitchen", "score": 0.79}]
Author info

David Berenstein

GitHubdavidberenstein1957/classy-classification

Categories pipeline standalone

Found a mistake or something isn't working?

If you've come across a universe project that isn't working or is incompatible with the reported spaCy version, let us know by opening a discussion thread.


Submit your project

If you have a project that you want the spaCy community to make use of, you can suggest it by submitting a pull request to the spaCy website repository. The Universe database is open-source and collected in a simple JSON file. For more details on the formats and available fields, see the documentation. Looking for inspiration your own spaCy plugin or extension? Check out the project idea label on the issue tracker.

Read the docsJSON source