Skip to main content

Alquimia Fair Forge library - Performance measurement for AI models and assistants

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

Fair Forge

Alquimia AI

Performance-measurement library for evaluating AI models and assistants

CI PyPI Python Versions License

DocumentationGitHub

What is Fair Forge?

Fair Forge provides comprehensive metrics for evaluating AI systems:

  • Toxicity - Detect toxic language patterns with DIDT fairness framework
  • Bias - Analyze biases across protected attributes (gender, race, religion, etc.)
  • Context - Assess how well responses align with provided context
  • Conversational - Evaluate dialogue quality using Grice's maxims
  • Humanity - Measure how natural responses are through emotional analysis
  • BestOf - Tournament-style comparison to find the best response
  • Explainability - Compute token attributions to understand model decisions

Quick Start

# Install with pip
pip install alquimia-fair-forge

# Or install specific modules
pip install "alquimia-fair-forge[toxicity]"
pip install "alquimia-fair-forge[bias]"
pip install "alquimia-fair-forge[explainability]"
pip install "alquimia-fair-forge[all]"
from fair_forge import Retriever, Dataset
from fair_forge.metrics.toxicity import Toxicity

class MyRetriever(Retriever):
    def load_dataset(self) -> list[Dataset]:
        # Load your dataset here
        pass

metrics = Toxicity.run(MyRetriever, verbose=True)

Explainability

from transformers import AutoModelForCausalLM, AutoTokenizer
from fair_forge.explainability import AttributionExplainer, Lime

model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-0.6B")
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-0.6B")

# Format prompt according to your model (user responsibility)
messages = [{"role": "user", "content": "What is gravity?"}]
prompt = tokenizer.apply_chat_template(messages, tokenize=False)

explainer = AttributionExplainer(model, tokenizer)
result = explainer.explain(
    prompt=prompt,
    target="Gravity is the force of attraction between objects.",
    method=Lime,  # Pass the method class directly
)

# Get most important words
for attr in result.get_top_k(5):
    print(f"'{attr.text}': {attr.score:.4f}")

Documentation

For complete documentation, guides, and API reference visit:

https://fairforge.alquimia.ai

License

MIT License - see LICENSE for details.

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

alquimia_fair_forge-1.2.0b3.tar.gz (775.0 kB view details)

Uploaded Source

Built Distribution

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

alquimia_fair_forge-1.2.0b3-py3-none-any.whl (799.0 kB view details)

Uploaded Python 3

File details

Details for the file alquimia_fair_forge-1.2.0b3.tar.gz.

File metadata

  • Download URL: alquimia_fair_forge-1.2.0b3.tar.gz
  • Upload date:
  • Size: 775.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for alquimia_fair_forge-1.2.0b3.tar.gz
Algorithm Hash digest
SHA256 19fdb84e0a97457726f74118edfe3ead0542219074e577ebb1746c103c521f92
MD5 2db630927c28ddf926a71938b3c39acd
BLAKE2b-256 dd7c15539659bad63829bcee351d0f27cfbe13516538961b95d1a77925e176a8

See more details on using hashes here.

File details

Details for the file alquimia_fair_forge-1.2.0b3-py3-none-any.whl.

File metadata

  • Download URL: alquimia_fair_forge-1.2.0b3-py3-none-any.whl
  • Upload date:
  • Size: 799.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for alquimia_fair_forge-1.2.0b3-py3-none-any.whl
Algorithm Hash digest
SHA256 fef7a9ee7df033d6804a536497f90ece266e69e593187f474b9700707ece6764
MD5 75e63e463e8c37eb8b426f5ad29ba715
BLAKE2b-256 a1bdd39b612acb3075ebebd9522f8ced137cf6fc86ad77c9701ecf399b8f43e2

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