본문 바로가기

Studying AI

RAG from scratch (1)

참고자료 :

https://www.youtube.com/playlist?list=PLfaIDFEXuae2LXbO1_PKyVJiQ23ZztA0x

https://wikidocs.net/book/14314

https://docs.smith.langchain.com/


Part 1 - Part 4.

★ Connecting LLMs to external data

- LLMs haven't seen your data

- private and recent data are not included

 

RAG : Retrieval Augmented Generation

RAG pipeline : Indexing → Retrieval → Generation

 

stage 1: Indexing

Index external documents into numerical representation → make retrieval of documents easier, easily searchable

Loading, splitting, and embedding (∵ limited context window)

Documents split embedding vectorstore

 

stage 2 : Retrieval

retrieve document(s) relevant to query

langchain supports diverse embedding models, indexing, document loaders, splitters

hyperparameter k : number of nearest neighbors to fetch

KNN search

 

stage 3 : Generation

important : add the retrieved docs (from stage 2) to context window to feed to LLM to generate answers

connecting retrieval with LLMs via prompt

prompt = a placeholder with keys(e.g. context, question)

 

LCEL(LangChain Expression Language)

few common methods : invoke, batch, stream

connect prompt to llm

 

 

 

'Studying AI' 카테고리의 다른 글

RAG from scratch (4)  (0) 2024.06.04
RAG from scratch (3)  (0) 2024.06.03
RAG from scratch (2)  (0) 2024.06.02