from zeroentropy import ZeroEntropy
zclient = ZeroEntropy()
# Example: reranking 5 retrieved snippets
query = "What is Retrieval Augmented Generation?"
documents = [
"RAG combines retrieval with generation by conditioning the LLM on external documents.",
"Retrieval-Augmented Generation is a machine learning technique introduced by Meta AI in 2020.",
"It uses reinforcement learning to generate music sequences.",
"RAG can improve factual accuracy by grounding answers in retrieved evidence.",
"Transformers are a type of deep learning architecture."
]
response = zclient.models.rerank(
model="zerank-2",
query=query,
documents=documents,
)
# Each document will include a score and be sorted by relevance
for doc in response.results:
print(doc)