Database
- Indexes
- Vectors
- Search
- Imports
- Backups
Inference
- Embed
- Rerank
Architecture
Rerank
Rerank results
Rerank query results according to their relevance to a query. This endpoint uses Pinecone’s hosted reranking models.
For guidance and examples, see Rerank documents.
POST
/
rerank
from pinecone.grpc import PineconeGRPC as Pinecone
pc = Pinecone(api_key="YOUR_API_KEY")
result = pc.inference.rerank(
model="bge-reranker-v2-m3",
query="The tech company Apple is known for its innovative products like the iPhone.",
documents=[
{"id": "vec1", "text": "Apple is a popular fruit known for its sweetness and crisp texture."},
{"id": "vec2", "text": "Many people enjoy eating apples as a healthy snack."},
{"id": "vec3", "text": "Apple Inc. has revolutionized the tech industry with its sleek designs and user-friendly interfaces."},
{"id": "vec4", "text": "An apple a day keeps the doctor away, as the saying goes."},
],
top_n=4,
return_documents=True,
parameters={
"truncate": "END"
}
)
print(result)
RerankResult(
model='bge-reranker-v2-m3',
data=[
{ index=2, score=0.48357219,
document={id="vec3", text="Apple Inc. has re..."} },
{ index=0, score=0.048405956,
document={id="vec1", text="Apple is a popula..."} },
{ index=3, score=0.007846239,
document={id="vec4", text="An apple a day ke..."} },
{ index=1, score=0.0006563728,
document={id="vec2", text="Many people enjoy..."} }
],
usage={'rerank_units': 1}
)
from pinecone.grpc import PineconeGRPC as Pinecone
pc = Pinecone(api_key="YOUR_API_KEY")
result = pc.inference.rerank(
model="bge-reranker-v2-m3",
query="The tech company Apple is known for its innovative products like the iPhone.",
documents=[
{"id": "vec1", "text": "Apple is a popular fruit known for its sweetness and crisp texture."},
{"id": "vec2", "text": "Many people enjoy eating apples as a healthy snack."},
{"id": "vec3", "text": "Apple Inc. has revolutionized the tech industry with its sleek designs and user-friendly interfaces."},
{"id": "vec4", "text": "An apple a day keeps the doctor away, as the saying goes."},
],
top_n=4,
return_documents=True,
parameters={
"truncate": "END"
}
)
print(result)
RerankResult(
model='bge-reranker-v2-m3',
data=[
{ index=2, score=0.48357219,
document={id="vec3", text="Apple Inc. has re..."} },
{ index=0, score=0.048405956,
document={id="vec1", text="Apple is a popula..."} },
{ index=3, score=0.007846239,
document={id="vec4", text="An apple a day ke..."} },
{ index=1, score=0.0006563728,
document={id="vec2", text="Many people enjoy..."} }
],
usage={'rerank_units': 1}
)
Authorizations
Body
application/json
Rerank documents for the given query
The body is of type object
.
Response
200
application/json
OK
The result of a reranking request.
Was this page helpful?
from pinecone.grpc import PineconeGRPC as Pinecone
pc = Pinecone(api_key="YOUR_API_KEY")
result = pc.inference.rerank(
model="bge-reranker-v2-m3",
query="The tech company Apple is known for its innovative products like the iPhone.",
documents=[
{"id": "vec1", "text": "Apple is a popular fruit known for its sweetness and crisp texture."},
{"id": "vec2", "text": "Many people enjoy eating apples as a healthy snack."},
{"id": "vec3", "text": "Apple Inc. has revolutionized the tech industry with its sleek designs and user-friendly interfaces."},
{"id": "vec4", "text": "An apple a day keeps the doctor away, as the saying goes."},
],
top_n=4,
return_documents=True,
parameters={
"truncate": "END"
}
)
print(result)
RerankResult(
model='bge-reranker-v2-m3',
data=[
{ index=2, score=0.48357219,
document={id="vec3", text="Apple Inc. has re..."} },
{ index=0, score=0.048405956,
document={id="vec1", text="Apple is a popula..."} },
{ index=3, score=0.007846239,
document={id="vec4", text="An apple a day ke..."} },
{ index=1, score=0.0006563728,
document={id="vec2", text="Many people enjoy..."} }
],
usage={'rerank_units': 1}
)