DEV Community

technonotes-hacker
technonotes-hacker

Posted on

LLM - Day 5 - RAG a Intro

Retrievel Augment Generation

  • 3 different Topics
  • when we need RAG ? You have Private Data Source Eg., கம்பெனி குள்ள இருக்கிற Confluence dataஓ or documents ( these won't be available to public )

  • The above funcationality should be available for my private data also. Eg., In my company leave policy.
  • This is resolved by RAG.

RAG Architecture

  • 3 parts are there.
  • Pre-processing steps --> RAG , ready பண்றதுக்கு முன்னாடி நான் இதெல்லாம் செய்யணும். இந்த diagramல dash dash இருக்குல்ல அதுதான்
  • Before pre-processing , let me draw a graph.

  • Orange x pointகு closeசா இருக்கிற point சொல்லுங்க. So [8,9,5] . How you told these point , how you processed ? Going to take distance of all points then sort. This is what we are going to get in Pre-processing.
  • Blue x are the chunks. what is Chunks ? A part. A part of what ? its the documents.
  • Eg., 500 character is a chunck. C1 . Then again C2 ... C5 etc , entire documents.எல்லா documentமெண்ட்டையும் துண்டு துண்டா உடைக்கும்.

  • Now all chunks C1 C2 etc is given to MODEL which is a EMBEDDING Model.
  • This EMBEDDING Model will give POINT.
  • Eg., You are very good food industry.
  • ஒரு ஒரு chunkகும் ஒரு ஒரு point. Related items occur closer together.
  • These points will be put in graph. You are creating a cluster like , with similar topics together.
  • EMBEDDING Model is nothing but LLM also it contains Transformer.
  • In simple -> நீ ஒரு TEXT குடுக்குற நான் ஒரு POINT கொடுக்கிறேன், அவ்வளவுதான் indirectly a Knowledge source.
  • So they are in MULTIDIMENTIONAL SPACE.
  • For a single chunk it will be 786D ( it means 786 different points ). To create this dimention , VECTOR DATABASE.
  • Vector & Embedding are almost similar. ( Here Vector will have direction in addition ).
  • Before giving to LLM , it will be chunked.
  • Vector DB eg., softwares below

  • Orange X is the query.
  • With this query , give me the TOP-K elements கொண்டு வா .
  1. One is Distance , It will give shortest distance algorithm like ( euclidean algorithm , manhattan algorithm , etc ).
  2. Another is Cosine similarity --> Lesser the angle , these points are more similar or closer to each other. , also its SEMENTIC. what is Sementic ? Occur close together. Eg., Rice and Biriyani , but indirectly they are close together. In simple , how similar these two points are.

  • Contexts --> Actual data from Vector DB. (this is nothing but the meta data).
  • Query + context --> you have right now.
  • Now with this AUGUMENT , its nothing but "PROMPT".
  • This Prompt will have "Query + context" then format , etc etc all condition. இந்த processசஸ ரெடி பண்றதுக்கு பேருதான் Augument.

  • Now we will give this to LLM. Eg., chatgpt , gemini.

  • For this LLM , its a query.

  • How the dynamic doc are handled ? Recreate or upend. Depends on the documents.

Notes

  1. "Confluence data" or data confluence means தரவு சங்கமம் (Tharavu Sangamam) — the combining of different data sources, streams, or types into one single place or system.
  2. obsidian graph
  3. https://plotly.com/python/3d-scatter-plots/
  4. Augument means COMBINING.
  5. Query is Orange X and Blue is Chunks. Along with the point , a meta data will be stored . DATA ABOVE THE POINT .

Top comments (0)