Architecture Note: Multi-modal RAG system supporting both text and image embeddings for cross-modal retrieval and semantic understanding.
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#C17852', 'primaryTextColor': '#F0F6FC', 'primaryBorderColor': '#4A5E32', 'lineColor': '#E6C98F', 'secondaryColor': '#161B22', 'tertiaryColor': '#0D1117', 'background': '#0D1117', 'mainBkg': '#161B22', 'nodeBorder': '#4A5E32', 'clusterBkg': '#161B22', 'clusterBorder': '#4A5E32', 'titleColor': '#E6C98F', 'edgeLabelBackground': '#161B22'}}}%%
flowchart LR
subgraph Input["๐ฅ Input"]
Q["๐ User Query"]
end
subgraph Embed["๐ข Embedding"]
QE["๐ข Query Embedding
text-embedding-ada"]
end
subgraph Retrieve["๐ Retrieval"]
VS[("๐๏ธ ChromaDB")]
SS["๐ฏ Similarity Search
top_k=5"]
RD["๐ Retrieved Docs"]
end
subgraph Augment["๐ Augmentation"]
CT["๐ Context Template"]
PR["๐ Prompt Builder"]
end
subgraph Generate["๐ง Generation"]
LLM["๐ค GPT-4"]
RS["โ
Response"]
end
Q --> QE
QE --> VS
VS --> SS
SS --> RD
RD --> CT
CT --> PR
Q --> PR
PR --> LLM
LLM --> RS
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#C17852', 'primaryTextColor': '#F0F6FC', 'primaryBorderColor': '#4A5E32', 'lineColor': '#E6C98F', 'secondaryColor': '#161B22', 'tertiaryColor': '#0D1117', 'background': '#0D1117', 'mainBkg': '#161B22', 'nodeBorder': '#4A5E32', 'clusterBkg': '#161B22', 'clusterBorder': '#4A5E32', 'titleColor': '#E6C98F', 'edgeLabelBackground': '#161B22'}}}%%
flowchart TB
subgraph Sources["๐ฅ Data Sources"]
PDF["๐ PDF Documents"]
IMG["๐ผ๏ธ Images"]
TXT["๐ Text Files"]
end
subgraph Parse["โ๏ธ Parsing"]
PL["๐ PDF Loader"]
IL["๐ผ๏ธ Image Loader"]
TL["๐ Text Loader"]
end
subgraph Chunk["โ๏ธ Chunking"]
TS["โ๏ธ Text Splitter
RecursiveCharacter"]
IC["๐ผ๏ธ Image Chunks
Caption + Embed"]
end
subgraph Embed["๐ข Embedding"]
TE["๐ Text Embeddings
OpenAI"]
IE["๐ผ๏ธ Image Embeddings
OpenCLIP"]
end
subgraph Store["๐พ Storage"]
TC[("๐ Text Collection")]
IC2[("๐ผ๏ธ Image Collection")]
META[("๐ Metadata")]
end
PDF --> PL
IMG --> IL
TXT --> TL
PL --> TS
IL --> IC
TL --> TS
TS --> TE
IC --> IE
TE --> TC
IE --> IC2
TE --> META
IE --> META
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#C17852', 'primaryTextColor': '#F0F6FC', 'primaryBorderColor': '#4A5E32', 'lineColor': '#E6C98F', 'secondaryColor': '#161B22', 'tertiaryColor': '#0D1117', 'background': '#0D1117', 'mainBkg': '#161B22', 'nodeBorder': '#4A5E32', 'clusterBkg': '#161B22', 'clusterBorder': '#4A5E32', 'titleColor': '#E6C98F', 'edgeLabelBackground': '#161B22'}}}%%
flowchart LR
subgraph Doc["๐ Document"]
RAW["๐ Raw Text"]
end
subgraph Preprocess["โ๏ธ Preprocessing"]
CLN["๐งน Clean Text"]
NRM["๐ Normalize"]
end
subgraph Split["โ๏ธ Splitting"]
RC["โ๏ธ RecursiveCharacter
chunk=1000, overlap=200"]
CH["๐ฆ Chunks"]
end
subgraph Embed["๐ข Embedding"]
API["๐ OpenAI API"]
VEC["๐ 1536-dim Vectors"]
end
subgraph Store["๐พ ChromaDB"]
COL[("๐ฆ Collection")]
IDX["๐ HNSW Index"]
end
RAW --> CLN
CLN --> NRM
NRM --> RC
RC --> CH
CH --> API
API --> VEC
VEC --> COL
COL --> IDX
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#C17852', 'primaryTextColor': '#F0F6FC', 'primaryBorderColor': '#4A5E32', 'lineColor': '#E6C98F', 'secondaryColor': '#161B22', 'tertiaryColor': '#0D1117', 'background': '#0D1117', 'mainBkg': '#161B22', 'nodeBorder': '#4A5E32', 'clusterBkg': '#161B22', 'clusterBorder': '#4A5E32', 'titleColor': '#E6C98F', 'edgeLabelBackground': '#161B22'}}}%%
flowchart TB
subgraph Input["๐ฅ Query Input"]
TQ["๐ Text Query"]
IQ["๐ผ๏ธ Image Query"]
end
subgraph Embed["๐ข Query Embedding"]
TE["๐ Text Embedding
OpenAI"]
IE["๐ผ๏ธ Image Embedding
OpenCLIP"]
end
subgraph Project["๐ Projection"]
UP["๐ Unified Space
CLIP Alignment"]
end
subgraph Search["๐ Parallel Search"]
ST["๐ Search Text Collection"]
SI["๐ผ๏ธ Search Image Collection"]
end
subgraph Merge["๐ Result Fusion"]
RR["๐ฏ Reciprocal Rank Fusion"]
FD["๐ Fused Documents"]
end
subgraph Output["๐ค Output"]
RS["โ
Multi-Modal Results"]
end
TQ --> TE
IQ --> IE
TE --> UP
IE --> UP
UP --> ST
UP --> SI
ST --> RR
SI --> RR
RR --> FD
FD --> RS
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#C17852', 'primaryTextColor': '#F0F6FC', 'primaryBorderColor': '#4A5E32', 'lineColor': '#E6C98F', 'secondaryColor': '#161B22', 'tertiaryColor': '#0D1117', 'background': '#0D1117', 'mainBkg': '#161B22', 'nodeBorder': '#4A5E32', 'clusterBkg': '#161B22', 'clusterBorder': '#4A5E32', 'titleColor': '#E6C98F', 'edgeLabelBackground': '#161B22'}}}%%
flowchart LR
subgraph Query["๐ฅ Query"]
Q["๐ User Question"]
end
subgraph Initial["๐ Initial Retrieval"]
VS[("๐๏ธ ChromaDB")]
IR["๐ฏ top_k=20
Candidates"]
end
subgraph Rerank["๐ Reranking"]
CR["๐ Cross-Encoder
Relevance Score"]
TP["๐ Rerank Scores"]
SR["๐ Top N Results"]
end
subgraph Generate["๐ง Generation"]
CTX["๐ Context Window"]
LLM["๐ค GPT-4"]
end
subgraph Output["๐ค Output"]
ANS["โ
Answer"]
end
Q --> VS
VS --> IR
IR --> CR
Q --> CR
CR --> TP
TP --> SR
SR --> CTX
CTX --> LLM
LLM --> ANS
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#C17852', 'primaryTextColor': '#F0F6FC', 'primaryBorderColor': '#4A5E32', 'lineColor': '#E6C98F', 'secondaryColor': '#161B22', 'tertiaryColor': '#0D1117', 'background': '#0D1117', 'mainBkg': '#161B22', 'nodeBorder': '#4A5E32', 'clusterBkg': '#161B22', 'clusterBorder': '#4A5E32', 'titleColor': '#E6C98F', 'edgeLabelBackground': '#161B22'}}}%%
flowchart TB
subgraph User["๐ค User Interface"]
UI["๐ป Chat Interface"]
end
subgraph Query["๐ Query Processing"]
QA["๐ Query Analysis"]
QE["๐ข Query Embedding"]
end
subgraph Retrieval["๐ Retrieval Layer"]
direction TB
TC[("๐ Text
Collection")]
IC[("๐ผ๏ธ Image
Collection")]
HY["๐ Hybrid Search"]
end
subgraph Embeddings["๐ข Embedding Models"]
OAI["๐ OpenAI
text-embedding-ada"]
CLIP["๐ผ๏ธ OpenCLIP
ViT-B/32"]
end
subgraph Generation["๐ง Generation"]
CTX["๐ Context Builder"]
GPT["๐ค GPT-4"]
end
subgraph Output["๐ค Response"]
ANS["โ
Answer"]
SRC["๐ Sources"]
end
UI --> QA
QA --> QE
QE --> OAI
QE --> CLIP
OAI --> TC
CLIP --> IC
TC --> HY
IC --> HY
HY --> CTX
CTX --> GPT
GPT --> ANS
GPT --> SRC
ANS --> UI
SRC --> UI