Instructions to use davidleitw/fdem-4b-FP8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use davidleitw/fdem-4b-FP8 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="davidleitw/fdem-4b-FP8") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("davidleitw/fdem-4b-FP8") model = AutoModelForMultimodalLM.from_pretrained("davidleitw/fdem-4b-FP8", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use davidleitw/fdem-4b-FP8 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "davidleitw/fdem-4b-FP8" # 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-FP8", "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-FP8
- SGLang
How to use davidleitw/fdem-4b-FP8 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "davidleitw/fdem-4b-FP8" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "davidleitw/fdem-4b-FP8", "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 images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "davidleitw/fdem-4b-FP8" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "davidleitw/fdem-4b-FP8", "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" } } ] } ] }' - Docker Model Runner
How to use davidleitw/fdem-4b-FP8 with Docker Model Runner:
docker model run hf.co/davidleitw/fdem-4b-FP8
fdem-4b-FP8
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.
An FP8 checkpoint of fdem-4b for vLLM, made with llm-compressor (scheme FP8_DYNAMIC, no calibration data) from the bf16 release weights. On Ada, Hopper and Blackwell GPUs vLLM computes in FP8. On an A100, which has no FP8 math, vLLM keeps the weights in FP8 and computes in 16-bit, which saves memory but not time.
Usage
git clone https://github.com/davidleitw/fdem && cd fdem
pip install . vllm==0.33.0
hf download davidleitw/fdem-4b-FP8 --local-dir fdem-4b-FP8
MODEL_DIR=fdem-4b-FP8 ./examples/serve_vllm.sh # vLLM on :8091, the fdem API on :8000
examples/serve_vllm.sh passes --dtype bfloat16; vLLM reads the FP8 scheme from this repository's config. Requests are the same as for fdem-4b.
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.
| Set | Right | Wrong | Blank | Filled empty fields | Same answer as bf16 |
|---|---|---|---|---|---|
| Held-back, English (2,957 stated / 218 empty) | 2,896 | 32 | 29 | 7 / 218 | 99.4% |
| Held-back, Chinese DRCD (948) | 891 | 38 | 19 | - | 97.2% |
| Held-back, Japanese JaWildText (1,077 / 156) | 1,048 | 25 | 4 | 10 / 156 | 98.6% |
| Real-usage (1,757 / 389) | 1,572 | 123 | 62 | 23 / 389 | 96.8% |
Speed and peak memory, measured on one RTX 5090 with vLLM 0.33.0 on 200 benchmark documents sent as text: a median 0.289 s per document one request at a time (bf16: 0.345 s) and 14.8 documents per second at 32 requests in flight (bf16: 11.4). GPU memory in use peaked at 27.8 GiB, as with bf16, because vLLM takes up to 90% of the card for weights and cache (--gpu-memory-utilization 0.90); the FP8 weights take 6.8 GB, against 9.3 GB in bf16. 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 vLLM's own API, 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
- 8