MovieSentimentLM (SmolLM3-3B Fine-Tuned Adapter)

This is a 4-bit quantized QLoRA adapter for HuggingFaceTB/SmolLM3-3B, fine-tuned to classify the sentiment of movie reviews into positive or negative using the Rotten Tomatoes dataset.

Model Details

  • Base Model: HuggingFaceTB/SmolLM3-3B
  • Method: QLoRA (4-bit quantization via bitsandbytes, adapter rank = 8, alpha = 16)
  • Task: Binary Sentiment Classification (prompt/completion style, assistant-only loss)
  • Max Length: 192 tokens

Evaluation Results

Validation Accuracy & F1-Score

  • Baseline (Zero-Shot) Accuracy: 87.43%
  • Fine-Tuned Validation Accuracy: 93.62%
  • Fine-Tuned Test (Held-Out) Accuracy: 92.21%
  • Fine-Tuned Test Macro F1: 92.21%

Confusion Matrix (Test Set)

[[501,  32],
 [ 51, 482]]

Quick Inference Code

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel

base_model_name = "HuggingFaceTB/SmolLM3-3B"
adapter_name = "Marwanpng/MovieSentimentLM"

tokenizer = AutoTokenizer.from_pretrained(base_model_name)
model = AutoModelForCausalLM.from_pretrained(
    base_model_name,
    torch_dtype=torch.float16,
    device_map="auto"
)
model = PeftModel.from_pretrained(model, adapter_name)

system_prompt = "You are a movie review sentiment classifier. Respond with exactly one lowercase word: positive or negative."
review = "The acting was fantastic and the story was moving."

messages = [
    {'role': 'system', 'content': system_prompt},
    {'role': 'user', 'content': f"Classify the sentiment of this movie review:\n{review}"}
]

prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, enable_thinking=False)
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")

outputs = model.generate(**inputs, max_new_tokens=4)
print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
Downloads last month
25
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Marwanpng/MovieSentimentLM

Adapter
(79)
this model

Dataset used to train Marwanpng/MovieSentimentLM