ragtime


Nameragtime JSON
Version 0.0.31 PyPI version JSON
download
home_pageNone
SummaryRagtime 🎹 is an LLMOps framework to automatically evaluate Retrieval Augmented Generation (RAG) systems and compare different RAGs / LLMs
upload_time2024-05-03 09:21:23
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT License Copyright (c) 2024 reciTAL Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords evaluation llm rag
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <img src="img/Ragtime_logo.png" alt="Ragtime 🎹 LLM Ops for all">

# Presentation
**Ragtime** 🎹 is an LLMOps framework which allows you to automatically:
1. evaluate a Retrieval Augmented Generation (RAG) system
2. compare different RAGs / LLMs
3. 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. A LLM can return many equivalent 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 (see [HuggingFace's `lighteval`](https://github.com/huggingface/lighteval?tab=readme-ov-file#metrics-for-generative-tasks))

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`: generate `Answer`s with 1 or several `LLM`s. Each `LLM` uses a `Prompter` to get a prompt to be fed with and to post-process the `LLMAnswer` returned by the `LLM`
- `FactGenerator`: generate `Facts` from the answers with human validation equals to 1. `FactGenerator` also uses an `LLM` to generate the facts
- `EvalGenerator`: generate `Eval`s based on `Answer`s and `Facts`. Also uses a `LLM` to perform the evaluations.
- `LLM`: generates text and return `LLMAnswer` objects
- `LLMAnswer`: answer returned by an LLM. Contains a `text` field, returned by the LLM, plus a `cost`, a `duration`, a `timestamp` and a `prompt` field, being the prompt used to generate the answer
- `Prompter`: a prompter is used to generate a prompt for an LLM and to post-process the text returned by the LLM
- `Expe`: an experiment object, containing a list of `QA` objects
- `QA`: an element an `Expe`. Contains a `Question` and, optionally, `Facts`, `Chunks` and `Answers`.
- `Question`: contains a `text` field for the question's text. Can also contain a `meta` dictionary
- `Facts`: a list of `Fact`, with a `text` field being the fact in itself and an `LLMAnswer` object if the fact has been generated by an LLM
- `Chunks`: a list of `Chunk` containing the `text` of the chunk and optionally a `meta` dictionary with extra data associated with the retriever
- `Answers`: the answer to the question is in the `text` field plus an `LLMAnswer` containing all the data related to the answer generation, plus an `Eval` object related to the evaluation of the answer
- `Eval`: contains a `human` field to store human evaluation of the answer as well as a `auto` field when the evaluation is done automatically. In this case, it also contains an `LLMAnswer` 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](https://github.com/recitalAI/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:
```shell
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](https://litellm.vercel.app/docs/providers).

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](https://litellm.vercel.app/docs/providers/vertex#gemini-pro).
Also make sure your project has `Vertex AI` API enabled.
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "ragtime",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "reciTAL <ragtime@recital.ai>",
    "keywords": "Evaluation, LLM, RAG",
    "author": null,
    "author_email": "Gilles Moyse <gilles@recital.ai>",
    "download_url": "https://files.pythonhosted.org/packages/ff/6f/7a0bba4703c88b92d8b9f90bdb0f515cc869d3df86eff420b01ad7002486/ragtime-0.0.31.tar.gz",
    "platform": null,
    "description": "<img src=\"img/Ragtime_logo.png\" alt=\"Ragtime \ud83c\udfb9 LLM Ops for all\">\n\n# Presentation\n**Ragtime** \ud83c\udfb9 is an LLMOps framework which allows you to automatically:\n1. evaluate a Retrieval Augmented Generation (RAG) system\n2. compare different RAGs / LLMs\n3. generate Facts to allow automatic evaluation\n\nIn Ragtime \ud83c\udfb9, a *RAG* is made of, optionally, a *Retriever*, and always, one or several *Large Language Model* (*LLM*).\n- A *Retriever* takes a *question* in input and returns one or several *chunks* or *paragraphs* retrieved from a documents knowledge base\n- A *LLM* is a text to text generator taking in input a *prompt*, made of a question and optional chunks, and returning an *LLMAnswer*\n\nYou can specify how *prompts* are generated and how the *LLMAnswer* has to be post-processed to return an *answer*.\n\n# How does it work?\nThe main idea in Ragtime \ud83c\udfb9 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. A LLM can return many equivalent 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 (see [HuggingFace's `lighteval`](https://github.com/huggingface/lighteval?tab=readme-ov-file#metrics-for-generative-tasks))\n\nIn Ragtime \ud83c\udfb9, 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.\n\nYou 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**.\n\n# Main objects\nThe main objects used in Ragtime \ud83c\udfb9 are:\n- `AnswerGenerator`: generate `Answer`s with 1 or several `LLM`s. Each `LLM` uses a `Prompter` to get a prompt to be fed with and to post-process the `LLMAnswer` returned by the `LLM`\n- `FactGenerator`: generate `Facts` from the answers with human validation equals to 1. `FactGenerator` also uses an `LLM` to generate the facts\n- `EvalGenerator`: generate `Eval`s based on `Answer`s and `Facts`. Also uses a `LLM` to perform the evaluations.\n- `LLM`: generates text and return `LLMAnswer` objects\n- `LLMAnswer`: answer returned by an LLM. Contains a `text` field, returned by the LLM, plus a `cost`, a `duration`, a `timestamp` and a `prompt` field, being the prompt used to generate the answer\n- `Prompter`: a prompter is used to generate a prompt for an LLM and to post-process the text returned by the LLM\n- `Expe`: an experiment object, containing a list of `QA` objects\n- `QA`: an element an `Expe`. Contains a `Question` and, optionally, `Facts`, `Chunks` and `Answers`.\n- `Question`: contains a `text` field for the question's text. Can also contain a `meta` dictionary\n- `Facts`: a list of `Fact`, with a `text` field being the fact in itself and an `LLMAnswer` object if the fact has been generated by an LLM\n- `Chunks`: a list of `Chunk` containing the `text` of the chunk and optionally a `meta` dictionary with extra data associated with the retriever\n- `Answers`: the answer to the question is in the `text` field plus an `LLMAnswer` containing all the data related to the answer generation, plus an `Eval` object related to the evaluation of the answer\n- `Eval`: contains a `human` field to store human evaluation of the answer as well as a `auto` field when the evaluation is done automatically. In this case, it also contains an `LLMAnswer` object related to the automatic evaluation\n\nAlmost every object in Ragtime \ud83c\udfb9 has a `meta` field, which is a dictionnary where you can store all the extra data you need for your specific use case.\n\n# Examples\nYou can now go to [ragtime-projects](https://github.com/recitalAI/ragtime-projects) to see examples of Ragtime \ud83c\udfb9 in action!\n\n# Troubleshooting\n## Setting the API keys on Windows\nAPI keys are stored in environment variables locally on your computer. If you are using Windows, you should first set the API keys values as:\n```shell\nsetx OPENAI_API_KEY sk-....\n```\nThe list of environment variable names to set, depending on the APIs you need to access, is given in the [LiteLLM documentation](https://litellm.vercel.app/docs/providers).\n\nOnce 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'])`.\n\n## Using Google LLMs\nExecute what's indicated in the [LiteLLM documentation](https://litellm.vercel.app/docs/providers/vertex#gemini-pro).\nAlso make sure your project has `Vertex AI` API enabled.",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 reciTAL  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Ragtime \ud83c\udfb9 is an LLMOps framework to automatically evaluate Retrieval Augmented Generation (RAG) systems and compare different RAGs / LLMs",
    "version": "0.0.31",
    "project_urls": {
        "Homepage": "https://github.com/recitalAI/ragtime-package",
        "Issues": "https://github.com/recitalAI/ragtime-package/issues"
    },
    "split_keywords": [
        "evaluation",
        " llm",
        " rag"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6da6132f4cc80c123e50acd11e623e7af5307323490421edce3193c82d0bbb4e",
                "md5": "dd9e724d1ee91730b949c0b508aa0e83",
                "sha256": "049cd9a871d128c2f02d407487d2d9ba77b0f0c8ad4b9a83c8a443d6ae0a9c81"
            },
            "downloads": -1,
            "filename": "ragtime-0.0.31-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "dd9e724d1ee91730b949c0b508aa0e83",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 158857,
            "upload_time": "2024-05-03T09:21:21",
            "upload_time_iso_8601": "2024-05-03T09:21:21.826411Z",
            "url": "https://files.pythonhosted.org/packages/6d/a6/132f4cc80c123e50acd11e623e7af5307323490421edce3193c82d0bbb4e/ragtime-0.0.31-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ff6f7a0bba4703c88b92d8b9f90bdb0f515cc869d3df86eff420b01ad7002486",
                "md5": "e12fc7e6df2d660e847292ae23b66f13",
                "sha256": "bdc801e7da99a8a36496c92650a6d25d8c708d8f4650526eb368e4779aae5f5b"
            },
            "downloads": -1,
            "filename": "ragtime-0.0.31.tar.gz",
            "has_sig": false,
            "md5_digest": "e12fc7e6df2d660e847292ae23b66f13",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 175786,
            "upload_time": "2024-05-03T09:21:23",
            "upload_time_iso_8601": "2024-05-03T09:21:23.395256Z",
            "url": "https://files.pythonhosted.org/packages/ff/6f/7a0bba4703c88b92d8b9f90bdb0f515cc869d3df86eff420b01ad7002486/ragtime-0.0.31.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-03 09:21:23",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "recitalAI",
    "github_project": "ragtime-package",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "ragtime"
}
        
Elapsed time: 0.26932s