Model Card for Model ID

Model Details

Base Model

  • unsloth/Llama-3.2-3B-Instruct

Features

  • Fine-tuned using Unsloth
  • 4-bit quantization support
  • PEFT / LoRA adapter
  • Fast inference support
  • Optimized for Colab and consumer GPUs

Installation & Guidance for Inference

!pip install -q unsloth

# Install latest Unsloth
!pip install -q --force-reinstall --no-cache-dir git+https://github.com/unslothai/unsloth.git

!pip install --upgrade torchao>=0.16.0

%%capture
import os

if "COLAB_" not in "".join(os.environ.keys()):
    !pip install unsloth
else:
    !pip install --no-deps bitsandbytes accelerate xformers==0.0.29.post3 peft trl==0.15.2 triton cut_cross_entropy unsloth_zoo
    !pip install sentencepiece protobuf "datasets>=3.4.1" huggingface_hub hf_transfer
    !pip install --no-deps unsloth

from unsloth import FastLanguageModel
import torch

max_seq_length = 2048
dtype = None
load_in_4bit = True

model, tokenizer = FastLanguageModel.from_pretrained(
    model_name = "unsloth/Llama-3.2-3B-Instruct",
    max_seq_length = max_seq_length,
    dtype = dtype,
    load_in_4bit = load_in_4bit,
)

model.load_adapter("YOUR_LORA_PATH", "default")

model.to("cuda")

model.enable_adapters()

messages = [
    {
        "role": "system",
        "content": "You are a reflective assistant who is master in Bhagavad Gita for chapter 8."
    },
    {
        "role": "user",
        "content": "What does Krishna call Karma in this chapter?"
    }
]

FastLanguageModel.for_inference(model)

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

from transformers import TextStreamer

text_streamer = TextStreamer(tokenizer)

_ = model.generate(
    input_ids = inputs,
    streamer = text_streamer,
    max_new_tokens = 2048,
    do_sample = True,
    temperature = 0.3,
    top_p = 0.9
)
Downloads last month
1
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support