DLM-NL2JSON-4B
A 4B-parameter service-specific LLM that outperforms GPT-4o (+14%p) and Qwen3.5-35B (+22%p) on structured JSON extraction from Korean natural language queries.
DLM (Domain-specific Language Model) is a series of task-specialized models by Data Science Lab., Ltd.. This model is a LoRA-merged Qwen3-4B fine-tuned for structured JSON extraction in the Busan Metropolitan City public data analytics service.
Key Results
Evaluated on 2,041 test samples across 10 task categories (field-level exact match, summary excluded):
| Model | Params | Accuracy | Accuracy (adj*) | Avg Latency |
|---|---|---|---|---|
| DLM-NL2JSON-4B | 4B | 94.4% | 96.8% | 2.59s |
| GPT-4o | ~200B+ | 80.5% | 82.5% | 1.58s |
| Qwen3.5-35B-A3B | 35B | 72.2% | 73.9% | 0.85s |
*adj: 64 CSM samples with known gold label noise excluded (see Evaluation section)
Per-Category Breakdown
| Category | N | DLM-NL2JSON-4B | GPT-4o | Qwen3.5-35B |
|---|---|---|---|---|
| ALP-A (population pattern) | 250 | 99.6% | 56.0% | 47.6% |
| ALP-B (population flow) | 250 | 98.4% | 50.4% | 46.8% |
| CSM (consumer spending) | 700 | 90.6% | 90.1% | 86.1% |
| CREDIT-Income | 58 | 94.8% | 53.4% | 34.5% |
| CREDIT-Spending | 77 | 97.4% | 92.2% | 51.9% |
| CREDIT-Loan/Default | 73 | 98.6% | 94.5% | 72.6% |
| CPI (business status) | 219 | 86.3% | 87.2% | 54.8% |
| GIS-Inflow | 72 | 97.2% | 79.2% | 93.1% |
| GIS-Outflow | 62 | 98.4% | 77.4% | 98.4% |
| GIS-Consumption | 280 | 98.2% | 99.6% | 97.5% |
DLM-NL2JSON-4B wins 8 out of 10 categories, with the largest gains on ALP (+43%p vs GPT-4o) and CREDIT-Income (+41%p).
Important: This is a Service-Specific Model
This model is NOT a general-purpose NL-to-JSON converter. It is trained exclusively for a fixed set of predefined schemas used in a specific production service. It will not generalize to arbitrary JSON schemas or different prompt formats.
To use this model correctly, you must:
- Use the exact system prompts it was trained on (one per task category โ see Usage section)
- Include the corresponding special token (
<TASK_CSM>,<TASK_CREDIT>,<TASK_GIS>,<TASK_ALP>,<TASK_CPI>) in the input - Expect output conforming only to the predefined schemas listed below
Why publish a service-specific model? This model serves as a reference implementation demonstrating that task-specific LoRA fine-tuning on a 4B model can dramatically outperform GPT-4o and larger open-source models on constrained structured output tasks. We believe the DLM (Domain-specific Language Model) approach โ training small, cheap-to-serve models for specific service endpoints โ is an underexplored but highly practical paradigm.
Intended Use
This model converts Korean natural language queries about public/economic data into structured JSON conforming to its predefined schemas. It is designed for and deployed in the Busan Metropolitan City Big Data Wave analytics dashboard.
Input: Free-form Korean query + task-specific system prompt
Output: Single-line JSON with exact schema compliance:
{"summary":"##2025๋
5์ ๋ถ์ฐ๊ด์ญ์ ํด์ด๋๊ตฌ ์ ํต/์๋ฃ ์๋น๋ถ์##","base_ym":202505,"region_nm":"๋ถ์ฐ๊ด์ญ์ ํด์ด๋๊ตฌ","industry_select":{"3":[],"8":[]},"sex_cd":[1],"age_cd":[30],"category":2}
Task Categories
| ID | Name | Schema Type |
|---|---|---|
| 0 | ALP-A | Population pattern (ptrn: residence/work/visit) |
| 1 | ALP-B | Population flow (flow_cd: inflow/outflow) |
| 2 | CSM | Consumer spending by industry |
| 3 | CREDIT-Income | Income statistics |
| 4 | CREDIT-Spending | Spending statistics |
| 5 | CREDIT-Loan | Loan/default statistics |
| 6 | CPI | Business/enterprise status |
| 9 | GIS-Inflow | Geographic inflow analysis |
| 10 | GIS-Outflow | Geographic outflow analysis |
| 11 | GIS-Consumption | Geographic consumption analysis |
Training Details
| Item | Value |
|---|---|
| Base model | Qwen/Qwen3-4B |
| Method | LoRA SFT โ merged full model |
| Training samples | 16,292 (Korean) |
| Validation samples | 2,034 |
| Special tokens | <TASK_CSM>, <TASK_CREDIT>, <TASK_GIS>, <TASK_ALP>, <TASK_CPI> |
| Max sequence length | 6,144 |
| Architecture | Qwen3ForCausalLM (36 layers, 2560 hidden, 32 heads) |
Training data consists of synthetically generated Korean natural language queries paired with structured JSON outputs, covering the Busan public data analytics domain.
Evaluation Methodology
- Metric: Field-level exact match โ each JSON key's value is compared against the gold label. The
summaryfield is excluded from comparison. - Test set: 2,041 samples, stratified by category
- Gold label noise: 64/700 CSM samples have
age_cdcapped at[10..60]instead of[10..70]for "all ages" queries, conflicting with the prompt specification. These affect all models equally and are excluded in the adjusted metric. - Train/Test overlap: 16/2,041 input strings (0.78%) appear in both sets โ retained for consistency.
- All models received identical system prompts per category.
Hardware
| Model | Serving | GPU |
|---|---|---|
| DLM-NL2JSON-4B | TensorRT-LLM | NVIDIA L4 24GB |
| GPT-4o | OpenAI API | N/A |
| Qwen3.5-35B-A3B | vLLM | NVIDIA A6000 48GB |
Usage
from transformers import AutoTokenizer, AutoModelForCausalLM
model_id = "dataslab/DLM-NL2JSON-4B"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_id, trust_remote_code=True)
# System prompt (example: CSM consumer spending schema โ abbreviated for readability)
# Full prompts per category are available in the repository's eval/prompts.py
system_prompt = """๋๋ ๋ฐ๋์ **JSON ํ ์ค**๋ง ์ถ๋ ฅํ๋ค. ์ค๋ช
/ํ
์คํธ/์ฝ๋ฉํธ/๋งํฌ๋ค์ด/์ฝ๋๋ธ๋ก/์ด๋ชจ์ง/๊ณต๋ฐฑ ์ค ๊ธ์ง.
์ถ๋ ฅ์ ํญ์ { ๋ก ์์ํ๊ณ } ๋ก ๋๋๋ค.
[์คํค๋ง: TASK_CSM] (ํค/ํ์
/์์ ์์)
{"summary":string,"base_ym":int,"region_nm":string,"industry_select":object,"sex_cd":[int],"age_cd":[int],"category":2}
[๊ธฐ๋ณธ๊ฐ]
- base_ym: 0, region_nm: "๋ถ์ฐ๊ด์ญ์"
- industry_select: ์
์ข
๋ฏธ์ง์ ์ ์ ๋๋ถ๋ฅ ํค๋ฅผ []๋ก ์ค์
- sex_cd: [0,1], age_cd: [10,20,30,40,50,60,70]
- category: ํญ์ 2
[๋๋ถ๋ฅ ์ฝ๋ํ] 1:์ฌํ/์๋ฐ 2:์ฌ๊ฐ/๋ฌธํ 3:์ ํต 4:์์/์ฃผ์ 5:์์๋ฃํ
6:์๋ฅ/์กํ 7:๋ฏธ์ฉ 8:์๋ฃ 9:๊ต์ก 10:์ํ 11:์๋์ฐจ"""
# Note: special token <TASK_CSM> must be included in the user message
user_query = "<TASK_CSM>\n2024๋
1์ ํด์ด๋๊ตฌ ์ค๋ ์๋ฅ/์กํ๋ ๋ทฐํฐ ์ชฝ ๋จ์ฑ 20~40๋ ์์ฃผ๋ก ์๋ ค์ค"
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_query}
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.0, do_sample=False)
print(tokenizer.decode(outputs[0][inputs.input_ids.shape[-1]:], skip_special_tokens=True))
# {"summary":"##2024๋
1์ ๋ถ์ฐ๊ด์ญ์ ํด์ด๋๊ตฌ ์ค๋ ์๋ฅ/์กํ/๋ฏธ์ฉ ์๋น๋ถ์##","base_ym":202401,"region_nm":"๋ถ์ฐ๊ด์ญ์ ํด์ด๋๊ตฌ ์ค๋","industry_select":{"6":[],"7":[]},"sex_cd":[0],"age_cd":[20,30,40],"category":2}
# Note: "๋ทฐํฐ" โ mapped to ๋ฏธ์ฉ(code 7), "ํด์ด๋๊ตฌ ์ค๋" โ normalized to "๋ถ์ฐ๊ด์ญ์ ํด์ด๋๊ตฌ ์ค๋"
vLLM / OpenAI-compatible serving
from openai import OpenAI
client = OpenAI(base_url="http://your-server:8006/v1", api_key="token")
resp = client.chat.completions.create(
model="DLM-NL2JSON-4B",
messages=[
{"role": "system", "content": system_prompt},
{"role": "user", "content": "<TASK_CSM>\n2024๋
1์ ํด์ด๋๊ตฌ ์ค๋ ์๋ฅ/์กํ๋ ๋ทฐํฐ ์ชฝ ๋จ์ฑ 20~40๋ ์์ฃผ๋ก ์๋ ค์ค"}
],
max_tokens=512,
temperature=0.0,
extra_body={"chat_template_kwargs": {"enable_thinking": False}} # disable thinking mode
)
print(resp.choices[0].message.content)
Important: When serving with vLLM/TensorRT-LLM, pass
chat_template_kwargs: {"enable_thinking": false}to disable the Qwen3 thinking mode. Otherwise, reasoning tokens will consume the output budget and truncate the JSON.
Known Limitations
- CPI category (86.3%) is the weakest โ complex industry classification codes (A~U with sub-codes) are harder to extract.
- CSM training data noise: ~8% of CSM training samples have
age_cdcapped at 60 instead of 70 for "all ages" queries, introducing inconsistency. - Domain-specific only: This model is trained exclusively for the Busan public data schema extraction task. It has no general-purpose capabilities and should not be used as a general chatbot.
- Korean only: All training data and prompts are in Korean.
Citation
If you use this model, please cite:
@misc{dsl-dlm-nl2json-4b,
title={DLM-NL2JSON-4B: A Domain-Specific Language Model for Korean Public Data Schema Extraction},
author={Data Science Lab., Ltd.},
year={2026},
url={https://huggingface.co/dataslab/DLM-NL2JSON-4B}
}
Contact
- Organization: Data Science Lab., Ltd.
- Project: Busan Metropolitan City Big Data Wave
- Downloads last month
- 22
Model tree for dataslab/DLM-NL2JSON-4B
Collection including dataslab/DLM-NL2JSON-4B
Evaluation results
- Exact Match Accuracy (raw) on Busan Public Data Query Test Setself-reported94.400
- Exact Match Accuracy (adjusted) on Busan Public Data Query Test Setself-reported96.800