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

Property Value
Base model Qwen/Qwen3.5-2B-Base
Method Prompt Tuning
Dataset stanfordnlp/sst2
Task Sentiment classification
Labels negative, positive
Virtual tokens 16
Prompt initialization Classify the sentiment of the movie review as positive or negative.
Adapter size 0.13 MiB

Evaluation

Evaluation scope: full SST-2 validation split.

Metric Base model Prompt Tuning
Generation accuracy 3.10% 94.27%
Forced-choice accuracy 51.49% 94.27%
Generation Macro F1 0.0573 0.9427
Forced-choice Macro F1 0.3502 0.9427
Perplexity — 1.0869

Usage

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.
Downloads last month
9
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for artyomboyko/qwen3.5-2b-sst2-prompt-tuning

Adapter
(40)
this model

Dataset used to train artyomboyko/qwen3.5-2b-sst2-prompt-tuning