text_classification.train()
Trains a Text Classification model on user-specified classes and domain.
No training data is needed, as the model uses
synthex.jobs.generate_data() under the
hood to generate a synthetic training dataset based on the provided classes and domain.
Info
Unlike most other tasks that can be performed with Artifex, Text Classification does not come with a pre-trained model that can be used out-of-the-box. This is because Text Classification is a general task that can be applied to a wide variety of domains and use-cases, each requiring different classes to be recognized. Therefore, users need to train their own Text Classification models using this method.
Arguments
- domain str
A string which specifies the domain or area that the model will be specialized in. - classes dict[str, str]
A dictionary, where each key is the name of a class (must be maximum 20 characters with no spaces), and each value is the description of that class. - output_path stroptional
A string which specifies the path where the output files will be generated. The output files consist of:- The training dataset
- The output model
safetensorand configuration files
- num_samples intoptionaldefault: 500
An integer which specifies the number of datapoints that the synthetic training dataset should consist of, and that the model will be trained on. The maximum number of datapoints you can train your model on depends on whether you are on a free or paid plan. - num_epochs stroptionaldefault: 3
An integer which specifies the number of epochs to train the model for.
- Python
from artifex import Artifex
text_classification = Artifex().text_classification
text_classification.train(
domain="chatbot conversations",
classes={
"politics": "Messages related to political topics and discussions.",
"sports": "Messages related to sports events and activities.",
"technology": "Messages about technology, gadgets, and software.",
"entertainment": "Messages about movies, music, and other entertainment forms.",
"health": "Messages related to health, wellness, and medical topics.",
}
)
- Response
None