LangChain Advanced RAG - Two-Stage Retrieval with Cross Encoder (BERT)

Sdílet
Vložit
  • čas přidán 1. 07. 2024
  • In this Video we discuss advanced retrieval techniques from Vector Databases with Query Expansion and Two-Stage Retrieval with a Cross Encoder. We use another Reranker on top to take the famous "lost in the middle" problem into consideration.
    Code: github.com/Coding-Crashkurse/...
    Timestamps:
    0:00 Two-Stage Retrieval in theory
    2:44 RAG and it´s issues
    9:31 Query Expansion
    11:50 Cross Encoder Reranking
    13:50 LongContext Reorder
    #openai #langchain

Komentáře • 39

  • @sivi3883
    @sivi3883 Před měsícem

    Best 15 mins of my day! You explained every single component in the code clear and crisp! Excited to check the other videos of yours. Thanks a bunch

  • @henkhbit5748
    @henkhbit5748 Před 5 měsíci +2

    Very informative.👍 Love the umap visualization 2 see the query and the embeddings.

  • @fuba44
    @fuba44 Před 4 měsíci +2

    UniqueList = list(set(ListWithDuplicates)) to replace those nested for loops. Love your content!

  • @user-ze9he1hw3d
    @user-ze9he1hw3d Před 4 měsíci

    The most productive 14 minutes of my day watching and learning from this video :)

  • @Canna_Science_and_Technology

    Thanks for the video. Perfect timing…. Need this for tomorrow.

  • @felipecordeiro8531
    @felipecordeiro8531 Před 8 dny

    I don't know the umap library, its very interesting. Good explanation about RAG advanced techniques, sucess for you!

  • @roguesecurity
    @roguesecurity Před 4 měsíci +1

    This channel is a gem 💎

  • @samyio4256
    @samyio4256 Před 2 měsíci

    Youre vids are insanely good. I doubt there is a better ai-prog-tuber

  • @kenchang3456
    @kenchang3456 Před 2 měsíci

    This video is terrific, I'll give it a try!

  • @micbab-vg2mu
    @micbab-vg2mu Před 5 měsíci

    Thank you for the great video:)

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

    Awesome video. So I glad I found this channel. Long shot question:
    After testing several chunk/overlaps, my experimentation indicates an optimal chunk_size=1000 and overlap=200. My RAG contains about 10 medical textbooks (~50,000 pages). However, every video I see on RAG nobody uses chunks anywhere near that large. Does it seem improbable that my ideal chunk size is 1,000, or is there likely another variable at play?

    • @sivi3883
      @sivi3883 Před měsícem

      Did you find anything?
      At least from my experience so far, with fixed chunk methodology (whatever be the chunk size or overlap) its easier to do POC but not for production grade quality. Did you try semantic chunking or chunking based on sections/headings and then capture relationship between the chunks via graph database?

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

    Thank, always nice videos!
    Do you have a favorite german cross-encoder?

  • @andreypetrunin5702
    @andreypetrunin5702 Před 4 měsíci

    Спасибо!!

    • @codingcrashcourses8533
      @codingcrashcourses8533  Před 4 měsíci

      Your welcome andreij:)

    • @andreypetrunin5702
      @andreypetrunin5702 Před 4 měsíci

      @@codingcrashcourses8533 I cannot run the code in VSCode.
      When running the import:
      From langchain_community.document_loaders import TextLoader, DirectoryLoader
      Error:
      File c:\Python311\Lib\enum.py:784, in EnumType.__getattr__(cls, name)
      782 return cls._member_map_[name]
      783 except KeyError:
      --> 784 raise AttributeError(name) from None
      AttributeError: COBOL
      I have installed the langchain-community library.

  • @user-pr6nm2di6d
    @user-pr6nm2di6d Před 5 měsíci +4

    Can u please make a video on retrieving data from SQL using SQL agents & Runnable using LCEL. If not possible here, if you can update the same in the udemy course. It helps alot

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

      I would rather do it here than on my udemy course, since it´s quite specific. Give me some time to do something like that please ;-)

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

      Looking for a similar video with LangChain templates. Production level SQL-ollama app. Greatly appreciated 🙏❤

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

      @@Sonu007OP have not worked with ollama yet, i am afraid my 7 year old computer wont get it running ^^

    • @codingcrashcourses8533
      @codingcrashcourses8533  Před 3 měsíci

      Video about this topic will be released on 03/25 and 03/28 :)

  • @vinaychitturi5183
    @vinaychitturi5183 Před 2 měsíci

    Thanks for the video..
    But while genering queries using llm_chain.invoke(query), facing exception related to output parser.
    OutputParserException: Invalid json output:

    • @vinaychitturi5183
      @vinaychitturi5183 Před 2 měsíci

      I resolved it temporarily by removing parser al together and formatted the output in the next step. Thank you again for the video. It is helpful.

    • @codingcrashcourses8533
      @codingcrashcourses8533  Před 2 měsíci

      Weird. Normally i never have Problems with that parser

  • @verybigwoods
    @verybigwoods Před 2 měsíci

    How much computation resource (specifically GPU) required in running this cross encoder model?

  • @sumangautam4016
    @sumangautam4016 Před 13 dny

    LLMChain() is deprecated and the output_parser in the examples also cause json output error.
    Would be nice, if you could update the github code. Thank you
    If anyone having issue with json output, here is a fix:
    from langchain_core.output_parsers import BaseOutputParser
    class LineList(BaseModel):
    lines: list[str] = Field(description="Lines of text")
    class LineListOutputParser(BaseOutputParser[LineList]):
    def __init__(self) -> None:
    super().__init__(pydantic_object=LineList)
    def parse(self, text: str) -> list[str]:
    lines = text.strip().split("
    ")
    return lines

  • @erenbagc9164
    @erenbagc9164 Před 4 měsíci

    What's the best way to evaluate this RAG?

    • @codingcrashcourses8533
      @codingcrashcourses8533  Před 4 měsíci

      Difficult topic. Performance or output Quality?

    • @erenbagc9164
      @erenbagc9164 Před 4 měsíci

      @@codingcrashcourses8533 well it should be advanced as much as possible since I got an advanced rag . I saw many cases that people used ragas,trulens etc. I'm indecisive

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

    Is this open source/free?