Instructions to use davidleitw/fdem-4b-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use davidleitw/fdem-4b-GGUF with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf davidleitw/fdem-4b-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf davidleitw/fdem-4b-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf davidleitw/fdem-4b-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf davidleitw/fdem-4b-GGUF:Q4_K_M
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf davidleitw/fdem-4b-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama cli -hf davidleitw/fdem-4b-GGUF:Q4_K_M
Use Docker
docker model run hf.co/davidleitw/fdem-4b-GGUF:Q4_K_M
- Llama new
- LM Studio
- Jan
- vLLM
How to use davidleitw/fdem-4b-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "davidleitw/fdem-4b-GGUF" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "davidleitw/fdem-4b-GGUF", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/davidleitw/fdem-4b-GGUF:Q4_K_M
- Ollama
How to use davidleitw/fdem-4b-GGUF with Ollama:
ollama run hf.co/davidleitw/fdem-4b-GGUF:Q4_K_M
- Unsloth Desktop
- Pi
How to use davidleitw/fdem-4b-GGUF with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf davidleitw/fdem-4b-GGUF:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:9931/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "davidleitw/fdem-4b-GGUF:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use davidleitw/fdem-4b-GGUF with Docker Model Runner:
docker model run hf.co/davidleitw/fdem-4b-GGUF:Q4_K_M
- Lemonade
How to use davidleitw/fdem-4b-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull davidleitw/fdem-4b-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.fdem-4b-GGUF-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use davidleitw/fdem-4b-GGUF with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf davidleitw/fdem-4b-GGUF:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:9931/v1 hermes config set model.default davidleitw/fdem-4b-GGUF:Q4_K_M
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use davidleitw/fdem-4b-GGUF with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf davidleitw/fdem-4b-GGUF:Q4_K_M
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:9931/v1 \ --custom-model-id "davidleitw/fdem-4b-GGUF:Q4_K_M" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
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.
confidencecomes 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
4-bit
8-bit