Views
No views yet
meta-llama/Llama-3.2-1B1from peft import AutoPeftModelForCausalLM
2from transformers import AutoTokenizer
3
4model = AutoPeftModelForCausalLM.from_pretrained(
5 "skhamzah123/llama-3.2-1b-prompt-tuning-tweet-peft"
6).to("cuda")
7
8tokenizer = AutoTokenizer.from_pretrained(
9 "skhamzah123/llama-3.2-1b-prompt-tuning-tweet-peft"
10)
11
12# Set pad token if missing
13if tokenizer.pad_token_id is None:
14 tokenizer.pad_token = tokenizer.eos_token
15 tokenizer.pad_token_id = tokenizer.eos_token_id
16
17# Classify a tweet
18tweet = "@customer_service This is unacceptable! Still waiting for help."
19inputs = tokenizer(f"Tweet text : {tweet} Label : ", return_tensors="pt").to("cuda")
20
21outputs = model.generate(
22 input_ids=inputs["input_ids"],
23 max_new_tokens=10,
24 pad_token_id=tokenizer.pad_token_id,
25)
26
27print(tokenizer.decode(outputs[0], skip_special_tokens=True))ought/raft – Twitter Complaints subsetcomplaint, no complaint| Parameter | Value |
|---|---|
| Learning Rate | 3e-2 |
| Epochs | 50 |
| Batch Size | 16 (train & eval) |
| Max Seq Length | 64 |
| Optimizer | AdamW |
| Trainer | TRL SFTTrainer |
| Setting | Value |
|---|---|
| Init Text | "Classify if the tweet is a complaint or no complaint. |
| " | |
| Virtual Tokens | 13 |
| Init Method | TEXT |