Intro Rag Blank
Intro Rag Blank
AI by Hand ✍
https://by-hand.ai/rag
2
Roadmap
Q/A
RAG Equation
Load
Prompt Advanced
Split
Index Retrieval
Embed
Store
RAG Equation
Beginner’s Guide to RAG - AI by Hand ✍
Download: https://by-hand.ai/rag
RAG = Query + Prompt + Context + LLM
How much does [INST] <<SYS>> You are a _______, respectful, ______
Tom make? assistant. Always answer as helpfully as possible,
while being safe. Your answers should ___ include
Search any harmful, _____________, racist, sexist, toxic,
dangerous, or illegal content. Please ensure that
your responses are socially _________ and positive
in nature. <</SYS>>
[/INST]
QUESTION:
[/INST]
Database LLM
Amy, 100, CEO
Tom, 50, Prof
Sam, 120, CTO
Search [/INST]
LLM
Download: https://by-hand.ai/rag
Summarize
Context information from ________ sources is below.
---------------------
{context_str}
---------------------
Query: {query_str}
Answer:
{context_list}
---------------------
Using only the choices above and not prior knowledge, return the
_________ that is most relevant to the question:
{query_str}
{context_str}
------------
Given the new context, refine the original answer to better answer
the query. If the context isn't useful, return the _________ answer.
Refined Answer:
Download: https://by-hand.ai/rag
id: 1 id: 2 id: 2
Load
date: 5/10 date: 5/15 date: 5/17
Split 每天都
吃一個
蘋果可
高山大
大海森
林動物
以保持 大自然
Embed 1 1 0 1 1 -2
1 0 1 1 1 1
0 0 1 0 0 1
0 1 0 0 1 1
Download: https://by-hand.ai/rag
LlamaHub Data Loaders
Download: https://by-hand.ai/rag
Split by Tokens
How are you doing today? I hope you're doing
TokenTextSplitter( well. Whether your day is busy or calm, I hope
chunk_size=4, you find a moment of joy. Life moves fast, with
chunk_overlap=0 many ups and downs. It's important to stop and
) enjoy the little things. Maybe today brought a
good chat, a tasty meal, or a beautiful sunset.
Cherish these happy moments. Each day is a
chance to make good memories and connect
with others. Take time to appreciate your
surroundings and the people in your life. Even
on challenging days, there are opportunities to
learn and grow. Let's embrace each experience
and look forward to tomorrow with optimism.
Download: https://by-hand.ai/rag
Massive Text Embedding Benchmark
https://huggingface.co/spaces/mteb/leaderboard
Download: https://by-hand.ai/rag
Choose a Vector Database
https://superlinked.com/vector-db-comparison
Download: https://by-hand.ai/rag
SQL – Retrieve by Similarity
query = Query(post_index)
._________(post)
._________(relevance_space.text, Param("________"))
Download: https://by-hand.ai/rag
RAG
DB
Prompt
doc-
doc-
doc-
Query
LLM
AI by Hand ✍ 2024 © Tom Yeh Download: https://by-hand.ai/rag
Multiple Embedding Spaces
DB
Prompt
doc-
doc-
doc-
Query
LLM
AI by Hand ✍ 2024 © Tom Yeh Download: https://by-hand.ai/rag
Superlinked Vector Compute
Memory
Search
Output 1
2
0 1 1 0 0 1 0 1 0
1 1 0 0 1 0 0 1 0
3
df = result._________() 0 1 1 1 0 0 1 0 1
__________(df)
doc-21
doc-42
doc-39
Query
LLM
AI by Hand ✍ 2024 © Tom Yeh Download: https://by-hand.ai/rag
RankGPT
Search Query: {query}.
The output format should be [] > [], e.g., [1] > [2].
do not ___________.
doc-21
doc-42
doc-39
Query
LLM
AI by Hand ✍ 2024 © Tom Yeh Download: https://by-hand.ai/rag
Multi-Query Retrieval
You are an AI language model assistant. Your task is to generate ____
different versions of the given user question to retrieve relevant
documents from a vector database.
doc-21
doc-42
doc-39
Query
LLM
AI by Hand ✍ 2024 © Tom Yeh Download: https://by-hand.ai/rag
Hypothetical Document Embeddings (HyDE)
DB
Prompt
doc-
doc-
doc-
Query
LLM
AI by Hand ✍ 2024 © Tom Yeh Download: https://by-hand.ai/rag
Q/A
Beginner’s Guide to RAG - AI by Hand ✍
Download: https://by-hand.ai/rag