Skip to main content

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 the ground truth and returns 0 INCORRECT or 1 CORRECT.
  • Answer Faithfulness: Evaluates if answer is "faithfull" based on the provided context 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 and ground truth answer.
  • Context Recall: Evaluates how many sentences in the answer can be attributed to retrieved documents, uses context and answer.

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:

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

Metadata

Release files for easyrag 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for easyrag 0.0.1
File Size Uploaded Provenance Actions
easyrag-0.0.1.tar.gz 116.9 kB Without provenance Details for easyrag-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for easyrag 0.0.1
File Interpreter ABI Platform Actions
easyrag-0.0.1-py3-none-any.whl Python 3 none any Details for easyrag-0.0.1-py3-none-any.whl

Total release size: 135.5 kB

Release files / easyrag-0.0.1.tar.gz

Download URL easyrag-0.0.1.tar.gz
Size 116.9 kB
Tags Source
SHA-256 checksum
How to use checksums
5ac39311bcb9f1ed4e071a5e878dffae85b72dddd86c1cb057229fda04cbf3ca
BLAKE2b-256 checksum
How to use checksums
0ce76c77268c9c39c01259d19479f55961ae4834fdb3b9720cbd24ad6122dfe5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.8

Release files / easyrag-0.0.1-py3-none-any.whl

Download URL easyrag-0.0.1-py3-none-any.whl
Size 18.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ce95c13752d452d5f43f50de20dfcfaa8f5eeba5b79088b7eb4e8b155e49eecf
BLAKE2b-256 checksum
How to use checksums
393cf3eb65b83d8ac36c770db3407502aafb2eec91ef1a0f2615d2af52e901ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.8

Security for easyrag 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page