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

feat(hugging_face): Add support for multiple models and dimensions #624

Conversation

bricesanchez
Copy link
Contributor

Hello! Thank you for this awesome gem!

I'm currently playing with it and i've seen Hugging face ruby gem can now support custom embedding models:

see: alchaplinsky/hugging-face@bee85a4

I've added the ability to change the embedding model and did some clean up in the class.

@andreibondarev
Copy link
Collaborator

@bricesanchez Thank you for the PR, looks like the specs are failing.

@bricesanchez
Copy link
Contributor Author

@andreibondarev You're right!

It looks like elasticsearch class looks like for the LLM dimensions (lib/langchain/vectorsearch/elasticsearch.rb:107).
And with my change, it breaks.

But it looks like there is no dimension mention in the hugging_face gem.

I can re-add it for simplicity.

What do you think?

@andreibondarev
Copy link
Collaborator

@bricesanchez Take a look at how we do it in the Ollama integration:

def default_dimensions
# since Ollama can run multiple models, look it up or generate an embedding and return the size
@default_dimensions ||=
EMBEDDING_SIZES.fetch(defaults[:embeddings_model_name].to_sym) do
embed(text: "test").embedding.size
end
end

@bricesanchez bricesanchez force-pushed the feat/hugging-face-custom-model branch from bd23d0d to ae4b051 Compare May 15, 2024 14:10
@bricesanchez
Copy link
Contributor Author

@andreibondarev, I've made the changes, don't hesitate if you have any comments!

@andreibondarev
Copy link
Collaborator

@bricesanchez Thank you! Left you a comment.

@bricesanchez bricesanchez force-pushed the feat/hugging-face-custom-model branch from 9333ac4 to e9b3240 Compare May 18, 2024 02:34
@andreibondarev
Copy link
Collaborator

@bricesanchez I'm going to review it shortly.

@andreibondarev andreibondarev self-requested a review May 19, 2024 01:35
Copy link
Collaborator

@andreibondarev andreibondarev left a comment

Choose a reason for hiding this comment

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

@bricesanchez Thank you for the PR! Looks great!

@andreibondarev andreibondarev merged commit 76d7453 into patterns-ai-core:main May 19, 2024
5 checks passed
@bricesanchez
Copy link
Contributor Author

Thank you @andreibondarev!

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.

None yet

2 participants