Does this work with re-rankers? #166
-
I'm trying to figure out how to get bge re-ranker to work. |
Beta Was this translation helpful? Give feedback.
Answered by
michaelfeil
Mar 21, 2024
Replies: 1 comment 1 reply
-
Yes, see this setion in readme (0.0.30) RerankingReranking gives you a score for similarity between a query and multiple documents. import asyncio
from infinity_emb import AsyncEmbeddingEngine, EngineArgs
query = "What is the python package infinity_emb?"
docs = ["This is a document not related to the python package infinity_emb, hence...",
"Paris is in France!",
"infinity_emb is a package for sentence embeddings and rerankings using transformer models in Python!"]
engine_args = EngineArgs(model_name_or_path = "BAAI/bge-reranker-base", engine="torch")
engine = AsyncEmbeddingEngine.from_args(engine_args)
async def main():
async with engine:
ranking, usage = await engine.rerank(query=query, docs=docs)
print(list(zip(ranking, docs)))
asyncio.run(main()) When using the CLI, use this command to launch rerankers: infinity_emb --model-name-or-path BAAI/bge-reranker-base |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
michaelfeil
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, see this setion in readme (0.0.30)
Reranking
Reranking gives you a score for similarity between a query and multiple documents.
Use it in conjunction with a VectorDB+Embeddings, or as standalone for small amount of documents.
Please select a model from huggingface that is a AutoModelForSequenceClassification with one class classification.