# heyisula/infosage-13b architecture

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

- Interactive diagram: https://gitdiagram.com/heyisula/infosage-13b
- Repository: https://github.com/heyisula/infosage-13b

## Overview

InfoSage is an educational assistant that combines a locally loaded, fine-tuned Llama model with local and optional live retrieval, exposed through a browser dashboard or terminal. The dashboard workflow is user → web UI → Flask API → response generation, with chat history handled separately. Training and index-building are distinct preparation paths that supply model adapters and retrieval data to local inference. The graph follows the README and shown source excerpts; some runtime details and notebook internals were not sampled, so undocumented links are omitted.

Main entry points: [`chat_llm.py`](https://github.com/heyisula/infosage-13b/blob/main/chat_llm.py) (Chat Engine), [`build_rag_index.py`](https://github.com/heyisula/infosage-13b/blob/main/build_rag_index.py) (Index Builder), [`gui/app.py`](https://github.com/heyisula/infosage-13b/blob/main/gui/app.py) (Flask API), [`gui/static/script.js`](https://github.com/heyisula/infosage-13b/blob/main/gui/static/script.js) (Chat Interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Cloud Training"]
  node_training_pipeline["QLoRA Training<br/>[train.ipynb]"]
end

subgraph group_retrieval["Knowledge Retrieval"]
  node_index_builder["Index Builder<br/>[build_rag_index.py]"]
  node_embedding["Embedding Model<br/>[build_rag_index.py]"]
  node_vector_store[("FAISS Knowledge Base")]
  node_live_search["Live Dataset Search<br/>[chat_llm.py]"]
  node_local_search["Local Retrieval<br/>[chat_llm.py]"]
end

subgraph group_inference["Local Inference"]
  node_chat_engine["Chat Engine<br/>[chat_llm.py]"]
  node_llm["Llama Inference<br/>[chat_llm.py]"]
  node_postprocess["Response Cleanup<br/>[chat_llm.py]"]
  node_terminal["Terminal Chat<br/>[chat_llm.py]"]
end

subgraph group_dashboard["Dashboard"]
  node_chat_ui["Chat Interface<br/>[script.js]"]
  node_flask_api["Flask API<br/>[app.py]"]
  node_chat_history[("Chat History<br/>[app.py]")]
end

node_user(("User"))
node_browser(("Browser"))
node_fineweb[("FineWeb-Edu")]
node_drive[("Google Drive")]
node_adapter["LoRA Adapter"]

node_user -->|"asks"| node_chat_ui
node_browser -->|"opens"| node_chat_ui
node_chat_ui -->|"sends requests"| node_flask_api
node_flask_api -->|"calls"| node_chat_engine
node_flask_api -->|"reads and writes"| node_chat_history
node_chat_engine -->|"retrieves locally"| node_local_search
node_local_search -->|"searches"| node_vector_store
node_chat_engine -.->|"searches when enabled"| node_live_search
node_live_search -->|"streams dataset"| node_fineweb
node_chat_engine -->|"generates"| node_llm
node_llm -->|"cleans response"| node_postprocess
node_index_builder -->|"streams samples"| node_fineweb
node_index_builder -->|"encodes passages"| node_embedding
node_index_builder -->|"writes index"| node_vector_store
node_training_pipeline -->|"trains on"| node_fineweb
node_training_pipeline -->|"saves checkpoints"| node_drive
node_drive -->|"migrates weights"| node_adapter
node_adapter -->|"loads for inference"| node_chat_engine
node_user -->|"enters prompt"| node_terminal

click node_training_pipeline "https://github.com/heyisula/infosage-13b/blob/main/train.ipynb"
click node_index_builder "https://github.com/heyisula/infosage-13b/blob/main/build_rag_index.py"
click node_embedding "https://github.com/heyisula/infosage-13b/blob/main/build_rag_index.py"
click node_live_search "https://github.com/heyisula/infosage-13b/blob/main/chat_llm.py"
click node_chat_ui "https://github.com/heyisula/infosage-13b/blob/main/gui/static/script.js"
click node_flask_api "https://github.com/heyisula/infosage-13b/blob/main/gui/app.py"
click node_chat_history "https://github.com/heyisula/infosage-13b/blob/main/gui/app.py"
click node_chat_engine "https://github.com/heyisula/infosage-13b/blob/main/chat_llm.py"
click node_local_search "https://github.com/heyisula/infosage-13b/blob/main/chat_llm.py"
click node_llm "https://github.com/heyisula/infosage-13b/blob/main/chat_llm.py"
click node_postprocess "https://github.com/heyisula/infosage-13b/blob/main/chat_llm.py"
click node_terminal "https://github.com/heyisula/infosage-13b/blob/main/chat_llm.py"

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_training_pipeline,node_user,node_browser toneBlue
class node_index_builder,node_embedding,node_vector_store,node_live_search,node_local_search,node_fineweb,node_drive toneAmber
class node_chat_engine,node_llm,node_postprocess,node_terminal toneMint
class node_chat_ui,node_flask_api,node_chat_history toneRose
class node_adapter toneIndigo
```

## Components

### Cloud Training

- [QLoRA Training](https://github.com/heyisula/infosage-13b/blob/main/train.ipynb): `train.ipynb`

### Knowledge Retrieval

- [Index Builder](https://github.com/heyisula/infosage-13b/blob/main/build_rag_index.py): `build_rag_index.py`
- [Embedding Model](https://github.com/heyisula/infosage-13b/blob/main/build_rag_index.py): `build_rag_index.py`
- **FAISS Knowledge Base**
- [Live Dataset Search](https://github.com/heyisula/infosage-13b/blob/main/chat_llm.py): `chat_llm.py`
- [Local Retrieval](https://github.com/heyisula/infosage-13b/blob/main/chat_llm.py): `chat_llm.py`

### Local Inference

- [Chat Engine](https://github.com/heyisula/infosage-13b/blob/main/chat_llm.py): `chat_llm.py`
- [Llama Inference](https://github.com/heyisula/infosage-13b/blob/main/chat_llm.py): `chat_llm.py`
- [Response Cleanup](https://github.com/heyisula/infosage-13b/blob/main/chat_llm.py): `chat_llm.py`
- [Terminal Chat](https://github.com/heyisula/infosage-13b/blob/main/chat_llm.py): `chat_llm.py`

### Dashboard

- [Chat Interface](https://github.com/heyisula/infosage-13b/blob/main/gui/static/script.js): `gui/static/script.js`
- [Flask API](https://github.com/heyisula/infosage-13b/blob/main/gui/app.py): `gui/app.py`
- [Chat History](https://github.com/heyisula/infosage-13b/blob/main/gui/app.py): `gui/app.py`

### Other components

- **User**
- **Browser**
- **FineWeb-Edu**
- **Google Drive**
- **LoRA Adapter**

## Connections

- User → Chat Interface: asks (evidence: `README.md`)
- Browser → Chat Interface: opens (evidence: `README.md`)
- Chat Interface → Flask API: sends requests (evidence: `gui/static/script.js`)
- Flask API → Chat Engine: calls (evidence: `gui/app.py`)
- Flask API → Chat History: reads and writes (evidence: `gui/app.py`)
- Chat Engine → Local Retrieval: retrieves locally (evidence: `chat_llm.py`)
- Local Retrieval → FAISS Knowledge Base: searches (evidence: `chat_llm.py`)
- Chat Engine → Live Dataset Search: searches when enabled (evidence: `chat_llm.py`)
- Live Dataset Search → FineWeb-Edu: streams dataset (evidence: `chat_llm.py`)
- Chat Engine → Llama Inference: generates (evidence: `chat_llm.py`)
- Llama Inference → Response Cleanup: cleans response (evidence: `chat_llm.py`)
- Index Builder → FineWeb-Edu: streams samples (evidence: `build_rag_index.py`)
- Index Builder → Embedding Model: encodes passages (evidence: `build_rag_index.py`)
- Index Builder → FAISS Knowledge Base: writes index (evidence: `build_rag_index.py`)
- QLoRA Training → FineWeb-Edu: trains on (evidence: `README.md`)
- QLoRA Training → Google Drive: saves checkpoints (evidence: `README.md`)
- Google Drive → LoRA Adapter: migrates weights (evidence: `README.md`)
- LoRA Adapter → Chat Engine: loads for inference (evidence: `README.md`)
- User → Terminal Chat: enters prompt (evidence: `chat_llm.py`)
