Skip to main content

llama-index packs sentence_window_retriever integration

Project description

Sentence Window Retriever

This LlamaPack provides an example of our sentence window retriever.

This specific template shows the e2e process of building this. It loads a document, chunks it up, adds surrounding context as metadata to each chunk, and during retrieval inserts the context back into each chunk for response synthesis.

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 SentenceWindowRetrieverPack --download-dir ./sentence_window_retriever_pack

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

Code Usage

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

from llama_index.core.llama_pack import download_llama_pack

# download and install dependencies
SentenceWindowRetrieverPack = download_llama_pack(
    "SentenceWindowRetrieverPack", "./sentence_window_retriever_pack"
)

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

Then, you can set up the pack like so:

# create the pack
# get documents from any data loader
sentence_window_retriever_pack = SentenceWindowRetrieverPack(
    documents,
)

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

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

You can also use modules individually.

# get the sentence vector index
index = sentence_window_retriever_pack.sentence_index

# get the node parser
node_parser = sentence_window_retriever_pack.node_parser

# get the metadata replacement postprocessor
postprocessor = sentence_window_retriever_pack.postprocessor

# get the query engine
query_engine = sentence_window_retriever_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

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_sentence_window_retriever-0.6.0.tar.gz.

File metadata

  • Download URL: llama_index_packs_sentence_window_retriever-0.6.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_packs_sentence_window_retriever-0.6.0.tar.gz
Algorithm Hash digest
SHA256 73c9e8793973a2c536f7fdd567bb1b9b1bc97f734638c3de89ec2bc8ed1ec1b7
MD5 437c0857cfdb1e2c3eef66754252e06a
BLAKE2b-256 1130fe480b7416776a22f70ed5280cdba055cda2ccd040a67ae61a355b991b86

See more details on using hashes here.

File details

Details for the file llama_index_packs_sentence_window_retriever-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: llama_index_packs_sentence_window_retriever-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_packs_sentence_window_retriever-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ab82f9940cc9d58a21edcdb8f77de6c75ea255119549f82f3661ae00e6ef642c
MD5 ee5b60759759c0af27acd4a020fcf257
BLAKE2b-256 0706e9dd02f62338859805b7b1dc454a32eda8cc04774b15b1a5b4547f582202

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