Skip to content
/ artifex Public

A Python library to train task-specific LLMs without training data, for offline NLP and Text Classification tasks, such as Guardrail Models and Intent Classification πŸ€–πŸš€

License

Notifications You must be signed in to change notification settings

tanaos/artifex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

26 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Artifex

Artifex – Train task specific LLMs without training data, for offline NLP and Text Classification

Documentation | Tutorial

Artifex – Latest PyPi package version Artifex – Tests status Artifex – GitHub commit activity Artifex – Documentation

🎯 Create Task-Specific LLMs β€’ πŸ“Š No training data needed β€’ 🌱 No GPU needed β€’ πŸ–₯️ Perform offline NLP


Artifex is a Python library to create small, task-specific LLMs to perform offline NLP and text classification tasks without training data.

Examples of offline NLP tasks you can perform with models created by Artifex include:

  • πŸ›‘οΈ Guardrail Model: Flags unsafe, harmful, or off-topic messages.
  • πŸ—£οΈ Intent Classification: Classify user intents based on their messages.

We will be adding more tasks soon, based on user feedback. Want Artifex to perform a specific task? Suggest one or vote one up.

πŸ”₯ Why Artifex?

  • 🎯 Create Task-Specific LLMs: General-purpose LLMs are designed for open-ended tasks, but Artifex allows you to create models tailored to specific use cases.
  • πŸ“Š No training data needed: Uses synthetic data generation under the hood.
  • 🌱 No GPU needed: All models are designed to run efficiently on CPU.
  • πŸ’Έ Reduce your LLM API bills: Offload tasks to offline task-specific models and reduce the number of paid API calls to general-purpose LLMs.
  • πŸ”§ Prebuilt templates for common tasks:

πŸš€ Quick Start

Install Artifex with:

pip install artifex

πŸ›‘οΈ Create a Guardrail Model

Create an offline chatbot guardrail model model with Artifex and integrate it into your chatbot in 2 simple steps:

1. Train a guardrail model based on your requirements:

from artifex import Artifex

guardrail = Artifex().guardrail

guardrail.train(
    instructions=[
        "Soft medical advice is allowed, but it should be general and not specific to any individual.",
        "Anything that is about cosmetic products, including available products or their usage, is allowed.",
        "Anything else, including hard medical advice, is not allowed under any circumstances.",
    ]
)

➑️ Model will be saved by default to artifex_output/run-<timestamp>/output_model/

2. Replace your chatbot's guardrail-related API calls with calls to your new local guardrail model:

"""
🚫 Instead of calling the OpenAI (or any other) API to check if a message is safe:
"""

# response = openai.ChatCompletion.create(...)
# is_safe = response.choices[0].message.content

"""
βœ… Load your local guardrail model (assuming it was generated in the default 
'artifex_output/run-<timestamp>/output_model/' directory) and use it instead:
"""

guardrail = Artifex().guardrail

guardrail.load("artifex_output/run-<timestamp>/output_model/")

is_safe = guardrail(user_message)

(Optional) 3. Not satisfied with the model's performance? Is it getting some edge-cases wrong? Just keep training it!

guardrail = Artifex().guardrail

guardrail.load("artifex_output/run-<timestamp>/output_model/")

guardrail.train(
    instructions=[
        "While soft medical advice is allowed, saying that 'you should take X medication' is not allowed.",
        "While discussing cosmetic products is allowed, recommending a competitor's product is not.",
    ]
)

πŸ—£οΈ Create an Intent Classification model

1. Train an intent classification model based on your requirements:

from artifex import Artifex

intent_classifier = Artifex().intent_classifier

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.",
    }
)

2. Use your new local intent classification model to classify user messages:

label = intent_classifier("I forgot to set up that meeting with John, could you do that for me?")
print(label)

# >>> ["schedule_meeting"]

πŸ”— More Examples & Demos

Guardrail Model

  1. Tutorial β€” create a Guardrail Model with Artifex
  2. Demo β€” try a Guardrail Model trained with Artifex
  3. HF page β€” see a Guardrail Model trained with Artifex

Intent Classification Model

  1. Tutorial β€” create an Intent Classification Model with Artifex

πŸ”‘ Plans

Free plan: each user enjoys 1500 training datapoints per month and 500 training datapoints per job for free; this is enough to train 3-5 models per month for free.

Pay-as-you-go: for additional usage beyond the free plan:

  1. create an account on our platform
  2. add credits to it
  3. create an Api Key and pass it to Artifex at instantiation, then use it normally:
    from artifex import Artifex
    
    guardrail = Artifex(api_key="<your-api-key>").guardrail
    The pay-as-you-go pricing is 1$ per 100 datapoints. Once you finish your credits, if you have not exceeded the monthly limit, you will be automatically switched to the free plan.

Find out more about our plans on the Tanaos documentation.

🀝 Contributing

Contributions are welcome! Whether it's a new task module, improvement, or bug fix β€” we’d love your help. Not ready to contribute code? You can also help by suggesting a new task or voting up any suggestion.

git clone https://github.com/tanaos/artifex.git
cd artifex
pip install -e .

πŸ“š Documentation & Support

About

A Python library to train task-specific LLMs without training data, for offline NLP and Text Classification tasks, such as Guardrail Models and Intent Classification πŸ€–πŸš€

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages