# siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach architecture

> Architecture diagram of the GitHub repository siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach
- Repository: https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach

## Overview

This checkout contains the VM3 judge and model-preparation/training scripts; the README describes VM1 and VM2 as separately deployed services, but their source files are not in this tree. The principal workflow is a judge request, a deterministic fact-check override or five weighted signals, and a thresholded verdict. Training is a separate data-preparation branch. Runtime links among the five signal functions are documented in the judge source; external deployment links rely on the README.

Main entry points: [`app.py`](https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach/blob/main/app.py) (Weighted ensemble), [`data_prep.py`](https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach/blob/main/data_prep.py) (Data preparation), [`train_distilbert_v1.py`](https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach/blob/main/train_distilbert_v1.py) (DistilBERT V1 training), [`train_distilbert_v2.py`](https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach/blob/main/train_distilbert_v2.py) (DistilBERT V2 training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Judge runtime"]
  node_judge_api["Judge API<br/>[app.py]"]
  node_fact_override["Fact override<br/>[app.py]"]
  node_ensemble["Weighted ensemble<br/>[app.py]"]
end

subgraph group_signals["Judging signals"]
  node_selfcheck["SelfCheckGPT<br/>[app.py]"]
  node_distilbert_v2["DistilBERT V2<br/>[app.py]"]
  node_flant5["Flan-T5 CoT<br/>[app.py]"]
  node_distilbert_v1["DistilBERT V1<br/>[app.py]"]
  node_qwen["Qwen judge<br/>[app.py]"]
end

subgraph group_training["Data and training"]
  node_data_prep["Data preparation<br/>[data_prep.py]"]
  node_train_v2["DistilBERT V2 training"]
  node_train_t5["Flan-T5 training<br/>[train_flant5.py]"]
  node_train_v1["DistilBERT V1 training"]
end

node_user(("Evaluator"))
node_frontend["Streamlit dashboard"]
node_llm_service["VM2 LLM service"]
node_halubench[("HaluBench dataset")]

node_user -->|"enters passage"| node_frontend
node_frontend -->|"requests responses"| node_llm_service
node_frontend -->|"submits evaluation"| node_judge_api
node_judge_api -->|"checks facts"| node_fact_override
node_judge_api -->|"scores request"| node_ensemble
node_ensemble -->|"scores consistency"| node_selfcheck
node_ensemble -->|"scores answer"| node_distilbert_v2
node_ensemble -->|"scores answer"| node_flant5
node_ensemble -->|"scores answer"| node_distilbert_v1
node_ensemble -->|"scores answer"| node_qwen
node_halubench -->|"loads dataset"| node_data_prep
node_data_prep -->|"supplies training data"| node_train_v2
node_data_prep -->|"supplies training data"| node_train_t5
node_train_v1 -.->|"trains baseline"| node_distilbert_v1

click node_judge_api "https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach/blob/main/app.py"
click node_fact_override "https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach/blob/main/app.py"
click node_ensemble "https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach/blob/main/app.py"
click node_selfcheck "https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach/blob/main/app.py"
click node_distilbert_v2 "https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach/blob/main/app.py"
click node_flant5 "https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach/blob/main/app.py"
click node_distilbert_v1 "https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach/blob/main/app.py"
click node_qwen "https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach/blob/main/app.py"
click node_data_prep "https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach/blob/main/data_prep.py"
click node_train_v2 "https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach/blob/main/train_distilbert_v2.py"
click node_train_t5 "https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach/blob/main/train_flant5.py"
click node_train_v1 "https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach/blob/main/train_distilbert_v1.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_judge_api,node_fact_override,node_ensemble toneBlue
class node_selfcheck,node_distilbert_v2,node_flant5,node_distilbert_v1,node_qwen,node_halubench toneAmber
class node_data_prep,node_train_v2,node_train_t5,node_train_v1 toneMint
class node_user,node_frontend,node_llm_service toneIndigo
```

## Components

### Judge runtime

- [Judge API](https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach/blob/main/app.py): `app.py`
- [Fact override](https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach/blob/main/app.py): `app.py`
- [Weighted ensemble](https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach/blob/main/app.py): `app.py`

### Judging signals

- [SelfCheckGPT](https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach/blob/main/app.py): `app.py`
- [DistilBERT V2](https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach/blob/main/app.py): `app.py`
- [Flan-T5 CoT](https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach/blob/main/app.py): `app.py`
- [DistilBERT V1](https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach/blob/main/app.py): `app.py`
- [Qwen judge](https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach/blob/main/app.py): `app.py`

### Data and training

- [Data preparation](https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach/blob/main/data_prep.py): `data_prep.py`
- [DistilBERT V2 training](https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach/blob/main/train_distilbert_v2.py): `train_distilbert_v2.py`
- [Flan-T5 training](https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach/blob/main/train_flant5.py): `train_flant5.py`
- [DistilBERT V1 training](https://github.com/siddhavi/detecting-llm-hallucinations-on-cpu-based-systems--a-cloud-assisted-approach/blob/main/train_distilbert_v1.py): `train_distilbert_v1.py`

### Other components

- **Evaluator**
- **Streamlit dashboard**
- **VM2 LLM service**
- **HaluBench dataset**

## Connections

- Evaluator → Streamlit dashboard: enters passage (evidence: `README.md`)
- Streamlit dashboard → VM2 LLM service: requests responses (evidence: `README.md`)
- Streamlit dashboard → Judge API: submits evaluation (evidence: `README.md`)
- Judge API → Fact override: checks facts (evidence: `app.py`)
- Judge API → Weighted ensemble: scores request (evidence: `app.py`)
- Weighted ensemble → SelfCheckGPT: scores consistency (evidence: `app.py`)
- Weighted ensemble → DistilBERT V2: scores answer (evidence: `app.py`)
- Weighted ensemble → Flan-T5 CoT: scores answer (evidence: `app.py`)
- Weighted ensemble → DistilBERT V1: scores answer (evidence: `app.py`)
- Weighted ensemble → Qwen judge: scores answer (evidence: `app.py`)
- HaluBench dataset → Data preparation: loads dataset (evidence: `data_prep.py`)
- Data preparation → DistilBERT V2 training: supplies training data (evidence: `README.md`)
- Data preparation → Flan-T5 training: supplies training data (evidence: `README.md`)
- DistilBERT V1 training → DistilBERT V1: trains baseline
