Local Retrieval Augmented Generation (RAG) from Scratch (step by step tutorial)

Поділитися
Вставка
  • Опубліковано 21 лис 2024

КОМЕНТАРІ • 197

  • @mrdbourke
    @mrdbourke  8 місяців тому +55

    Who’s ready to build a local RAG pipeline from scratch? 🔨🔥
    PS A big shout out to NVIDIA for sponsoring this video!
    Be sure to checkout NVIDIA GTC for the latest developments in AI, deep learning and GPU technology.
    It’s running from March 18-21 in San Jose California but is free to attend virtually (what I’m doing): nvda.ws/3GUZygQ

    • @nikosterizakis
      @nikosterizakis 8 місяців тому

      Once again, an awesome video, Daniel. Two comments only, if I may: a. lose the tash :) b. I just got a mac pro and you started coding on a windows :(

    • @kameshsingh7867
      @kameshsingh7867 8 місяців тому

      Great video, I have been waiting for such video on RAG. Thanks Daniel

    • @Dan-Levi
      @Dan-Levi 5 місяців тому

      Great stuff, thanks for making this available for us noobs! I managed to follow it to the end with my custom source of text (a phpbb forum's posts), although it wasn't very good at answering it did produce some answers.
      All text was in norwegian, and the topics and the related answers was concatenated to its each line in a txt file.
      I'm sure i could have done this much better but for a first try i was rather satisfied!
      Could not have done this without this video tho, so yeah, great stuff!
      Any tips on models i can use for scandinavian/norwegian? I tried to search around a bit and after a quick talk with chatgpt (lol) i found the NB-BERT (Norwegian BERT), but did not manage to get it going.

    • @robertovillegas2220
      @robertovillegas2220 5 місяців тому

      It would be great if you do a video on how to add to the query a file, just like in the Chat GPT. My use case is that, A group of files as a context for the RAG and a query with a document of the RAG to compare the document in the query vs criteria in the content of other documents and evaluate compliance of the document in the query.

    • @hassan_sid
      @hassan_sid 4 місяці тому

      This video is a gem. I have recently completed watching your Tensorflow and PyTorch tutorials. Those videos are great in terms of resources. Plz, make a video on fine-tuning LLMs. Looking for more amazing videos from you in the future.

  • @TheYephers
    @TheYephers 7 місяців тому +29

    A lot of times I struggle to make it through a 10 or 20 minute video on this stuff. But somehow I can watch 5hours or even 24hours of you. I love how you keep it lite and you let use see your typos. You are a special an unique person and I am glad you do what you do. I really loved your 24 hour pytorch video too.

  • @hpac9687
    @hpac9687 8 місяців тому +11

    I'm a follower for quite some time and also a big advocate for open sourcing, knowledge exchange and community building. Really happy to see you consistently push yourself and your work but never loosing site of your core values. Great Job!

  • @amitkumarchejara6042
    @amitkumarchejara6042 7 місяців тому +6

    Finished the tutorial today and will start building something using this tremendous knowledge. Thankyou so much!!
    And a note : We are happy and excited with any Idea that pops into your head about a new educational video.
    we need tutorial on different frameworks and building from scratch.

  • @NuwanChamara-e1e
    @NuwanChamara-e1e 2 місяці тому +2

    Thank you so much! I just finished watching this video. As a beginner in ML/RAG, your teaching style is really helpful for entry-level users like me.
    I am from Sri Lanka

  • @AprendizSerial1979
    @AprendizSerial1979 6 місяців тому +7

    I must give you my total gratitude for taking your time (5 hours) to explain baby steps such invaluable knowledge.

  • @arda8206
    @arda8206 2 місяці тому +4

    How do you guys not give a like to this video if you watch it fully? Excellent content as always.

  • @_MrCode
    @_MrCode 8 місяців тому +17

    Machine Learning Bootcamps will never exist 'cause of Daniel 🤗

    • @newxceo
      @newxceo 8 місяців тому +5

      Yeah! Tutorials on these topics are rare, he can make huge amount of money but he teaches as an ideal teacher.

  • @r0f115L4m
    @r0f115L4m 8 місяців тому +9

    It’s always a good day when Daniel drops one of these tutorials. Love it!

  • @彧汪
    @彧汪 2 місяці тому

    After reading and manually building the local RAG, it took three afternoons, thanks to the author

  • @merzougahmed4248
    @merzougahmed4248 6 днів тому

    Finished the whole 5:40min Hours. thank you so much for sharing this video. I have tried the RAG system on some of the Geostatistics books that I have and it comes up with really good results. if there are any advanced topics on improving RAGs please share them. I found that the code sometimes have a hard time understanding difficult concepts and just ignore them. my assumption is the embedding can be improved to include better understanding.

  • @ahmeterdonmez9195
    @ahmeterdonmez9195 6 днів тому +1

    This guy is game changer really...........

  • @mustafamaree
    @mustafamaree 8 місяців тому +4

    Great content i am watching TF course now thanks for your effort to make the learning easy and fun

  • @evharten
    @evharten 5 місяців тому

    Almost 6 hours of training but it only took me two day's to get through and build our own RAG model, it was a breeze. Very good training and it really helped me in understanding what RAG is and how to implement it. Thank you very much!

  • @jparra2K
    @jparra2K 2 місяці тому

    What a GREAT tutorial Daniel!! Truly step-by-step. Thanks for putting this together. I did not have major issues following it through. The decision of using Jupyter notebooks here was key..

  • @Stefan_2117
    @Stefan_2117 Місяць тому

    Such a great tutorial mate, kept my interest in every minute of this long video. God bless you 🙏

  • @Mrwingsofchickenwings
    @Mrwingsofchickenwings Місяць тому +1

    i would love seeing this done for graph rag. Fantatic tutorial❤

  • @vasoyarutvik2897
    @vasoyarutvik2897 4 місяці тому +1

    Hey daniel, i have seen tensorflow and pytorch code videos and I just loved it and today I have completed this video.i just want to say thank you so much. love your content and your teaching style as well. love from INDIA. good luck

  • @tejasvix
    @tejasvix 3 місяці тому

    I am baffled by the sheer quality of this content, damn thanks, would love to see a similar tutorial on fine-tuning newer models like llama 3.1 or mistral ones

  • @studywithjames
    @studywithjames 4 місяці тому

    I am going to be a Graduate Researcher at my University and going to research RAG! I was worried since I was new to RAG until this video! Thanks, Daniel!

  • @mortitotti
    @mortitotti 4 місяці тому +2

    So much useful information in one video. Can't be more grateful for this awsome work.

  • @afai264
    @afai264 6 місяців тому +1

    Excellent , I've been watching your videos for a while (the Python in 24 hours took some time to get through!) I like how you explain absolutely everything and don't jump ahead (even if some things may seem obvious) , it may take longer but by the end you get a very good understanding of the topic and all the concepts.

    • @mrdbourke
      @mrdbourke  6 місяців тому

      Thank you! Glad you enjoy!

  • @tobichls
    @tobichls 8 місяців тому +5

    Funny that I happened to find this video, it's gonna be very helpful for a project that I'm working on.

    • @mrdbourke
      @mrdbourke  8 місяців тому +3

      Good timing! Enjoy!

  • @Trashpanda_404
    @Trashpanda_404 7 місяців тому

    Jesus almost 6 hours! 😳 Gonna have to do a rail of Adderal and dig in. 😂 Seriously though with my ADHD I’ll have to break it down in sections, but I’m excited to watch the content. Thanks for the in-depth video brothers!

  • @akj3344
    @akj3344 8 місяців тому +2

    Gonna watch this after buying gpu. Love your TF course and ZTM community!

  • @dozeoffix2255
    @dozeoffix2255 Місяць тому

    Hi Daniel, Thank you very much. This is concise .I understand this and finished building this RAG.

  • @parinaztabari2332
    @parinaztabari2332 3 місяці тому

    This tutorial is awesome!!! Thank you, Daniel. You are a fantastic teacher! I look forward to future videos about creating an app with this and optimizing LLMs locally! Super cool.

  • @felipeanime1999
    @felipeanime1999 4 місяці тому

    Holy shit, this was awsome, first time implementing rag, following all steps, just immediately fell in love. Also, I would love to see a deploy using gradio, and adding a "upload file" feature on it. Thanks for sharing your knowledge Daniel!!!

  • @darryloatridge7329
    @darryloatridge7329 6 місяців тому

    Thanks Daniel, so much to love about this video. Firstly I love this is true Python open-source code and not frameworks chained together. The delivery style works perfectly for me, with occasional offshoots to related, though not required, subjects of interest. Your thoughts and advice along with extensive notes build the perfect all-round package. Please Please do more on LLM optimization techniques you suggested and any other in-depth subject you care to share like embedding.

  • @knubbe
    @knubbe 8 місяців тому

    Finally! Now no more second guessing on what LLM RAG’s are. My boy Daniel got us covered!!

    • @mrdbourke
      @mrdbourke  8 місяців тому

      You will definitely know what RAG’s are after this!

  • @Daily_language
    @Daily_language 4 місяці тому

    Great! instead of following those wrapped functions defined by langchain, using this method could learn the details of RAG.

  • @CodeSnap01
    @CodeSnap01 8 місяців тому

    Loved it daniel . Always admire your work , please add deployment methods , it will help alot

  • @basittanveer2358
    @basittanveer2358 3 місяці тому +1

    Yes, we want an extension video on how to get this all into an app
    Video Stamp 3:36:50

  • @umer-un
    @umer-un 6 місяців тому

    Oh there you are Daniel, always ready to help with complex concepts.

  • @joaquingale
    @joaquingale 21 день тому

    Are you kidding me? how can you be so easy to follow? I don't mean only in the technical part because I guess that not everyone can follow it, I mean in making such a long, code and faceless piece on content so entertaining and useful!

  • @DataScienceGarage
    @DataScienceGarage 7 місяців тому +1

    This is a golden video! Thanks a lot for sharing this! :)

  • @bigwoodtony4063
    @bigwoodtony4063 8 місяців тому

    Always love your content, and I am going to follow throughout and build my own RAG tooo!

  • @טלזמיר
    @טלזמיר 2 місяці тому

    The best tutorial I have ever watched!
    So enspiring!

  • @AnyDeal
    @AnyDeal 7 місяців тому

    Great work Daniel educate the world 🌎 Keep going 🚴‍♂️

  • @Ony_mods
    @Ony_mods 3 місяці тому +3

    if i could, i would give this video multiple thumb up! 🥰

  • @mohammed333suliman
    @mohammed333suliman 8 місяців тому

    as always great stuff . thank you Dan . Based on this , can you make a video or share resources about evaluation methods . and additional one for deployment.

  • @AshishWaikar
    @AshishWaikar 5 місяців тому +1

    This is great tutorial for RAG! Just amazing!

  • @leprodige5388
    @leprodige5388 7 місяців тому +1

    You are the goat of this planet. Thanks for the video, it's very clear.

  • @gokuljs8704
    @gokuljs8704 6 місяців тому

    It is always good to mention system requirements in the course. this needs GPU to run it

  • @haraldhuber3077
    @haraldhuber3077 Місяць тому

    hi @mrdbourke, thanks a lot for the great stuff you provide. if you don't know what to do ;) it would be really cool to get also some insights/tutorial/video on the following topic
    - Our example only focuses on text from a PDF, however, we could extend it to include figures and images from a PDF file or any other source
    Thanks a lot. Cheers from Austria :)
    Harry

  • @mehmetozkaya284
    @mehmetozkaya284 3 місяці тому

    Thank you so much for everthing Daniel!

  • @pranavpai_
    @pranavpai_ 4 місяці тому

    I came from your "Day in a Life as a Startup Founder video". Do you have a video on setting up what you have set up in your business? How to create the infrastructure, deploy models etc., in a business context. Or anything close to that.

  • @PyroGamez2016
    @PyroGamez2016 5 місяців тому

    Day 1:
    42:01
    Day 2:
    1:31:27
    Day 3:
    2:22:44
    Day 4:
    4:03:57

  • @amitkumarchejara6042
    @amitkumarchejara6042 8 місяців тому +1

    This is what we were waiting for!!
    Great content, All the best!!

  • @KaranSharma-cg6uh
    @KaranSharma-cg6uh 8 місяців тому

    Hi Dan, great content and thank you! Is it possible to have another video on the "optional" chat application for a complete end-to-end RAG pipeline? Thanks again!

  • @prateekgupta2408
    @prateekgupta2408 Місяць тому

    really cool video daniel. i really liked it!

  • @vasoyarutvik2897
    @vasoyarutvik2897 4 місяці тому

    Hello daniel. i love your content i just want to request you to create video on LLM from scratch and Stabel diffusing image generation from scratch. thank you again for very good leaning resources. good luck

  • @b4ubaskar
    @b4ubaskar 2 місяці тому

    Really very informative , thanks a lot

  • @romaind4853
    @romaind4853 6 місяців тому

    Very interesting and well made. Thank you!

  • @michelecarbonella2189
    @michelecarbonella2189 Місяць тому

    Thank you so much for this great video. I have a question. Let's suppose that a PDF has a lot of images which include numbers or other information. Which library should we use to retrieve information from those images?"

  • @abdullahiabdulwasiu
    @abdullahiabdulwasiu 4 місяці тому

    Alot of insights here. Pls you could also show fine tuning of the LLM for a specific domain instead of embedding. 🎉

  • @Alex-bv2eu
    @Alex-bv2eu 8 місяців тому

    Great video ! I will definitively make my own.
    Is there other ways to evaluate the LLM responses ? In order to evaluate automatically many answers given by the LLM (as for supervised learning for example) I guess we would have to pay the GPT4 access to the API... Could we use embeddings and cosine again to compare the generated answer to a label ? Or maybe use another local LLM on a bigger hardware ?
    Thank you so much !

  • @AryanMishra_21
    @AryanMishra_21 4 місяці тому

    You are God, There is Daniel and then there is Jesus! Thanks for this!!!!

    • @mrdbourke
      @mrdbourke  4 місяці тому

      Hahaha that’s a very big compliment! Thank you for the kind words

  • @dipayanbhowal7025
    @dipayanbhowal7025 5 місяців тому

    This tutorial is just too good

  • @ken-cheenshang6829
    @ken-cheenshang6829 3 місяці тому

    amazing tutorial, thanks for you share!

  • @sarathgentela9444
    @sarathgentela9444 7 місяців тому

    Great Video Daniel! Thank you Would be a small word. Do you think We can apply same mechanism to build a chatbot on a CSV file or SQL database. How can we handle different columns with different datatypes likes strings for names, integers for ranks, counts,and scores and float for rates and other metrics. How to make an embedding model understand the differences?
    Would Love if you can make a video on it.

  • @Itsme-havefuntogether
    @Itsme-havefuntogether 6 місяців тому +1

    I see the whole video and I didn't expect that we are using a pretrained model for that 😢 I am watching because your title said from the start , for that we can directly use the model like gpt 2 or other that will work in less then 10 lines of code 😕

    • @costa2150
      @costa2150 6 місяців тому

      gpt 2 cant query the pdf used in this tutorial

    • @Itsme-havefuntogether
      @Itsme-havefuntogether 6 місяців тому

      @@costa2150 simple we can use any model from the hugging face library to do that In even short code

  • @deepsuchak.09
    @deepsuchak.09 8 місяців тому

    Big fan!
    Amazing content as usual
    Binging this asap!!

  • @nocopyrightgameplaystockvi231
    @nocopyrightgameplaystockvi231 25 днів тому

    2:56:28 The power of RTX 4090

  • @artmiss-x8o
    @artmiss-x8o 3 місяці тому

    one of the best tutorials

  • @יוליתשובה
    @יוליתשובה 7 місяців тому

    Thank you so much for a great video!
    I watched all of your deep learning and machine learning content and absolutely loved it!
    Always craving for more, can we expect a following video teaching Attention models and transformers or vision-related generative models such as DDPM?

  • @Treefrog890
    @Treefrog890 4 місяці тому +1

    nice tutorial! Anyone else using gemma-2b-it with 4 bit precision and getting answers like 'The context does not provide any information about the best source to fulfill nutritional requirements, so I cannot answer this question from the provided context.'? Maybe a larger llm will help.

    • @cavemanpl5166
      @cavemanpl5166 4 місяці тому

      hi, the same here on old 8gb nvidia 3060. i tested it on two gpus and the same gemma-2b-it model works smooth and painless on new 64gb ampre

  • @alisamalakhova
    @alisamalakhova 6 місяців тому

    This is such a great and helpful video!!

  • @robertcowher
    @robertcowher 2 місяці тому

    Thanks for putting together an awesome walk through here. I'm thinking about using this implementation as a base and doing a video tutorial on turning it into an app or website & backing it with ChatGPT(for all the folks without crazy GPU power). Do you have any objections to me using your code for that purpose, assuming it's all properly attributed back to you with links to the channel?

    • @mrdbourke
      @mrdbourke  2 місяці тому +1

      Hey Robert! Feel free to adapt the code for your own purposes + tutorial :)
      It should all be available at the GitHub link in the description.
      Links back would be really appreciated.
      Cheers

    • @robertcowher
      @robertcowher 2 місяці тому

      @@mrdbourke Much appreciated! I'll let you know what I come up with.

    • @robertcowher
      @robertcowher Місяць тому

      @@mrdbourke Just wanted to say I wrapped up the series. Thanks again, this was a lot of fun to build. ua-cam.com/video/P3k-KRNEL_I/v-deo.html

  • @albertdaba
    @albertdaba 2 місяці тому

    Awesome content! however I got stuck with the Numpy/Spacey installation, I'm currently getting an error

  • @mpc5584
    @mpc5584 6 місяців тому

    Thanks soooooo much this is a lifesaver!

  • @AnshumanKumar007
    @AnshumanKumar007 8 місяців тому

    Need videos on RAG agents that can handle math also.
    Working with clients, I am really seeing the limitations of the RAG framework when it comes to math stuff. It just sucks.
    RAG + Graph Agent is worth exploring.

  • @FireFly969
    @FireFly969 8 місяців тому

    A wonderfull project men, thank you so much ❤

    • @mrdbourke
      @mrdbourke  8 місяців тому

      You’re welcome! Have fun!

  • @Dr_Varghese_Manappallil_Joy
    @Dr_Varghese_Manappallil_Joy 8 місяців тому

    Hi Danny !!!....Great Job !!!!...Sky is the limit

  •  3 місяці тому

    Amazing video thank you. Can you do something for FAISS

  • @nhtna4706
    @nhtna4706 2 місяці тому

    All good, but how sure r u that the LLM being used doesn’t take the privately hosted proprietary data? Can u throw some light?

  • @PrithivThanga
    @PrithivThanga 7 місяців тому

    return torch.mm(a, b.transpose(0, 1))
    RuntimeError: Tensor for argument #2 'mat2' is on CPU, but expected it to be on GPU (while checking arguments for mm)

  • @amitsingha1637
    @amitsingha1637 3 місяці тому

    Superb (Recommended)

  • @hassan_sid
    @hassan_sid 5 місяців тому

    @mrdbourke Can you make a detailed video on LLM fine tuning?

  • @andydataguy
    @andydataguy 8 місяців тому

    This is awesome!! Thank you 🙌🏾💜

  • @ComputingAndCoding
    @ComputingAndCoding 6 місяців тому

    Excellent Video!

  • @sewingsugar9892
    @sewingsugar9892 Місяць тому +1

    Simple RAG pipeline ---> 5.5 hours ?!

    • @davide0965
      @davide0965 Місяць тому

      Build a RAG pipeline in just 267 steps

    • @sewingsugar9892
      @sewingsugar9892 Місяць тому +1

      @@davide0965 Build a *simple* RAG pipeline in just 267 steps

  • @kavyajeetbora2585
    @kavyajeetbora2585 7 місяців тому

    Thanks @mrdbourke, this was really helpfull in breaking down some concepts in LLM.

  • @leonardommarques
    @leonardommarques 4 місяці тому

    this was entertaining to watch.

  • @mohammedmouaadhdjawedbaghd2990
    @mohammedmouaadhdjawedbaghd2990 6 місяців тому

    Thanks for the video, I see that all the optimization techniques in order to speed up the process of generating the output requires a good GPU, is there any techniques recommanded that fits on the cpu (i don't have a gpu) , thanks

  • @RamyAnwar-o4z
    @RamyAnwar-o4z 4 місяці тому

    thank you daniel

  • @dhualshammaa2062
    @dhualshammaa2062 4 місяці тому

    Do you have video showing how to great an phone app using LLM from A to Z ?

  • @rohitmondal4143
    @rohitmondal4143 4 місяці тому

    Hi, please bring in the optimised generation video of llm please

  • @artinwords8308
    @artinwords8308 7 місяців тому

    Hi Daniel, thanks a lot for your support! I'm a real beginner (art historian).... where do I put in the code??? THANKS from Vienna

  • @panizzutti
    @panizzutti 13 днів тому

    such a good video

  • @alessiosaladino6664
    @alessiosaladino6664 5 місяців тому

    Hi, I want to watch this video but since it is 5 hours long i first need some informations:
    -Does it requires any paid API subscription?
    -The models and the code can also run on google colab?
    -Does it requires any training or it relies on pre-trained models?
    Thank you!

  • @jahidmdhasan1021
    @jahidmdhasan1021 3 місяці тому +1

    Should I try to build on GTX 1650Ti will be able to run, or it will crash

  • @continuouslearner
    @continuouslearner 8 місяців тому +1

    Can i run this on my macbook M1 or do i need to purchase a nvidia GPU + windows OS? Can you clarify?

    • @mrdbourke
      @mrdbourke  8 місяців тому +4

      You can run this on a MacBook, however, you will need to change the device to “mps” (Metal Performance Shaders) rather than “cuda”. For example, `device = “mps” if torch.backends.mps.is_available() else “cpu”`, see more here: pytorch.org/docs/stable/notes/mps.html
      Also, depending on how much memory you have available will depend on the LLM you can use

  • @RameshP-ds4xt
    @RameshP-ds4xt 3 місяці тому

    Excellent

  • @holycake123
    @holycake123 4 місяці тому

    Which one is better - a MacBook Pro with the M3 Max chip, or a setup with an RTX 4090 for tasks like creating embeddings and building an RAG system?

    • @shivampradhan6101
      @shivampradhan6101 4 місяці тому

      an RTX 4090

    • @holycake123
      @holycake123 4 місяці тому

      @@shivampradhan6101 thanks, what if the llm requires more than 24GB VRAM to run?

  • @Mars18542
    @Mars18542 8 місяців тому

    Great tutorial 👏

  • @nayeemuddinkhan5852
    @nayeemuddinkhan5852 6 місяців тому

    Well done !

  • @iFastee
    @iFastee 7 місяців тому

    so, at around the 5ish hour mark, where we're playing with the base prompt and connecting it to our retrieved context, I am wondering how can I be sure that all that fits my LLM context window?
    am I missing something here? is the llm context window much greater than for example our previous embedding model that tokenized max 384 tokens per sample (i know its not apples to apples, as the embedding model will embed all the sequences and maybe leave some tokens out on some of them, but in the llm window context we have to make sure we are fitting literally everything in our prompt)?

  • @georgijestanisic3287
    @georgijestanisic3287 Місяць тому

    I built this and was following along great until we got to the step of actually generating text with Local LLMs. I have a GPU with 6gb VRAM and my system 16gb normal RAM. I run models in Ollama just fine or through the Python package for Ollama no issue. However, in this example I tried following along with the Transformers package and hugginface models and my results were just horrible. It was taking minutes and minutes to just generate 256 tokens. Any explanation why? I was using Gemma-2B-it here and quantizing.

  • @EricEhlert
    @EricEhlert 6 місяців тому

    Is there any practical difference in approach between RAG as described here and RAG for tabular data (CSVs and excel docs)?