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

Unable to instantiate HuggingfaceEmbeddings #1806

Open
sadaisystems opened this issue Jan 4, 2025 · 1 comment
Open

Unable to instantiate HuggingfaceEmbeddings #1806

sadaisystems opened this issue Jan 4, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@sadaisystems
Copy link

[x] I have checked the documentation and related resources and couldn't resolve my bug.

Describe the bug
Unable to instantiate HuggingfaceEmbeddings, because it doesn't implement asynchronous embed methods of base BaseRagasEmbeddings class.

Ragas version: 0.2.9
Python version: 3.12.8

Code to Reproduce
Code is taken from the docs basically.

from ragas.dataset_schema import SingleTurnSample
from ragas.embeddings import HuggingfaceEmbeddings
from ragas.metrics import SemanticSimilarity

sample = SingleTurnSample(
    response="The Eiffel Tower is located in Paris.",
    reference="The Eiffel Tower is located in Paris. I has a height of 1000ft."
)
ragas_embeddings = HuggingfaceEmbeddings(model_name="BAAI/bge-reranker-v2-m3")
scorer = SemanticSimilarity(embeddings=ragas_embeddings, is_cross_encoder=True)

await scorer.single_turn_ascore(sample)

Error trace

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
File /home/magnesium/sadaivault/prrag/kilt_eval.py:[1](https://file+.vscode-resource.vscode-cdn.net/home/magnesium/sadaivault/prrag/kilt_eval.py:1)
----> 1 ragas_embeddings = HuggingfaceEmbeddings(model_name="BAAI/bge-reranker-v2-m3")

TypeError: Can't instantiate abstract class HuggingfaceEmbeddings without an implementation for abstract methods 'aembed_documents', 'aembed_query'

Expected behavior
I expected the object to be instantiated and functional.

@sadaisystems sadaisystems added the bug Something isn't working label Jan 4, 2025
@jjmachan
Copy link
Member

jjmachan commented Jan 7, 2025

hey @sadaisystems could you maybe check out fastembed https://github.com/qdrant/fastembed it had async support last time I checked, which was a while back, could you check it out?

let me know if you need help. I'll try it out in my end and share the code snippet too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants