Views
No views yet
apply_chat_template() method:1messages = [
2 {"role": "system", "content": "You are a helpful assistant."},
3 {"role": "user", "content": "Your question here"}
4]
5inputs = tokenizer.apply_chat_template(messages, tokenize=True, return_tensors="pt")| Model | Strict Prompt | Strict Inst | Loose Prompt | Loose Inst |
|---|---|---|---|---|
| Base | 0.4399 | 0.5731 | 0.4787 | 0.6067 |
| Fine-tuned | 0.3050 | 0.4376 | 0.3327 | 0.4700 |
| Δ | ↘ -0.1349 | ↘ -0.1355 | ↘ -0.1460 | ↘ -0.1367 |
| Benchmark | What It Tests | Base | Fine-tuned | Improvement |
|---|---|---|---|---|
| IFEval | Tests ability to follow specific instructions | 43.99% | 30.50% | ↘ -13.49% (-30.7%) |
| GSM8K | Tests math reasoning and chain-of-thought | - | - | - |
| HellaSwag | Tests real-world knowledge and common sense | - | - | - |
| MMLU | Tests broad knowledge retention (detects catastrophic forgetting) | - | - | - |
| TruthfulQA | Tests tendency to generate truthful answers | - | - | - |
1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model = AutoModelForCausalLM.from_pretrained(
4 "./outputs/Llama-3.2-1B-Instruct-bnb-4bit-lima/merged_16bit",
5 device_map="auto"
6)
7tokenizer = AutoTokenizer.from_pretrained("./outputs/Llama-3.2-1B-Instruct-bnb-4bit-lima/merged_16bit")
8
9messages = [{"role": "user", "content": "Your question here"}]
10inputs = tokenizer.apply_chat_template(messages, tokenize=True, return_tensors="pt").to("cuda")
11outputs = model.generate(inputs, max_new_tokens=256)
12print(tokenizer.decode(outputs[0]))