Upload folder using huggingface_hub
Browse files
README.md
CHANGED
|
@@ -144,28 +144,37 @@ model_id = "dataslab/DLM-NL2JSON-4B"
|
|
| 144 |
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
| 145 |
model = AutoModelForCausalLM.from_pretrained(model_id, trust_remote_code=True)
|
| 146 |
|
| 147 |
-
# System prompt (example:
|
|
|
|
| 148 |
system_prompt = """λλ λ°λμ **JSON ν μ€**λ§ μΆλ ₯νλ€. μ€λͺ
/ν
μ€νΈ/μ½λ©νΈ/λ§ν¬λ€μ΄/μ½λλΈλ‘/μ΄λͺ¨μ§/곡백 μ€ κΈμ§.
|
|
|
|
| 149 |
|
| 150 |
-
[μ€ν€λ§:
|
| 151 |
-
{"summary":string,"base_ym":int,"region_nm":string,"
|
| 152 |
|
| 153 |
[κΈ°λ³Έκ°]
|
| 154 |
- base_ym: 0, region_nm: "λΆμ°κ΄μμ"
|
| 155 |
-
-
|
| 156 |
- sex_cd: [0,1], age_cd: [10,20,30,40,50,60,70]
|
| 157 |
-
- category:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
|
| 159 |
messages = [
|
| 160 |
{"role": "system", "content": system_prompt},
|
| 161 |
-
{"role": "user", "content":
|
| 162 |
]
|
| 163 |
|
| 164 |
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 165 |
inputs = tokenizer(text, return_tensors="pt").to(model.device)
|
| 166 |
outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.0, do_sample=False)
|
| 167 |
print(tokenizer.decode(outputs[0][inputs.input_ids.shape[-1]:], skip_special_tokens=True))
|
| 168 |
-
# {"summary":"##λΆμ°κ΄μμ ν΄μ΄λꡬ μ
|
|
|
|
| 169 |
```
|
| 170 |
|
| 171 |
### vLLM / OpenAI-compatible serving
|
|
@@ -178,7 +187,7 @@ resp = client.chat.completions.create(
|
|
| 178 |
model="DLM-NL2JSON-4B",
|
| 179 |
messages=[
|
| 180 |
{"role": "system", "content": system_prompt},
|
| 181 |
-
{"role": "user", "content": "
|
| 182 |
],
|
| 183 |
max_tokens=512,
|
| 184 |
temperature=0.0,
|
|
|
|
| 144 |
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
| 145 |
model = AutoModelForCausalLM.from_pretrained(model_id, trust_remote_code=True)
|
| 146 |
|
| 147 |
+
# System prompt (example: CSM consumer spending schema β abbreviated for readability)
|
| 148 |
+
# Full prompts per category are available in the repository's eval/prompts.py
|
| 149 |
system_prompt = """λλ λ°λμ **JSON ν μ€**λ§ μΆλ ₯νλ€. μ€λͺ
/ν
μ€νΈ/μ½λ©νΈ/λ§ν¬λ€μ΄/μ½λλΈλ‘/μ΄λͺ¨μ§/곡백 μ€ κΈμ§.
|
| 150 |
+
μΆλ ₯μ νμ { λ‘ μμνκ³ } λ‘ λλλ€.
|
| 151 |
|
| 152 |
+
[μ€ν€λ§: TASK_CSM] (ν€/νμ
/μμ μμ)
|
| 153 |
+
{"summary":string,"base_ym":int,"region_nm":string,"industry_select":object,"sex_cd":[int],"age_cd":[int],"category":2}
|
| 154 |
|
| 155 |
[κΈ°λ³Έκ°]
|
| 156 |
- base_ym: 0, region_nm: "λΆμ°κ΄μμ"
|
| 157 |
+
- industry_select: μ
μ’
λ―Έμ§μ μ μ λλΆλ₯ ν€λ₯Ό []λ‘ μ€μ
|
| 158 |
- sex_cd: [0,1], age_cd: [10,20,30,40,50,60,70]
|
| 159 |
+
- category: νμ 2
|
| 160 |
+
|
| 161 |
+
[λλΆλ₯ μ½λν] 1:μ¬ν/μλ° 2:μ¬κ°/λ¬Έν 3:μ ν΅ 4:μμ/μ£Όμ 5:μμλ£ν
|
| 162 |
+
6:μλ₯/μ‘ν 7:λ―Έμ© 8:μλ£ 9:κ΅μ‘ 10:μν 11:μλμ°¨"""
|
| 163 |
+
|
| 164 |
+
# Note: special token <TASK_CSM> must be included in the user message
|
| 165 |
+
user_query = "<TASK_CSM> 2024λ
1μ ν΄μ΄λꡬ μ€λ μλ₯/μ‘νλ λ·°ν° μͺ½ λ¨μ± 20~40λ μμ£Όλ‘ μλ €μ€"
|
| 166 |
|
| 167 |
messages = [
|
| 168 |
{"role": "system", "content": system_prompt},
|
| 169 |
+
{"role": "user", "content": user_query}
|
| 170 |
]
|
| 171 |
|
| 172 |
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 173 |
inputs = tokenizer(text, return_tensors="pt").to(model.device)
|
| 174 |
outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.0, do_sample=False)
|
| 175 |
print(tokenizer.decode(outputs[0][inputs.input_ids.shape[-1]:], skip_special_tokens=True))
|
| 176 |
+
# {"summary":"##2024λ
1μ λΆμ°κ΄μμ ν΄μ΄λꡬ μ€λ μλ₯/μ‘ν/λ―Έμ© μλΉλΆμ##","base_ym":202401,"region_nm":"λΆμ°κ΄μμ ν΄μ΄λꡬ μ€λ","industry_select":{"6":[],"7":[]},"sex_cd":[0],"age_cd":[20,30,40],"category":2}
|
| 177 |
+
# Note: "λ·°ν°" β mapped to λ―Έμ©(code 7), "ν΄μ΄λꡬ μ€λ" β normalized to "λΆμ°κ΄μμ ν΄μ΄λꡬ μ€λ"
|
| 178 |
```
|
| 179 |
|
| 180 |
### vLLM / OpenAI-compatible serving
|
|
|
|
| 187 |
model="DLM-NL2JSON-4B",
|
| 188 |
messages=[
|
| 189 |
{"role": "system", "content": system_prompt},
|
| 190 |
+
{"role": "user", "content": "<TASK_CSM> 2024λ
1μ ν΄μ΄λꡬ μ€λ μλ₯/μ‘νλ λ·°ν° μͺ½ λ¨μ± 20~40λ μμ£Όλ‘ μλ €μ€"}
|
| 191 |
],
|
| 192 |
max_tokens=512,
|
| 193 |
temperature=0.0,
|