Skip to main content

Overview

This example demonstrates how to extract structured data from unstructured documents using AXON’s probe operation, epistemic types, and validation. It shows how to handle missing fields, ensure data quality, and maintain confidence scores.

Use Case

Extract structured information from:
  • Resumes and CVs
  • Invoices and receipts
  • Product descriptions
  • News articles
  • Customer feedback
  • Research papers

Complete Code

data_extraction.axon

Key Components

Persona: DataExtractor

Defines an extraction specialist:
  • Domain: Information extraction, NLP, data processing
  • Tone: Precise (exact, no embellishment)
  • High threshold: 0.80 for accurate extraction

Context: ExtractionMode

Configured for extraction:
  • Stateless: No memory (each extraction independent)
  • Thorough: Careful examination
  • Very low temperature: 0.1 for deterministic extraction

Anchor: NoGuessing

Prevents hallucination:
  • Requires: Evidence from source text
  • Minimum confidence: 0.75
  • Explicit unknowns: “Field not found” instead of guessing
Never let the LLM “fill in” missing fields with plausible guesses. Use the NoGuessing anchor to ensure all extractions cite source text.

Custom Types with Validation

Refinement types with pattern matching:
  • Compile-time guarantee of format
  • Runtime validation
Range-constrained for monetary values.
Structured person data:
  • name: Required factual claim
  • email, phone, location: Optional validated fields
Work experience entry:
  • Company, role, duration: Facts
  • Description: Opinion (subjective characterization)

Flow: ExtractResume

Four-step extraction pipeline: Step 1: ExtractPerson
Uses probe for targeted field extraction. Validation
Ensures:
  • High confidence (≥0.80)
  • Required field (name) present
Step 2: ExtractExperience
Extracts multiple experience entries. Step 3: ExtractSkills
Probes for skills-related fields. Step 4: ExtractEducation
Extracts education as list of facts. Synthesis
Combines all extractions into structured output.

Usage

Run Extraction

Example Input (Resume)

Example Output

Advanced Patterns

Invoice Extraction

Product Data Extraction

Multi-Document Extraction

Incremental Extraction with Memory

Best Practices

1. Use Probe for Targeted Extraction

2. Validate Required Fields

3. Use Optional Types for Missing Data

4. Apply Range Constraints

5. Use Very Low Temperature

6. Require Text Evidence

Contract Analyzer

Legal contract analysis with entity extraction

Sentiment Analysis

Analyze text sentiment with confidence tracking

Multi-Step Reasoning

Complex reasoning with chain-of-thought
  • Flow — Probe and extraction operations
  • Types — Refinement types and validation
  • Anchor — Prevent hallucination
  • Persona — Define extraction specialists