-
Notifications
You must be signed in to change notification settings - Fork 14
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
[Draft] Experiment using api-inference-community for inference definitions #82
base: main
Are you sure you want to change the base?
Conversation
embeddings2 = self.model.encode(inputs["sentences"], convert_to_tensor=True) | ||
similarities = util.pytorch_cos_sim(embeddings1, embeddings2).tolist()[0] | ||
return {"similarities": similarities} | ||
return {"similarities": self.model(inputs)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm doing this for backwards compatibility, but note that this is inconsistent with the other APIs and https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/src/tasks/sentence-similarity/inference.ts
|
||
|
||
SENTENCE_TRANSFORMERS_TASKS = { | ||
"sentence-similarity": SentenceSimilarityPipeline, | ||
"sentence-embeddings": SentenceEmbeddingPipeline, | ||
"sentence-ranking": RankingPipeline, | ||
#"sentence-ranking": RankingPipeline, # To be implemented |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removing for now as there's not one
["Lets create an embedding", "Lets create an embedding"], | ||
) | ||
assert isinstance(res["scores"], float) | ||
#@require_torch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All other tests pass 🔥
Re: https://huggingface.slack.com/archives/C069KSP486B/p1719846796695499
Community counterpart huggingface/api-inference-community#445
A challenge will be installing both
sentence-transformers
anddiffusers
dependencies fromapi-inference-community
which likely mismatch.