Heritage Impact Project 2026 · Albert School B2 · BDD group 1
Every figure keeps the sentence it came from.
The client, an international foundation, funds cultural heritage protection projects in conflict-affected regions, and each project leaves a trail of PDF and Word reports. Our engine reads all of them with the foundation's own AI model. It keeps every useful point together with the exact quote and page behind it, then builds the foundation's 126-column project table from that evidence. The result is ready for Power BI, and any value can be traced back to the report it came from.
Fictional figures, scaled from the real results.
1In one minute
The idea behind the engine
An AI model reading reports can summarise well and still invent a figure. The engine is designed so that every claim it keeps is tied to text that code can find in the document.
Read everything
Every page, paragraph, table row and scanned image of every report is read, in seven languages, by the foundation's own model on Azure. No other AI ever sees the content.
Keep evidence, not answers
Each useful point becomes an item: a one-line English understanding, the verbatim quote or quotes behind it with file, page and character position, and the themes it belongs to.
Build the table from the evidence
A second engine reads only the stored items, never the documents again. The model states facts with their quotes. Code turns them into table cells, checks them, and sends doubtful cells to a review list.
Why it is built this way
Every value links to a quote, a file and a page. A reader can always check the source.
Each quote must appear word for word in the document, or it is sent back for repair, then dropped. Figures must appear in a quote, and dates and amounts are validated.
An empty cell means "not found", never zero. When documents disagree, every value is kept and flagged. The model never reconciles them.
Every student signed an NDA. Documents and outputs stay on the local machine. The only output safe to share is a numbers-only summary of each run.
- Understanding
- sha256:758ffa2c1c27 one English sentence, written by the model
- Quote 1
- sha256:98fedbe4ddb3 final report (PDF) · p. 6 · chars 2311–2397
- Quote 2
- sha256:620cd5ed3cfb foundation analysis (Word) · ¶ 52 · chars 114–190
- Buckets
- interventionproject_results
- Checks
- ✓ quotes found word for word · ✓ understanding check passed · merged from 2 documents · results vote 3 of 3
What the engine does not do: it does not score or judge projects. It recognises, extracts and files information, so that people can compare and evaluate projects with the sources in front of them.
2How it works
Method: two engines and one boundary
Engine 1 turns documents into items. Engine 2 turns items into the foundation's table. Everything runs on the local machine, and content only travels to the foundation's model and back.
Engine 1, step by step
The real order of a run. Steps marked "loop" send their own output back for correction before anything is kept.
- Prepare
- Group files into projectsThe Grant ID at the start of the file name decides the project, not the folder.
- Read each documentPyMuPDF and pypdf for PDF, lxml for Word (text boxes, footnotes, table rows), LibreOffice for .doc/.rtf, Tesseract OCR on every image.
- Set duplicates asideIdentical files are skipped. Near-copies (85%+ shared) contribute only their new parts.
- Reuse stored extractionsAn unchanged document is never paid for twice.
- Extract
- Chunk and add contextChunks of 12,000 characters at most. An agent adds up to 4 helpful units (annexes, acronyms), marked "context only".
- Pass 1: extractionOne call per chunk returns items. A chunk refused by the content filter is split and retried.loop · split
- Quote validationEach quote must be found word for word in the text, or it goes back for repair.loop · 2 rounds
- Pass 2: missed pointsFixes buckets and adds missed points. Units with no item are re-read while coverage is under 80%.loop · 3 rounds
- Pass 3: understanding checkAn understanding may only say what its quotes say; otherwise it is rewritten or dropped.loop · 2 rounds
- Consolidate
- Merge across documentsThe same point in several documents becomes one item. Each pair is decided twice. Updates and contradictions are flagged.2 readings
- Decide bucketsA vote over 3 readings, a separate vote on results, then fixed rules applied by code (for example, location only for verified places).vote · 3
- Project profilePartners and their roles, regions, cultures and religions. Each value is marked documents, derived or general knowledge.
- Save and exportAn evidence file per project, CSV tables for Power BI, and the numbers-only run summary.
Engine 2: from evidence to the foundation's table
fill_contract.pyClient project table126 columns, one row per project. 26 metadata columns come from the start of each document, then the file names, then the Intake List. 100 KPI columns cover SDGs, immovable and movable heritage, training, jobs, climate and dialogue. Every cell has its quote in client_evidence.csv.
build_sheets.py · discover_fields.pySheets and new fieldsA summary per project and theme, with comparable figures (money in USD at the World Bank rate of its year). Discovery proposes facts that recur across projects as new fields, and the group approves them in a table.
build_field_tree.py · build_final_tables.pyThree levels of detailColumns that mean similar things are joined with a minimum spanning tree and cut at three levels: same fact, general field, theme. A merged cell keeps every value; nothing is summed.
Where the model calls go
One batch of 10 projects, 21 Oct · 1,101 calls · 0 failed
Only 63 calls (6%) are the first extraction pass. The rest check, repair, merge and vote. That is the cost of accuracy: the agentic engine makes about three times the calls of the baseline.
2How it works
Data samples, hashed
What the tables look like. Each tab shows one of the engine's real output tables, with its real columns and value formats.
How these samples were made. Every text value is replaced by the first 12 characters of a SHA-256 hash of invented placeholder text. Grant IDs and country codes are pseudonyms (20XX-…, XA…) and numbers are invented at a realistic scale. No value from the foundation's data appears on this page; the real tables never leave the confidential data folder.
The fact table of engine 1. One row is one quote of one item in one bucket. Item #0017 from the figure above has 2 quotes and 2 buckets, so it fills 4 rows.
| evidence_id | item_id | bucket | understanding | quote | source_file | page | paragraph | char_start–end | extraction_pass | understanding_check | flag |
|---|---|---|---|---|---|---|---|---|---|---|---|
| ev-fb331e | 20XX-0001#0017 | intervention | 758ffa2c1c27 | 98fedbe4ddb3 | doc-2c3e37bf.pdf | 6 | — | 2311–2397 | primary | passed | — |
| ev-8cc591 | 20XX-0001#0017 | project_results | 758ffa2c1c27 | 98fedbe4ddb3 | doc-2c3e37bf.pdf | 6 | — | 2311–2397 | result_vote | passed | — |
| ev-b951c9 | 20XX-0001#0017 | intervention | 758ffa2c1c27 | 620cd5ed3cfb | doc-14fe23f5.docx | — | 52 | 114–190 | primary | passed | — |
| ev-cddb43 | 20XX-0001#0017 | project_results | 758ffa2c1c27 | 620cd5ed3cfb | doc-14fe23f5.docx | — | 52 | 114–190 | result_vote | passed | — |
| ev-76b5d5 | 20XX-0001#0046 | financial_information | 8ee89d00d02d | 9d377cc69a69 | doc-2c3e37bf.pdf | 3 | — | 455–538 | rule | passed | possible update |
Counting rule: count points of information with DISTINCTCOUNT(item_id), never by counting rows. The five rows above hold two items.
One row per project, the hub of the Power BI model. Status and freshness say whether the row can be trusted as complete.
| project_id | status | freshness | documents | items | evidence_records | buckets_with_evidence | country | umbrella | regions | classification_origin |
|---|---|---|---|---|---|---|---|---|---|---|
| 20XX-0001 | ok | fresh | 2 | 74 | 389 | 24 | XAA | U20XX-0001 | f5e5b83c4179 | engine |
| 20XX-0002 | ok | fresh | 1 | 41 | 197 | 19 | XAB | — | f347fe0804d4 (derived) | engine |
| 20XX-0003 | partial | stale | 3 | 142 | 731 | 28 | XAC | U20XX-0001 | 4c8c0ca326db (general knowledge) | engine |
One row per document: how well it was read. needs_review tells a person which file to open.
| project_id | file_name | file_type | ingestion_status | page_count | pages_ocr | source_units | extraction_status | unit_coverage | needs_review |
|---|---|---|---|---|---|---|---|---|---|
| 20XX-0001 | doc-2c3e37bf.pdf | ok | 44 | 0 | 44 | ok | 0.90 | False | |
| 20XX-0001 | doc-14fe23f5.docx | docx | ok | — | — | 236 | ok | 0.86 | False |
| 20XX-0003 | doc-3d3b0e4c.pdf | ok | 57 | 9 | 57 | partial | 0.79 | True |
Heritage identity, one row per value. The source column separates what the documents say from what the model only knows in general.
| project_id | attribute | value | source | evidence_item_ids | origin |
|---|---|---|---|---|---|
| 20XX-0001 | region | f5e5b83c4179 | documents | 20XX-0001#0005 | engine |
| 20XX-0001 | culture | fb0fc6d07035 | derived | 20XX-0001#0005 | engine |
| 20XX-0001 | religion | 9041ff4d8376 | general knowledge | — | engine |
| 20XX-0004 | region | 1a6df29aa4a1 | general knowledge | — | classification agent |
The foundation's project table (engine 2): exactly 126 columns, in the foundation's order. Many cells stay blank because the reports do not state them. A blank is shown as "—", never as 0.
| project_name | grantee | implementation_country | place | status | target_start_date | grant_agreement_usd | project_manager | … | + 100 KPI columns |
|---|---|---|---|---|---|---|---|---|---|
| f9757e28ec9c | b94303fd3e91 | XAA | bf1531bda25f | 5f6ed82398e8 | 2021-05-03 | 180,000 | — | … | SDGs, buildings, objects, trainees, jobs… |
| cd44fdcd1bad | 3a5d0045306e | XAB | 1c0eff585748 | — | — | — | — | … | mostly blank |
| 3c93697f28c1 | — | XAC | 09735e0536d6 | a90d2b80c7b4 | 2022-09-12 | — | ce3c75c3a8db | … | SDG primary goal set |
The quote behind each cell of the foundation's table. Cells that need a person go to client_review.csv with the reason.
| grant_id | field_key | document_id | page | verbatim_quote | char_start–end | extracted_value | review_status | item_id |
|---|---|---|---|---|---|---|---|---|
| 20XX-0001 | grant_agreement_usd | doc-2c3e37bf | 3 | 9d377cc69a69 | 455–538 | 191749e75e67 | machine_extracted | 20XX-0001#0046 |
| 20XX-0001 | target_start_date | doc-2c3e37bf | 1 | 98e8dbe30217 | 64–109 | 372c52c06caa | machine_extracted | — |
| 20XX-0003 | place | doc-3d3b0e4c | 5 | 6f12d1e50dd3 | 52–118 | 9da656507d90 | needs_review | — |
2How it works
Results on the real reports
First full measurement, 20–21 October 2026. A quality agent re-read 337 items and 131 passages across 14 of the 87 projects extracted at the time. The judge is the same model as the extractor, so this is a second reading, not an independent referee.
Estimates against targets
Dot = estimate · bar = 95% interval · dashed line = target
The third row is a tested variant: it changes the three code rules that add buckets after the model. It is stored as a separate data set until the group decides. The optimistic count is shown; the pessimistic count is 65%.
Client table: cells filled by column group
101 projects · 21 Oct
2,220 of 12,726 cells filled (17%), 164 flagged for review, 0 failed calls. The SDG group is almost complete. Most heritage, training and jobs KPIs are never stated in the reports.
Field tree: fewer columns, information kept
125 columns · 78 projects
| Level | Columns | Information kept |
|---|
Columns are joined by meaning using two readings of the foundation's model, on names and definitions only. 47 columns have no value in any project yet.
What works
- Reading: 150 documents read, none failed; only 10 needed OCR.
- Faithfulness: understandings say what their quotes say; none gets the main point wrong.
- First-pass filing: the quality agent would remove only 0.9% of the buckets the first extraction pass assigns.
- Reliability: a batch of 10 projects ran 1,101 calls with 0 failures, despite 414 rate-limit answers from Azure.
What does not, yet
- Recall: 1.20 missed points per 1,000 characters; 17% of items leave out a fact their own quote states.
- Buckets: only 70% of items have every bucket right. Most wrong buckets come from code rules, not the model.
- Lost quotes: in 2–3 PDFs, many quotes cannot be found word for word in the text layer as read, so their points are dropped.
- Pace: about 12 minutes per project. Azure's rate limit sets the speed, not the code.
2How it works
The presentation
The final presentation is a four-minute animation in three chapters: the global network of projects, then reports turned into analytics and Power BI, then the network in reverse. It is not published here because it shows the client’s name; three stills from chapter 2 follow.
3Inside the engine
The details that make it hold
For readers who want to check the reasoning: the themes, what went wrong in quality and why, the data protection, and the decisions the group took.
The 36 buckets (version 2, approved 19 October)
An item goes into every bucket that fits; buckets overlap by design. The grouping into themes below is for reading only, the engine treats all 36 equally. Outlined chips carry a rule applied by code. Hover a chip for its definition.
Why quality is lost, and the fix for each cause
| Problem | Main cause found | Evidence | Fix |
|---|---|---|---|
| Wrong buckets | Code rules that add buckets after the model (location, sdg_evidence), then the votes | Rules add 7% of buckets but cause 44% of the removals; the first pass alone, 0.9% | Align the rules with the bucket definitions (group decision). The tested variant raises right buckets from 70% to 77% |
| Missing facts | Items that pack several quotes or facts into one short summary | 12% miss a fact with 1 quote, 25–30% with 2 or more; 37% when the summary is under 0.6× the quote's length | "One fact per item" in the prompts (quality plan Q2, not built yet) |
| Missed points | One item taken from a passage holding several facts; much worse on OCR'd text | 2.37 missed per 1,000 characters when one item quotes the passage, 0.73 with 4 or more; OCR'd pages 5.25 against 0.87 | Same as above, plus a check of OCR quality |
| Lost quotes | The PDF text layer of a few documents | 36–57 lost quotes per 100 PDF pages against 0.37 per 100 Word paragraphs; 68% of all lost quotes in 2 projects | A person inspects those PDFs; re-read and re-extract |
Ruled out by the data: merging does not cause the missed points, the repair loops do not cause the missing facts (0 of 12 repaired items), and PDF as a format is not the cause (per character, text PDF pages and Word paragraphs miss about the same).
Client table: why cells stay empty
Run of 21 Oct · 78 projects · every empty cell counted once
Show as a table
| Column group | Cells | Filled | Nothing found | Not read | Left out |
|---|
Nothing found: the evidence was read, but the model found no value. Not read: no item sat in the group's buckets. Left out: a value was found but a rule held it back (unclear or planned status, found only in one of the foundation's own analyses, conflicting values, an invalid date or figure).
Data protection, enforced
| Only the foundation's model | The engine refuses any endpoint that is not https://….azure.com; the Claude client was removed from the code. |
| Data outside the code | A data folder inside the repository is refused; all outputs go to CLIENT_DATA_DIR. |
| No content on screen | Scripts print file names, counts, statuses and error types only. |
| Assistant fenced in | Hooks and a sandbox stop the AI coding assistant from reading documents, data folders or .env, and from reaching public AI services. |
| Shareable output | Run summaries hold numbers and Grant IDs only; a test plants names and text and checks none appear. |
| Nothing published | No git, no cloud, Power BI Desktop only, the .pbix stays in the data folder. |
Key decisions by the group
| Project key | The file name decides the project; a file naming several grants belongs to each. |
| Merging | No merge without the model confirming "same point"; the most complete understanding wins. |
| Buckets | Every bucket that fits. Version 2 added 5 buckets after stress tests found unstable boundaries (15 of 39 test sentences filed consistently). |
| Profile | General knowledge is allowed when documents are silent, always labelled. No web search. "Secular" is never inferred from silence. |
| Conflicts | Different values stay in the review table; the model never reconciles or sums them. |
| SDGs | One primary SDG per project: the one the reports make most prominent. |
| Accuracy vs cost | Accuracy first (the agentic engine), with stored extractions so nothing is paid for twice. |
4Reference
Timeline, open items and where to look
Timeline (2026)
- Kickoff with the foundation and Albert School
- The foundation's agent kit installed; Earth / Action globe site built
- Independent audit of the first engine; 23 of 27 adversarial checks failed and drove the fixes
- Data rules enforced; the foundation's Azure model connected; profile, partners, logo agent
- Phase 1: cache, OCR of every image, legacy formats, statuses, parallel projects
- Umbrella and classification agents; dashboard and presentation briefs; globe prototype
- Agentic engine becomes the default; quality improvement plan
- Bucket stress tests, then bucket version 2 (36 buckets)
- Full extraction in batches of 10; engine 2 built
- Quality measured on real reports and diagnosed; field tree; final tables
- Complete animated presentation assembled
Open items
- Buckets: decide on the code-rules variant (location, sdg_evidence, project_results).
- Recall: build "one fact per item"; check OCR; inspect the PDFs that lose quotes.
- Independent check: run
human_audit.py, the only measure not made by the model. - Umbrellas: approve the recommended groups of related grants.
- Engine 2: full field discovery, approval, and wiring approved fields into the sheets.
- Power BI: build the dashboard locally on the final tables.
- Prototypes: connect a globe dashboard to the real CSVs (server-side); update briefs from 31 to 36 buckets.
- Cost: fill
config/pricing.yamlso run summaries show costs.
Tech and size
| Language | Python 3.11+: pydantic, PyYAML, PyMuPDF, pypdf, lxml, numpy, openai SDK (pointed at Azure), openpyxl; Tesseract and LibreOffice |
| Model | The foundation's own GPT deployment on Azure AI Foundry; no embedding deployment |
| Code | 25,300 lines in src/ (60 modules), 14,600 in scripts/ (37), 4,000 in the agents |
| Tests | 70 files, 521 passed and 2 skipped (21 Oct), offline on invented data only |
| Dashboards | Earth / Action (React, Vite, d3-geo) and Field / Archive (Next.js 16, Tailwind), both with Power BI embed slots |
| History | No git (group decision); notes/STATUS_AND_AUDIT_TRAIL.md records about 160 closed items, decisions and incidents |
Where to read more
| Running it | cultural-project-intelligence/README.md, PIPELINE.md |
| Architecture | extractor_explained.md, notes/ENGINE_AND_BUILD.md |
| Status and decisions | notes/STATUS_AND_AUDIT_TRAIL.md |
| Quality | notes/EXTRACTION_QUALITY_FINDINGS.md, quality.html |
| Client table | notes/CONTRACT_PLAN.md, notes/STANDARDISATION_PLAN.md |
| Power BI | notes/POWER_BI_QUICKSTART.md, notes/TABLE_COLUMNS_EXPLAINED.md |
| Run numbers | run_summaries/ |
Glossary
| Grant ID | <year>-<number>, the project key in every table |
| Unit | The smallest piece of read text: a PDF page, a Word paragraph, a table row, the OCR text of an image |
| Chunk | Consecutive units, at most 12,000 characters; one model call each |
| Item | One point of information: understanding + verbatim quote(s) + bucket(s) |
| Bucket | One of 36 themes an item can be filed under |
| Umbrella | A group of related grants (joint report, phases), approved by the group; ID = U + earliest grant |
| Agentic engine | The default since 15 Oct: agents, feedback loops and votes on the foundation's model. The baseline is the engine before that date |
| Partial | A project or document where something did not finish; re-run it, finished work comes from the cache |
| Contract | The foundation's 126-column project table (schema version 1.1.0) |