Skip to content

Conversation

osanseviero
Copy link

@osanseviero osanseviero commented Aug 13, 2024

Re: https://huggingface.slack.com/archives/C069KSP486B/p1719846796695499

Community counterpart huggingface/api-inference-community#445

A challenge will be installing both sentence-transformers and diffusers dependencies from api-inference-community which likely mismatch.

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)}
Copy link
Author

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
Copy link
Author

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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All other tests pass 🔥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant