Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Generative AI: Semantische Suche und LLMs jenseits des Hello World-RAG-Tutorials

Generative AI: Semantische Suche und LLMs jenseits des Hello World-RAG-Tutorials

Slides für meine Session auf der BASTA Spring 2024

Sebastian Gingter

February 13, 2024
Tweet

More Decks by Sebastian Gingter

Other Decks in Programming

Transcript

  1. ▪ Was Sie ▪ Hintergrundwissen und Theorie zu RAG ▪

    Überblick über ▪ die auftreten können ▪ Pragmatische Methoden für die Verwendung im RAG ▪ Demos ( ) ▪ Was Sie erwartet ▪ ChatGPT, CoPilot(s) ▪ Grundlagen von ML ▪ Deep Dives in LLMs, Vektor-Datenbanken, LangChain Semantische Suche und LLMs jenseits des Hello World-RAG-Tutorials 2
  2. ▪ Generative AI in business settings ▪ Flexible and scalable

    backends ▪ All things .NET ▪ Pragmatic end-to-end architectures ▪ Developer productivity ▪ Software quality [email protected] @phoenixhawk https://www.thinktecture.com Sprachzentrierte Anwendungen mit Large Language Models, Python & .NET Developer Consultant @ Thinktecture AG 4
  3. Special Day Generative AI für Business-Anwendungen Thema Sprecher Datum, Uhrzeit

    Generative AI: Large Language Models – Szenarien, Use Cases und Patterns für Business-Anwendungen Christian Weyer DI, 13. Februar 2024, 10.45 bis 11.45 Generative AI: A Story About LLM Prompting (and how Tools like TypeChat Can Help) Rainer Stropek DI, 13. Februar 2024, 12.15 bis 13.15 Generative AI: Semantische Suche und LLMs jenseits des Hello World- RAG-Tutorials Sebastian Gingter DI, 13. Februar 2024, 15.30 bis 16.30 Generative AI: Optimierte Informationssuche durch AI-gesteuerte Datenquellenwahl Marco Frodl DI, 13. Februar 2024, 17.00 bis 18.00 Generative AI: Private GPT LLMs: Azure OpenAI Service sicher deployen mit Terraform Kenny Pflug DI, 13. Februar 2024, 19.00 bis 20.00
  4. 6 ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪

    Semantische Suche und LLMs jenseits des Hello World-RAG-Tutorials 6
  5. 7 ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪ Semantische

    Suche und LLMs jenseits des Hello World-RAG-Tutorials 7
  6. 8 Semantische Suche und LLMs jenseits des Hello World-RAG-Tutorials Introduction

    Embeddings Vector-DBs Indexing Retrieval Indexing II RAG 8
  7. Semantische Suche und LLMs jenseits des Hello World-RAG-Tutorials Indexing &

    (Semantic) search Cleanup & Split Text Embedding Question Text Embedding Save Query Relevant Text Question LLM 10 Vector DB Embedding model Embedding model Indexing / Embedding QA
  8. 11 ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪

    ▪ Semantische Suche und LLMs jenseits des Hello World-RAG-Tutorials 11
  9. 12 ▪ ▪ ▪ ▪ ▪ ➔ Semantische Suche und

    LLMs jenseits des Hello World-RAG-Tutorials 12
  10. 13 Semantische Suche und LLMs jenseits des Hello World-RAG-Tutorials Introduction

    Embeddings Vector-DBs Indexing Retrieval Indexing II RAG 13
  11. 15 ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪ Semantische

    Suche und LLMs jenseits des Hello World-RAG-Tutorials 15
  12. 16 ▪ ▪ ▪ ▪ ▪ Semantische Suche und LLMs

    jenseits des Hello World-RAG-Tutorials 16
  13. 17 ▪ ▪ Ԧ 𝑎 = 𝑎𝑥 𝑎𝑦 Semantische Suche

    und LLMs jenseits des Hello World-RAG-Tutorials 17
  14. 20 Semantische Suche und LLMs jenseits des Hello World-RAG-Tutorials Ԧ

    𝑎 = 𝑎𝑢 𝑎𝑣 𝑎𝑤 𝑎𝑥 𝑎𝑦 𝑎𝑧 20
  15. 22 𝐵𝑟𝑜𝑡ℎ𝑒𝑟 − 𝑀𝑎𝑛 + 𝑊𝑜𝑚𝑎𝑛 ≈ 𝑆𝑖𝑠𝑡𝑒𝑟 Semantische Suche

    und LLMs jenseits des Hello World-RAG-Tutorials Man Woman Brother Sister https://arxiv.org/abs/1301.3781 22
  16. 25 Semantische Suche und LLMs jenseits des Hello World-RAG-Tutorials [

    0.50451 , 0.68607 , -0.59517 , -0.022801, 0.60046 , -0.13498 , -0.08813 , 0.47377 , -0.61798 , -0.31012 , -0.076666, 1.493 , -0.034189, -0.98173 , 0.68229 , 0.81722 , -0.51874 , -0.31503 , -0.55809 , 0.66421 , 0.1961 , -0.13495 , -0.11476 , -0.30344 , 0.41177 , -2.223 , -1.0756 , -1.0783 , -0.34354 , 0.33505 , 1.9927 , -0.04234 , -0.64319 , 0.71125 , 0.49159 , 0.16754 , 0.34344 , -0.25663 , -0.8523 , 0.1661 , 0.40102 , 1.1685 , -1.0137 , -0.21585 , -0.15155 , 0.78321 , -0.91241 , -1.6106 , -0.64426 , -0.51042 ] 25 http://jalammar.github.io/illustrated-word2vec/
  17. 28 ▪ ▪ ▪ ▪ ▪ Semantische Suche und LLMs

    jenseits des Hello World-RAG-Tutorials 28
  18. 30 Semantische Suche und LLMs jenseits des Hello World-RAG-Tutorials Introduction

    Embeddings Vector-DBs Indexing Retrieval Indexing II RAG 30
  19. 31 ▪ ▪ ▪ ▪ ▪ Semantische Suche und LLMs

    jenseits des Hello World-RAG-Tutorials 31
  20. ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪

    ▪ ▪ ▪ Semantische Suche und LLMs jenseits des Hello World-RAG-Tutorials Vector-Databases ▪ 32
  21. 33 ▪ ▪ 𝑆𝐶(a,b) = a ∙𝑏 𝑎 × 𝑏

    ▪ ▪ ▪ ~ ▪ ∞ ▪ ▪ ▪ ▪ Semantische Suche und LLMs jenseits des Hello World-RAG-Tutorials 33
  22. 35 Semantische Suche und LLMs jenseits des Hello World-RAG-Tutorials Introduction

    Embeddings Vector-DBs Indexing Retrieval Indexing II RAG 35
  23. 36 ▪ ▪ ▪ ▪ ▪ Semantische Suche und LLMs

    jenseits des Hello World-RAG-Tutorials 36
  24. 37 ▪ Import documents from different sources, in different formats

    ▪ LangChain has very strong support for loading data ▪ Support for cleanup ▪ Support for splitting Semantische Suche und LLMs jenseits des Hello World-RAG-Tutorials 37 https://python.langchain.com/docs/integrations/document_loaders
  25. 38 ▪ HTML Tags ▪ Formatting information ▪ Normalization ▪

    lowercasing ▪ stemming, lemmatization ▪ remove punctuation & stop words ▪ Enrichment ▪ tagging ▪ keywords, categories ▪ metadata Semantische Suche und LLMs jenseits des Hello World-RAG-Tutorials 38
  26. 39 ▪ Document is too large / too much content

    / not concise enough Semantische Suche und LLMs jenseits des Hello World-RAG-Tutorials ▪ by size (text length) ▪ by character (\n\n) ▪ by paragraph, sentence, words (until small enough) ▪ by size (tokens) ▪ overlapping chunks (token-wise) 39
  27. 41 Semantische Suche und LLMs jenseits des Hello World-RAG-Tutorials Introduction

    Embeddings Vector-DBs Indexing Retrieval Indexing II RAG 41
  28. 42 Semantische Suche und LLMs jenseits des Hello World-RAG-Tutorials 𝑎

    𝑏 𝑐 … “What is the name of the teacher?” Doc. 1: 0.86 Doc. 2: 0.84 Doc. 3: 0.79 … (Answer generation) 42
  29. 44 Semantische Suche und LLMs jenseits des Hello World-RAG-Tutorials Introduction

    Embeddings Vector-DBs Indexing Retrieval Indexing II RAG 44
  30. 47 ▪ Semantische Suche und LLMs jenseits des Hello World-RAG-Tutorials

    LLM, e.g. GPT-3.5-turbo Embedding 𝑎 𝑏 𝑐 … Vector- Database Doc. 3: 0.86 Doc. 2: 0.81 Doc. 1: 0.81 Weighted result Hypothetical Document Embedding- Model Write a company policy that contains all information which will answer the given question: {QUERY} “What should I do, if I missed the last train?” https://arxiv.org/abs/2212.10496 47
  31. 48 ▪ ▪ ▪ ▪ ▪ ▪ ▪ Semantische Suche

    und LLMs jenseits des Hello World-RAG-Tutorials 48
  32. 49 Semantische Suche und LLMs jenseits des Hello World-RAG-Tutorials Write

    3 questions, which are answered by the following document. 𝑎 𝑏 𝑐 … 49
  33. 50 ▪ Semantische Suche und LLMs jenseits des Hello World-RAG-Tutorials

    𝑎 𝑏 𝑐 … Doc. 3: 0.89 Doc. 1: 0.86 Doc. 2: 0.76 “What should I do, if I missed the last train?” 50
  34. Semantische Suche und LLMs jenseits des Hello World-RAG-Tutorials Indexing &

    (Semantic) search Cleanup & Split Text Embedding Question Text Embedding Save Query Relevant Text Question LLM 53 Vector DB Embedding model Embedding model Indexing / Embedding QA
  35. 54 ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪

    ▪ ▪ Semantische Suche und LLMs jenseits des Hello World-RAG-Tutorials 54