fdem-9b

fdem fills a list of fields from one document: text, a page image or one PDF page. It returns one typed value per field. The model is trained to return null for a field the document does not state, and the response gives the reason. Use it through the fdem Python package, which builds the prompt the model was trained on and checks and converts its answers.

Video: 43-second introduction, on the GitHub page.

fdem-9b is a fine-tune of Qwen/Qwen3.5-9B, merged into bf16 weights (19.3 GB). It reads text and page images. Its prompt version is general-v7-en (document, then fields); fdem.json in this repository names it, and the fdem package reads it.

Other formats: fdem-9b-FP8 (vLLM), fdem-9b-GGUF (llama.cpp, Ollama, LM Studio), fdem-9b-MLX-4bit (Apple Silicon). Each has its own measured scores. The other size: fdem-4b.

Usage

The package is on PyPI as fdem-extract (pip install fdem-extract; you still import fdem). The steps below also use the serving script in the repository, so clone it and install from there. With vLLM 0.33.0 on Linux and an NVIDIA GPU:

git clone https://github.com/davidleitw/fdem && cd fdem
pip install . vllm==0.33.0
hf download davidleitw/fdem-9b --local-dir fdem-9b
MODEL_DIR=fdem-9b ./examples/serve_vllm.sh        # vLLM on :8091, the fdem API on :8000
# in a second terminal, once serve_vllm.sh prints a line starting with ready:
curl -s localhost:8000/v1/extract -H 'Content-Type: application/json' -d '{
  "state": "Invoice INV-1042 from Acme Trading Ltd.\nInvoice date: 2026-04-17\nTotal due: NT$3,480",
  "fields": {"invoice_number": {"type": "text"}, "invoice_date": {"type": "date"},
             "total_due": {"type": "number"}, "due_date": {"type": "date"}}
}'
# "answers": {"invoice_number": "INV-1042", "invoice_date": "2026-04-17", "total_due": 3480, "due_date": null},
# "null_reasons": {"due_date": "not_stated"}, plus spans, confidence and checks

From Python:

from pathlib import Path
from fdem import Extractor

extractor = Extractor.vllm("fdem-9b")                 # or Extractor.transformers("fdem-9b") without vLLM
result = extractor.extract(fields={"total": {"type": "number"}, "date": {"type": "date"}},
                           image=Path("receipt.jpg").read_bytes())
print(result["answers"], result["null_reasons"])

API reference: docs/api.md. Recipes: docs/cookbook.md.

Scores

On the fdem benchmark. Right, Wrong and Blank count the fields the document states; "Filled empty fields" counts fields the document leaves empty that the model filled anyway. Filled answers on stated fields that matched neither the expected answer nor a listed alternative were judged by reviewers who did not see which model wrote them.

Set Right Wrong Blank Filled empty fields Documents fully right
Held-back, English (343 documents) 2,900 19 38 8 / 218 302 / 343
Held-back, Chinese DRCD (270 passages) 915 23 10 - 240 / 270
Held-back, Japanese JaWildText (320 receipts) 1,026 49 2 6 / 156 267 / 320
Real-usage (198 documents) 1,604 114 39 21 / 389 102 / 198

On the English held-back documents, fdem-9b makes the fewest wrong answers plus fills of empty fields among the 9B-class or smaller open models that were tested: 0.85 per 100 fields, against 1.54 for NuExtract3 and 1.67 for the untrained Qwen3.5-9B. On the real-usage set it makes 6.29 wrong answers plus fills of empty fields per 100 fields, against 7.78 for the untrained Qwen3.5-9B, and fills 21 of 389 empty fields, against 67.

All tables, every compared model and how each was run: docs/results.md. Speed, with hardware and runtime: on one RTX 5090 with vLLM 0.33.0, on 200 benchmark documents sent as text, each with its own field list, a median 0.557 s per document one request at a time and 5.6 documents per second at 32 requests in flight; how this was measured, and the other formats: docs/results.md.

Intended use

Pulling typed fields (names, numbers, dates, times, durations, lists and tables) out of invoices, receipts, forms, contracts, statements, filings, notices and web pages, where an empty answer is better than a guessed one. Check the answers that matter: spans, null_reasons and confidence in each response point to the ones worth a second look.

Out of scope: decisions about people made without human review (credit, hiring, benefits), identifying people in documents, and multi-page reasoning across a whole PDF.

Limitations

  • One page per request. Up to 20 fields, 200,000 characters of text and 16,384 tokens per request. Field names must be English.
  • Measured on English, Chinese (mostly Traditional) and Japanese (receipts as text). Other languages are untested.
  • confidence comes from token probabilities; use it to sort answers for review, not as the chance of being right.
  • Scores hold only with fdem building the prompt. Calling the weights with your own prompt, directly or through Ollama or llama.cpp, is not measured.

Licence

The weights are released under Apache-2.0, the licence of the base model Qwen3.5-9B (also Apache-2.0). The training data and training code are not part of this release. The benchmark documents keep their sources' licences, listed in the benchmark README.

Citation

@software{lei2026fdem,
  author  = {Lei, David},
  title   = {{FDEM}: Field-level Data Extraction Model},
  version = {0.1.0},
  year    = {2026},
  url     = {https://github.com/davidleitw/fdem}
}
Downloads last month
40
Safetensors
Model size
10B params
Tensor type
BF16
·
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for davidleitw/fdem-9b

Finetuned
Qwen/Qwen3.5-9B
Finetuned
(1,624)
this model
Quantizations
4 models

Collection including davidleitw/fdem-9b