How to Improve LLMs with RAG (Overview + Python Code)

  Рет қаралды 14,877

Shaw Talebi

Shaw Talebi

Күн бұрын

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/KZbin-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
🎥 KZbin: / @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 KZbin Comment Responder with RAG - 9:34
What's next? - 20:58

Пікірлер: 37
@ShawhinTalebi
@ShawhinTalebi Ай бұрын
Check out more videos in this series 👇 👉 Series Playlist: kzbin.info/aero/PLz-ep5RbHosU2hnz5ejezwaYpdMutMVB0 🎥 Fine-tuning with QLoRA: kzbin.info/www/bejne/jqHSfHVpqtiggcU -- 📰 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/KZbin-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] kzbin.info/www/bejne/m5fFn2BpqbV8la8 [3] docs.llamaindex.ai/en/stable/understanding/loading/loading.html [4] kzbin.info/www/bejne/kJuYg3atmrp7f80
@ifycadeau
@ifycadeau Ай бұрын
This is so helpful! Thanks Shaw, you never miss!
@ShawhinTalebi
@ShawhinTalebi Ай бұрын
Glad it was helpful!
@saadowain3511
@saadowain3511 Ай бұрын
Thank you Talebi. No one explains the subject like you
@ShawhinTalebi
@ShawhinTalebi Ай бұрын
Thanks :) Glad it was clear!
@GetPaidToLivePodcast
@GetPaidToLivePodcast Ай бұрын
Incredible breakdown Shaw!
@bangarrajumuppidu8354
@bangarrajumuppidu8354 Ай бұрын
superb explanation Shaw !😍
@michaelpihosh5904
@michaelpihosh5904 Ай бұрын
Thanks Shaw!
@examore-lite
@examore-lite Ай бұрын
Thank you very much!
@deadlyecho
@deadlyecho 24 күн бұрын
Very good explanation 👏 👌
@tomasbusse2410
@tomasbusse2410 19 күн бұрын
Very useful indeed
@ariel-dev
@ariel-dev Ай бұрын
Really great
@lplp6961
@lplp6961 Ай бұрын
good work!
@Blogservice-Fuerth
@Blogservice-Fuerth Ай бұрын
Great 🙏
@nayem5330
@nayem5330 Ай бұрын
Very useful.
@ShawhinTalebi
@ShawhinTalebi Ай бұрын
Glad it was helpful!
@firespark804
@firespark804 Ай бұрын
Awesome video, thanks! I'm wondering if instead of using top_k documents/batches one could define a threshold/distance for the used batches?
@halle845
@halle845 Ай бұрын
Thanks!
@ShawhinTalebi
@ShawhinTalebi Ай бұрын
Thank you! Glad it was helpful 😁
@nistelbergerkurt5309
@nistelbergerkurt5309 Ай бұрын
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?
@ShawhinTalebi
@ShawhinTalebi Ай бұрын
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: kzbin.info/www/bejne/i5mck4yfi9eKldU&ab_channel=JamesBriggs
@zahrahameed4098
@zahrahameed4098 10 күн бұрын
Thankyou so much. Becoming a fan of yours! Please do a video on Rag with llamaIndex + llama3 if it's free and not paid.
@ShawhinTalebi
@ShawhinTalebi 4 күн бұрын
Great suggestion. That's a good excuse to try out Llama3 :)
@Pythonology
@Pythonology Ай бұрын
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 ...?
@ShawhinTalebi
@ShawhinTalebi Ай бұрын
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.
@TheLordSocke
@TheLordSocke 10 күн бұрын
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. 😢
@ShawhinTalebi
@ShawhinTalebi 4 күн бұрын
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
@vamsitharunkumarsunku4583
@vamsitharunkumarsunku4583 Ай бұрын
So we get top 3 similar chunks from RAG right, We are adding 3 chunks to prompt template?
@ShawhinTalebi
@ShawhinTalebi Ай бұрын
Yes exactly!
@halle845
@halle845 Ай бұрын
Any recommendations or experience on which embeddings database to use?
@ShawhinTalebi
@ShawhinTalebi Ай бұрын
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
@TheRcfrias
@TheRcfrias 11 күн бұрын
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?
@ShawhinTalebi
@ShawhinTalebi 11 күн бұрын
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.
@TheRcfrias
@TheRcfrias 11 күн бұрын
@@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.
@jjen9595
@jjen9595 Ай бұрын
hello, do you have a video showing how to make a datasett and upload it to huggind face?
@ShawhinTalebi
@ShawhinTalebi Ай бұрын
Not currently, but the code to do that is available on GitHub: github.com/ShawhinT/KZbin-Blog/blob/main/LLMs/qlora/create-dataset.ipynb
QLoRA-How to Fine-tune an LLM on a Single GPU (w/ Python Code)
36:58
What is RAG? (Retrieval Augmented Generation)
11:37
Don Woodlock
Рет қаралды 67 М.
Зу-зу Күлпәш. Агроном. (5-бөлім)
55:20
ASTANATV Movie
Рет қаралды 569 М.
Did you find it?! 🤔✨✍️ #funnyart
00:11
Artistomg
Рет қаралды 67 МЛН
КИРПИЧ ОБ ГОЛОВУ #shorts
00:24
Паша Осадчий
Рет қаралды 6 МЛН
Reliable, fully local RAG agents with LLaMA3
21:19
LangChain
Рет қаралды 71 М.
How to Use Perplexity Pro
11:10
AI Review Room
Рет қаралды 1,6 М.
Prompt Engineering: How to Trick AI into Solving Your Problems
29:58
I Was Wrong About AI Consulting (what I learned)
9:56
Shaw Talebi
Рет қаралды 4,7 М.
Fine-tuning Large Language Models (LLMs) | w/ Example Code
28:18
Shaw Talebi
Рет қаралды 223 М.
ADVANCED Python AI Agent Tutorial - Using RAG
40:59
Tech With Tim
Рет қаралды 109 М.
NEW GPT-4o: My Mind is Blown.
6:28
Joshua Chang
Рет қаралды 380 М.
I Analyzed My Finance With Local LLMs
17:51
Thu Vu data analytics
Рет қаралды 373 М.
Зу-зу Күлпәш. Агроном. (5-бөлім)
55:20
ASTANATV Movie
Рет қаралды 569 М.