Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llama_index_packs_corrective_rag-0.3.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file llama_index_packs_corrective_rag-0.3.1.tar.gz.

File metadata

File hashes

Hashes for llama_index_packs_corrective_rag-0.3.1.tar.gz
Algorithm Hash digest
SHA256 b9d7bdd0caf0e9d1522bcb50ffb9c98578766233ef04ca9ef7954a1b5cc56a3e
MD5 1ed72f32142ba36508bbf627109afbe9
BLAKE2b-256 820419e2df0104990e2e99dc9742943dfee106cb0df21b06e7609186f8c2c1e0

See more details on using hashes here.

File details

Details for the file llama_index_packs_corrective_rag-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_packs_corrective_rag-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 18276f18dc03be0740d9dcce18258b51eb2aaf88135113ac33ceacd342f01126
MD5 52713e496e21c082149e37ed6ff09dff
BLAKE2b-256 4e1616defd92103b382961093dfe5fdec7a01093ee517867d35cd8352fda42ae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page