CoolFace
Modelpublic

artyomboyko/qwen3.5-2b-sst2-prompt-tuning

sourceHugging Faceapache-2.0updated 1mo agoView on Hugging Face
0likes13downloads
Model Card

qwen3.5-2b-sst2-prompt-tuning

Prompt Tuning adapter for `Qwen/Qwen3.5-2B-Base`, fine-tuned on `stanfordnlp/sst2` for binary sentiment classification.

The adapter predicts positive or negative.

Model Details

PropertyValue
Base modelQwen/Qwen3.5-2B-Base
MethodPrompt Tuning
Datasetstanfordnlp/sst2
TaskSentiment classification
Labelsnegative, positive
Virtual tokens16
Prompt initializationClassify the sentiment of the movie review as positive or negative.
Adapter size0.13 MiB

Evaluation

Evaluation scope: full SST-2 validation split.

MetricBase modelPrompt Tuning
Generation accuracy3.10%94.27%
Forced-choice accuracy51.49%94.27%
Generation Macro F10.05730.9427
Forced-choice Macro F10.35020.9427
Perplexity—1.0869

Usage

python
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-prompt-tuning"

tokenizer = (
    AutoTokenizer.from_pretrained(
        BASE_MODEL_ID
    )
)

if tokenizer.pad_token_id is None:
    tokenizer.pad_token = (
        tokenizer.eos_token
    )

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)

Limitations

  • —Designed for English SST-2 sentiment classification.
  • —Requires the documented prompt format and the base model Qwen/Qwen3.5-2B-Base.