Skip to main content

Infer-Retrieve-Rerank LlamaPack

This is our implementation of the paper "In-Context Learning for Extreme Multi-Label Classification by Oosterlinck et al.

The paper proposes "infer-retrieve-rerank", a simple paradigm using frozen LLM/retriever models that can do "extreme"-label classification (the label space is huge).

  1. Given a user query, use an LLM to predict an initial set of labels.
  2. For each prediction, retrieve the actual label from the corpus.
  3. Given the final set of labels, rerank them using an LLM.

All of these can be implemented as LlamaIndex abstractions.

A full notebook guide can be found here.

CLI Usage

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

llamaindex-cli download-llamapack InferRetrieveRerankPack --download-dir ./infer_retrieve_rerank_pack

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

Code Usage

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

from llama_index.core.llama_pack import download_llama_pack

# download and install dependencies
InferRetrieveRerankPack = download_llama_pack(
    "InferRetrieveRerankPack", "./infer_retrieve_rerank_pack"
)

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

Then, you can set up the pack like so:

# create the pack
pack = InferRetrieveRerankPack(
    labels,  # list of all label strings
    llm=llm,
    pred_context="<pred_context>",
    reranker_top_n=3,
    verbose=True,
)

The run() function runs predictions.

pred_reactions = pack.run(inputs=[s["text"] for s in samples])

You can also use modules individually.

# call the llm.complete()
llm = pack.llm
label_retriever = pack.label_retriever

Metadata

Release files for llama-index-packs-infer-retrieve-rerank 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llama-index-packs-infer-retrieve-rerank 0.5.1
File Size Uploaded Provenance Actions
llama_index_packs_infer_retrieve_rerank-0.5.1.tar.gz 5.6 kB Without provenance Details for llama_index_packs_infer_retrieve_rerank-0.5.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llama-index-packs-infer-retrieve-rerank 0.5.1
File Interpreter ABI Platform Actions
llama_index_packs_infer_retrieve_rerank-0.5.1-py3-none-any.whl Python 3 none any Details for llama_index_packs_infer_retrieve_rerank-0.5.1-py3-none-any.whl

Total release size: 10.9 kB

Release files / llama_index_packs_infer_retrieve_rerank-0.5.1.tar.gz

Download URL llama_index_packs_infer_retrieve_rerank-0.5.1.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
bfacb68361075ed9a5e9f079a194c19234f58955877b87b739922a6b9730b0bf
BLAKE2b-256 checksum
How to use checksums
ac89b8b8ba89fe2f3d3e6d23a8e580fcd5ff218a5309d1ad629826e4e21e4980
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.17

Release files / llama_index_packs_infer_retrieve_rerank-0.5.1-py3-none-any.whl

Download URL llama_index_packs_infer_retrieve_rerank-0.5.1-py3-none-any.whl
Size 5.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
25067ebf2a002c447b80acb5e0cdb0807a1e44fe0a03c61a0b3a8f3811382f57
BLAKE2b-256 checksum
How to use checksums
d154e46485c573cca7eaac4fa466cb06f61cb56282ea8d76b5123cb71d500f2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.17

Security for llama-index-packs-infer-retrieve-rerank 0.5.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page