Views
No views yet
Qwen/Qwen3.5-2B-Base,
fine-tuned on
stanfordnlp/sst2
for binary sentiment classification.positive or negative.| Property | Value |
|---|---|
| Base model | Qwen/Qwen3.5-2B-Base |
| Method | LoRA |
| Dataset | stanfordnlp/sst2 |
| Task | Sentiment classification |
| Labels | negative, positive |
| LoRA rank | 16 |
| LoRA alpha | 32 |
| LoRA dropout | 0.05 |
| Target modules | all-linear |
| Adapter size | 64.21 MiB |
| Metric | Base model | LoRA |
|---|---|---|
| Generation accuracy | 3.10% | 94.84% |
| Forced-choice accuracy | 51.49% | 94.95% |
| Generation Macro F1 | 0.0573 | 0.9484 |
| Forced-choice Macro F1 | 0.3502 | 0.9495 |
| Perplexity | — | 1.0801 |
1import torch
2from peft import PeftModel
3from transformers import AutoModelForCausalLM, AutoTokenizer
4
5BASE_MODEL_ID = "Qwen/Qwen3.5-2B-Base"
6ADAPTER_ID = "artyomboyko/qwen3.5-2b-sst2-lora"
7
8tokenizer = AutoTokenizer.from_pretrained(
9 BASE_MODEL_ID
10)
11
12base_model = AutoModelForCausalLM.from_pretrained(
13 BASE_MODEL_ID,
14 dtype="auto",
15)
16
17model = PeftModel.from_pretrained(
18 base_model,
19 ADAPTER_ID,
20)
21
22device = torch.device(
23 "cuda"
24 if torch.cuda.is_available()
25 else "cpu"
26)
27
28model = model.to(device)
29model.eval()
30
31review = "a wonderfully acted and moving story"
32
33prompt = (
34 "Classify the sentiment of this movie review as positive or negative.\n"
35 f"Review: {review}\n"
36 "Sentiment:"
37)
38
39inputs = tokenizer(
40 prompt,
41 return_tensors="pt",
42).to(device)
43
44with torch.inference_mode():
45 outputs = model.generate(
46 **inputs,
47 max_new_tokens=4,
48 do_sample=False,
49 pad_token_id=tokenizer.eos_token_id,
50 )
51
52generated = outputs[
53 :,
54 inputs["input_ids"].shape[1]:,
55]
56
57prediction = tokenizer.decode(
58 generated[0],
59 skip_special_tokens=True,
60).strip()
61
62print(prediction)Qwen/Qwen3.5-2B-Base.