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:
- Obtain the API-KEY from the Alibaba Cloud ModelStudio platform.
- 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.2.1.tar.gz
.
File metadata
- Download URL: llama_index_postprocessor_dashscope_rerank-0.2.1.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2091e4ad876f1b2381fedce08189a0a8080fbb74f7a0e45060067bf1fa20b08 |
|
MD5 | 94f3aff80cdbc41f7ad08d70ffe3d4a7 |
|
BLAKE2b-256 | f88a81b1d6665fa9f6d2d62070ccccbc36776802f0737f09484eee83687465e8 |
File details
Details for the file llama_index_postprocessor_dashscope_rerank-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: llama_index_postprocessor_dashscope_rerank-0.2.1-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 516a9f5aae5a6ce1c4e7014fa32cd8236771965bbd3b91136e6bf3e989bbc35b |
|
MD5 | 3491fa8a4d308842638d5493f844ec1e |
|
BLAKE2b-256 | f64f23124a6582dae6ab7c8e1789d558a7fd579a6ba0bdfed4f508a93f061035 |