Skip to main content
Do you like Artifex? Give it a ⭐ star on GitHub!

Train an Intent Classification Model

Train an Intent Classification Model. 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 requirements.

Training can be performed on both:

  • An untrained base model:

    Artifex().intent_classifier.train()
  • A model that was previously trained with Artifex, in order to train it further:

    Artifex().intent_classifier.load("trained/model/path").train()

    For more information on the load() method, see the load() method documentation.

Arguments


  • classes
    dict[str, str]

    A dictionary, where each key is the name of an intent (must be maximum 10 characters with no spaces), and each value is the description of that intent.
  • output_path
    str
    optional

    A string which specifies the path where the output files will be generated. The output files consist of:
    • The training dataset
    • The output model safetensor and configuration files
  • num_samples
    int
    optional
    default: 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
    str
    optional
    default: 3

    An integer which specifies the number of epochs to train the model for.
from artifex import Artifex

intent_classifier = Artifex().intent_classifier

"""
If you want to fine-tune an already trained model,
load it first:

intent_classifier.load("path/to/trained/model")
"""

intent_classifier.train(
classes={
"send_email": "Intent to send an email to someone.",
"schedule_meeting": "Intent to schedule a meeting with someone.",
"cancel_meeting": "Intent to cancel a previously scheduled meeting.",
"reschedule_meeting": "Intent to change the date or time of a previously scheduled meeting.",
}
)
None