Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Inference 1.1.0 (w/ Rerank API) #389

Merged
merged 3 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ lz4 = { version = ">=3.1.3", optional = true }
protobuf = { version = "^4.25", optional = true }
protoc-gen-openapiv2 = {version = "^0.0.1", optional = true }
pinecone-plugin-interface = "^0.0.7"
pinecone-plugin-inference = "^1.0.3"
pinecone-plugin-inference = "^1.1.0"

[tool.poetry.group.types]
optional = true
Expand Down
40 changes: 40 additions & 0 deletions tests/integration/inference/test_rerank.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from pinecone import Pinecone
from pinecone.grpc import PineconeGRPC


class TestInferencePluginRerank:
def test_rerank(self, api_key):
pc = Pinecone(api_key=api_key)

model = "bge-reranker-v2-m3"
result = pc.inference.rerank(
model=model,
query="i love dogs",
documents=["dogs are pretty cool", "everyone loves dogs", "I'm a cat person"],
top_n=1,
return_documents=True,
)
assert len(result.data) == 1
assert result.data[0].index == 1
assert result.data[0].document.text == "everyone loves dogs"
assert result.model == model
assert isinstance(result.usage.rerank_units, int)
assert result.usage.rerank_units == 1

def test_rerank_grpc(self, api_key):
pc = PineconeGRPC(api_key=api_key)

model = "bge-reranker-v2-m3"
result = pc.inference.rerank(
model=model,
query="i love dogs",
documents=["dogs are pretty cool", "everyone loves dogs", "I'm a cat person"],
top_n=1,
return_documents=True,
)
assert len(result.data) == 1
assert result.data[0].index == 1
assert result.data[0].document.text == "everyone loves dogs"
assert result.model == model
assert isinstance(result.usage.rerank_units, int)
assert result.usage.rerank_units == 1
Loading