Skip to main content

No project description provided

Project description

Relari Evaluation Tookit

Requirements

Installation

poetry install

Usage

Before being able to use the evaluation toolkit, you need to export the API key

export RELARI_API_KEY=<your_api_key>

To run the evaluation toolkit, you then need to define the evaluation pipeline

dataset = Dataset("<path_to_dataset>")

retriever = Module(
    name="retriever",
    input=dataset.question,
    output=List[Dict[str, str]],
)

reranker = Module(
    name="reranker",
    input=retriever,
    output=List[Dict[str, str]],
)

llm = Module(
    name="llm",
    input=reranker,
    output=str,
)

pipeline = Pipeline([retriever, reranker, llm], dataset=dataset)

this will inform the evaluator about the modules and the dataset you want to use.

Suppose you have three functions retrieve, rerank, and ask that implement the threes steps of the pipeline. You can then use the ralari evaluation toolkit as follows:

from relari.eval.manager import eval_manager
from relari import RelariClient

client = RelariClient()

eval_manager.set_pipeline(pipeline)
eval_manager.set_metadata({"name": "SimpleRAG"})
with eval_manager.new_experiment as experiment:
  for sample in experiment:
    q = eval_manager.curr_sample["question"]
    # Run and log Retriever results
    retrieved_docs = retrieve(q)  # Your retrieve function
    eval_manager.log("retriever", [doc.__dict__ for doc in retrieved_docs])
    # Run and log Reranker results
    reranked_docs = rerank(q, retrieved_docs) # Your rerank function
    eval_manager.log("reranker", [doc.__dict__ for doc in reranked_docs])
    # Run and log Generator results
    response = ask(q, reranked_docs) # Your answer generation function
    eval_manager.log("llm", response)
    print(f"Q: {q}\nA: {response}\n")

eval_manager.evaluation.save(Path("results.jsonl"))
client.start_remote_evaluation()

This will run the evaluation pipeline on the dataset and log the results to the Relari API.

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

relari-0.1.4.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

relari-0.1.4-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file relari-0.1.4.tar.gz.

File metadata

  • Download URL: relari-0.1.4.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.2 Darwin/23.1.0

File hashes

Hashes for relari-0.1.4.tar.gz
Algorithm Hash digest
SHA256 8c3abed39d1e83ed29181322dad1585aa2eab3881a9e3ddf32c5bcc09289c522
MD5 b080d7ab0400b22c7465a18f714e69e1
BLAKE2b-256 67f77451d6f365a462d719d6137ea9a95fcd984ab9531ed5386ff63b7ae7db02

See more details on using hashes here.

File details

Details for the file relari-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: relari-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.2 Darwin/23.1.0

File hashes

Hashes for relari-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f63057679db9fa2ddd353a385a280ede1d21ed0f207f4cc57ed6c554a4a7ed8a
MD5 ccacf1c58e68555b0ed550834333f853
BLAKE2b-256 38df3c6380193a08436683c03e09a67ddd2ae177f218b1f4beedaa0075447e9a

See more details on using hashes here.

Supported by

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