← All posts

From PDFs in S3 to searchable data: an ingestion pipeline that reruns safely

Retrieval quality is capped by ingestion quality. If entities come out of your documents wrong, no amount of prompt tuning fixes the answers downstream.

The shape of the pipeline

  1. Land raw files in S3, partitioned by date. Never overwrite them.
  2. Extract text, tables and forms with Amazon Textract.
  3. Enrich with LLM entity extraction — few-shot examples plus a ReAct or chain-of-thought prompt per entity type.
  4. Index into OpenSearch for hybrid (keyword + vector) retrieval.

Each step is its own Airflow task, so a failure retries one step, not the whole run.

Three rules that keep it safe to rerun

  • Raw is immutable. Every later step can be rebuilt from the landed files.
  • Writes are idempotent. Key every record by document id + version, and upsert. Rerunning a day must never duplicate rows.
  • Fail closed. If validation fails — empty extraction, schema drift, a sudden drop in entity counts — do not publish the new index.

Measuring it

Track context precision and recall on a small labelled set every run. Ours stayed above 80%; when it dipped, the cause was almost always an upstream document format change, not the model.

Treat extraction quality as a data contract, not a model detail.

Keep reading

Subagents, hooks and skills: the three levers of a Claude Code harness

How I split work across subagents, enforce behaviour with hooks, and package know-how as skills — the setup behind agents that automate 50,000+ hours a year.

The 10 metrics I track before an LLM feature ships

Faithfulness, relevance, correctness and friends — a practical evaluation loop that improved response quality by 38%.