Package: ragelo
Elo-based RAG Agent evaluatorRAGElo[^1] is a streamlined toolkit for evaluating Retrieval Augmented Generation (RAG)-powered Large Language Models (LLMs) question answering agents using the Elo rating system.While it has become easier to prototype and incorporate generative LLMs in production, evaluation is still the most challenging part of the solution. Comparing different outputs from multiple prompt and pipeline variations to a "gold standard" is not easy. Still, we can ask a powerful LLM to judge between pairs of answers and a set of questions.This led us to develop a simple tool for tournament-style Elo ranking of LLM outputs. By comparing answers from different RAG pipelines and prompts over multiple questions, RAGElo computes a ranking of the different settings, providing a good overview of what works (and what doesn't).⚙️ InstallationpipinstallrageloIf you want to use RAGElo as a standalone CLI app, use the[cli]tag:pipinstallragelo[cli]🚀 QuickstartAfter installing RAGElo as a CLI app, you can run it with the following command:ragelorun-allqueries.csvdocuments.csvanswers.csv

----------AgentScoresbyEloranking----------agent1:1026.7agent2:973.3We need three files for running an end-to-end evaluation:queries.csv,documents.csv, andanswers.csv:queries.csv:query_id,query
0, "What is the capital of Brazil?"
1, "What is the capital of France?"documents.csv:query_id,doc_id,document_text
0,0, "Brasília is the capital of Brazil."
0,1, "Rio de Janeiro used to be the capital of Brazil."
1,2, "Paris is the capital of France."
1,3, "Lyon is the second largest city in France."answers.csv:query_id,agent,answer
0, agent1, "Brasília is the capital of Brazil, according to [0]."
0, agent2, "According to [1], Rio de Janeiro used to be the capital of Brazil until 1960."
1, agent1, "Paris is the capital of France, according to [2]."
1, agent2, "Lyon is the second largest city in France, according to [3]."The OpenAI API key should be set as an environment variable (OPENAI_API_KEY). Alternatively, you can set a credentials file and pass it as an option toragelo:credentials.txt:OPENAI_API_KEY=<your_key_here>ragelo--credentialscredentials.txtrun-allqueries.csvdocuments.csvanswers.csv🧩 ComponentsWhileRAGElois meant to be used as an end-to-end tool, we can also invoke each of its components individually:📜retrieval-annotatorTheretrieval-annotatortool annotates retrieved documents based on their relevance to the user query. This is done regardless of the answers provided by the Agents. By default, it uses thereasonerannotator, which only outputs the reasoning for the relevance judgment:rageloretrieval-annotatorqueries.csvdocuments.csvreasonings.csvThereasonings.csvoutput file is a csv file with query_id, document_id and answer columns:tests/data/reasonings.csv.💬answers-annotatorTheanswers-annotatortool annotates the answers generated by the Agents, taking the quality of the documents retrieved by the retrieval pipeline. By default, it uses thePairwiseWithReasoningannotator, which generateskrandom pairs of answers for each query and chooses the best answer based on the relevant documents cited in the answer. It relies on thereasonings.csvfile generated by thedocuments-annotator:rageloanswers-annotatorqueries.csvanswers.csvreasonings.csvanswers_eval.jsonlTheanswers_eval.jsonloutput file is a JSONL file with each line containing the prompt for evaluating the pair of answers, the output of the annotator, and the best answer. An output file example is provided attests/data/answers_eval.jsonl🏆agents-rankerFinally, theagents-rankertool ranks the agents by simulating an Elo tournament where the output of each game is given by the answers from theanswers-annotator:rageloagents-rankeranswers_eval.jsonlagents_ranking.csvThe output of this step is written to the output fileagents_ranking.csvwith columns agent and score:tests/data/agents_ranking.csv.🙋 ContributingTo install the development dependencies, download the repository and run the following:gitclonehttps://github.com/zeta-alpha/ragelo&&cdragelo
pipinstall-e'.[dev]'This will install the requirement dependencies in an editable mode (i.e., any changes to the code don't need to be rebuilt.)
For building a new version, use thebuildcommand:python-mbuild✅ TODOAdd option to few-shot examplesAdd CI/CD for publishingTesting!Publish on PyPiAdd more document evaluators (Microsoft)Split Elo evaluatorInstall as standalone CLI[^1]: The RAGElo logo was created using Dall-E 3 and GPT-4 with the following prompt: "Vector logo design for a toolkit named 'RAGElo'. The logo should have bold, modern typography with emphasis on 'RAG' in a contrasting color. Include a minimalist icon symbolizing retrieval or ranking."