Skip to main content

Small Language Model Inference, Fine-Tuning, Evaluation and Observability.

Project description

Artifex

Artifex – Train task specific Small Language Models 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

Small Language Model Inference, Fine-Tuning and Observability. No GPU, no labeled data needed.


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 Language Models for your specific task. This approach allows you to create effective models without the need for large labeled datasets.
  3. Tracking model performance locally with built-in evaluation and monitoring tools.

Why Artifex?

Modern AI workflows are often

  • Expensive (API usage, GPUs)
  • Dependent on third-parties
  • Data-hungry (require large labeled datasets)

Artifex changes that:

  • Run tiny models locally on CPU (100M params, 500MB)
  • Keep all data private (no API required)
  • Generate synthetic data automatically for fine-tuning
  • Fine-tune models for specific tasks (moderation, NER, classification, etc.)

Available Models & Tasks

At this time, Artifex supports the following models:

Task Available Languages Description Default Model How to use
Guardrail English, German, Spanish Flags unsafe, harmful, or off-topic messages. tanaos/tanaos-guardrail-v2 (English version, see the page for the other languages) Examples
Intent Classification English Classifies user messages into predefined intent categories. tanaos/tanaos-intent-classifier-v1 Examples
Reranker English Ranks a list of items or search results based on relevance to a query. cross-encoder/mmarco-mMiniLMv2-L12-H384-v1 Examples
Sentiment Analysis English Determines the sentiment (positive, negative, neutral) of a given text. tanaos/tanaos-sentiment-analysis-v1 Examples
Emotion Detection English Identifies the emotion expressed in a given text. tanaos/tanaos-emotion-detection-v1 Examples
Named Entity Recognition English Detects and classifies named entities in text (e.g., persons, organizations, locations). tanaos/tanaos-NER-v1 Examples
Text Anonymization English Removes personally identifiable information (PII) from text. tanaos/tanaos-text-anonymizer-v1 Examples
Spam Detection English, German, Spanish, Italian Identifies whether a message is spam or not. tanaos/tanaos-spam-detection-v1 (English version, see the page for the other languages) Examples
Topic Classification English Classifies text into predefined topics. tanaos/tanaos-topic-classification-v1 Examples
Text Summarization English Rewrites text in a more concise way. tanaos/tanaos-text-summarization-v1 Examples

Looking for models in other languages? Our Enterprise License includes models in any language. Reach out at info@tanaos.com for more details.

For each model, Artifex provides:

  1. Inference API to use a default, pre-trained Small Language Model 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.
  3. Load API to load your fine-tuned model locally on CPU, and use it for inference or further fine-tuning.
  4. Built-in, automatic evaluation and monitoring tools to track model performance over time, locally on your machine.

Quick Start

Install Artifex with:

pip install artifex

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?"))

# >>> [{'is_safe': False, 'scores': {'violence': 0.625, 'non_violent_unethical': 0.0066, 'hate_speech': 0.0082, 'financial_crime': 0.0072, 'discrimination': 0.0029, 'drug_weapons': 0.6633, 'self_harm': 0.0109, 'privacy': 0.003, 'sexual_content': 0.0029, 'child_abuse': 0.005, 'terrorism_organized_crime': 0.1278, 'hacking': 0.0096, 'animal_abuse': 0.009, 'jailbreak_prompt_inj': 0.0131}}]

Learn more about the default guardrail model and what it considers safe vs unsafe on our Guardrail 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_categories = {
        "violence": "Content describing or encouraging violent acts",
        "bullying": "Content involving harassment or intimidation of others",
        "misdemeanor": "Content involving minor criminal offenses",
        "vandalism": "Content involving deliberate destruction or damage to property"
    },
    output_path=model_output_path
)

guardrail.load(model_output_path)
print(guardrail("I want to destroy public property."))

# >>> [{'is_safe': False, 'scores': {'violence': 0.592, 'bullying': 0.0066, 'misdemeanor': 0.672, 'vandalism': 0.772}}]

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 our Documentation.

Monitoring, Evaluation & Observability

Artifex includes built-in tools to automatically monitor and evaluate the inference and training performance of your models over time. This logging is performed entirely on your machine. Monitoring and logging are crucial to ensure your models are performing as expected and to identify any potential issues early on. All logs are written automatically after every inference and training session in the artifex_logs/ folder in your current working directory.

Logs include operation-level metrics (e.g., inference duration, CPU & RAM usage, training loss, etc.), daily aggregated metrics and any errors encountered during inference or training. Additionally, warnings for potential issues (e.g., high inference duration, low confidence scores, high training loss, etc.) are logged in a separate warnings log file for easier identification and troubleshooting.

License, Paid & Enterprise solutions

Artifex is fair code distributed under the Sustainable Use License and Tanaos Enterprise License.

  • Source available: source code is always visible
  • Extensible: you can add your own models and functionalities

Enterprise licenses are available for additional features and support. Contact us at info@tanaos.com for more details. Enterprise features include:

  • Higher-Performance Models
    • Improved accuracy
    • Better handling of edge cases
    • Reduced false positives/negatives
  • Custom Models
    • Models fine-tuned on your specific data and requirements
    • Support for any language, domain or task
  • Production-Ready Models
    • Models trained on 1000x more data
    • 10x lower inference latency
  • Dedicated Support
    • Priority support
    • Custom feature requests
    • Dedicated onboarding and training

Additional information about license can be found in the docs.

Contributing

Contributions are welcome! Whether it's a bug fix or a new feature you want to add, we'd love your help. Check out our Contribution Guidelines to get started.

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.9.0.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.9.0-py3-none-any.whl (866.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for artifex-0.9.0.tar.gz
Algorithm Hash digest
SHA256 4d96030c53c70f26efb7d9848dc8cff62706d43b7ff2f3123ec1f4119cecdbc0
MD5 09075bdffcd2eac6fbfd07040d3b9c51
BLAKE2b-256 941e4d736ab4d8d9b33dad4ebb2f7e5afc2adc78280810f0998be6e11b411743

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for artifex-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2a127e86eb979127e9dbbb268f60598e8a89bcf24a5732f43aa37af45a22c220
MD5 750f543c8f03e855d41608b0634eb0da
BLAKE2b-256 460edc7ad056f6e70ea7722815a603181356b6639701cdc0171e4532b86941d8

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