2.3 KiB
2.3 KiB
Reranker
The Reranker pipeline runs embeddings queries and re-ranks them using a similarity pipeline.
Example
The following shows a simple example using this pipeline.
from txtai import Embeddings
from txtai.pipeline import Reranker, Similarity
# Embeddings instance
embeddings = Embeddings()
embeddings.load(provider="huggingface-hub", container="neuml/txtai-wikipedia")
# Similarity instance
similarity = Similarity(path="colbert-ir/colbertv2.0", lateencode=True)
# Reranking pipeline
reranker = Reranker(embeddings, similarity)
reranker("Tell me about AI")
Note: Content must be enabled with the embeddings instance for this to work properly.
See the link below for a more detailed example.
| Notebook | Description | |
|---|---|---|
| What's new in txtai 9.0 | Learned sparse vectors, late interaction models and rerankers |
Configuration-driven example
Pipelines are run with Python or configuration. Pipelines can be instantiated in configuration using the lower case name of the pipeline. Configuration-driven pipelines are run with workflows or the API.
config.yml
embeddings:
similarity:
# Create pipeline using lower case class name
reranker:
# Run pipeline with workflow
workflow:
translate:
tasks:
- reranker
Run with Workflows
from txtai import Application
# Create and run pipeline with workflow
app = Application("config.yml")
list(app.workflow("reranker", ["Tell me about AI"]))
Run with API
CONFIG=config.yml uvicorn "txtai.api:app" &
curl \
-X POST "http://localhost:8000/workflow" \
-H "Content-Type: application/json" \
-d '{"name":"rerank", "elements":["Tell me about AI"]}'
Methods
Python documentation for the pipeline.

