Skip to main content

LlamaIndex Postprocessor Integration: Google Rerank

Uses Google's Discovery Engine Ranking API to rerank search results based on query relevance.

Installation

pip install llama-index-postprocessor-google-rerank

Prerequisites

Usage

from llama_index.core import VectorStoreIndex, SimpleDirectoryReader
from llama_index.postprocessor.google_rerank import GoogleRerank

documents = SimpleDirectoryReader("./data/paul_graham/").load_data()
index = VectorStoreIndex.from_documents(documents=documents)

reranker = GoogleRerank(
    top_n=3,
    project_id="your-gcp-project-id",
    model="semantic-ranker-default-004",
)

query_engine = index.as_query_engine(
    similarity_top_k=10,
    node_postprocessors=[reranker],
)
response = query_engine.query("What did Sam Altman do in this essay?")
print(response)

Available Models

Model Context Window Notes
semantic-ranker-default-004 (default) 1024 tokens Latest, multilingual
semantic-ranker-default-003 512 tokens Multilingual
semantic-ranker-default-002 512 tokens English only

Configuration

Parameter Type Default Description
model str "semantic-ranker-default-004" Ranking model name
top_n int 2 Number of top results to return
project_id str None GCP project ID (falls back to GOOGLE_CLOUD_PROJECT env var, then ADC)
location str "global" GCP location for the ranking config
ranking_config str "default_ranking_config" Ranking config resource name
credentials Credentials None Optional Google auth credentials object

Metadata

Release files for llama-index-postprocessor-google-rerank 0.3.0

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-postprocessor-google-rerank 0.3.0
File Size Uploaded Provenance Actions
llama_index_postprocessor_google_rerank-0.3.0.tar.gz 5.1 kB Without provenance Details for llama_index_postprocessor_google_rerank-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llama-index-postprocessor-google-rerank 0.3.0
File Interpreter ABI Platform Actions
llama_index_postprocessor_google_rerank-0.3.0-py3-none-any.whl Python 3 none any Details for llama_index_postprocessor_google_rerank-0.3.0-py3-none-any.whl

Total release size: 10.1 kB

Release files / llama_index_postprocessor_google_rerank-0.3.0.tar.gz

Download URL llama_index_postprocessor_google_rerank-0.3.0.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
18d759621067704048b621a8bb89ce8e5445f1af52a0f945bd6a25df6c1dcc65
BLAKE2b-256 checksum
How to use checksums
c3044b00e51aa14512739220f0b45e9b10814fb505ffdb7c356248fbe22013a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / llama_index_postprocessor_google_rerank-0.3.0-py3-none-any.whl

Download URL llama_index_postprocessor_google_rerank-0.3.0-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f4def60e81dc2d86df1927241184780817c1f46e07a3e341091bf987931ba00a
BLAKE2b-256 checksum
How to use checksums
8a52568cc92982293f24be618d1754b8b0c11716a8ec504f01831c1483e1c3c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for llama-index-postprocessor-google-rerank 0.3.0

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