llama-index packs corrective_rag paper implementation
Project description
Corrective Retrieval Augmented Generation Llama Pack
This LlamaPack implements the Corrective Retrieval Augmented Generation (CRAG) paper
Corrective Retrieval Augmented Generation (CRAG) is a method designed to enhance the robustness of language model generation by evaluating and augmenting the relevance of retrieved documents through a an evaluator and large-scale web searches, ensuring more accurate and reliable information is used in generation.
This LlamaPack uses Tavily AI API for web-searches. So, we recommend you to get the api-key before proceeding further.
Installation
pip install llama-index llama-index-tools-tavily-research
CLI Usage
You can download llamapacks directly using llamaindex-cli
, which comes installed with the llama-index
python package:
llamaindex-cli download-llamapack CorrectiveRAGPack --download-dir ./corrective_rag_pack
You can then inspect the files at ./corrective_rag_pack
and use them as a template for your own project.
Code Usage
You can download the pack to a the ./corrective_rag_pack
directory:
from llama_index.core.llama_pack import download_llama_pack
# download and install dependencies
CorrectiveRAGPack = download_llama_pack(
"CorrectiveRAGPack", "./corrective_rag_pack"
)
# You can use any llama-hub loader to get documents!
corrective_rag = CorrectiveRAGPack(documents, tavily_ai_api_key)
From here, you can use the pack, or inspect and modify the pack in ./corrective_rag_pack
.
The run()
function contains around logic behind Corrective Retrieval Augmented Generation - CRAG paper.
response = corrective_rag.run("<query>", similarity_top_k=2)
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
Hashes for llama_index_packs_corrective_rag-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad14ccccfed69b0dd4553f2e83f30d4a7975bd352a2d8a8a984748ecbc556dc1 |
|
MD5 | d9e4503cb674d4fd679203e1056abc17 |
|
BLAKE2b-256 | 86c83caabb1c39b267e51701b5327ba9a6f231167a457cec42322e5f3b0d018e |
Hashes for llama_index_packs_corrective_rag-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f792ffd45bcea4700ea470838f0ca764090f39d85163d71aa109cc5e19521dbb |
|
MD5 | f4c3ea707c656d10c72d2c10ac538840 |
|
BLAKE2b-256 | 7de6f72ccaf68255e40e7790fa57dedb438bac9a5b8a9eaab977c2ed49bb8911 |