Argument parsing with structured class.
Project description
ReRanker
ReRanker for hybrid retrieval.
For end-to-end text query service, check qtext.
Ranking
rank(query: str, docs: list[str])
- cross-encoder model
- cohere model
- diversity (Max Marginal Relevance)
rank(docs: list[Record])
- time decay with expressions
- title n-gram with bm25
- content n-gram with bm25
- document boost with expressions
- title embedding with content embedding
- title keywords with content keywords
- combination of the above features
Installation
pip install reranker
Usage
If you need the cross-encoder model service, you can start the server with the following command:
docker compose -f serving/compose.yaml up -d encoder
If you need the semantic highlight service, you can start the server with the following command:
docker compose -f serving/compose.yaml up -d colbert
from datetime import datetime, timedelta
from reranker import ReRanker, CrossEncoderClient, TimeDecayRanker
reranker = ReRanker(
steps=[
CrossEncoderClient(
model_name="cross-encoder/ms-marco-MiniLM-L-6-v2",
addr="http://localhost:8000",
),
TimeDecayRanker(decay_rate=0.5),
]
)
reranker.rank(
query="What is the capital of France?",
docs=[
"Paris is the capital of France.",
"The Eiffel Tower is in Paris.",
"The Louvre is in Paris.",
],
)
reranker.rank(
query=Record(
text="What is the capital of France?",
timestamp=datetime.now(),
),
docs=[
Record(
text="Paris is the capital of France.",
timestamp=datetime.now() - timedelta(days=1),
),
Record(
text="The Eiffel Tower is in Paris.",
timestamp=datetime.now() - timedelta(days=2),
),
Record(
text="The Louvre is in Paris.",
timestamp=datetime.now() - timedelta(days=3),
),
]
)
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
reranker-0.2.1.tar.gz
(15.1 kB
view details)
Built Distribution
File details
Details for the file reranker-0.2.1.tar.gz
.
File metadata
- Download URL: reranker-0.2.1.tar.gz
- Upload date:
- Size: 15.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ee87f6a9d17600bba815323e40798ba86cecf737946103eb40bbe2a12793730 |
|
MD5 | 629ade5e94fbbc45d1a82a6eb57bcf29 |
|
BLAKE2b-256 | 2456dad558224864ae1dd6c639dab6d2bc637f51dd7c7c6dc6bc36c40a7b51ba |
File details
Details for the file reranker-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: reranker-0.2.1-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6ca4a61e233ab62dd07b44cfaeb8a669dfe1d91103dd6150db5010fbed8296d |
|
MD5 | 9a0b319f4a13800d68d570f5a3210db6 |
|
BLAKE2b-256 | 05243a7f5a53fee8baab97c66d87ed89c36b088a509f654861daa26df93a4bc2 |