LLaMAIndexReranker
Python template · sinapsis_llama_index.templates.llama_index_reranker
Overview
Rerank retrieved LLM contexts with LlamaIndex's `SentenceTransformerRerank`.
This template expects contexts to already be present in `LLMConversationPacket.contexts`, typically from `LLaMAIndexNodeRetriever`. It reranks the contexts using the packet's current `content` as the query and writes the reranked contexts back into the same packet.
Capabilities
Capabilities: not setInstallation
Install the published package using pip or uv.
pip install sinapsis-llama-index==1.0.0uv pip install sinapsis-llama-index==1.0.0uv add sinapsis-llama-index==1.0.0Configuration
Effective fields from the inspector schema, including nested Pydantic model fields.
Optional
Default: null
Configuration for the sentence-transformer reranker.
Optional
Default: null
Cross-encoder model used for reranking. Defaults to `"cross-encoder/stsb-distilroberta-base"`.
Optional
Default: "cross-encoder/stsb-distilroberta-base"
Number of reranked candidates to keep. Defaults to `2`.
Optional
Default: 2
Device used by the reranker. If `"auto"`, it resolves to `"cuda"` when available, otherwise `"cpu"`. Defaults to `"auto"`.
Optional
Default: "auto"
Allow execution of remote code for custom models. Defaults to `True`.
Optional
Default: true
Whether to preserve the original retrieval score in metadata. Defaults to `False`.
Optional
Default: false
Context categories that should be reranked.
Required
Default: null
Configuration example
Example from the Python docstring:
agent:
name: my_test_agent
templates:
- template_name: InputTemplate
class_name: InputTemplate
attributes: {}
- template_name: LLaMAIndexReranker
class_name: LLaMAIndexReranker
template_input: InputTemplate
attributes:
rerank_config:
model: "cross-encoder/stsb-distilroberta-base"
top_n: 2
device: cpu
rerank_categories: ["rag", "document"]Show schema-based configuration skeleton
templates:
- template_name: "LLaMAIndexReranker"
class_name: "LLaMAIndexReranker"
attributes:
rerank_config:
model: "cross-encoder/stsb-distilroberta-base"
top_n: 2
device: "auto"
trust_remote_code: true
keep_retrieval_score: false
rerank_categories: "<required>"
Inheritance
sinapsis_core.template_base.template.TemplateEnvironment variables
Environment definitions belong to their canonical Python modules.
No directly related environment variables listed.