
Scaling the gold standard from 72 to 300+ claims
LLM pre-annotation (Gemma 4) + human review (Shiny)
Hugo Rodrigues
Source:vignettes/llm-annotation-workflow.Rmd
llm-annotation-workflow.RmdWhy scale the gold standard
The extraction benchmark (vignette("llm-kg-benchmark"))
runs on 30 synthetic abstracts × 72 claims – enough to validate the
infrastructure, not enough for a paper. With 300 claims annotated on
real abstracts from OpenAlex / SciELO:
- The 95% Wilson confidence interval on F1 narrows from
[0.69, 0.88]to[0.75, 0.84]– narrow enough to declare differences between backends. - With subgroups by topic (management, climate, texture, …) each cell holds at least 30 claims, the statistical minimum for subgroup analysis.
- Claims in real abstracts expose each LLM’s idiosyncrasies with real pedological jargon (Latin names of grass species, WRB acronyms, etc.).
Annotating 300 claims from scratch would take a pedologist about two days. This tool cuts that to about three hours through pre-annotation plus review.
The three-step workflow
┌────────────────────────┐
│ corpus.jsonl │ (fetched from OpenAlex/SciELO)
│ abstracts only │
└───────────┬────────────┘
│ llm_preannotate()
▼
┌────────────────────────┐
│ draft_gold.jsonl │ (Gemma 4 extractions, status="draft")
└───────────┬────────────┘
│ llm_annotation_launch()
▼
┌────────────────────────┐
│ reviewed.jsonl │ (human accept / edit / reject / add)
└───────────┬────────────┘
│ llm_annotation_export()
▼
┌────────────────────────┐
│ gold_v2_final.jsonl │ (publication-grade, drafts removed)
└────────────────────────┘
Step 1 – Build the corpus
Option A (production): fetch 100-300 real abstracts on Cerrado pedogenesis from OpenAlex:
library(edaphos)
# OpenAlex -- orthogonal queries to cover the domain
queries <- c(
"cerrado AND (pedogenesis OR soil formation)",
"cerrado AND soil organic carbon",
"(cerrado OR savanna) AND (clay OR texture) AND soil",
"cerrado AND (land use change OR deforestation) AND soil"
)
corpus_list <- lapply(queries, function(q) {
causal_corpus_openalex(q, max_results = 50L)
})
corpus <- do.call(rbind, corpus_list)
corpus <- causal_corpus_deduplicate(corpus) # drop DOI duplicates
nrow(corpus) # ~180-200 unique abstracts
# Convert to the schema the pre-annotator expects
corpus_records <- lapply(seq_len(nrow(corpus)), function(i) {
list(
abstract_id = paste0("OA_", sprintf("%04d", i)),
title = corpus$title[i],
abstract_text = corpus$abstract[i],
year = corpus$year[i],
doi = corpus$doi[i]
)
})
# Write JSONL
con <- file("cerrado_corpus_openalex_2026.jsonl", "w")
for (r in corpus_records) writeLines(
jsonlite::toJSON(r, auto_unbox = TRUE), con)
close(con)Option B (demo): use the 30 synthetic abstracts already shipped:
# Produces inst/extdata/cerrado_gold_standard_v1_draft.jsonl
source("data-raw/annotation_tool_demo.R")Step 2 – Pre-annotation with Gemma 4
llm_preannotate() reads the corpus and writes a draft in
which every claim has status = "draft", so the reviewer
knows it came from the LLM and not from a person:
llm_preannotate(
corpus = "cerrado_corpus_openalex_2026.jsonl",
backend = "ollama", # local, free
model = "gemma4:latest",
output_path = "draft_gold_v2.jsonl",
cache_dir = "~/.cache/edaphos_annotation",
verbose = TRUE
)With Ollama running and gemma4:latest pulled, 100
abstracts take about 25 minutes. cache_dir makes the run
resume-safe – if the process dies, re-run it and it skips the cache
hits.
No Ollama? Use the deterministic fallback:
llm_preannotate(corpus, backend = "simulator",
output_path = "draft_gold_v2.jsonl")The simulator does not understand the abstracts – it only samples vocabulary-to-vocabulary pairs – but it produces a draft in a valid schema, useful for testing the review tool.
Step 3 – Human review (Shiny)
This is the three-hour part. Open the reviewer:
llm_annotation_launch(
draft_path = "draft_gold_v2.jsonl",
output_path = "reviewed_gold_v2.jsonl",
keyboard_shortcuts = TRUE
)The app opens in your default browser. The interface has three tabs.
Tab 1 – Review
- Header: abstract ID + title + metadata + the full abstract text in a highlighted box.
-
Claims table: each claim takes one row, with
editable dropdowns for
cause/effect(restricted to the canonical vocabulary), a radio button forpolarity, a slider forconfidence, a text field forrationale, and two buttons: ✓ Accept ✗ Reject. -
Navigation buttons: “+ Add missed claim” (adds a
new row with
status = "added"), “← Previous”, “Accept all →”, “Save & Next →”. - Sidebar: progress counters + a reminder of the shortcuts.
Keyboard shortcuts (fast mode)
| Key | Action |
|---|---|
n |
Save & Next |
p |
Previous |
a |
Accept all visible |
+ |
Add missed claim |
1–9
|
Toggle Accept on claim n |
With shortcuts you can review about 2 abstracts per minute when Gemma
4 got the claims right (just a + n). Complex
claims take about 30 s to edit.
Tab 2 – Stats
- Table per abstract: n_draft · n_accepted · n_edited · n_added · n_rejected.
- Bar plot of canonical-vocabulary coverage across accepted claims – useful to see whether the corpus covers all 22 concepts or has gaps.
Tab 3 – Export
Clicking “Validate & export” runs the logic of
llm_annotation_export():
- Drops every
rejectedclaim. - Drops claims still at
status = "draft"(the reviewer did not touch them – we exclude them conservatively). - Removes the internal
statusfield. - Validates vocabulary + polarity + confidence.
- Writes
reviewed_gold_v2_final.jsonl.
Step 4 – Re-run the benchmark
With the expanded gold standard, point the benchmark runner at the new file:
# Edit data-raw/llm_benchmark_run.R line 22:
# gold_path <- "inst/extdata/cerrado_gold_standard_v2_final.jsonl"
source("data-raw/llm_benchmark_run.R")The P/R/F1/κ figures are then publication-grade.
Annotation good practice
Suggested annotation criteria (for internal consistency within your gold standard):
-
Be conservative with confidence.
0.90+only when the text cites a controlled study or a quantified magnitude;0.70for claims well supported by mechanism but without a number;0.50for suggestive ones. -
Canonical vocabulary first. If the text mentions
“tree cover”, use
vegetation. If it mentions “annual rainfall”, usemean_annual_precipitation. Consistency matters more than literal fidelity. -
Polarity is a sign, not a magnitude. “Reduces SOC”
→
-. “Increases”, “raises”, “accelerates” →+. Conditional claims (“reduces if > 2 AU/ha”) are still-in the gold standard; the confidence may drop. -
One claim per direct mechanism. If the text says
“rainfall → NPP → SOC”, record two claims
(
precip → vegetation,vegetation → soc), not one indirect claim. - Rationale = one line. A fragment of the text that supports the claim. Useful for later audits and for training the next iteration of the prompt.
Further features
Production corpus fetcher
# Needs the network. Free. About 40 s for 6 queries x 60 results.
Sys.setenv(EDAPHOS_CORPUS_MAILTO = "rodrigues.machado.hugo@gmail.com")
source("data-raw/cerrado_corpus_v2_fetch.R")
# -> inst/extdata/cerrado_corpus_openalex_v2.jsonl (~150 abstracts)Live DAG preview
In the app, the DAG tab renders a
DiagrammeR::grViz() of the graph aggregated from every
claim whose status is accepted | edited |
added:
- A min_support slider filters edges by number of occurrences (useful when the corpus is large and you want only edges confirmed by several abstracts).
- Edge colours: green = +, red = −.
- Edge width ∝ mean confidence.
- A label toggle shows the structure without names (useful for paper figures).
Dark mode
A toggle in the sidebar (uses bslib::input_dark_mode()).
It follows the operating system’s preference.
Publishing on Zenodo
The Publish tab packages everything into a Zenodo-ready directory:
# The same, programmatically
edaphos::llm_annotation_to_zenodo(
reviewed_path = "reviewed_gold_v2_final.jsonl",
output_dir = "~/Desktop/zenodo_cerrado_kg",
title = "Cerrado Pedogenesis KG (edaphos, v2, 2026-04)",
authors = data.frame(
family_name = "Rodrigues", given_name = "Hugo",
orcid = "0000-0002-8070-8126",
affiliation = "Your institution"
),
keywords = c("Cerrado", "pedometrics", "soil organic carbon",
"knowledge graph", "causal inference"),
license = "CC-BY-4.0",
zip = TRUE
)Contents of the bundle:
| File | Role |
|---|---|
gold_standard.jsonl |
Clean gold standard (draft/rejected removed) |
kg.ttl |
Graph serialised as RDF 1.1 Turtle (each claim becomes
a reified rdf:Statement with predicates
eda:polarity, eda:confidence,
dct:source) |
metadata.json |
DataCite-compatible; ready for the Zenodo REST API |
README.md |
Description, counts, provenance, citation |
Upload by hand at https://zenodo.org/deposit/new, paste the fields of
metadata.json into the form, publish, and record the minted
DOI in your paper’s CITATION.cff.
Next steps
These are open items, named rather than numbered.
- Full production run: fetcher → Gemma 4 → human annotation → Zenodo deposit with a real DOI. About three hours of a pedologist’s time plus about 40 minutes of machine time.
-
Weighted voting by default: make weighted voting
(Gemma + Claude) the default of
causal_llm_ingest_abstract_voted(), calibrated by the backend-vs-gold κ derived from the benchmark.
References
- Landis, J. R. & Koch, G. G. (1977). “The measurement of observer agreement for categorical data.” Biometrics 33, 159-174.
- Ollama (2026). https://ollama.com
- OpenAlex (2026). https://openalex.org