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
- A Google Cloud project with the Discovery Engine API enabled
- Authentication via Application Default Credentials or explicit credentials
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.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| llama_index_postprocessor_google_rerank-0.2.0.tar.gz | 5.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| llama_index_postprocessor_google_rerank-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.1 kB
Release files / llama_index_postprocessor_google_rerank-0.2.0.tar.gz
| Download URL | llama_index_postprocessor_google_rerank-0.2.0.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b8308bd7cd04c3e1d8b1f609d765a708d7369ebedd478236f718fbc9545801d4
|
|
BLAKE2b-256 checksum How to use checksums |
5b0d4abaf447d96d90725429f832ee896b87b721af15233967c612f92e29a67c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","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}
|
Release files / llama_index_postprocessor_google_rerank-0.2.0-py3-none-any.whl
| Download URL | llama_index_postprocessor_google_rerank-0.2.0-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e7c5ac45f9dd21ba58d9c704a63d2a64e539578ae4af28c9a07130714b86c7f2
|
|
BLAKE2b-256 checksum How to use checksums |
0c737a4eefdc3a63d49d02a96e70a36523d1b647623a7ef431294389eabd94cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","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}
|
Security for llama-index-postprocessor-google-rerank 0.2.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.