Add M1: OCR hub import, WITSML, labels T1-T3, T4 questions, trial raters, draft protocol

- OCR: match the colleague's full-set Dataset Hub export to the DDRs by content
  (3,059/3,066 pages) and QC it against the HTML (CER 2.40%, exact 0.9181).
- WITSML parser and formation tops: 21 DDR wellbores with time logs, 1,384
  reports; WITSML 15/9-F-15 S is DDR 15/9-F-15.
- Deterministic labels T1-T3 (configs/labels.yaml), 1,662 T4 questions with SQL,
  pandas and raw-XML answers in full agreement.
- Trial label validation by three blind LLM raters (not an author or expert audit)
  and rater agreement script; draft protocol_v1 (not locked): split by well.
- Literature notes and BibTeX; docs, report and run_m1.sh synchronised.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 08:34:35 +00:00
parent a3c175638f
commit 17916650a5
37 changed files with 11098 additions and 415 deletions

View File

@@ -4,40 +4,38 @@ Volve-DIA: a public benchmark and baselines for drilling-context recognition, NP
Read first: `docs/plan.md` (plan, gates, decisions; §1 data facts, §6 roadmap, §10 forbidden claims, §12 decision log), `README.md` (setup, scripts, logging), `docs/danh-gia-huong-NCKH-2026-10-29.md` (why this direction, competitors, references; local only, not in git), `docs/technical_overview.md` (a lecture for newcomers: drilling, DDR, leakage, tasks, labels, OCR, evaluation, code map). Progress page: `report.html`. These docs are in Vietnamese.
## Status (29/10/2026)
## Status (17/11/2026)
- **P0 (infrastructure) done and committed** (first commit on `main`, 29/10/2026). The project folder is `/home/jovyan/lamlvh/Volve-DIA` (renamed from `Scientific` on 29/10/2026); pushed to remote `origin` `https://gitea.vts-ai.space/lamlvh/Volve-DIA`, which is **public**. `scripts/run_p0.sh` runs scripts 00–05 and the tests in about 3.3 min (run 20261029-105934_p0: all ok, 40 tests pass).
- **Data:** `data/Volve` is a symlink to `ML-Porosity/data/Volve`. The three subtrees read here (`Well_technical_data`, `Reports`, `WITSML Realtime drilling data`, about 20 GB) are hashed in `data_manifest/volve_dia.json`.
- **DDR XML parsed** (`02`): 1,759 reports, 26 wellbores, 23,447 activities (480 `fail`), 17 tables in `outputs/ddr/volve_ddr.duckdb`. The counts are locked in `EXPECTED` and the source checks are in `outputs/ddr/summary.json` (plan §1.2).
- Gaps found while writing the technical overview (plan §1.2, §12 item 9): `diaHole` is NULL in 990 reports, 260 of them with drilling activities (2,618 rows, 24 wellbores); `ropCurrent` is a sentinel everywhere, so ROP comes from `distDrill`, `bits.bitRun_ropAv` (88 values, 80 reports) or WITSML.
- **Three versions of every report:** each DDR exists as XML (the source), publisher HTML and a PDF rendered from the HTML (3,066 pages, born-digital).
- Render QC (`03`, 272,544 items): the HTML prints exactly what the XML holds, except two flags. *Tight well* and *HPHT* are 0 in every XML but "Y" in all 1,759 HTML reports, a publisher render bug. Take them from the XML only.
- **OCR parser:** chandra on the shared vLLM service (`configs/ocr.yaml`). The request and prompt are a byte copy of vopec-chatbot's (prompt hash-checked).
- Pilot done: one report per wellbore, 26 reports, 47 pages, all ok; 6.2 s/page wall with 4 workers.
- OCR QC (`05`) against the HTML: content CER 2.50%, WER 5.57%, exact rate 0.923 over 5,835 items. Operations cells: exact 0.859, CER 3.12%.
- Error types (hallucinated units, autocorrected source typos, merged or split columns, shifted depth values) are in plan §1.3. The parser repairs and QC rules that produced these numbers are in plan §12 item 6.
- **Full OCR not started.** All 1,759 reports (3,066 pages, about 5.3 h) are waiting because the OCR service has returned 503 since the pilot. The platform page says the environment is not running (pod does not exist). The service is shared and its pod is not ours, so ask the user to restart it.
- **P0 (infrastructure) done and committed** (first commit on `main`, 29/10/2026). The project folder is `/home/jovyan/lamlvh/Volve-DIA`; remote `origin` `https://gitea.vts-ai.space/lamlvh/Volve-DIA` is **public**. `scripts/run_p0.sh` runs scripts 00–05 and the tests.
- **M1 machine work done on 17/11/2026, not committed** (git shows many untracked and modified files; commit only when the user asks). `scripts/run_m1.sh` chains the M1 steps but has not been run end to end. Last pytest run by the WITSML agent: 141 passed.
- **Data:** `data/Volve` is now a real directory (no longer a symlink); `/home` has about 75 GB free (98%). The manifest holds 25,571 files (formation tops added), `--check` ok. Third-party material is in `data/third_party/` (untracked).
- **DDR XML:** 1,759 reports, 26 wellbores (11 wells), 23,447 activities; counts locked in `EXPECTED`. Render bugs: *Tight well* and *HPHT* ("Y" in every HTML), and the Bit Record "End mMD" column (prints `bitRun_mdHoleStart`). `03` covers only the header, 31 fields, summaries and Operations.
- **OCR:** a colleague ran the full OCR and exported it through Dataset Hub (credentials only in `.env`, never in committed files or runlog commands). `scripts/04_ocr_hub.py` matches pages to DDRs by content (3,059 of 3,066 pages, 1,752 of 1,759 reports complete; 7 pages unmatched, 16 pages with a date disagreement not yet inspected). QC on the hub pages (`scripts/05_ocr_qc.py --source hub`, 1,752 reports): content CER 2.40%, WER 5.56%, exact 0.9181; depth fields and rig name are the weakest. The shared vLLM service is not used any more; `04_ocr.py` and its page cache stay for the pilot.
- **WITSML** (`06_parse_witsml.py`, written by a subagent; its figures are locked in `EXPECTED` and 30 tests): 21 DDR wellbores have time logs (not 14), 1,384 reports (not 964); WITSML `15/9-F-15 S` is DDR `15/9-F-15` and two more names are shifted by one. Formation tops: 409 picks, 24 DDR wellbores with own picks, 2 with shared picks. Tables in `outputs/witsml/` (2.2 GB, gitignored).
- **Labels T1–T3** (`07_labels.py`, `configs/labels.yaml`): T1 section with forward fill (672 published + 260 filled drilling days), T2 NPT (a) 3,577 rows / (b) 4,286 rows, T3 844 / 979 positive cells (only 50% of NPT rows can be located in depth).
- **T4** (`08_t4_questions.py`, `configs/t4_templates.yaml`): 1,662 questions from 39 templates; SQL, independent pandas and raw-XML answers agree 100%.
- **Protocol:** `configs/protocol_v1.yaml` is a **draft, not locked** (split by well with leave-one-well-out; development wells F-7 and F-9; class evaluability rule: at least 3 wells with at least 5 items; NPT definition a unless audit 1 says otherwise). Locked by SHA-256 at G1, before any model run.
- **Trial audit:** 100 masked items drawn (`09_audit.py sample`, `outputs/audit/trial_100/`) and rated blind by three LLM raters (Sonnet, Opus, Haiku; `RATINGS_llm_*.csv`, `scripts/09_rater_agreement.py` -> `raters.json`). They are **LLM raters, not an author audit**: never describe them as the author's, a human or an expert audit. Median weighted kappa against the code labels: NPT a 0.553, NPT b 0.574, cause a 0.456, operation class 0.434; Fleiss between raters about 0.66. No human rated; there is no human time per row.
- **Literature:** `docs/literature_notes.md`, `docs/references.bib`. No public NPT label set on Volve is independent of the DDR codes; the plan's "three independent label sets" was dropped. PetroAgents full text read (`docs/lit_petroagents.pdf`): well-day unit, 60-example samples, leakage ablation on 30 examples, split by wellbore.
- Nothing is running.
- **Agents:** delegate to Sonnet; to Opus only for very complex work; do not use Fable (user decision 17/11/2026).
## Next
Roadmap and gates: `docs/plan.md` §6. Month 1 (M1) = data, labels, protocol.
Roadmap and gates: `docs/plan.md` §6, §12 item 1.
1. **Full DDR OCR once the service answers:**
`setsid nohup scripts/runlog.sh -n ocr_full -- scripts/04_ocr.py --all > /dev/null 2>&1 &`
While the service is down, the script stops before sending any page ("OCR service not available: HTTP 503", exit 1), so starting it is also the check. It resumes from the page cache, keeps 4 workers, and stops by itself if 8 pages in a row fail. Then run `scripts/runlog.sh scripts/05_ocr_qc.py` on all 1,759 reports and update plan §1.3 and `report.html`.
2. **WITSML parser** (time logs, 68 channels at about 3 s; bhaRun, message, trajectory, mudLog) into DuckDB with the TADI sentinels and filters (plan §4.1). Check whether WITSML `15/9-F-15 S` is DDR `15/9-F-15`, and find the source folder of the formation tops (both [XM], plan §1.1, §4.1).
3. **Code → label mapping** (`configs/labels.yaml`, public): T1 phase from hole size, T2 NPT and cause group from `stateDetailActivity` + `proprietaryCode` + `state`, T3 MD intervals on a 10 m grid. T1 needs a fill rule for the 260 drilling days without `diaHole` (plan §4.3). Check `15_9_19_A_1980_01_01` (a 1980 date; no activities).
4. **T4 question templates** with SQL answers on DuckDB and cited row ids.
5. **Trial blind self-audit** of 100 activity rows (codes masked; estimates label agreement and time per row) and a draft of the evaluation protocol (`configs/protocol_v1.yaml`), which must decide whether GroupKFold groups by wellbore or by well (26 wellbores in 11 wells; sidetracks share the upper hole; plan §4.5 [XM]). Blind audit 1 (about 300 rows, stratified by wellbore and class) follows in M2, and the protocol is locked by SHA-256 at gate G1, **before any model run** (plan §4.4, §6, §12 item 1).
6. Read PetroAgents, Bassey 2026 and EAGE 2026101276 in full; download DrillScribe, the Anatoly5ms repo and the OMAE 2024 stuck-pipe set (plan §12 item 1).
1. M2 label validation is by blind LLM raters (at least 3 model families, 300 rows, second pass), not an author audit: no human rater is available (decision 17/11/2026, plan §12 item 20). Never call it an author, expert or manual audit.
2. C4 reports results with and without the 16 date-disagreement pages; the 7 unmatched reports are dropped.
3. Decided 17/11 (plan §12 item 21): WITSML suspect values (-999, -99999, 99999, 9999, |v| > 1e15) are missing at feature stage; formation picks file is the label source; 7 unmatched OCR reports are dropped from C4; NPT definition a vs b decided at M2 (trial favours b by 0.021, not conclusive).
4. M2: blind LLM-rater validation (about 300 rows, strata zone, cause group, well), cross-checks against DrillScribe and a re-implementation of the Anatoly5ms text rules, then lock `protocol_v1` at G1.
5. Read in full: EAGE 2026101276, SPE-236554-MS, SPE-235330-MS, IPTC-25191-MS.
## Conventions
- **Ground truth:** every label and every T4 answer comes from the XML (and WITSML), by code, with provenance. HTML and PDF are renders: never take a label from them. People only *validate* labels (blind audit, independent label sets, calibrated judge); they never create them.
- **Ground truth:** every label and every T4 answer comes from the XML (and WITSML), by code, with provenance. HTML and PDF are renders: never take a label from them. Labels are only *validated* (blind LLM raters, cross-checks with third-party sets, calibrated judge), never created by raters. No human rater is available, so no result may be called a human, author or expert audit.
- **No leakage:** activity codes (`proprietaryCode`, `stateDetailActivity`, `state`) are masked in model inputs for T2 and T3. T3 uses only features from before the event. Splits are by wellbore (GroupKFold); nothing is chosen on test wellbores. Report results with and without the masked codes.
- **Locked protocols:** the evaluation protocol is locked by SHA-256 before the first model run. Never edit a locked protocol or relax a threshold. New decisions go into a new protocol with a recorded deviation. Report results as they come out, including failures.
- **OCR service:** the URL lives only in the untracked `.env` (`VOLVE_DIA_OCR_URL`; template `.env.example`). Read it only through `volve_dia.ocr.service_url()`. Never put it on a command line (`runlog` records the command in `logs/index.csv`), in a committed file, or in output shown to the user. The service is shared with vopec-chatbot: keep `workers: 4`. The model, prompt hash, dpi, max_tokens and temperature form the page-cache key, so changing one re-reads every page.
- **OCR service and Dataset Hub:** the Hub URL, dataset id and API key live only in the untracked `.env` (`DATASET_HUB_URL`, `DATASET_HUB_API_KEY`, `VOLVE_DIA_OCR_HUB_DATASET`); never put them on a command line, in a committed file or in output shown to the user. The OCR service URL lives only in the untracked `.env` (`VOLVE_DIA_OCR_URL`; template `.env.example`). Read it only through `volve_dia.ocr.service_url()`. Never put it on a command line (`runlog` records the command in `logs/index.csv`), in a committed file, or in output shown to the user. The service is shared with vopec-chatbot: keep `workers: 4`. The model, prompt hash, dpi, max_tokens and temperature form the page-cache key, so changing one re-reads every page.
- **Git:** work on `main`. Do not create branches unless the user explicitly asks. Commit only when the user asks. End commit messages with a co-author line for the agent.
- **Language:** code, figures, paper text and commit messages in academic English. `README.md`, `docs/plan.md`, `docs/technical_overview.md`, `report.html` and explanations to the user in Vietnamese.
- **Decisions:** decide from evidence and proceed.
@@ -49,7 +47,7 @@ Roadmap and gates: `docs/plan.md` §6. Month 1 (M1) = data, labels, protocol.
## Not in git (other machines)
`data/` (the Volve symlink), `outputs/`, `logs/runs/`, `.env`, `docs/*.DOCX`, `docs/*.pdf`, `docs/danh-gia-huong-NCKH-2026-10-29.md` and the `.venv` are gitignored. Check the data with `scripts/00_data_manifest.py --check` and regenerate `outputs/` with `scripts/run_p0.sh`, except the OCR page cache `outputs/ocr/pages/`: it holds hours of GPU time, so copy it rather than reading the pages again.
`data/` (the Volve copy, OCR hub export, third-party repos), `outputs/`, `logs/runs/`, `.env`, `docs/*.DOCX`, `docs/*.pdf`, `docs/danh-gia-huong-NCKH-2026-10-29.md` and the `.venv` are gitignored. Check the data with `scripts/00_data_manifest.py --check` and regenerate `outputs/` with `scripts/run_p0.sh`, except the OCR page cache `outputs/ocr/pages/`: it holds hours of GPU time, so copy it rather than reading the pages again.
## Skills