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

[Draft] Experiment using api-inference-community for inference definitions #82

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

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