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

Built Distribution

File details

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

File metadata

File hashes

Hashes for llama_index_packs_corrective_rag-0.3.0.tar.gz
Algorithm Hash digest
SHA256 e65cad5cdbf9a161417232807b9b4699d264a57fc7f56d8ea2235a908d1d8225
MD5 5e3d78bbd1bf963cbd423d939348ec68
BLAKE2b-256 222525bbd82689b160829ac6f9ba43619e6787ae7b32cf3d68f37cfda7d142ad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llama_index_packs_corrective_rag-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c1654d84f6799e821d2052dcb1657d02888bf02e55c19fb8ef89e3cf0066cceb
MD5 5186c998f8d54a0caee5004781c10087
BLAKE2b-256 f4717ab85d3f52ffe64c57d6fabb64c9b3024bc7af0899dfd4ddf3d6b5202a00

See more details on using hashes here.

Supported by

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