How to Improve LLMs with RAG (Overview + Python Code)
HTML-код
- Опубликовано: 7 июн 2024
- 👉 Need help with AI? Reach out: shawhintalebi.com/
In this video, I give a beginner-friendly introduction to retrieval augmented generation (RAG) and show how to use it to improve a fine-tuned model from a previous video in this LLM series.
👉 Series Playlist: • Large Language Models ...
🎥 Fine-tuning with QLoRA: • QLoRA-How to Fine-tune...
📰 Read more: medium.com/towards-data-scien...
💻 Colab: colab.research.google.com/dri...
💻 GitHub: github.com/ShawhinT/RUclips-B...
🤗 Model: huggingface.co/shawhin/shawgp...
Resources
[1] github.com/openai/openai-cook...
[2] • LlamaIndex Webinar: Bu...
[3] docs.llamaindex.ai/en/stable/...
[4] • LlamaIndex Webinar: Ma...
--
Book a call: calendly.com/shawhintalebi
Homepage: shawhintalebi.com/
Socials
/ shawhin
/ shawhintalebi
/ shawhint
/ shawhintalebi
The Data Entrepreneurs
🎥 RUclips: / @thedataentrepreneurs
👉 Discord: / discord
📰 Medium: / the-data
📅 Events: lu.ma/tde
🗞️ Newsletter: the-data-entrepreneurs.ck.pag...
Support ❤️
www.buymeacoffee.com/shawhint
Intro - 0:00
Background - 0:53
2 Limitations - 1:45
What is RAG? - 2:51
How RAG works - 5:03
Text Embeddings + Retrieval - 5:35
Creating Knowledge Base - 7:37
Example Code: Improving RUclips Comment Responder with RAG - 9:34
What's next? - 20:58
Check out more videos in this series 👇
👉 Series Playlist: ruclips.net/p/PLz-ep5RbHosU2hnz5ejezwaYpdMutMVB0
🎥 Fine-tuning with QLoRA: ruclips.net/video/XpoKB3usmKc/видео.html
--
📰 Read more: medium.com/towards-data-science/how-to-improve-llms-with-rag-abdc132f76ac?sk=d8d8ecfb1f6223539a54604c8f93d573
💻 Colab: colab.research.google.com/drive/1peJukr-9E1zCo1iAalbgDPJmNMydvQms?usp=sharing
💻 GitHub: github.com/ShawhinT/RUclips-Blog/tree/main/LLMs/rag
🤗 Model: huggingface.co/shawhin/shawgpt-ft
Resources
[1] github.com/openai/openai-cookbook/blob/main/examples/Question_answering_using_embeddings.ipynb
[2] ruclips.net/video/efbn-3tPI_M/видео.html
[3] docs.llamaindex.ai/en/stable/understanding/loading/loading.html
[4] ruclips.net/video/Zj5RCweUHIk/видео.html
Thank you Talebi. No one explains the subject like you
Thanks :) Glad it was clear!
This is so helpful! Thanks Shaw, you never miss!
Glad it was helpful!
superb explanation Shaw !😍
very nice. thank you for explaining in details.
Incredible breakdown Shaw!
Very good explanation 👏 👌
Thank you very much!
Very useful indeed
Thanks Shaw!
Really great
good work!
Awesome video, thanks! I'm wondering if instead of using top_k documents/batches one could define a threshold/distance for the used batches?
Very useful.
Glad it was helpful!
Solid video
great video as always 👍
does a reranker improve the quality of the output for a RAG approach? like that we could take the output directly from the reranker, right? or what is your experience with reranker?
Great questions! That's the idea. A reranker is typically applied to the top-k (say k=25) search results to further refine the chunks. The reason you wouldn't use a reranker directly on the entire knowledge base is because it is (much) more computationally expense than the text embedding-based search described here. I've haven't used a reranker in any use case, but it seems to be most beneficial when working with a large knowledge base.
This video may be helpful: ruclips.net/video/Uh9bYiVrW_s/видео.html&ab_channel=JamesBriggs
Thankyou so much. Becoming a fan of yours!
Please do a video on Rag with llamaIndex + llama3 if it's free and not paid.
Great suggestion. That's a good excuse to try out Llama3 :)
Great 🙏
Happy Nowruz, kheyli khoob! Question: how would you propose to evaluate a document on the basis of certain guidelines? I mean, to see how far it complies with the guidelines or regulations for writing a certain document. Is RAG any good? shall we just embed the guidelines in the prompt right before the writing? or shall we store the guidelines as a separate document and do RAG? Or ...?
Happy New Year!
That's a good question. It sounds like you want the model to evaluate a given document based on some set of guidelines. If the guidelines are static, you can fix them into the prompt. However, if you want the guidelines to be dynamic, you can house them in a database which is dynamically integrated into the prompt based on the user's input.
Thanks!
Thank you! Glad it was helpful 😁
Hi Talebi. Thanks for all you show us. But one question : I did your code with mine database, without the fine tuning and it works, very quickly answers but poor contents. That is the point of fine tuning make better answers ?
It sounds like you may need to do some additional optimizations to improve your system. I discuss some finer points here: towardsdatascience.com/how-to-improve-llms-with-rag-abdc132f76ac?sk=d8d8ecfb1f6223539a54604c8f93d573#bf88
Nice Video, any ideas for doing this on PowerPoints? Want to build a kind of knowledge base from previous projects but the grafics are a problem. Even GPT4V is not always interpreting them correctly. 😢
If GPT4V is having issues you may need to either 1) wait for better models to come out or 2) parse the knowledge from the PPT slides in a more clever way.
Feel free to book office hours if you want to dig into it a bit more: calendly.com/shawhintalebi/office-hours
what do you mean with 'not to scale?' isn't the book at the size of the earth?
So we get top 3 similar chunks from RAG right, We are adding 3 chunks to prompt template?
Yes exactly!
Any recommendations or experience on which embeddings database to use?
Good question! Performance of embedding models will vary by domain, so some experimentation is always required. However, I've found the following 2 resources helpful as a starting place.
HF Leaderboard: huggingface.co/spaces/mteb/leaderboard
SentenceTransformers: www.sbert.net/docs/pretrained_models.html
Rag is great for semi-static or static content as knowledge base, but which path do you use for dynamic, time-relevant data like current sales from a database?
That's a great question. The short answer is RAG can handle this sort of data (at least in principle). The longer answer involves taking a step back and asking oneself "why do I want to use RAG/LLMs/AI for this use case?" This helps get to the root of the problem you are trying to solve and hopefully give more clarity about potential solutions.
@@ShawhinTalebi Its a common use case at work to know how sales have been improving during the current day or week. It would be nice to know how to link the LLM with the corporate database for current information and reporting.
Great video! What is fat-tailedness?
😉 ruclips.net/video/Wcqt49dXtm8/видео.htmlsi=E_R7A7IrkbAUVaOs
hello, do you have a video showing how to make a datasett and upload it to huggind face?
Not currently, but the code to do that is available on GitHub: github.com/ShawhinT/RUclips-Blog/blob/main/LLMs/qlora/create-dataset.ipynb
Vector retrieval is quite shite. Trust me. To improve accuracy of retrieval, you need to use multiple methods.