stanfordnlp/sst2
Viewer • Updated • 70k • 38.4k • 163
How to use artyomboyko/qwen3.5-2b-sst2-lora with PEFT:
from peft import PeftModel
from transformers import AutoModelForCausalLM
base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3.5-2B-Base")
model = PeftModel.from_pretrained(base_model, "artyomboyko/qwen3.5-2b-sst2-lora")LoRA adapter for
Qwen/Qwen3.5-2B-Base,
fine-tuned on
stanfordnlp/sst2
for binary sentiment classification.
The adapter predicts 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 |
Evaluation scope: full SST-2 validation split.
| 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 |
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
BASE_MODEL_ID = "Qwen/Qwen3.5-2B-Base"
ADAPTER_ID = "artyomboyko/qwen3.5-2b-sst2-lora"
tokenizer = AutoTokenizer.from_pretrained(
BASE_MODEL_ID
)
base_model = AutoModelForCausalLM.from_pretrained(
BASE_MODEL_ID,
dtype="auto",
)
model = PeftModel.from_pretrained(
base_model,
ADAPTER_ID,
)
device = torch.device(
"cuda"
if torch.cuda.is_available()
else "cpu"
)
model = model.to(device)
model.eval()
review = "a wonderfully acted and moving story"
prompt = (
"Classify the sentiment of this movie review as positive or negative.\n"
f"Review: {review}\n"
"Sentiment:"
)
inputs = tokenizer(
prompt,
return_tensors="pt",
).to(device)
with torch.inference_mode():
outputs = model.generate(
**inputs,
max_new_tokens=4,
do_sample=False,
pad_token_id=tokenizer.eos_token_id,
)
generated = outputs[
:,
inputs["input_ids"].shape[1]:,
]
prediction = tokenizer.decode(
generated[0],
skip_special_tokens=True,
).strip()
print(prediction)
Qwen/Qwen3.5-2B-Base.Base model
Qwen/Qwen3.5-2B-Base