Skip to main content

Create your private AI model with no training data or GPUs 🤖🚀.

Project description

Artifex

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

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

Create Task-Specific SLMs • No training data needed • No GPU needed • CPU Inference & Fine-Tuning


Artifex is a Python library for:

  1. Using pre-trained task-specific Small Language Models on CPU
  2. Fine-tuning them on CPU without any training data — just based on your instructions for the task at hand.
    How is it possible? Artifex generates synthetic training data on-the-fly based on your instructions, and uses this data to fine-tune small LLMs for your specific task. This approach allows you to create effective models without the need for large labeled datasets.

At this time, we support 8 tasks:

  • Text Classification: Classifies text into user-defined categories.
  • Guardrail: Flags unsafe, harmful, or off-topic messages.
  • Intent Classification: Classifies user messages into predefined intent categories.
  • Reranker: Ranks a list of items or search results based on relevance to a query.
  • Sentiment Analysis: Determines the sentiment (positive, negative, neutral) of a given text.
  • Emotion Detection: Identifies the emotion expressed in a given text.
  • Named Entity Recognition (NER): Detects and classifies named entities in text (e.g., persons, organizations, locations).
  • Text Anonymization: Removes personally identifiable information (PII) from text.

For each task, Artifex provides three easy-to-use APIs:

  1. Inference API to use a default, pre-trained small LLM to perform that task out-of-the-box locally on CPU.
  2. Fine-tune API to fine-tune the default model based on your requirements, without any training data and on CPU. The fine-tuned model is generated on your machine and is yours to keep.
  3. Load API to load your fine-tuned model locally on CPU, and use it for inference or further fine-tuning.

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

Use Cases & Tutorials

Quick Start

Install Artifex with:

pip install artifex

Text Classification model

Create & use a custom Text Classification model

Train your own text classification model, use it locally on CPU and keep it forever:

from artifex import Artifex

model_output_path = "./output_model/"

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

text_classification.load(model_output_path)

print(text_classification("What do you think about the latest AI advancements?"))

# >>> [{'label': 'technology', 'score': 0.9913}]

Guardrail Model

Use the default Guardrail model

Use Artifex's default guardrail model, which is trained to flag unsafe or harmful messages out-of-the-box:

from artifex import Artifex

guardrail = Artifex().guardrail
print(guardrail("How do I make a bomb?"))

# >>> [{'label': 'unsafe', 'score': 0.9976}]

Learn more about the default guardrail model and what it considers safe vs unsafe on our Guarderail HF model page.

Create & use a custom Guardrail model

Need more control over what is considered safe vs unsafe? Fine-tune your own guardrail model, use it locally on CPU and keep it forever:

from artifex import Artifex

guardrail = Artifex().guardrail

model_output_path = "./output_model/"

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

guardrail.load(model_output_path)
print(guardrail("Does your competitor offer discounts on their products?"))

# >>> [{'label': 'unsafe', 'score': 0.9970}]

Reranker model

Use the default Reranker model

Use Artifex's default reranker model, which is trained to rank items based on relevance out-of-the-box:

from artifex import Artifex

reranker = Artifex().reranker

print(reranker(
    query="Best programming language for data science",
    documents=[
        "Java is a versatile language typically used for building large-scale applications.",
        "Python is widely used for data science due to its simplicity and extensive libraries.",
        "JavaScript is primarily used for web development.",
    ]
))

# >>> [('Python is widely used for data science due to its simplicity and extensive libraries.', 3.8346), ('Java is a versatile language typically used for building large-scale applications.', -0.8301), ('JavaScript is primarily used for web development.', -1.3784)]

Create & use a custom Reranker model

Want to fine-tune the Reranker model on a specific domain for better accuracy? Fine-tune your own reranker model, use it locally on CPU and keep it forever:

from artifex import Artifex

reranker = Artifex().reranker

model_output_path = "./output_model/"

reranker.train(
    domain="e-commerce product search",
    output_path=model_output_path
)

reranker.load(model_output_path)
print(reranker(
    query="Laptop with long battery life",
    documents=[
        "A powerful gaming laptop with high-end graphics and performance.",
        "An affordable laptop suitable for basic tasks and web browsing.",
        "This laptop features a battery life of up to 12 hours, perfect for all-day use.",
    ]
))

# >>> [('This laptop features a battery life of up to 12 hours, perfect for all-day use.', 4.7381), ('A powerful gaming laptop with high-end graphics and performance.', -1.8824), ('An affordable laptop suitable for basic tasks and web browsing.', -2.7585)]

Other Tasks

For more details and examples on how to use Artifex for the other available tasks, check out the Available Tasks section below and our Documentation.

Available Tasks & Examples

All models displayed below can be used out-of-the-box on CPU and can be fine-tuned on CPU.

Task Default Model Default & Fine-Tuned Model Size Code Examples
Text Classification No default model — must be trained 0.1B params, 470Mb Examples
Guardrail tanaos/tanaos-guardrail-v1 0.1B params, 500Mb Examples
Intent Classification tanaos/tanaos-intent-classifier-v1 0.1B params, 500Mb Examples
Reranker cross-encoder/mmarco-mMiniLMv2-L12-H384-v1 0.1B params, 470Mb Examples
Sentiment Analysis tanaos/tanaos-sentiment-analysis-v1 0.1B params, 470Mb Examples
Emotion Detection tanaos/tanaos-emotion-detection-v1 0.1B params, 470Mb Examples
Named Entity Recognition tanaos/tanaos-NER-v1 0.1B params, 500Mb Examples
Text Anonymization tanaos/tanaos-text-anonymizer-v1 0.1B params, 500Mb Examples

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 .

Before making a contribution, please review the CONTRIBUTING.md and CLA.md, which include important guidelines for contributing to the project.

FAQs

  • Why having Guardrail, Intent Classification, Emotion Detection, Sentiment Analysis etc. as separate tasks, if you already have a Text Classification task? The Text Classification task is a general-purpose task that allows users to create custom classification models based on their specific needs. Guardrail, Intent Classification, Emotion Detection, Sentiment Analysis etc. are specialized tasks with pre-defined categories and behaviors that are commonly used in various applications. They are provided as separate tasks for two reasons: first, convenience (users can quickly use these models without needing to define their own categories); second, performance (the specialized model typically performs better than re-defining the same model through the general Text Classification model).

Documentation & Support

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

artifex-0.4.1.tar.gz (1.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

artifex-0.4.1-py3-none-any.whl (856.6 kB view details)

Uploaded Python 3

File details

Details for the file artifex-0.4.1.tar.gz.

File metadata

  • Download URL: artifex-0.4.1.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for artifex-0.4.1.tar.gz
Algorithm Hash digest
SHA256 327269a44b3ff2e4daf9777747fd3fa7073498da6bc69765a12121574b9555ec
MD5 6eceb60d9b2bc666aa442f61ca453efc
BLAKE2b-256 c8a84fe66f53fc458a122a404dfc6e52c9077110151fec21a541fc6a7034a1dd

See more details on using hashes here.

File details

Details for the file artifex-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: artifex-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 856.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for artifex-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4d0f3065785c2ce6acb4e3a6707a9e59c272e64c9e8ecc775152bbfa3db60a67
MD5 84990f6bd4ef03e92b028d62acd9c1d8
BLAKE2b-256 1b56130e08636acdb04142cd3a1ea8d6547d2e3c337abce445592567b69c5e59

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page