Instructions to use unidocs/Gemma4-E4B-Instruct-KD-Model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use unidocs/Gemma4-E4B-Instruct-KD-Model with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="unidocs/Gemma4-E4B-Instruct-KD-Model") 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)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("unidocs/Gemma4-E4B-Instruct-KD-Model") model = AutoModelForMultimodalLM.from_pretrained("unidocs/Gemma4-E4B-Instruct-KD-Model", 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=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use unidocs/Gemma4-E4B-Instruct-KD-Model with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "unidocs/Gemma4-E4B-Instruct-KD-Model" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "unidocs/Gemma4-E4B-Instruct-KD-Model", "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/unidocs/Gemma4-E4B-Instruct-KD-Model
- SGLang
How to use unidocs/Gemma4-E4B-Instruct-KD-Model 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 "unidocs/Gemma4-E4B-Instruct-KD-Model" \ --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": "unidocs/Gemma4-E4B-Instruct-KD-Model", "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 "unidocs/Gemma4-E4B-Instruct-KD-Model" \ --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": "unidocs/Gemma4-E4B-Instruct-KD-Model", "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 unidocs/Gemma4-E4B-Instruct-KD-Model with Docker Model Runner:
docker model run hf.co/unidocs/Gemma4-E4B-Instruct-KD-Model
- Gemma4-E4B-Instruct-KD-Model
- Model Description
- Repository Contents / 저장소 구성
- Intended Uses & Limitations
- Training Data
- Training Procedure
- Evaluation Results
- Use with transformers
- Use with adapters / 어댑터 사용법
- Limitations and Bias
- License and Attribution
- Legal Disclaimer
- 법적 책임 면책 조항
- Model Card Contact
- Additional Information
Gemma4-E4B-Instruct-KD-Model
This is a lightweight multimodal model that Unidocs distilled from Gemma 4 31B into E4B, specialized for Korean chart & table document understanding.
유니닥스(주)에서 Gemma 4 31B 모델을 E4B로 경량화(지식증류)하여 한국어 차트·표 문서 이해에 특화시킨 멀티모달 모델임
Model Description
Lightweight VLM (Vision-Language Model) developed by Unidocs as a result of the "Development of Multimodal RAG-based AI Agent in Offline Environments for Administrative Education Innovation" project under the AI Voucher (Advanced GPU Utilization Support Program), released on July 20, 2026.
A model distilled from a Gemma 4 31B teacher into google/gemma-4-E4B-it (student) via knowledge distillation, trained on Korean public/administrative document chart and table data from AI Hub (aihub.or.kr), performing visual question answering, key-information extraction, and structure recognition over chart and table images with Korean text input/output.
유니닥스(주)에서 AI 바우처(첨단 GPU 활용 지원 사업)의 "행정 교육 혁신을 위한 오프라인 환경 내 멀티모달 RAG 기반 AI 에이전트 개발" 과제의 결과로 2026년 7월 20일 공개함
google/gemma-4-E4B-it 모델에 Gemma 4 31B를 teacher로 하는 지식증류를 적용하고, AIHub(aihub.or.kr)의 한국어 공공·행정 문서 차트/표 데이터로 학습하여 차트·표 이미지에 대한 한국어 질의응답, 핵심정보 추출, 구조 인식을 수행하는 경량 VLM(Vision-Language Model) 모델임
Repository Contents / 저장소 구성
This repository contains the base merged model plus three task-specific LoRA adapters. Each evaluation score below is produced by a different configuration — see the Evaluation Results table.
본 저장소는 병합 완료된 기본 모델과 과제별 LoRA 어댑터 3종을 함께 제공합니다. 아래 평가 수치는 각각 서로 다른 구성에서 산출되었습니다.
| Path | Contents | Base |
|---|---|---|
| (repo root) | Merged model for document QA (bf16, 4 shards) | google/gemma-4-E4B-it |
adapters/extract-chart/ |
Key-information extraction adapter | google/gemma-4-E4B-it |
adapters/chart-structure/ |
Chart structure recognition adapter | this repo |
adapters/dpo/ |
Preference-aligned adapter (table structure path) | this repo |
Note:
adapters/extract-chartis trained on the originalgoogle/gemma-4-E4B-it, while the other two are trained on this repository's merged model. Load each adapter on top of its correct base — see "Use with adapters" below.
Intended Uses & Limitations
This model is intended for VQA, key-information extraction, and structure recognition over charts and tables in Korean public/administrative documents, suitable for lightweight offline deployment.
It is specialized for Korean chart/table images, may underperform on other domains or complex reasoning, and outputs may contain errors requiring human verification.
본 모델은 한국어 공공·행정 문서의 차트/표에 대한 질의응답, 핵심정보 추출, 구조 인식 용도이며, 오프라인 경량 배포에 적합함. 한국어
차트·표에 특화되어 타 도메인이나 복잡한 추론에서는 성능이 낮을 수 있고, 오류가 발생할 수 있어 사람의 검증이 필요함.
Training Data
The model was fine-tuned on publicly available Korean chart and table image-text datasets provided by AI Hub.
All training images and labels are sourced from AI Hub open datasets.
과학기술정보통신부, 한국지능정보사회진흥원에서 관리하고 있는 AIHub의 아래의 데이터를 활용함
- 031.차트 이미지-텍스트 쌍 데이터
- 032.표 이미지-텍스트 쌍 데이터
Training Procedure
This is a fine-tuned model of google/gemma-4-E4B-it, distilled from a Gemma 4-31B teacher on AIHub Korean chart and table datasets.
google/gemma-4-E4B-it 모델을 Gemma 4 31B teacher로부터 지식증류하여 AIHub 한국어 차트·표 데이터셋으로 미세조정한 모델임
Evaluation Results
Evaluated on a held-out Korean chart and table evaluation set built from AI Hub 031 (Chart) and 032 (Table) datasets. Evaluation images and source annotations are excluded from all training manifests.
Scoring follows a two-stage protocol: (1) normalized substring match, then (2) semantic equivalence judged by the Gemma 4 31B teacher on items that fail stage 1. Stage 2 is applied because open-ended answers (trends, summaries) are unfairly penalized by substring matching.
평가셋은 학습에 사용된 모든 매니페스트에서 원천 파일·이미지 단위로 분리(held-out)하여 구축하였고, 채점은 정규화 부분일치(1단) → 31B teacher의 의미 동치 판정(2단) 2단계 프로토콜을 따름
| Task | Metric | Score | Evaluation Size | Configuration |
|---|---|---|---|---|
| Document Question Answering | Accuracy | 83.3% | 2,000 | Base model (repo root) |
| Key Information Extraction | Macro F1 | 88.6% | 2,000 | google/gemma-4-E4B-it + adapters/extract-chart |
| Chart Structure Recognition | Accuracy | 88.8% | 250 | This repo + adapters/chart-structure |
| Table Structure Recognition * | Accuracy | 85.2% | 250 | This repo + adapters/dpo + external table detector |
* Table structure recognition is a hybrid system result, not model-only performance. Questions asking for exact row/column counts are routed to an external table detector (MinerU-based), mirroring the deployed system. The vision encoder compresses each image into 280 soft tokens, so counting rows in a large table is not reliably solvable by the model alone. Model-only accuracy on this subset is substantially lower. See Limitations and Bias.
Inference speed: 1.19 s/sample on average (NVIDIA B200, batch size 1, 100 samples, bf16 merged model). Measured conservatively — a time-to-first-token pass and a full generation pass are summed, so the prefill cost is counted twice.
All figures above were re-measured on 2026-07-20 with the exact weights published in this repository.
Use with transformers
Starting with transformers >= 5.5.0 , you can run multimodal inference by leveraging the Auto classes with the generate() function.
This model takes an image and text as input, so use AutoProcessor and AutoModelForImageTextToText instead of the text-generation pipeline.
Make sure to update your transformers installation via pip install --upgrade transformers.
from transformers import AutoProcessor, AutoModelForImageTextToText
from PIL import Image
import torch
model_id = "unidocs/Gemma4-E4B-Instruct-KD-Model"
processor = AutoProcessor.from_pretrained(model_id)
model = AutoModelForImageTextToText.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
)
image = Image.open("chart.jpg")
messages = [
{
"role": "user",
"content": [
{"type": "image", "image": image},
{"type": "text", "text": "이 차트에서 가장 값이 큰 항목은 무엇인가요?"},
],
},
]
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, use_cache=True)
generated = outputs[0][inputs["input_ids"].shape[-1]:]
print(processor.decode(generated, skip_special_tokens=True))
Note: Set use_cache=True when generating. For serving, you can use vLLM:
vllm serve unidocs/Gemma4-E4B-Instruct-KD-Model \
--max-model-len 8192 \
--limit-mm-per-prompt image=1
Use with adapters / 어댑터 사용법
Install peft (pip install peft), then load the adapter on top of its correct base model.
Key-information extraction — base is the original google/gemma-4-E4B-it:
from transformers import AutoProcessor, AutoModelForImageTextToText
from peft import PeftModel
import torch
base = AutoModelForImageTextToText.from_pretrained(
"google/gemma-4-E4B-it", torch_dtype=torch.bfloat16, device_map="auto")
model = PeftModel.from_pretrained(
base, "unidocs/Gemma4-E4B-Instruct-KD-Model", subfolder="adapters/extract-chart")
processor = AutoProcessor.from_pretrained("unidocs/Gemma4-E4B-Instruct-KD-Model")
Chart structure recognition — base is this repository:
base = AutoModelForImageTextToText.from_pretrained(
"unidocs/Gemma4-E4B-Instruct-KD-Model", torch_dtype=torch.bfloat16, device_map="auto")
model = PeftModel.from_pretrained(
base, "unidocs/Gemma4-E4B-Instruct-KD-Model", subfolder="adapters/chart-structure")
Replace the subfolder with adapters/dpo for the preference-aligned variant used in the
table structure path. Note that reproducing the reported 85.2% additionally requires the
external table detector described above.
Limitations and Bias
This model may produce biased or inaccurate results. It should not be solely relied upon for critical decisions based on extracted document values.
The model's knowledge is limited to its training data and cut-off date.
It may exhibit biases present in the training data, which is centered on Korean public and administrative documents.
The model may occasionally produce incorrect or inconsistent information.
Exact row/column counting on tables is limited by the vision encoder's soft-token compression, and an external table detector is recommended for such cases. The reported table structure score reflects that hybrid configuration.
Open-ended answers (trends, summaries) score poorly under substring matching; the reported figures use a two-stage protocol with semantic judging.
Knowledge distillation cannot transfer capabilities that are absent from the teacher model itself.
모델의 지식은 훈련 데이터와 마감일로 제한됩니다.
훈련 데이터가 한국어 공공·행정 문서 중심이므로 해당 도메인의 편향이 있을 수 있습니다.
모델은 가끔 잘못되거나 일관되지 않은 정보를 생성할 수 있습니다.
표의 정확한 행·열 카운팅은 비전 인코더의 소프트토큰 압축 한계로 제한적이며, 이 경우 외부 표 검출기 활용을 권장합니다. 보고된 표 구조 인식 수치는 이 하이브리드 구성 기준입니다.
개방형 답변(추세·요약)은 부분일치 채점에서 낮게 측정되며, 보고 수치는 의미 판정을 포함한 2단 채점 기준입니다.
teacher 모델 자체가 갖지 못한 능력은 증류를 통해 전달되지 않습니다.
이 모델은 편향되거나 부정확한 결과를 생성할 수 있습니다. 문서에서 추출한 값을 중요한 의사결정에 이 모델에만 의존해서는 안 됩니다.
License and Attribution
This model is a derivative work of google/gemma-4-E4B-it (Apache-2.0, © Google DeepMind),
modified by Unidocs Inc. through knowledge distillation from a Gemma 4 31B teacher and
fine-tuning on AI Hub Korean chart/table datasets. The original Apache-2.0 notices of the
base model are retained and acknowledged. This derivative is released under CC BY-NC-SA 4.0.
본 모델은 google/gemma-4-E4B-it(Apache-2.0, © Google DeepMind)의 파생물로, 유니닥스(주)가
Gemma 4 31B teacher로부터의 지식증류 및 AI Hub 한국어 차트·표 데이터셋 미세조정을 통해 변경한
것입니다. 원 베이스 모델의 Apache-2.0 고지를 유지·명시하며, 본 파생물은 CC BY-NC-SA 4.0으로
배포됩니다.
Legal Disclaimer
The model developers and distributors bear no legal responsibility for any consequences arising from the use of this model.
This includes any direct, indirect, incidental, special, punitive, or consequential damages resulting from the model's output.
By using this model, users assume all risks that may arise, and the responsibility for verifying and appropriately using the model's output lies solely with the user.
This model is intended to assist document understanding and information extraction. It should not be used as the sole basis for legal, financial, governmental, or other high-impact decisions without human verification.
This disclaimer applies to the maximum extent permitted by applicable law.
법적 책임 면책 조항
본 모델의 사용으로 인해 발생하는 모든 결과에 대해 모델 개발자 및 배포자는 어떠한 법적 책임도 지지 않습니다.
이는 모델의 출력으로 인한 직접적, 간접적, 우발적, 특수한, 징벌적 또는 결과적 손해를 포함합니다.
사용자는 본 모델을 사용함으로써 발생할 수 있는 모든 위험을 감수하며, 모델의 출력에 대한 검증 및 적절한 사용에 대한 책임은 전적으로 사용자에게 있습니다.
본 모델은 문서 이해 및 정보 추출을 지원하기 위한 용도로 설계되었습니다. 법률·금융·행정 등 중요한 의사결정에는 반드시 사람의 검증을 거쳐야 합니다.
이 면책 조항은 관련 법률이 허용하는 최대 범위 내에서 적용됩니다.
Model Card Contact
유석 (tobewiseys@unidocs.co.kr), 나영민 (ym@unidocs.co.kr), 김환석 (kcss4499@unidocs.co.kr)
Additional Information
For more details about the base model, please refer to the original Gemma4 documentation.
- Downloads last month
- 42