Skip to main content

trieval

RAG evaluation with exactly 6 metrics. Nothing more.

Every RAG system has 3 variables: Q (Question), C (Context), A (Answer).

3 variables → 6 pairwise relationships → 6 metrics.

The 6 Metrics

# Metric Notation Evaluates
1 Context Relevance C|Q Is the retrieved context relevant to the question?
2 Faithfulness A|C Does the answer stick to the context?
3 Answer Relevance A|Q Does the answer solve the user's question?
4 Context Support C|A Does the context fully support the answer?
5 Answerability Q|C Can this question be answered with this context?
6 Self-Containment Q|A Can someone understand the question from the answer?

Install

pip install trieval

Quick Start

from trieval import Evaluator

evaluator = Evaluator(model="openai:gpt-4o-mini")
result = await evaluator.evaluate(
    question="What is photosynthesis?",
    context="Photosynthesis is the process by which plants convert sunlight into energy.",
    answer="Photosynthesis is how plants make food from sunlight.",
)

print(result.overall_score)       # 0.0–1.0
print(result.retrieval_score)     # avg of C|Q + Q|C
print(result.generation_score)    # avg of A|C + A|Q
print(result.diagnose())          # ["All metrics healthy"] or failure categories

Failure Diagnosis

When your RAG system fails, it's always one of these:

  • Retrieval issues — C|Q and Q|C scores are low (wrong context retrieved)
  • Generation issues — A|C and A|Q scores are low (bad answer generation)
  • End-to-end mismatch — A|C is fine but C|A is low (faithful but unsupported)

Architecture

Built with pydantic-ai (LLM-based metric agents) and LangGraph (evaluation workflow orchestration).

RAGInput(Q, C, A)
    ↓
Evaluator.evaluate()
    ↓
LangGraph: evaluate_metrics → diagnose_failures
    ↓
EvaluationResult (scores + diagnosis)

Each metric is a pydantic-ai Agent with a tailored system prompt. All 6 run concurrently via asyncio.gather inside the LangGraph evaluation node.

Development

uv sync --group dev
pytest                                    # run tests
pytest --cov=trieval --cov-branch         # with coverage
ruff check trieval/ tests/                # lint
ruff format trieval/ tests/               # format
mypy trieval/                             # type check

Documentation

  • API Reference — Full API for Evaluator, EvaluationResult, MetricResult, RAGInput, and individual metric functions
  • Changelog — Version history

License

MIT

Metadata

Release files for trieval 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trieval 0.0.1
File Size Uploaded Provenance Actions
trieval-0.0.1.tar.gz 10.6 kB Without provenance Details for trieval-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for trieval 0.0.1
File Interpreter ABI Platform Actions
trieval-0.0.1-py3-none-any.whl Python 3 none any Details for trieval-0.0.1-py3-none-any.whl

Total release size: 23.0 kB

Release files / trieval-0.0.1.tar.gz

Download URL trieval-0.0.1.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
73b54b26ff32a18cb935ddd51642746ee86b5a3bab3f93032e4b394bfb4a8e59
BLAKE2b-256 checksum
How to use checksums
7139739d86c529dbbaeb102fb3935e8dffefc2d960556d8debfcf6d999e7e00e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.2

Release files / trieval-0.0.1-py3-none-any.whl

Download URL trieval-0.0.1-py3-none-any.whl
Size 12.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1f0d56c3a325d195660680a25720b7699718eeb4b0035c118963f81b02847bdb
BLAKE2b-256 checksum
How to use checksums
0d9e5878f374fefdb92a19d6294eb622c6d783505146b83f7e723183c4539e5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.2

Security for trieval 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page