Views
No views yet
1"will it rain in Paris this weekend?"
2 -> {"location": "Paris", "date": "this_weekend", "metric": "rain", "time_of_day": null}| slot | values |
|---|---|
location | place name, or null |
date | today, tomorrow, day_after_tomorrow, this_weekend, next_weekend, next_week, a weekday, or null |
metric | temperature, rain, snow, wind, humidity, uv, cloud, general |
time_of_day | morning, afternoon, evening, night, or null |
| metric | base | finetuned |
|---|---|---|
| valid JSON | 100.0% | 100.0% |
| exact match | 64.5% | 98.6% |
| field accuracy | 90.7% | 99.7% |
| slot F1 | 0.894 | 0.996 |
1from transformers import AutoModelForCausalLM, AutoTokenizer
2from peft import PeftModel
3
4base = "Qwen/Qwen2.5-1.5B-Instruct"
5tok = AutoTokenizer.from_pretrained(base)
6model = AutoModelForCausalLM.from_pretrained(base, device_map="auto")
7model = PeftModel.from_pretrained(model, "Nicholas55555/qwen2.5-1.5b-weather-intent")
8
9sys = "You extract structured intent from weather questions. Return ONLY a JSON object..."
10msgs = [{"role": "system", "content": sys},
11 {"role": "user", "content": "do I need an umbrella in Denver tomorrow morning?"}]
12prompt = tok.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True)
13out = model.generate(**tok(prompt, return_tensors="pt").to(model.device), max_new_tokens=64)
14print(tok.decode(out[0], skip_special_tokens=True))