xenova / transformers.js

State-of-the-art Machine Learning for the web. Run 🤗 Transformers directly in your browser, with no need for a server!
https://huggingface.co/docs/transformers.js
Apache License 2.0
11.08k stars 684 forks source link

Consultation on the use of the library with chatbot models #814

Open mate07 opened 3 months ago

mate07 commented 3 months ago

Question

Hello, Greetings Vladimir, programmer in a web environment with PHP, JS, AJAX, first I apologize for my English, my native language is Latin Spanish, I am not very good at writing it, I have used a translator, I wanted to consult, how can I use this interesting and useful tool, to be able to create a chatbot that can respond with personalized information from PDFs, the query is more like using the library, how to use the models both from Hugging Face and downloaded from the script that you share in the documentation and which models would be the most useful for this task considering that you will have to speak in Spanish, I remain attentive

xenova commented 3 months ago

Hi there 👋 You can certainly use Transformers.js for that :) I'd recommend checking out our v3/dev branch (here), which enables WebGPU support. You can probably use Phi-3 for this, and we actually made a demo for it recently (see below). You'd need to implement the PDF parsing + RAG pipeline yourself, but you can use Transformers.js for computing embeddings. See here for an example model + usage: https://huggingface.co/Xenova/all-MiniLM-L6-v2.

Online demo: https://huggingface.co/spaces/Xenova/experimental-phi3-webgpu Demo source code: https://github.com/xenova/transformers.js/tree/v3/examples/webgpu-chat

https://github.com/xenova/transformers.js/assets/26504141/6c42e61b-f381-4835-bf63-f37cc752a16b

jca41 commented 2 months ago

Hi, i've done a small POC around RAG recently. Results are okay-ish, i haven't tested many model permutations.

Please have a look and let me know if you have questions https://gist.github.com/jca41/3094f71c9d8a30ce785b55b60e7a1ba4