fdem-4b-GGUF

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.

GGUF files of fdem-4b for llama.cpp, Ollama and LM Studio: Q8_0 and Q4_K_M, with the vision projector in BF16 (needed for page images). Converted from the bf16 release weights with llama.cpp b11146; the chat template is embedded. The Ollama Modelfile (Modelfile.fdem-4b, for Q4_K_M) is in this repository and in examples/ollama/ of the GitHub repository.

File Quantization Size
fdem-4b-Q8_0.gguf Q8_0 4.5 GB
fdem-4b-Q4_K_M.gguf Q4_K_M 2.7 GB
mmproj-fdem-4b-bf16.gguf vision projector, BF16 0.68 GB
Modelfile.fdem-4b Ollama Modelfile for Q4_K_M

Usage

Run fdem in front of the runtime as the client: fdem builds the trained prompt, sends it to the runtime's OpenAI-compatible endpoint, and checks and converts the answer. fdem needs the tokenizer and fdem.json from the bf16 repository (no weights).

git clone https://github.com/davidleitw/fdem && cd fdem && pip install .
hf download davidleitw/fdem-4b --exclude "*.safetensors" --local-dir fdem-4b
hf download davidleitw/fdem-4b-GGUF --local-dir fdem-4b-GGUF

# Pick one runtime. llama-server runs in the foreground; start fdem-serve in a second terminal.

# llama.cpp (use fdem-4b-Q8_0.gguf for the 8-bit file)
llama-server -m fdem-4b-GGUF/fdem-4b-Q4_K_M.gguf --mmproj fdem-4b-GGUF/mmproj-fdem-4b-bf16.gguf -c 16384 --jinja --port 8080
# in a second terminal, once the server is up:
fdem-serve --model fdem-4b --backend chat --server-kind llama-server --server-url http://127.0.0.1:8080/v1

# or Ollama, with the Ollama app or `ollama serve` running
ollama create fdem-4b -f fdem-4b-GGUF/Modelfile.fdem-4b
fdem-serve --model fdem-4b --backend chat --server-kind ollama --server-url http://127.0.0.1:11434/v1 --server-model fdem-4b

# or LM Studio: load the GGUF and the projector, start the local server, then
fdem-serve --model fdem-4b --backend chat --server-kind lm-studio --server-url http://127.0.0.1:1234/v1

Each fdem-serve starts the fdem API on port 8000. In Python: Extractor.chat("fdem-4b", server_url="http://127.0.0.1:8080/v1", server_kind="llama-server").

Requests to port 8000 are the same as for fdem-4b. Confidence needs per-token log-probabilities from the runtime; without them (LM Studio, for one) every confidence is null, and a min_confidence threshold then rejects every filled value. Calling Ollama or llama.cpp directly with your own prompt skips the trained prompt and the answer checks, and its results are not measured. Through llama.cpp or LM Studio, a request with no system message gets a default instruction prompt from the embedded chat template, and that is not the trained fdem prompt either (the Ollama Modelfile adds no such prompt). Page images work through Ollama: in the release smoke test (Ollama 0.40.18, Q4_K_M, 50 held-back rows) it answered all 25 page-image rows, and 43 of the 50 rows got exactly the same answers as from llama-server.

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

Scores

Measured on this variant itself, on the fdem benchmark, with fdem as the client. Do not assume the bf16 scores of fdem-4b. "Same answer as bf16" is the share of fields where this variant's answer equals the bf16 model's.

Q8_0

Set Right Wrong Blank Filled empty fields Same answer as bf16
Held-back, English (2,957 stated / 218 empty) 2,886 36 35 7 / 218 98.7%
Held-back, Chinese DRCD (948) 889 32 27 - 99.1%
Held-back, Japanese JaWildText (1,077 / 156) 1,048 23 6 8 / 156 99.8%
Real-usage (1,757 / 389) 1,572 119 66 20 / 389 98.7%

Q4_K_M

Set Right Wrong Blank Filled empty fields Same answer as bf16
Held-back, English (2,957 stated / 218 empty) 2,899 33 25 10 / 218 97.9%
Held-back, Chinese DRCD (948) 888 41 19 - 91.1%
Held-back, Japanese JaWildText (1,077 / 156) 1,039 33 5 16 / 156 97.1%
Real-usage (1,757 / 389) 1,555 143 59 23 / 389 93.3%

Speed and peak memory, measured on one RTX 5090 with llama-server (8 slots of 16,384 tokens, all layers on the GPU) on 50 benchmark documents sent as text: Q8_0 a median 0.728 s per document one request at a time, 2.0 documents per second at 8 requests in flight and 10.2 GiB of GPU memory at peak; Q4_K_M 0.655 s, 2.0 per second and 8.5 GiB. All tables: 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.
  • A compressed variant can give a different answer from the bf16 model on some fields; the table above says how often.

Licence

The weights are released under Apache-2.0, the licence of the base model Qwen3.5-4B (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
134
GGUF
Model size
4B params
Architecture
qwen35
Hardware compatibility
Log In to add your hardware

4-bit

8-bit

Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for davidleitw/fdem-4b-GGUF

Finetuned
Qwen/Qwen3.5-4B
Quantized
(5)
this model

Collection including davidleitw/fdem-4b-GGUF