Ragtime 🎹 is an LLMOps framework to automatically evaluate Retrieval Augmented Generation (RAG) systems and compare different RAGs / LLMs
Project description
Presentation
Ragtime 🎹 is an LLMOps framework which allows you to automatically:
- evaluate a Retrieval Augmented Generation (RAG) system
- compare different RAGs / LLMs
- generate Facts to allow automatic evaluation
In Ragtime 🎹, a RAG is made of, optionally, a Retriever, and always, one or several Large Language Model (LLM).
- A Retriever takes a question in input and returns one or several chunks or paragraphs retrieved from a documents knowledge base
- A LLM is a text to text generator taking in input a prompt, made of a question and optional chunks, and returning an LLMAnswer
You can specify how prompts are generated and how the LLMAnswer has to be post-processed to return an answer.
How does it work?
The main idea in Ragtime 🎹 is to evaluate answers returned by a RAG based on Facts that you define. Indeed, it is very difficult to evaluate RAGs and/or LLMs because you cannot define a "good" answer. Indeed a LLM can return many equialent answers expressed in different ways, making impossible a simple string comparison to determine whether an answer is right or wrong. Even though many proxies have been created, counting the number of common words like in ROUGE for instance is not very precise.
In Ragtime 🎹, answers returned by a RAG or a LLM are evaluated against a set of facts. If the answer validates all the facts, then the answer is deemed correct. Conversely, if some facts are not validated, the answer is considered wrong. The number of validated facts compared to the total number of facts to validate defines a score.
You can either define facts manually, or have a LLM define them for you. The evaluation of facts against answers is done automatically with another LLM.
Main objects
The main objects used in Ragtime 🎹 are:
AnswerGenerator
: generateAnswer
s with 1 or severalLLM
s. EachLLM
uses aPrompter
to get a prompt to be fed with and to post-process theLLMAnswer
returned by theLLM
FactGenerator
: generateFacts
from the answers with human validation equals to 1.FactGenerator
also uses anLLM
to generate the factsEvalGenerator
: generateEval
s based onAnswer
s andFacts
. Also uses aLLM
to perform the evaluations.LLM
: generates text and returnLLMAnswer
objectsLLMAnswer
: answer returned by an LLM. Contains atext
field, returned by the LLM, plus acost
, aduration
, atimestamp
and aprompt
field, being the prompt used to generate the answerPrompter
: a prompter is used to generate a prompt for an LLM and to post-process the text returned by the LLMExpe
: an experiment object, containing a list ofQA
objectsQA
: an element anExpe
. Contains aQuestion
and, optionally,Facts
,Chunks
andAnswers
.Question
: contains atext
field for the question's text. Can also contain ameta
dictionaryFacts
: a list ofFact
, with atext
field being the fact in itself and anLLMAnswer
object if the fact has been generated by an LLMChunks
: a list ofChunk
containing thetext
of the chunk and optionally ameta
dictionary with extra data associated with the retrieverAnswers
: the answer to the question is in thetext
field plus anLLMAnswer
containing all the data related to the answer generation, plus anEval
object related to the evaluation of the answerEval
: contains ahuman
field to store human evaluation of the answer as well as aauto
field when the evaluation is done automatically. In this case, it also contains anLLMAnswer
object related to the automatic evaluation
Almost every object in Ragtime 🎹 has a meta
field, which is a dictionnary where you can store all the extra data you need for your specific use case.
Examples
You can now go to ragtime-projects to see examples of Ragtime 🎹 in action!
Troubleshooting
Setting the API keys on Windows
API keys are stored in environment variables locally on your computer. If you are using Windows, you should first set the API keys values as:
setx OPENAI_API_KEY sk-....
The list of environment variable names to set, depending on the APIs you need to access, is given in the LiteLLM documentation.
Once the keys are set, just call ragtime.config.init_API_keys
with the list of environment variables to make accessible to Python, for instance init_API_keys(['OPENAI_API_KEY'])
.
Using Google LLMs
Execute what's indicated in the LiteLLM documentation.
Also make sure your project has Vertex AI
API enabled.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ragtime-0.0.29.tar.gz
.
File metadata
- Download URL: ragtime-0.0.29.tar.gz
- Upload date:
- Size: 174.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08911cc233b167ba85c002adebf9a6edb205cef191b35103b2d509ee8ac4fb92 |
|
MD5 | f9b31f107b499d3b8f9566c8d49c6c1d |
|
BLAKE2b-256 | 484c64a44b2f399ca495374b7bc96984f31927917bbc79ba73261153e28d64e0 |
File details
Details for the file ragtime-0.0.29-py3-none-any.whl
.
File metadata
- Download URL: ragtime-0.0.29-py3-none-any.whl
- Upload date:
- Size: 158.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c083b62e5dd303099ba305cb76cd63b9cb488e3c67ab40c4c05e4c750deca435 |
|
MD5 | 7b80bf2ed48089d620c53d7a239cac69 |
|
BLAKE2b-256 | 4e5de9053447b0579799166ff3ca861692abf259700bf1dde7b34d15b9d2161e |