# reichenbch/rag-examples architecture

> Architecture diagram of the GitHub repository reichenbch/rag-examples, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/reichenbch/rag-examples
- Repository: https://github.com/reichenbch/rag-examples

## Overview

This repository demonstrates three RAG approaches for private-dataset question answering and parsing, plus a Gradio chat application for the LangChain/LlamaIndex/OpenAI approach. In the app, a user question is language-identified, used to construct a language-specific prompt, and passed to a retrieval QA chain backed by a persisted FAISS index and ChatGPT; the answer is returned to chat. The notebooks also document Meta’s original RAG, multilingual variants, and evaluation metrics. Notebook internals are not sampled, so those branches are shown only at the documented capability level.

Main entry points: [`gradio_app.py`](https://github.com/reichenbch/rag-examples/blob/main/gradio_app.py) (Chat interface), [`dataset.txt`](https://github.com/reichenbch/rag-examples/blob/main/dataset.txt) (Private dataset), [`faiss_doc_idx/index.faiss`](https://github.com/reichenbch/rag-examples/blob/main/faiss_doc_idx/index.faiss) (Persisted FAISS index), [`LangChain LLamaIndex RAG.ipynb`](https://github.com/reichenbch/rag-examples/blob/main/LangChain%20LLamaIndex%20RAG.ipynb) (LlamaIndex LangChain RAG)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_chat["Gradio application"]
  node_chat_ui["Chat interface<br/>[gradio_app.py]"]
  node_language_id["Language identification<br/>[gradio_app.py]"]
  node_prompt["Language prompt<br/>[gradio_app.py]"]
  node_chat_history["Chat history<br/>[gradio_app.py]"]
end

subgraph group_rag["Retrieval and generation"]
  node_qa_chain["Retrieval QA chain<br/>[gradio_app.py]"]
  node_retriever["FAISS retriever<br/>[gradio_app.py]"]
  node_faiss_index[("Persisted FAISS index<br/>[index.faiss]")]
  node_embeddings["OpenAI embeddings<br/>[gradio_app.py]"]
  node_chat_model["ChatGPT generation<br/>[gradio_app.py]"]
end

subgraph group_notebooks["Notebook implementations"]
  node_meta_rag["Original Meta RAG"]
  node_framework_rag["LlamaIndex LangChain RAG"]
  node_labse_rag["LaBSE multilingual RAG"]
  node_evaluation["WER and ROUGE metrics"]
end

node_user(("Questioner"))
node_openai["OpenAI service"]
node_fasttext_service["FastText model source"]
node_dataset["Private dataset<br/>[dataset.txt]"]

node_user -->|"asks"| node_chat_ui
node_chat_ui -->|"identifies language"| node_language_id
node_chat_ui -->|"builds prompt"| node_prompt
node_chat_ui -->|"formats history"| node_chat_history
node_chat_ui -->|"runs query"| node_qa_chain
node_qa_chain -->|"uses prompt"| node_prompt
node_qa_chain -->|"retrieves context"| node_retriever
node_retriever -->|"searches"| node_faiss_index
node_faiss_index -->|"loads with"| node_embeddings
node_qa_chain -->|"generates answer"| node_chat_model
node_chat_model -.->|"calls"| node_openai
node_language_id -->|"downloads model"| node_fasttext_service
node_qa_chain -->|"returns answer"| node_chat_ui
node_dataset -->|"uses dataset"| node_meta_rag
node_dataset -->|"uses dataset"| node_framework_rag
node_dataset -->|"uses dataset"| node_labse_rag
node_framework_rag -->|"reports metrics"| node_evaluation
node_labse_rag -->|"reports metrics"| node_evaluation

click node_chat_ui "https://github.com/reichenbch/rag-examples/blob/main/gradio_app.py"
click node_language_id "https://github.com/reichenbch/rag-examples/blob/main/gradio_app.py"
click node_prompt "https://github.com/reichenbch/rag-examples/blob/main/gradio_app.py"
click node_chat_history "https://github.com/reichenbch/rag-examples/blob/main/gradio_app.py"
click node_qa_chain "https://github.com/reichenbch/rag-examples/blob/main/gradio_app.py"
click node_retriever "https://github.com/reichenbch/rag-examples/blob/main/gradio_app.py"
click node_faiss_index "https://github.com/reichenbch/rag-examples/blob/main/faiss_doc_idx/index.faiss"
click node_embeddings "https://github.com/reichenbch/rag-examples/blob/main/gradio_app.py"
click node_chat_model "https://github.com/reichenbch/rag-examples/blob/main/gradio_app.py"
click node_meta_rag "https://github.com/reichenbch/rag-examples/blob/main/Meta%20Original%20RAG%20Model%20Implementation.ipynb"
click node_framework_rag "https://github.com/reichenbch/rag-examples/blob/main/LangChain%20LLamaIndex%20RAG.ipynb"
click node_labse_rag "https://github.com/reichenbch/rag-examples/blob/main/LaBSE%20%2B%20RAG%20-%20Multilingual%20Support.ipynb"
click node_dataset "https://github.com/reichenbch/rag-examples/blob/main/dataset.txt"
click node_evaluation "https://github.com/reichenbch/rag-examples/blob/main/LangChain%20LLamaIndex%20RAG.ipynb"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_chat_ui,node_language_id,node_prompt,node_chat_history toneBlue
class node_qa_chain,node_retriever,node_faiss_index,node_embeddings,node_chat_model toneAmber
class node_meta_rag,node_framework_rag,node_labse_rag,node_evaluation toneMint
class node_user,node_openai,node_fasttext_service toneIndigo
class node_dataset toneTeal
```

## Components

### Gradio application

- [Chat interface](https://github.com/reichenbch/rag-examples/blob/main/gradio_app.py): `gradio_app.py`
- [Language identification](https://github.com/reichenbch/rag-examples/blob/main/gradio_app.py): `gradio_app.py`
- [Language prompt](https://github.com/reichenbch/rag-examples/blob/main/gradio_app.py): `gradio_app.py`
- [Chat history](https://github.com/reichenbch/rag-examples/blob/main/gradio_app.py): `gradio_app.py`

### Retrieval and generation

- [Retrieval QA chain](https://github.com/reichenbch/rag-examples/blob/main/gradio_app.py): `gradio_app.py`
- [FAISS retriever](https://github.com/reichenbch/rag-examples/blob/main/gradio_app.py): `gradio_app.py`
- [Persisted FAISS index](https://github.com/reichenbch/rag-examples/blob/main/faiss_doc_idx/index.faiss): `faiss_doc_idx/index.faiss`
- [OpenAI embeddings](https://github.com/reichenbch/rag-examples/blob/main/gradio_app.py): `gradio_app.py`
- [ChatGPT generation](https://github.com/reichenbch/rag-examples/blob/main/gradio_app.py): `gradio_app.py`

### Notebook implementations

- [Original Meta RAG](https://github.com/reichenbch/rag-examples/blob/main/Meta%20Original%20RAG%20Model%20Implementation.ipynb): `Meta Original RAG Model Implementation.ipynb`
- [LlamaIndex LangChain RAG](https://github.com/reichenbch/rag-examples/blob/main/LangChain%20LLamaIndex%20RAG.ipynb): `LangChain LLamaIndex RAG.ipynb`
- [LaBSE multilingual RAG](https://github.com/reichenbch/rag-examples/blob/main/LaBSE%20%2B%20RAG%20-%20Multilingual%20Support.ipynb): `LaBSE + RAG - Multilingual Support.ipynb`
- [WER and ROUGE metrics](https://github.com/reichenbch/rag-examples/blob/main/LangChain%20LLamaIndex%20RAG.ipynb): `LangChain LLamaIndex RAG.ipynb`

### Other components

- **Questioner**
- **OpenAI service**
- **FastText model source**
- [Private dataset](https://github.com/reichenbch/rag-examples/blob/main/dataset.txt): `dataset.txt`

## Connections

- Questioner → Chat interface: asks (evidence: `README.md`)
- Chat interface → Language identification: identifies language (evidence: `gradio_app.py`)
- Chat interface → Language prompt: builds prompt (evidence: `gradio_app.py`)
- Chat interface → Chat history: formats history (evidence: `gradio_app.py`)
- Chat interface → Retrieval QA chain: runs query (evidence: `gradio_app.py`)
- Retrieval QA chain → Language prompt: uses prompt (evidence: `gradio_app.py`)
- Retrieval QA chain → FAISS retriever: retrieves context (evidence: `gradio_app.py`)
- FAISS retriever → Persisted FAISS index: searches (evidence: `gradio_app.py`)
- Persisted FAISS index → OpenAI embeddings: loads with (evidence: `gradio_app.py`)
- Retrieval QA chain → ChatGPT generation: generates answer (evidence: `gradio_app.py`)
- ChatGPT generation → OpenAI service: calls (evidence: `README.md`)
- Language identification → FastText model source: downloads model (evidence: `gradio_app.py`)
- Retrieval QA chain → Chat interface: returns answer (evidence: `gradio_app.py`)
- Private dataset → Original Meta RAG: uses dataset (evidence: `README.md`)
- Private dataset → LlamaIndex LangChain RAG: uses dataset (evidence: `README.md`)
- Private dataset → LaBSE multilingual RAG: uses dataset (evidence: `README.md`)
- LlamaIndex LangChain RAG → WER and ROUGE metrics: reports metrics (evidence: `README.md`)
- LaBSE multilingual RAG → WER and ROUGE metrics: reports metrics (evidence: `README.md`)
