Spaces:
Running
Running
update docs
Browse files
docs/README.md
CHANGED
|
@@ -4,41 +4,40 @@ This folder contains the handover documentation for the Audit Assistant project.
|
|
| 4 |
|
| 5 |
The architecture documentation follows the [arc42](https://arc42.org/) standard. Diagrams use the [C4 model](https://c4model.com/) conventions. The operations runbook follows the [Diátaxis](https://diataxis.fr/) "how-to guide" pattern.
|
| 6 |
|
| 7 |
-
> **Status:** the documentation set is being built out as part of the project close-out. The Status column in each table below shows what is complete and what is in progress.
|
| 8 |
-
|
| 9 |
## How to read this documentation
|
| 10 |
|
| 11 |
- **First-time readers.** Start with [Introduction, Goals & Constraints](architecture/01-introduction-goals-constraints.md) and [Context & Scope](architecture/02-context-and-scope.md). Together they take about 10 minutes and give you the system at a glance.
|
| 12 |
-
- **Reviewers / auditors.** Go to the [Architecture Decision Records](architecture/adrs/) — each ADR explains one key design choice with its rationale, alternatives considered and consequences.
|
| 13 |
-
- **Operators and future maintainers.** Start with the [Operations Runbook](runbook/) and [System Requirements](system-requirements.md).
|
| 14 |
- **Evaluators.** See the [Evaluation document](evaluation.md) — methodology, metrics, and reproducibility instructions.
|
| 15 |
|
| 16 |
## Documentation map
|
| 17 |
|
| 18 |
### Architecture (arc42)
|
| 19 |
|
| 20 |
-
| # | Document | What it covers |
|
| 21 |
-
|---|---|---|
|
| 22 |
-
| 1 | [Introduction, Goals & Constraints](architecture/01-introduction-goals-constraints.md) | arc42 §1, §2; quality goals summary |
|
| 23 |
-
| 2 | [Context & Scope](architecture/02-context-and-scope.md) | arc42 §3; business + technical context diagrams |
|
| 24 |
-
| 3 | [Solution Strategy & Building Blocks](architecture/03-solution-strategy-and-building-blocks.md) | arc42 §4, §5; container + component diagrams |
|
| 25 |
-
| 4 | [Runtime View](architecture/04-runtime-view.md) | arc42 §6;
|
| 26 |
-
| 5 | [Deployment View](architecture/05-deployment-view.md) | arc42 §7; HF Spaces topology + env vars |
|
| 27 |
-
| 6 | [Crosscutting Concepts](architecture/06-crosscutting-concepts.md) | arc42 §8; config, logging, errors, secrets, caching, concurrency
|
| 28 |
-
| – | [Architecture Decision Records](architecture/adrs/) | arc42 §9;
|
| 29 |
-
| 7 | [Quality, Risks & Glossary](architecture/07-quality-risks-glossary.md) | arc42 §10, §11, §12; quality scenarios + risk register + glossary |
|
| 30 |
|
| 31 |
### Operations and references
|
| 32 |
|
| 33 |
-
| Document | What it covers |
|
| 34 |
-
|---|---|
|
| 35 |
-
| [Interfaces](interfaces.md) | External integration interfaces and internal module interfaces |
|
| 36 |
-
| [Operations Runbook](runbook/) | How-to guides for routine operational tasks (
|
| 37 |
-
| [Evaluation](evaluation.md) | Evaluation methodology, metrics, reproducibility
|
| 38 |
-
| [System Requirements](system-requirements.md) | Hardware, software, network requirements |
|
| 39 |
-
| [Stack & Dependencies](stack-and-dependencies.md) | Dependency versions and recommended upgrade path |
|
| 40 |
-
| [Cost & Performance](cost-and-performance.md) |
|
| 41 |
-
| [Accountability, Transparency, Limitations & Biases](accountability-transparency-limitations-biases.md) | WP5 final-stage assessments |
|
|
|
|
| 42 |
|
| 43 |
## External references
|
| 44 |
|
|
@@ -46,9 +45,4 @@ The architecture documentation follows the [arc42](https://arc42.org/) standard.
|
|
| 46 |
- [C4 model](https://c4model.com/) — diagram conventions used in the architecture views
|
| 47 |
- [Diátaxis](https://diataxis.fr/) — documentation framework used for the runbook
|
| 48 |
- [Project README](../README.md) — repository overview and quickstart
|
| 49 |
-
|
| 50 |
-
## Deferred items
|
| 51 |
-
|
| 52 |
-
Items intentionally deferred during this documentation pass will be listed here as they come up, so reviewers and future maintainers can see them at a glance.
|
| 53 |
-
|
| 54 |
-
*(none yet)*
|
|
|
|
| 4 |
|
| 5 |
The architecture documentation follows the [arc42](https://arc42.org/) standard. Diagrams use the [C4 model](https://c4model.com/) conventions. The operations runbook follows the [Diátaxis](https://diataxis.fr/) "how-to guide" pattern.
|
| 6 |
|
|
|
|
|
|
|
| 7 |
## How to read this documentation
|
| 8 |
|
| 9 |
- **First-time readers.** Start with [Introduction, Goals & Constraints](architecture/01-introduction-goals-constraints.md) and [Context & Scope](architecture/02-context-and-scope.md). Together they take about 10 minutes and give you the system at a glance.
|
| 10 |
+
- **Reviewers / auditors.** Go to the [Architecture Decision Records](architecture/adrs/README.md) — each ADR explains one key design choice with its rationale, alternatives considered and consequences.
|
| 11 |
+
- **Operators and future maintainers.** Start with the [Operations Runbook](runbook/README.md) and [System Requirements](system-requirements.md).
|
| 12 |
- **Evaluators.** See the [Evaluation document](evaluation.md) — methodology, metrics, and reproducibility instructions.
|
| 13 |
|
| 14 |
## Documentation map
|
| 15 |
|
| 16 |
### Architecture (arc42)
|
| 17 |
|
| 18 |
+
| # | Document | What it covers |
|
| 19 |
+
|---|---|---|
|
| 20 |
+
| 1 | [Introduction, Goals & Constraints](architecture/01-introduction-goals-constraints.md) | arc42 §1, §2; quality goals summary |
|
| 21 |
+
| 2 | [Context & Scope](architecture/02-context-and-scope.md) | arc42 §3; business + technical context diagrams |
|
| 22 |
+
| 3 | [Solution Strategy & Building Blocks](architecture/03-solution-strategy-and-building-blocks.md) | arc42 §4, §5; container + component diagrams |
|
| 23 |
+
| 4 | [Runtime View](architecture/04-runtime-view.md) | arc42 §6; agent-graph + retrieval sequence diagrams; resolver-agent dynamic-lookup flow |
|
| 24 |
+
| 5 | [Deployment View](architecture/05-deployment-view.md) | arc42 §7; HF Spaces topology + env vars |
|
| 25 |
+
| 6 | [Crosscutting Concepts](architecture/06-crosscutting-concepts.md) | arc42 §8; config, logging, errors, secrets, caching, concurrency, prompt-cache convention, MMR diversity, LLM-adapter resilience, observability, one-time-init lifecycle, test strategy |
|
| 26 |
+
| – | [Architecture Decision Records](architecture/adrs/README.md) | arc42 §9; 7 ADRs on the key design choices (multi-agent, dense-only retrieval, reranker skip, LLM model choice, HF Spaces deployment, chunking, MMR-Jaccard) |
|
| 27 |
+
| 7 | [Quality, Risks & Glossary](architecture/07-quality-risks-glossary.md) | arc42 §10, §11, §12; quality scenarios + risk register + glossary |
|
| 28 |
|
| 29 |
### Operations and references
|
| 30 |
|
| 31 |
+
| Document | What it covers |
|
| 32 |
+
|---|---|
|
| 33 |
+
| [Interfaces](interfaces.md) | External integration interfaces and internal module interfaces |
|
| 34 |
+
| [Operations Runbook](runbook/README.md) | How-to guides for routine operational tasks (7 how-tos + index) |
|
| 35 |
+
| [Evaluation](evaluation.md) | Evaluation methodology, metrics, reproducibility instructions |
|
| 36 |
+
| [System Requirements](system-requirements.md) | Hardware, software, network requirements |
|
| 37 |
+
| [Stack & Dependencies](stack-and-dependencies.md) | Dependency versions and recommended upgrade path |
|
| 38 |
+
| [Cost & Performance](cost-and-performance.md) | Per-query cost summary, hybrid model strategy, prompt-cache savings, monitoring; full analysis linked |
|
| 39 |
+
| [Accountability, Transparency, Limitations & Biases](accountability-transparency-limitations-biases.md) | WP5 final-stage assessments |
|
| 40 |
+
| [DEFERRED.md](DEFERRED.md) | Known open items + design notes carried forward post-handover |
|
| 41 |
|
| 42 |
## External references
|
| 43 |
|
|
|
|
| 45 |
- [C4 model](https://c4model.com/) — diagram conventions used in the architecture views
|
| 46 |
- [Diátaxis](https://diataxis.fr/) — documentation framework used for the runbook
|
| 47 |
- [Project README](../README.md) — repository overview and quickstart
|
| 48 |
+
- [CHANGELOG](../CHANGELOG.md) — chronological record of notable changes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
docs/accountability-transparency-limitations-biases.md
CHANGED
|
@@ -29,7 +29,7 @@
|
|
| 29 |
|
| 30 |
- The system runs **two to three LLM calls per turn** (analysis, optionally rewrite, answer generation). Token usage is logged server-side but not surfaced in the UI.
|
| 31 |
- The system runs **Qdrant queries** (one or more `count()` calls for pre-validation + one vector search). Latency is hidden behind a "Thinking..." spinner.
|
| 32 |
-
- Conversations are **logged server-side** to a Hugging Face dataset (`GIZ/spaces_logs`) for audit and analytics purposes. This is not currently disclosed in the UI — a privacy note should be added to the application
|
| 33 |
- The system **infers filters from the user's natural-language query** (year, source category, district, entity type). These inferred filters drive what gets retrieved. The reasoning is captured in `resolution_notes` and logged server-side but not always surfaced to the user.
|
| 34 |
|
| 35 |
### Improving transparency — recommended next steps
|
|
|
|
| 29 |
|
| 30 |
- The system runs **two to three LLM calls per turn** (analysis, optionally rewrite, answer generation). Token usage is logged server-side but not surfaced in the UI.
|
| 31 |
- The system runs **Qdrant queries** (one or more `count()` calls for pre-validation + one vector search). Latency is hidden behind a "Thinking..." spinner.
|
| 32 |
+
- Conversations are **logged server-side** to a Hugging Face dataset (`GIZ/spaces_logs`) for audit and analytics purposes. This is not currently disclosed in the UI — a privacy note should be added to the application footer before the system is exposed to end-users (tracked in [`DEFERRED.md`](DEFERRED.md) #21).
|
| 33 |
- The system **infers filters from the user's natural-language query** (year, source category, district, entity type). These inferred filters drive what gets retrieved. The reasoning is captured in `resolution_notes` and logged server-side but not always surfaced to the user.
|
| 34 |
|
| 35 |
### Improving transparency — recommended next steps
|
docs/architecture/04-runtime-view.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
| 1 |
# 4. Runtime View
|
| 2 |
|
| 3 |
> *arc42 §6 — Runtime View. This document traces the system's behaviour during a typical user interaction, from the moment a query is submitted in the Streamlit UI through to the final answer being rendered.*
|
| 4 |
-
>
|
| 5 |
-
> *Status: first draft, built from system walkthroughs. Will be cross-linked to the building-block view (§5) once that's drafted.*
|
| 6 |
|
| 7 |
## 4.1 Top-level interaction
|
| 8 |
|
|
|
|
| 1 |
# 4. Runtime View
|
| 2 |
|
| 3 |
> *arc42 §6 — Runtime View. This document traces the system's behaviour during a typical user interaction, from the moment a query is submitted in the Streamlit UI through to the final answer being rendered.*
|
|
|
|
|
|
|
| 4 |
|
| 5 |
## 4.1 Top-level interaction
|
| 6 |
|
docs/runbook/update-knowledge-base.md
CHANGED
|
@@ -68,28 +68,45 @@ comparable to old chunks).
|
|
| 68 |
|
| 69 |
### 3. Run the ingestion script
|
| 70 |
|
| 71 |
-
|
| 72 |
-
|
|
|
|
|
|
|
| 73 |
|
| 74 |
```bash
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
--docs-dir reports/new_batch_2025/ \
|
| 79 |
-
--append # don't recreate the collection, just add new docs
|
| 80 |
-
```
|
| 81 |
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
python scripts/ingest_corpus.py \
|
| 85 |
--collection BAAI-bge-m3-full \
|
| 86 |
-
--
|
| 87 |
-
--
|
| 88 |
-
--override-source "CSBAG" \
|
| 89 |
-
--override-year 2025 \
|
| 90 |
-
--override-district "Gulu"
|
| 91 |
```
|
| 92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
### 4. Wait for ingestion to complete
|
| 94 |
|
| 95 |
For ~50 typical audit-report PDFs:
|
|
|
|
| 68 |
|
| 69 |
### 3. Run the ingestion script
|
| 70 |
|
| 71 |
+
The canonical batch-ingestion script is `maintanance/batch_ingest_folder.py`.
|
| 72 |
+
It recursively walks a folder of PDFs, chunks them with Docling, embeds
|
| 73 |
+
with `BAAI/bge-m3`, and uploads to Qdrant in batches. Resumable via a
|
| 74 |
+
state file, retries on transient failures.
|
| 75 |
|
| 76 |
```bash
|
| 77 |
+
# Required environment variables
|
| 78 |
+
export QDRANT_URL=https://...
|
| 79 |
+
export QDRANT_API_KEY=...
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
+
# Standard invocation: ingest all PDFs under a folder, append to existing collection
|
| 82 |
+
python maintanance/batch_ingest_folder.py "/path/to/reports/new_batch_2025" \
|
|
|
|
| 83 |
--collection BAAI-bge-m3-full \
|
| 84 |
+
--chunk-size 512 \
|
| 85 |
+
--batch-size 32
|
|
|
|
|
|
|
|
|
|
| 86 |
```
|
| 87 |
|
| 88 |
+
Useful flags:
|
| 89 |
+
|
| 90 |
+
| Flag | Purpose |
|
| 91 |
+
|---|---|
|
| 92 |
+
| `--collection BAAI-bge-m3-full` | Target Qdrant collection name (default already matches production) |
|
| 93 |
+
| `--chunk-size 512` | Chunk size in tokens (default; matches the existing corpus) |
|
| 94 |
+
| `--batch-size 32` | Embedding batch size (lower if RAM-constrained) |
|
| 95 |
+
| `--pdf-batch-size 4` | How many PDFs Docling processes together (default 4) |
|
| 96 |
+
| `--max-retries 5` | Retries per file on transient failure (default 3) |
|
| 97 |
+
| `--no-skip-existing` | Re-upload chunks that already exist in Qdrant (default: skip) |
|
| 98 |
+
| `--resume` (no value) | Auto-find the most recent state file for this folder and continue |
|
| 99 |
+
| `--resume STATE_FILE.json` | Continue from a specific state file |
|
| 100 |
+
| `--no-wait` | Use non-blocking Qdrant upserts (faster but less safe if interrupted) |
|
| 101 |
+
|
| 102 |
+
State files (`ingestion_state_<batch_name>_<timestamp>.json`) are written
|
| 103 |
+
to the working directory; they let you resume after a crash or network
|
| 104 |
+
blip without re-uploading already-ingested chunks.
|
| 105 |
+
|
| 106 |
+
For one-off cleanup after a partial ingest, use
|
| 107 |
+
`maintanance/ingest_missing_files.py` instead — it scans Qdrant for missing
|
| 108 |
+
chunks and only ingests those.
|
| 109 |
+
|
| 110 |
### 4. Wait for ingestion to complete
|
| 111 |
|
| 112 |
For ~50 typical audit-report PDFs:
|