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

guardrail.train()

Fine-tunes a pre-trained Guardrail model on user-specified instructions. 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 instructions.

Both the base Guardrail model tanaos/tanaos-guardrail-v1 and previously trained models can be further trained using this method:

  • Fine-tune the base Guardrail model:
    Artifex().guardrail.train()
  • Fine-tune a model that was previously trained with Artifex, in order to train it further:
    Artifex().guardrail.load("trained/model/path").train()

Arguments


  • unsafe_content
    list[str]

    A list of strings, where each string describes a type of content that should be classified as "unsafe" by the guardrail.
  • 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

guardrail = Artifex().guardrail

guardrail.train(
unsafe_content=[
"Discussing a competitor's products or services.",
"Sharing our employees' personal information.",
"Providing instructions for illegal activities.",
]
)
None