Skip to main content

llama-index packs raptor integration

Project description

Raptor Retriever LlamaPack

This LlamaPack shows how to use an implementation of RAPTOR with llama-index, leveraging the RAPTOR pack.

RAPTOR works by recursively clustering and summarizing clusters in layers for retrieval.

There two retrieval modes:

  • tree_traversal -- traversing the tree of clusters, performing top-k at each level in the tree.
  • collapsed -- treat the entire tree as a giant pile of nodes, perform simple top-k.

See the paper for full algorithm details.

CLI Usage

You can download llamapacks directly using llamaindex-cli, which comes installed with the llama-index python package:

llamaindex-cli download-llamapack RaptorPack --download-dir ./raptor_pack

You can then inspect/modify the files at ./raptor_pack and use them as a template for your own project.

Code Usage

You can alternaitvely install the package:

pip install llama-index-packs-raptor

Then, you can import and initialize the pack! This will perform clustering and summarization over your data.

from llama_index.packs.raptor import RaptorPack

pack = RaptorPack(documents, llm=llm, embed_model=embed_model)

The run() function is a light wrapper around retriever.retrieve().

nodes = pack.run(
    "query",
    mode="collapsed",  # or tree_traversal
)

You can also use modules individually.

# get the retriever
retriever = pack.retriever

Persistence

The RaptorPack comes with the RaptorRetriever, which offers ways of saving/reloading!

If you are using a remote vector-db, just pass it in

# Pack usage
pack = RaptorPack(..., vector_store=vector_store)

# RaptorRetriever usage
retriever = RaptorRetriever(..., vector_store=vector_store)

Then, to re-connect, just pass in the vector store again and an empty list of documents

# Pack usage
pack = RaptorPack([], ..., vector_store=vector_store)

# RaptorRetriever usage
retriever = RaptorRetriever([], ..., vector_store=vector_store)

Check out the notebook here for complete details!.

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_raptor-0.1.1.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

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

llama_index_packs_raptor-0.1.1-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_packs_raptor-0.1.1.tar.gz.

File metadata

  • Download URL: llama_index_packs_raptor-0.1.1.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.13 Linux/6.5.0-1015-azure

File hashes

Hashes for llama_index_packs_raptor-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2eddde86ee131ac93a6dbb8f9f9651bacb7450dfd7e7367b9720a518cb826236
MD5 41a11d83ee94b21611cc98c4bbd46289
BLAKE2b-256 f59922e3fe8e308da01804edb42b2f00da09cbaa8a13c477fde9b6de488ad24c

See more details on using hashes here.

File details

Details for the file llama_index_packs_raptor-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_packs_raptor-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2312cb83a010d53fa96faf2b0cc66c2f40ddd00fa300d6b57b251c964bedcd86
MD5 4f68e73e95ac533dff04f5b3b7b7dc70
BLAKE2b-256 62af64847ef029159430a572377f5b372949490b2f6561f87700675d1405b1cc

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