Skip to main content

llama-index packs fusion_retriever integration

Project description

Fusion Retriever Packs

Hybrid Fusion Pack

This LlamaPack provides an example of our hybrid fusion retriever method.

This specific template fuses results from our vector retriever and bm25 retriever; of course, you can provide any template you want.

Check out the notebook here.

CLI Usage

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

llamaindex-cli download-llamapack HybridFusionRetrieverPack --download-dir ./hybrid_fusion_pack

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

Code Usage

You can download the pack to a the ./hybrid_fusion_pack directory:

from llama_index.core.llama_pack import download_llama_pack

# download and install dependencies
HybridFusionRetrieverPack = download_llama_pack(
    "HybridFusionRetrieverPack", "./hybrid_fusion_pack"
)

From here, you can use the pack, or inspect and modify the pack in ./hybrid_fusion_pack.

Then, you can set up the pack like so:

# create the pack
hybrid_fusion_pack = HybridFusionRetrieverPack(
    nodes, chunk_size=256, vector_similarity_top_k=2, bm25_similarity_top_k=2
)

The run() function is a light wrapper around query_engine.query().

response = hybrid_fusion_pack.run("Tell me about a Music celebrity.")

You can also use modules individually.

# use the fusion retriever
nodes = hybrid_fusion_pack.fusion_retriever.retrieve("query_str")

# use the vector retriever
nodes = hybrid_fusion_pack.vector_retriever.retrieve("query_str")
# use the bm25 retriever
nodes = hybrid_fusion_pack.bm25_retriever.retrieve("query_str")

# get the query engine
query_engine = hybrid_fusion_pack.query_engine

Query Rewriting Retriever Pack

This LlamaPack provides an example of query rewriting through our fusion retriever.

This specific template takes in a single retriever, and generates multiple queries against the retriever, and then fuses the results together.

Check out the notebook here.

CLI Usage

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

llamaindex-cli download-llamapack QueryRewritingRetrieverPack --download-dir ./query_rewriting_pack

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

Code Usage

You can download the pack to a the ./query_rewriting_pack directory:

from llama_index.core.llama_pack import download_llama_pack

# download and install dependencies
QueryRewritingRetrieverPack = download_llama_pack(
    "QueryRewritingRetrieverPack", "./query_rewriting_pack"
)

From here, you can use the pack, or inspect and modify the pack in ./query_rewriting_pack.

Then, you can set up the pack like so:

# create the pack
query_rewriting_pack = QueryRewritingRetrieverPack(
    nodes,
    chunk_size=256,
    vector_similarity_top_k=2,
)

The run() function is a light wrapper around query_engine.query().

response = query_rewriting_pack.run("Tell me a bout a Music celebrity.")

You can also use modules individually.

# use the fusion retriever
nodes = query_rewriting_pack.fusion_retriever.retrieve("query_str")

# use the vector retriever
nodes = query_rewriting_pack.vector_retriever.retrieve("query_str")

# get the query engine
query_engine = query_rewriting_pack.query_engine

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_fusion_retriever-0.5.1.tar.gz (5.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_fusion_retriever-0.5.1.tar.gz.

File metadata

File hashes

Hashes for llama_index_packs_fusion_retriever-0.5.1.tar.gz
Algorithm Hash digest
SHA256 257752dd641a6b10fec0cd315349d74da9a6b3f8bbe41f677f12cfbb56621255
MD5 5c1aacd7dd37e57a71ed34353744e7cc
BLAKE2b-256 49b32ca1d429a65bb94d6b9228169975a6525252e2af59a5189f2dfa314a1223

See more details on using hashes here.

File details

Details for the file llama_index_packs_fusion_retriever-0.5.1-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_packs_fusion_retriever-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 00e9bbc03960381762688a7e0027cf7ea48e64d579f5cb65fbe735ff61c1c564
MD5 5661a8c7a6174040de4725e12e61c0a5
BLAKE2b-256 70538510e17da076c8a68bea5c2e4e665bef75b0574a06f649078402bdc82ff2

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