hkyoo89 commited on
Commit
4eb9b7f
Β·
verified Β·
1 Parent(s): 5b051ff

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +17 -8
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: CREDIT schema)
 
148
  system_prompt = """λ„ˆλŠ” λ°˜λ“œμ‹œ **JSON ν•œ 쀄**만 좜λ ₯ν•œλ‹€. μ„€λͺ…/ν…μŠ€νŠΈ/μ½”λ©˜νŠΈ/λ§ˆν¬λ‹€μš΄/μ½”λ“œλΈ”λ‘/이λͺ¨μ§€/곡백 쀄 κΈˆμ§€.
 
149
 
150
- [μŠ€ν‚€λ§ˆ: κ°œμΈμ‹ μš© 톡합]
151
- {"summary":string,"base_ym":int,"region_nm":string,"job_cd":[int],"perc_cd":[int],"sex_cd":[int],"age_cd":[int],"category":int}
152
 
153
  [κΈ°λ³Έκ°’]
154
  - base_ym: 0, region_nm: "λΆ€μ‚°κ΄‘μ—­μ‹œ"
155
- - job_cd: [0,1,2], perc_cd: [0,1,2,3,4,5,6,7,8,9]
156
  - sex_cd: [0,1], age_cd: [10,20,30,40,50,60,70]
157
- - category: μ†Œλ“=3, μ†ŒλΉ„=4, λŒ€μΆœ/연체=5"""
 
 
 
 
 
 
158
 
159
  messages = [
160
  {"role": "system", "content": system_prompt},
161
- {"role": "user", "content": "λΆ€μ‚° ν•΄μš΄λŒ€κ΅¬ μ†Œλ“ 남성 30λŒ€ 3λΆ„μœ„"}
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":"##λΆ€μ‚°κ΄‘μ—­μ‹œ ν•΄μš΄λŒ€κ΅¬ μ†Œλ“ν†΅κ³„##","base_ym":0,"region_nm":"λΆ€μ‚°κ΄‘μ—­μ‹œ ν•΄μš΄λŒ€κ΅¬","job_cd":[0,1,2],"perc_cd":[2],"sex_cd":[0],"age_cd":[30],"category":3}
 
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": "λΆ€μ‚° ν•΄μš΄λŒ€κ΅¬ μ†Œλ“ 남성 30λŒ€ 3λΆ„μœ„"}
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,