davidmigloz / langchain_dart

Build LLM-powered Dart/Flutter applications.
https://langchaindart.dev
MIT License
429 stars 77 forks source link

Add support for HuggingFaceHub LLMs #19

Open davidmigloz opened 1 year ago

davidmigloz commented 1 year ago

The Hugging Face Hub is a platform with over 120k models, 20k datasets, and 50k demo apps (Spaces), all open source and publicly available, in an online platform where people can easily collaborate and build ML together.

https://python.langchain.com/en/latest/modules/models/llms/integrations/huggingface_hub.html

jtkeyva commented 9 months ago

any update on this?

davidmigloz commented 9 months ago

No progress yet, unfortunately.

It should be pretty straightforward to integrate. There's already a Dart client (huggingface_dart), so it's just about implementing the LangChain.dart wrappers around it.

Happy to help if anyone wants to give it a try.

jtkeyva commented 9 months ago

thanks for the update

huzaifansari54 commented 1 month ago

hii! can i work on this task using huggingface_client: pkg i try (huggingface_dart) it is missing some api like audio and vision apis can u assign me this task and kindly guide which pkg I should use i also mange hugging face client pkg recently i worked on it resolve some issue ,and add new text to image API

jtkeyva commented 1 month ago

@huzaifansari54 that would be great

davidmigloz commented 1 month ago

Hey @huzaifansari54,

That would be great 🙂

You can add the implementation to the langchain_huggingface package. You can check how other integrations are implemented (eg. ChatAnthropic), it should be pretty similar.

Let me know if you have any questions or issues!

huzaifansari54 commented 1 month ago

Can suggest me docs of python or javascript of hugging face lang chain implementation it would be great 👍

davidmigloz commented 1 month ago

Let's start with the LLM integration (the Hugging Face Inference Endpoint):

In LangChain python, the wrapper is called HuggingFaceEndpoint:

In LangChain JS, the wrapper is called HuggingFaceInference:

Which name do you prefer? I would say HuggingFaceInference sounds better.

To start the implementation:

  1. Create a llm directory (langchain_huggingface/lib/src/llm)
  2. Create 3 files: a. huggingface_inference.dart: where the wrapper implementation will go b. types.dart: where to place the HuggingFaceInferenceOptions class c. mappers.dart: where to place all the mapping logic from the huggingface_client classes to the LangChain.dart ones.
  3. Add all the options HuggingFace supports in HuggingFaceInferenceOptions
  4. Implement the mapping logic
  5. Implement the HuggingFaceInference wrapper that calls the client with the passed options and maps the reponse to the LangChain.dart abstractions using the mappers.

You can check other integrations to have a reference.

huzaifansari54 commented 1 month ago

thanks

huzaifansari54 commented 1 month ago

hugging face llm is done but there is an issue in hugging_face_client pkg i resolved the issue and sent a pull request ASAP this pull request 17 merge by owner of pkg . also i start working on chat model support for Hugging face when it is complete i will start work on chat model for lang chain dart hugging face

davidmigloz commented 1 month ago

Great progress, thanks for the update!