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.
Evaluated on 2,041 test samples across 10 task categories (field-level exact match, summary excluded):
Training data consists of synthetically generated Korean natural language queries paired with structured JSON outputs, covering the Busan public data analytics domain.
1from transformers import AutoTokenizer, AutoModelForCausalLM
2
3model_id = "dataslab/DLM-NL2JSON-4B"
4tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
5model = AutoModelForCausalLM.from_pretrained(model_id, trust_remote_code=True)
6
7# System prompt (example: CSM consumer spending schema — abbreviated for readability)
8# Full prompts per category are available in the repository's eval/prompts.py
9system_prompt = """너는 반드시 **JSON 한 줄**만 출력한다. 설명/텍스트/코멘트/마크다운/코드블록/이모지/공백 줄 금지.
10출력은 항상 { 로 시작하고 } 로 끝난다.
11
12[스키마: TASK_CSM] (키/타입/순서 엄수)
13{"summary":string,"base_ym":int,"region_nm":string,"industry_select":object,"sex_cd":[int],"age_cd":[int],"category":2}
14
15[기본값]
16- base_ym: 0, region_nm: "부산광역시"
17- industry_select: 업종 미지정 시 전 대분류 키를 []로 설정
18- sex_cd: [0,1], age_cd: [10,20,30,40,50,60,70]
19- category: 항상 2
20
21[대분류 코드표] 1:여행/숙박 2:여가/문화 3:유통 4:음식/주점 5:음식료품
226:의류/잡화 7:미용 8:의료 9:교육 10:생활 11:자동차"""
23
24# Note: special token <TASK_CSM> must be included in the user message
25user_query = "<TASK_CSM>\n2024년 1월 해운대구 중동 의류/잡화랑 뷰티 쪽 남성 20~40대 위주로 알려줘"
26
27messages = [
28 {"role": "system", "content": system_prompt},
29 {"role": "user", "content": user_query}
30]
31
32text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
33inputs = tokenizer(text, return_tensors="pt").to(model.device)
34outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.0, do_sample=False)
35print(tokenizer.decode(outputs[0][inputs.input_ids.shape[-1]:], skip_special_tokens=True))
36# {"summary":"##2024년 1월 부산광역시 해운대구 중동 의류/잡화/미용 소비분석##","base_ym":202401,"region_nm":"부산광역시 해운대구 중동","industry_select":{"6":[],"7":[]},"sex_cd":[0],"age_cd":[20,30,40],"category":2}
37# Note: "뷰티" → mapped to 미용(code 7), "해운대구 중동" → normalized to "부산광역시 해운대구 중동"
1from openai import OpenAI
2
3client = OpenAI(base_url="http://your-server:8006/v1", api_key="token")
4resp = client.chat.completions.create(
5 model="DLM-NL2JSON-4B",
6 messages=[
7 {"role": "system", "content": system_prompt},
8 {"role": "user", "content": "<TASK_CSM>\n2024년 1월 해운대구 중동 의류/잡화랑 뷰티 쪽 남성 20~40대 위주로 알려줘"}
9 ],
10 max_tokens=512,
11 temperature=0.0,
12 extra_body={"chat_template_kwargs": {"enable_thinking": False}} # disable thinking mode
13)
14print(resp.choices[0].message.content)
1@misc{dsl-dlm-nl2json-4b,
2 title={DLM-NL2JSON-4B: A Domain-Specific Language Model for Korean Public Data Schema Extraction},
3 author={Data Science Lab., Ltd.},
4 year={2026},
5 url={https://huggingface.co/dataslab/DLM-NL2JSON-4B}
6}