Skip to main content

llama-index postprocessor dashscope-rerank integration

Project description

LlamaIndex Postprocessor Integration: DashScope-Rerank

The llama-index-postprocessor-dashscope-rerank package contains LlamaIndex integrations for the gte-rerank series models provided by Alibaba Tongyi Laboratory.

Installation

pip install --upgrade llama-index llama-index-core llama-index-postprocessor-dashscope-rerank

Setup

Get started:

  1. Obtain the API-KEY from the Alibaba Cloud ModelStudio platform.
  2. Set API-KEY
export DASHSCOPE_API_KEY=YOUR_DASHSCOPE_API_KEY

Example:

from llama_index.core.data_structs import Node
from llama_index.core.schema import NodeWithScore
from llama_index.postprocessor.dashscope_rerank import DashScopeRerank

nodes = [
    NodeWithScore(node=Node(text="text1"), score=0.7),
    NodeWithScore(node=Node(text="text2"), score=0.8),
]

dashscope_rerank = DashScopeRerank(top_n=5)
results = dashscope_rerank.postprocess_nodes(nodes, query_str="<user query>")
for res in results:
    print("Text: ", res.node.get_content(), "Score: ", res.score)

output

Text:  text1 Score:  0.25589250620997755
Text:  text2 Score:  0.18071043165292258

Parameters

Name Type Description Default
model str model name gte-rerank
top_n int The number of top documents to be returned in the ranking; if not specified, all candidate documents will be returned. If the specified top_n value exceeds the number of input candidate documents, all documents will be returned. 3
return_documents bool Whether to return the original text for each document in the returned sorted result list, with the default value being False. False
api_key str The DashScope api key. None

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

File details

Details for the file llama_index_postprocessor_dashscope_rerank-0.3.0.tar.gz.

File metadata

File hashes

Hashes for llama_index_postprocessor_dashscope_rerank-0.3.0.tar.gz
Algorithm Hash digest
SHA256 bd8d9f99e029c87489b2e7bfd5ae0830377c73f735d0b03608e7039752c0097d
MD5 e92e59c6c2ee4c0d763e5cf1eb8e7941
BLAKE2b-256 b88193ef104482991f7bbd0a3168f083d6f6b1804643638c114cbebde088e077

See more details on using hashes here.

File details

Details for the file llama_index_postprocessor_dashscope_rerank-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_postprocessor_dashscope_rerank-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f1c4d15ad09d24ef9aed08c4fbd3119c50bac0f764d805ab619a401b6ecbb262
MD5 a969b60920912e93a86cfc5b974ce04e
BLAKE2b-256 fefab6bb07968514ca3c4c6f3f5f83ceae3aca318b96c44a710bc7e1898469bf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page