CoolFace
Modelpublic

strectelite/mnli-llama3.2-1b-qlora-10k

sourceHugging Faceapache-2.0updated 1y agoView on Hugging Face
0likes10downloads
Model Card

MNLI - LLaMA 3.2 1B - QLoRA (10k subset, 4-bit)

Model Summary

This is a QLoRA fine-tuned version of `meta-llama/Llama-3.2-1B-Instruct` on the MNLI (Multi-Genre Natural Language Inference) dataset from GLUE.

  • —Base model: LLaMA 3.2 1B Instruct
  • —Fine-tuning method: QLoRA with 4-bit quantization
  • —Train subset: 10k samples (8k train / 1k val / 1k test from train split)
  • —Evaluation: Official GLUE dev sets (matched / mismatched) + held-out 1k test split
  • —Trainable parameters: 5.64M (0.45% of base model)
  • —Hardware: NVIDIA T4 (fp16)

⚠️ Note: This repo contains only the LoRA adapter weights. You need access to the base model from Meta to use it.


Usage

python
from transformers import AutoTokenizer, AutoModelForSequenceClassification, BitsAndBytesConfig
from peft import PeftModel
import torch

BASE = "meta-llama/Llama-3.2-1B-Instruct"
ADAPTER = "streetelite/mnli-llama3.2-1b-qlora-10k"

bnb = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_quant_type="nf4",
    bnb_4bit_compute_dtype=torch.float16,
    bnb_4bit_use_double_quant=True
)

tokenizer = AutoTokenizer.from_pretrained(ADAPTER)
model = AutoModelForSequenceClassification.from_pretrained(
    BASE,
    num_labels=3,
    quantization_config=bnb,
    torch_dtype=torch.float16,
    device_map="auto"
)
model = PeftModel.from_pretrained(model, ADAPTER).eval()

inputs = tokenizer(
    "A man is playing guitar.",
    "A person is making music.",
    return_tensors="pt",
    truncation=True
)
with torch.inference_mode():
    logits = model(**{k: v.to(model.device) for k, v in inputs.items()}).logits
    probs = logits.softmax(-1)
print(probs)

Results

GLUE dev (official)

SetAccuracyF1 (macro)F1 (weighted)MCCKappaMAE
Matched82.37%0.82100.82240.73580.73490.2068
Mismatched83.71%0.83480.83600.75580.75500.1894

Held-out test split (1k from train)

AccuracyF1 (macro)F1 (weighted)MCCKappaMAE
83.10%0.82800.82880.74960.74610.2010

Training Details

  • —Framework: Hugging Face Transformers + PEFT + bitsandbytes
  • —Quantization: 4-bit NF4 w/ double quantization
  • —LoRA config: r=8, alpha=16, dropout=0.1, target modules: q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
  • —Optimizer: pagedadamw8bit, lr=2e-4
  • —Batch size: 4 (gradient accumulation = 4 → effective 16)
  • —Epochs: 2
  • —Seed: 42
  • —Padding: dynamic

Intended Uses

  • —Primary: Natural language inference on text pairs (entailment, neutral, contradiction).
  • —Languages: English.
  • —Not intended for: non-English inputs, factual question answering, safety-critical applications without human review.

License

  • —Base model: LLaMA 3.2 1B Instruct — Meta license
  • —Adapter: Apache License 2.0