Skip to main content

Installation

Fair Forge uses a modular dependency system, allowing you to install only the components you need.

Requirements

  • Python 3.10 or higher
  • uv (recommended) or pip

Basic Installation

uv pip install alquimia-fair-forge

Optional Dependencies

Fair Forge provides optional dependency groups for each metric and feature:

Metrics

ExtraDescriptionDependencies
toxicityToxicity metric with clusteringsentence-transformers, hdbscan, umap-learn
biasBias metric with guardian modelsopenai, transformers
contextContext metric with LLM judgelangchain-core
conversationalConversational metriclangchain-core
humanityHumanity metric with NRC lexicon(included in core)
bestofBestOf tournament metriclangchain-core

Features

ExtraDescriptionDependencies
generatorsSynthetic dataset generationlangchain-core, transformers
generators-alquimiaGenerators with Alquimia supportlangchain-core, transformers
runnersTest execution runnershttpx, asyncio
cloudCloud storage backendslakefs-sdk

Combined Extras

ExtraDescription
allAll metrics and features
devDevelopment dependencies (pytest, ruff, mypy)

Installation Examples

# Install with toxicity metric support
uv pip install "alquimia-fair-forge[toxicity]"

LLM Provider Dependencies

Several metrics require LangChain-compatible chat models. Install your preferred provider:
uv pip install langchain-groq

Development Installation

For contributing to Fair Forge:
# Clone the repository
git clone https://github.com/Alquimia-ai/fair-forge.git
cd fair-forge

# Install with development dependencies
uv sync

# Run tests
uv run pytest

# Run linting
uv run ruff check .
uv run ruff format .

# Run type checking
uv run mypy fair_forge

Verifying Installation

import fair_forge

# Check version
print(f"Fair Forge version: {fair_forge.__version__}")

# Verify imports
from fair_forge.metrics.toxicity import Toxicity
from fair_forge.core.retriever import Retriever
from fair_forge.schemas.common import Dataset, Batch

print("Installation successful!")

Troubleshooting

Install the toxicity extras:
uv pip install "alquimia-fair-forge[toxicity]"
Install your preferred LLM provider:
uv pip install langchain-groq
For CPU-only installation:
uv pip install torch --index-url https://download.pytorch.org/whl/cpu
uv pip install "alquimia-fair-forge[toxicity]"
Ensure you’re using Python 3.10+:
python --version
# If needed, use pyenv to install a compatible version
pyenv install 3.11.0
pyenv local 3.11.0

Next Steps