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)# pip install -U transformers accelerate # 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=256) 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
- 22