Description
Project description
easyrag: Retrieval-Augmented Generation Uncovered
"easyrag: Retrieval-Augmented Generation Uncovered" is a multi-chapter project focused on exploring Retrieval-Augmented Generation (RAG) from simple implementations to advanced techniques. Utilizing open Large Language Models (LLMs) hosted on Hugging Face, this project aims to provide a comprehensive guide through the RAG landscape, demonstrating the power of combining retrieval mechanisms with generative models. Each part includes evaluation metrics allowing is to compare the performance of different techniques and models.
Retrieval-Augmented Generation (RAG) combines the retrieval of informational content with generative deep learning models. This approach enhances the model's ability to produce relevant and contextually rich responses by leveraging external knowledge sources. Building RAG applications always follows some kind of "flow" or "pipeline". Therefore i started to represent RAG applications through Graphs, which allows us to create understandable visuals for our RAG applications, which can include the cycles or conditional statements that are present in the application. We are going to use Langgraph to represent the RAG applications as graphs.
What is easyrag?
easyrag is also a library that provides helpful methods and classes to work with RAG applications. It is designed to be a lightweight and easy-to-use library that can be used to build and evaluate RAG applications. It is easy to hack and extend. It doesn't provide complex abstractions or extensive features.
Evaluation Metrics
easyrag implements a set of evaluation metrics to compare the performance of different RAG models. Those metrics are inspired and adopted from ragas, llamaindex and are adapted to work with Open LLMs, by adjusting the prompts and extending the examples.
Supported metrics include:
- Answer Correctness: Evaluates the
answer
with theground truth
and returns 0 INCORRECT or 1 CORRECT. - Answer Faithfulness: Evaluates if
answer
is "faithfull" based on the providedcontext
and returns a 0 UNFAITHFUL or 1 FAITHFUL, e.g. I cannot answer since no information is given in the context. - Context Precision: Evaluates how many of the retrieved documents are relevant to answer the question, uses
question
,context
andground truth
answer. - Context Recall: Evaluates how many sentences in the
answer
can be attributed to retrieved documents, usescontext
andanswer
.
Why those 4 metrics?
Those 4 metrics allow us to evaluate the performance of the whole RAG application. We can evaluate the performance of the retriever/ranking by using the Context Precision
and Context Recall
metrics. We can evaluate the performance of the generator by using the Answer Correctness
and Answer Faithfulness
metrics.
Datasets
To build and evaluate RAG applications, we need to have access to datasets. easyrag provides a set of datasets that can be used to build and evaluate RAG applications. The datasets are stored on Hugging Face and can be easily accessed using the datasets
library.
Supported datasets include:
- philschmid/easyrag-mini-wikipedia: Wikipedia based dataset with ~900 questions and ground truth answers + 3,200 documents for retrieval.
Installation and Setup
- Python 3.10 or later
- Access to Hugging Face Inference API
Clone the repository and install the required dependencies:
pip install git+https://github.com/philschmid/easyrag.git
Open the chapter you want to run.
Contributing
We welcome contributions to "easyrag"! If you have suggestions for improvements, please open an issue or submit a pull request.
- Fork the repository
- Create a new branch for your feature (git checkout -b feature/amazing-feature)
- Commit your changes (git commit -am 'Add some amazing feature')
- Push to the branch (git push origin feature/amazing-feature)
- Open a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
A special thank you to Hugging Face and Langchain for providing the platforms and tools that made this project possible. Also, big acknowledgment to ragas and llamaindex for providing the evaluation metrics and inspiration for this project.
Todos:
- semantic chunking
- replace all " with " to fix json parsing
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 easyrag-0.0.1.tar.gz
.
File metadata
- Download URL: easyrag-0.0.1.tar.gz
- Upload date:
- Size: 116.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ac39311bcb9f1ed4e071a5e878dffae85b72dddd86c1cb057229fda04cbf3ca |
|
MD5 | 3d61723cc662f2faabf389fafe80f319 |
|
BLAKE2b-256 | 0ce76c77268c9c39c01259d19479f55961ae4834fdb3b9720cbd24ad6122dfe5 |
File details
Details for the file easyrag-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: easyrag-0.0.1-py3-none-any.whl
- Upload date:
- Size: 18.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce95c13752d452d5f43f50de20dfcfaa8f5eeba5b79088b7eb4e8b155e49eecf |
|
MD5 | f9b4425653625417ef957a59e1700dad |
|
BLAKE2b-256 | 393cf3eb65b83d8ac36c770db3407502aafb2eec91ef1a0f2615d2af52e901ae |