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

Комментарии • 45

  • @ShawhinTalebi
    @ShawhinTalebi  2 месяца назад +2

    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

  • @saadowain3511
    @saadowain3511 2 месяца назад

    Thank you Talebi. No one explains the subject like you

  • @ifycadeau
    @ifycadeau 2 месяца назад

    This is so helpful! Thanks Shaw, you never miss!

  • @bangarrajumuppidu8354
    @bangarrajumuppidu8354 Месяц назад

    superb explanation Shaw !😍

  • @jagtapjaidip8
    @jagtapjaidip8 18 дней назад

    very nice. thank you for explaining in details.

  • @GetPaidToLivePodcast
    @GetPaidToLivePodcast 2 месяца назад +1

    Incredible breakdown Shaw!

  • @deadlyecho
    @deadlyecho Месяц назад

    Very good explanation 👏 👌

  • @examore-lite
    @examore-lite 2 месяца назад

    Thank you very much!

  • @tomasbusse2410
    @tomasbusse2410 Месяц назад

    Very useful indeed

  • @michaelpihosh5904
    @michaelpihosh5904 2 месяца назад

    Thanks Shaw!

  • @ariel-dev
    @ariel-dev 2 месяца назад

    Really great

  • @lplp6961
    @lplp6961 2 месяца назад

    good work!

  • @firespark804
    @firespark804 2 месяца назад

    Awesome video, thanks! I'm wondering if instead of using top_k documents/batches one could define a threshold/distance for the used batches?

  • @nayem5330
    @nayem5330 2 месяца назад

    Very useful.

  • @ridg2806
    @ridg2806 16 дней назад

    Solid video

  • @nistelbergerkurt5309
    @nistelbergerkurt5309 2 месяца назад

    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  2 месяца назад +1

      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

  • @zahrahameed4098
    @zahrahameed4098 Месяц назад

    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  27 дней назад +1

      Great suggestion. That's a good excuse to try out Llama3 :)

  • @Blogservice-Fuerth
    @Blogservice-Fuerth 2 месяца назад

    Great 🙏

  • @Pythonology
    @Pythonology 2 месяца назад

    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  2 месяца назад +1

      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.

  • @halle845
    @halle845 2 месяца назад

    Thanks!

    • @ShawhinTalebi
      @ShawhinTalebi  2 месяца назад

      Thank you! Glad it was helpful 😁

  • @edsleite
    @edsleite 18 дней назад

    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 ?

    • @ShawhinTalebi
      @ShawhinTalebi  12 дней назад

      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

  • @TheLordSocke
    @TheLordSocke Месяц назад

    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  27 дней назад

      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

  • @cexploreful
    @cexploreful День назад

    what do you mean with 'not to scale?' isn't the book at the size of the earth?

  • @vamsitharunkumarsunku4583
    @vamsitharunkumarsunku4583 2 месяца назад +1

    So we get top 3 similar chunks from RAG right, We are adding 3 chunks to prompt template?

  • @halle845
    @halle845 2 месяца назад

    Any recommendations or experience on which embeddings database to use?

    • @ShawhinTalebi
      @ShawhinTalebi  2 месяца назад

      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 Месяц назад

    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  Месяц назад

      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 Месяц назад

      @@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.

  • @orvirt8385
    @orvirt8385 13 дней назад

    Great video! What is fat-tailedness?

    • @ShawhinTalebi
      @ShawhinTalebi  12 дней назад

      😉 ruclips.net/video/Wcqt49dXtm8/видео.htmlsi=E_R7A7IrkbAUVaOs

  • @jjen9595
    @jjen9595 2 месяца назад

    hello, do you have a video showing how to make a datasett and upload it to huggind face?

    • @ShawhinTalebi
      @ShawhinTalebi  2 месяца назад

      Not currently, but the code to do that is available on GitHub: github.com/ShawhinT/RUclips-Blog/blob/main/LLMs/qlora/create-dataset.ipynb

  • @yameen3448
    @yameen3448 День назад

    Vector retrieval is quite shite. Trust me. To improve accuracy of retrieval, you need to use multiple methods.