Skip to main content

llama-index postprocessor google rerank integration

Project description

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

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_postprocessor_google_rerank-0.1.0.tar.gz.

File metadata

  • Download URL: llama_index_postprocessor_google_rerank-0.1.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","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_postprocessor_google_rerank-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8b4170c8c7f272fbea6b1181479ab1d73f598d9e06d6bbc6706bad1bed7e027c
MD5 b95529b588b043d43b68363f131ea3e4
BLAKE2b-256 f8021500d4ffee7e312eecfa67407ebe3c9980f8d5762f7c332e6aa6994a5731

See more details on using hashes here.

File details

Details for the file llama_index_postprocessor_google_rerank-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: llama_index_postprocessor_google_rerank-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","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_postprocessor_google_rerank-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 51cb5af09476ceb36b68015b07cef5a266011e5eefbd1b679a50fd17f7955cbe
MD5 2f67f44d4d1cbe98fdc7ab7017769682
BLAKE2b-256 68285dc1fa1ae2015122e29a5066ef9849a12775aa26187e0b2120c395b3298a

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