Better Retrieval Augmented Generation (RAG) with LangChain Parent-Child Retriever

Sdílet
Vložit
  • čas přidán 15. 11. 2023
  • In this video, we'll learn about the advanced capabilities of Langchain's Parent-Child Retriever in the context of retrieval-augmented generation (RAG) applications. The tutorial showcases how embedding chunks of text with links to larger 'parent' chunks can enhance the context provided to language models. It demonstrates practical steps in a Jupyter notebook, including loading a text document, converting it to a Langchain document, and storing it in Chroma DB. The video further explains the creation of parent and child splitters, embedding chunks using the Fast Embed library, and utilizing an in-memory store for parent documents. We'll see a comparison between querying parent and child retrievers and observe the impact on the quality of responses from a language model. We'll then use the Zephyr LLM with Ollama to compare answers to questions with the two retrievers.
    #Langchain #RAG #retrievalaugmenetedgeneration #RAGapps #LanguageModeling #AIDevelopment #AIApplications
    Notebook: github.com/mneedham/LearnData...
  • Věda a technologie

Komentáře • 13

  • @nrapendrasingh6964
    @nrapendrasingh6964 Před 7 měsíci +2

    Highly informative and engaging session.

  • @slipthetrap
    @slipthetrap Před 6 měsíci

    Again, very interesting. I enjoy that these are quick and to the point with so many that I want to try ... including it all on Github is great too. Thanks.
    Personally I am still on the hunt for a good setup to help with editing my writing; the best embeddings for manuscript, best vector db (so far it's Chroma), best LLM for performing editing stuff (plot holes, consistency, grammar, pov, tense, i.e. the usual stuff) ... yes, i do pay $20/mo for gpt's at openai, but it would be better to have everything locally on my MacBook M3 (which seems fast/big enough). Keep the info coming

  • @alexandershevchenko4167
    @alexandershevchenko4167 Před 5 měsíci +1

    how to save/load db (vectorstore) when using Parent Document retriever in langchain?

  • @akshaykumarmishra2129
    @akshaykumarmishra2129 Před 6 měsíci

    hi, let's say the content i'm retrieving from a vector db to pass as context to the llm (i am using gpt3.5) is large and
    i wanna generate questions based on this context but in my case gpt3.5 has max limit of 4096 tokens for which i had to iterate and
    change the context every time while calling this function "RetrievalQA.from_chain_type" which has retriever as an argument which takes
    the entire content it is retrieving as context but i want some of it to be passed as context every time or is there any other way ? i'm still a beginner

  • @onoff5604
    @onoff5604 Před 7 měsíci

    Getting Errors in Notebook: Many many thanks for the video on the topic and sharing your code! I am trying to follow along in a colab notebook but there are one or two types of issues. There is a nightmare of packages requiring different up/down graded versions of each-other, and if that is ever dodged, the # Initialize the retriever
    retriever = ParentDocumentRetriever( cell gives the error: ----> 2 retriever = ParentDocumentRetriever(
    3 vectorstore=vectorstore,
    4 docstore=store,
    5 child_splitter=child_splitter,
    TypeError: MultiVectorRetriever.__init__() got an unexpected keyword argument 'child_splitter' ...Did you ever see these issues? Did you find a solution?

    • @learndatawithmark
      @learndatawithmark  Před 7 měsíci

      Oh I didn't have any issues, but perhaps I was just lucky with the versions when I ran it. That sounds like they updated the MultiVectorReceiver class to have different parameter names I guess.
      It seems like they totally change the API actually if you look at the docs - python.langchain.com/docs/modules/data_connection/retrievers/multi_vector
      I'll pin the versions on future videos so at least we'll know which versions it actually worked on. Sorry about this.

  • @user-dc6vk5zv6q
    @user-dc6vk5zv6q Před 5 měsíci

    The effectiveness of the Parent-Child Retriever is contingent upon the exact match of the query within the documents. In instances where the query is not explicitly present in the documentation, and there exist multiple sentences resembling the query, the retriever may perform inadequately. This observation is based on personal experience, where the query "Usage flow of multi fund addition API" was not directly found, but the retrieved answer contained a heading related to "Mutual fund Addition," indicating a failure to accurately capture the specified sub-paragraph under the "Integration with multi fund addition API" heading.

    • @learndatawithmark
      @learndatawithmark  Před 5 měsíci

      Did you find a technique that's good for dealing with that problem?

    • @user-dc6vk5zv6q
      @user-dc6vk5zv6q Před 5 měsíci

      Open AI assistants works good but that is paid service. But I am trying to get better results using Langchain or hasystack.@@learndatawithmark

    • @learndatawithmark
      @learndatawithmark  Před 5 měsíci

      Do you think we need to do some re-ranking on the records before they are passed to the LLM?

    • @user-dc6vk5zv6q
      @user-dc6vk5zv6q Před 5 měsíci

      @@learndatawithmark reranking would help when in top K retrieval proper context is there. But in my case in top 5 retrieval. Proper context is not there. But generally reranking helps

    • @ugurkaraaslan9285
      @ugurkaraaslan9285 Před 5 měsíci

      How to find appropriate parent&child chunk size for Q&A application on a document 30-40 pages apart from brute forcing?Thanks in advance.