Easy 100% Local RAG Tutorial (Ollama) + Full Code

Поділитися
Вставка
  • Опубліковано 2 лют 2025

КОМЕНТАРІ • 90

  • @streetroller1000
    @streetroller1000 9 місяців тому +26

    Just want to say that you're probably one of the easiest to follow and most intuitive persons I've seen on UA-cam doing guides for LLMs!
    Thanks!

    • @AllAboutAI
      @AllAboutAI  9 місяців тому +2

      thnx mate:) appriciate it!

  • @crawfordscott3d
    @crawfordscott3d 9 місяців тому +3

    Really appreciate all your content and how much energy you put into learning all this and sharing it. Thanks buddy

  • @davidtindell950
    @davidtindell950 6 місяців тому +8

    So far, some of my "key findings" regarding "different Ollama-supported models" include: 1/5. Use OpenAI's "text-embedding-3-large" for high-quality embeddings -- but it is somewhat expensive. 2/5. Use "text-embedding-3-small" for a balance between performance and cost. 3/5. In addition to "llama3.1:8b", the "mistral:latest" model has good performance across various tasks. 4/5. For PDF's, use text extraction tools like PyPDF2 or pdfminer, but we must remove or skip encoding errors. Finding the ideal chunk size and overlap is difficult! 5/5: We must set up good benchmark datasets of relevant PDFs to compare results. ALSO: Unfortunately, "faiss-gpu" appears to be deprecated but an older conda version can be run under MS Win 10/11; however, the latest version appears to run only under Linux and, perhaps, Mac OS !?!?!

  • @gumshoe9496
    @gumshoe9496 9 місяців тому +5

    The discord link is still not working for me. Says it’s expired. Did you update the link or is this something on my end?

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

    Again, Thank You! As you suggest this local RAG program works fairly well and is certainly 'good enough' for my personal use cases.

  • @mrkubajski9528
    @mrkubajski9528 9 місяців тому +6

    can I add a folder including multiple PDFs and txts?

  • @ia360graus
    @ia360graus 9 місяців тому +1

    Thank you so much for this tutorial, Could you make a video with some use cases with RAG in your daily life?

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

      WTF? YOU PUT INTO THE AI SYSTEM DOCUMENTS THAT YOU WANT TO SEARCH ON THEN YOU ASK AI ABOUT YOUR DOCUMENTS? pretty simple use case.

  • @joshuapaul8042
    @joshuapaul8042 9 місяців тому +3

    very interesting. issues: 1. it uses tkinter! 2. it strips the text from the pdf so it doesn't preserve page numbers - so you can't ask questions about where the text was found.

  • @SSHVWork-px6ry
    @SSHVWork-px6ry 9 місяців тому +1

    it works after ollama run mistral this thank you

  • @davidtindell950
    @davidtindell950 7 місяців тому +3

    I am experimenting with different Ollama-supported models and embedding models to see what current works 'best' for PDF's. Any Recommendations ? Thank You.

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

      Any findings?

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

      ​@@cjjb So far, some of my "key findings" regarding "different Ollama-supported models" include: 1/5. Use OpenAI's "text-embedding-3-large" for high-quality embeddings -- but it is somewhat expensive. 2/5. Use "text-embedding-3-small" for a balance between performance and cost. 3/5. In addition to "llama3.1:8b", the "mistral:latest" model has good performance across various tasks. 4/5. For PDF's, use text extraction tools like PyPDF2 or pdfminer, but we must remove or skip encoding errors. Finding the ideal chunk size and overlap is difficult! 5/5: We must set up good benchmark datasets of relevant PDFs to compare results. ALSO: Unfortunately, "faiss-gpu" appears to be deprecated but an older conda version can be run under MS Win 10/11; however, the latest version appears to run only under Linux and, perhaps, Mac OS !?!?!

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

      @@cjjb "So far, some of my "key findings" regarding "different Ollama-supported models" include:
      ...
      1/5. Use OpenAI's "text-embedding-3-large" for high-quality embeddings -- but it is somewhat expensive.
      2/5. Use "text-embedding-3-small" for a balance between performance and cost.
      3/5. In addition to "llama3.1:8b", the "mistral:latest" model has good performance across various tasks.
      4/5. For PDF's, use text extraction tools like PyPDF2 or pdfminer, but we must
      ... remove or skip encoding errors. Finding the ideal chunk size and overlap is difficult!
      5/5: We must set up good benchmark datasets
      ... of relevant PDFs to compare results. ALSO: Unfortunately, "faiss-gpu" appears to be deprecated but an older conda version can be
      ... run under MS Win 10/11; however, the latest version appears to run only under Linux and, perhaps, Mac OS !?!?! "

    • @davidtindell950
      @davidtindell950 6 місяців тому +2

      @@cjjb please see the “key findings” that I posted for everyone’s review.

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

    I cannot find the pdf.py in your git, what does the pdf script do

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

    Thank you mate, now my friends think I'm an AI Engineer😎😎

  • @enesgul2970
    @enesgul2970 9 місяців тому +1

    Harikasınız

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

    Thank you very much for your content. The file sizes I will be using are large and it runs quite slowly on my local machine. What can I do to speed it up?

  • @michaelgoralski8028
    @michaelgoralski8028 7 місяців тому +2

    Does anyone else's script get stuck on generating the embeddings when you run it?

    • @AbhishekKumar-vt1iu
      @AbhishekKumar-vt1iu 7 місяців тому +1

      same here.. anyone having solution to this.

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

      @@AbhishekKumar-vt1iu it is due to limitations of computing resources in local machine

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

    Cool Beans! Thanks so very much you have helped me enormously.
    Thanks again

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

    So if I want to teach my AI my uni lessons, should I make all my pptx pdf docx files in to a single pdf . I am new to AI training and I am kinda struggling

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

    Thanks for this video!

  • @gigaluxYTube
    @gigaluxYTube 8 годин тому

    hello.must install python,ok?do you have a full tutorial for this?

  • @CharlesOkwuagwu
    @CharlesOkwuagwu 9 місяців тому +1

    Please how would you advice we run this on JSON files, not PDF.
    I have several Q-A in . JSON format, not PDF.

    • @ClipsofCoolStuff
      @ClipsofCoolStuff 9 місяців тому +5

      I made a pull request to the repo and he accepted it. If you repull the repo you should now have access to uploading PDF, TXT, and JSON files into the context.

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

      @@ClipsofCoolStuffmarkdown? 😅

  • @rickmarques10
    @rickmarques10 9 місяців тому +2

    Hey! There's any solution to make a good RAG like this using ollama on Openwebui?

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

    This is cool! how can you run this on a web interface? just curious

  • @pm1234
    @pm1234 9 місяців тому

    Great! Thank you! I'd like to have the same for local code (django). One liners won't work, so how to do this?

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

    Thanks to share your kwoledge with us! I have some questions because i have a similar code but it is not work as welll when the context is so extensive, how can i do? also, the chatbot lost when the history chat is large, i don't know hot to fix it. Yo have some idea? thanks

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

    Great! How to remove pdf?

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

    didnt work for me, despite what the video said the code is using from openai import OpenAI

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

      yeah, also doesnt' work for me. i have no openai api key and am not getting one foss or die

  • @gilzonme
    @gilzonme 9 місяців тому

    Oh Man that worksssssssssss!

  • @BalvinderNagi
    @BalvinderNagi 9 місяців тому +3

    I get the following error:
    python localrag.py
    Traceback (most recent call last):
    File "/Users/eil-its/Documents/experiments/workspace-python/llama3rag/localrag.py", line 130, in
    response = ollama.embeddings(model='mxbai-embed-large', prompt=content)
    File "/Users/eil-its/Documents/experiments/workspace-python/llama3rag/llama/lib/python3.9/site-packages/ollama/_client.py", line 198, in embeddings
    return self._request(
    File "/Users/eil-its/Documents/experiments/workspace-python/llama3rag/llama/lib/python3.9/site-packages/ollama/_client.py", line 73, in _request
    raise ResponseError(e.response.text, e.response.status_code) from None
    ollama._types.ResponseError: failed to generate embedding

    • @chriskingston1981
      @chriskingston1981 9 місяців тому

      me too, found any solution?

    • @kumarrohit557
      @kumarrohit557 9 місяців тому

      same facing this error

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

      same error

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

      ollama pull mxbai-embed-large , thats works for me

    • @GEORGE.M.M
      @GEORGE.M.M 6 місяців тому

      Try another Model delete the model he tells you to use in the video 'mistral' you can do this by running the command 'ollama rm mistral' and then install a model that is working for me and the one he has listed in his github llama3 'ollama pull llama3'. and do not forget 'ollama pull mxbai-embed-large'.

  • @cclementson1986
    @cclementson1986 9 місяців тому

    How would you deploy this in AWS for production? Would you use ollama and download the entire LLM model on an EC2 instance?

    • @ashishkgp
      @ashishkgp 9 місяців тому

      use an inference endpoint for llm and a cpu based ec2 instance. It may be cheaper

  • @JNET_Reloaded
    @JNET_Reloaded 9 місяців тому

    very good stuff

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

    Hi, thank you for the brilliant video and tutorial! I was wondering if you had any experience with implementing this process with LlaMA3 rather than Mistral, or if there was any difference in the implementation? Thank you :)

  • @Dylan-jq7hu
    @Dylan-jq7hu 9 місяців тому

    Will you be doing a video’s on ChatGPT the App version anymore?

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

    Hello sir lets get this on!!!

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

    what if i have plain text 40kb size? (not pdf)

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

    hi, can i build all the same using docker?

  • @brianclark4639
    @brianclark4639 9 місяців тому

    Getting this error: import PyPDF2
    File "C:\Anaconda\lib\site-packages\PyPDF2\__init__.py", line 12, in
    from ._encryption import PasswordType
    File "C:\Anaconda\lib\site-packages\PyPDF2\_encryption.py", line 34, in
    from ._utils import logger_warning
    File "C:\Anaconda\lib\site-packages\PyPDF2\_utils.py", line 55, in
    from typing_extensions import TypeAlias
    ModuleNotFoundError: No module named 'typing_extensions'

  • @martijnvanveldhuizen8417
    @martijnvanveldhuizen8417 7 днів тому

    I followed all the steps just like you, but when I want to upload the pdf I encounter the following issue:
    pdf.py': [Errno 2] No such file or directory
    Do you know what is going wrong?

  • @userrjlyj5760g
    @userrjlyj5760g 9 місяців тому

    What if my pdf has like a 1 million word/token, would this still work?

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

    script get stuck on generating the embeddings!

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

    muchas gracias, muy util, funciono el codigo

  • @fernabot
    @fernabot 9 місяців тому

    Really nice work! .. but is this really fully local? ... OpenAI?

  • @sebastianbecerra1034
    @sebastianbecerra1034 9 місяців тому +1

    no working in mac

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

      same on linux. apparently it's calling openai?

  • @user---------
    @user--------- 9 місяців тому

    Which video card and how much memory?

  • @TheHistoryCode125
    @TheHistoryCode125 9 місяців тому +36

    This video is a misleading tutorial that oversimplifies the process of creating a local RAG (Retrieval Augmented Generation) system. While the presenter claims to create a "100% local RAG in around 70 lines of code," they fail to address the complexities and limitations of such a system. The tutorial relies heavily on pre-built libraries and models, such as Ollama and sentence-transformers, without providing a deep understanding of how these components work together. Moreover, the presenter does not discuss the potential drawbacks of using a local RAG system, such as the limited amount of data it can handle and the lack of real-time updates. The video may give viewers a false sense of ease in implementing a RAG system, without considering the necessary expertise and resources required for a robust and reliable solution.

    • @sluggy6074
      @sluggy6074 9 місяців тому +54

      Thanks, GPT 4.

    • @pm1234
      @pm1234 9 місяців тому +21

      FYI GPTZero states this comment is 100% AI generated.

    • @userou-ig1ze
      @userou-ig1ze 9 місяців тому +8

      Jeez, it almost academic if it weren't reeking of AI

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

      Hahaha 😂 ​@@userou-ig1ze

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

      Well no shit no one’s gonna write a whole semantic search on parsed documents. Thats like saying “im gonna program my own garbage collector in java”

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

    awesome, i dont get it, anything easier that does not require any code ? thank you :)

  • @SuperConscious-d5x
    @SuperConscious-d5x 2 місяці тому

    Should add at thevery beginning that this does not expose any web UI ! Not useful for majority of people

  • @mytradingbuddy-vp5vm
    @mytradingbuddy-vp5vm 5 місяців тому

    Free Palestine.

  • @kumarrohit557
    @kumarrohit557 9 місяців тому +2

    i found an error when i run localrag.py
    File "D:\easy-local-rag-main\localrag.py", line 134, in
    response = ollama.embeddings(model='mxbai-embed-large', prompt=content)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\HP\AppData\Local\Programs\Python\Python312\Lib\site-packages\ollama\_client.py", line 198, in embeddings
    return self._request(
    ^^^^^^^^^^^^^^
    File "C:\Users\HP\AppData\Local\Programs\Python\Python312\Lib\site-packages\ollama\_client.py", line 73, in _request
    raise ResponseError(e.response.text, e.response.status_code) from None
    ollama._types.ResponseError: failed to generate embedding

    • @kumarrohit557
      @kumarrohit557 9 місяців тому

      please guide

    • @EduardoJGaido
      @EduardoJGaido 9 місяців тому

      @@kumarrohit557 have you tried before doing that ollama pull mxbai-embed-large ?

    • @Mike-dl7gt
      @Mike-dl7gt 7 місяців тому +1

      ollama pull mxbai-embed-large

    • @Mike-dl7gt
      @Mike-dl7gt 7 місяців тому

      @@EduardoJGaido .

    • @Mike-dl7gt
      @Mike-dl7gt 7 місяців тому

      @@kumarrohit557 .

  • @madraj10
    @madraj10 29 днів тому

    Cant make Torch to use GPU. It always uses CPI. Torch settings seem hardcoded?

  • @SSHVWork-px6ry
    @SSHVWork-px6ry 9 місяців тому

    raise self._make_status_error_from_response(err.response) from None
    openai.NotFoundError: Error code: 404 - {'error': {'message': "model 'mistral' not found, try pulling it first", 'type': 'api_error', 'param': None, 'code': None}}

    • @grahaml6072
      @grahaml6072 9 місяців тому

      You have to download the model. ollama pull mistral