phi3-mini-os-finetuned

A fine-tuned version of microsoft/Phi-3-mini-4k-instruct trained on a custom Operating Systems Q&A dataset built from the PES University OS syllabus.

Model Description

This model was fine-tuned using QLoRA (4-bit quantization + LoRA adapters) to answer questions about Operating Systems concepts β€” processes, scheduling, memory management, deadlocks, file systems, and more.

  • Base model: Phi-3 Mini 4K Instruct (3.8B parameters)
  • Fine-tuning method: QLoRA (4-bit quantization via bitsandbytes, LoRA via PEFT)
  • Trainable parameters: ~0.26% of total (LoRA adapters only)
  • Training data: 200 curated Q&A pairs from the PES University Operating Systems syllabus
  • Framework: HuggingFace Transformers + TRL (SFTTrainer)

Training Data

The dataset consists of 200 Q&A pairs covering OS topics including:

  • Process management and lifecycle
  • CPU scheduling algorithms (FCFS, SJF, Round Robin, Priority)
  • Deadlocks β€” conditions, detection, prevention, avoidance
  • Memory management β€” paging, segmentation, virtual memory
  • Page replacement algorithms (LRU, FIFO, Optimal)
  • File systems and I/O management
  • Synchronization β€” semaphores, mutexes, monitors

The dataset was curated manually from lecture notes and textbook material aligned with the PES University OS course syllabus.

How to Use

from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

model_id = "Prithvi-Aithal/phi3-mini-os-finetuned"

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

def ask_os(question):
    prompt = f"<|user|>\n{question}<|end|>\n<|assistant|>\n"
    inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
    
    with torch.no_grad():
        outputs = model.generate(
            **inputs,
            max_new_tokens=300,
            temperature=0.7,
            do_sample=True,
            pad_token_id=tokenizer.eos_token_id
        )
    
    response = tokenizer.decode(outputs[0], skip_special_tokens=True)
    return response.split("<|assistant|>")[-1].strip()

# Example
print(ask_os("What is the difference between a process and a thread?"))
print(ask_os("Explain Banker's Algorithm for deadlock avoidance."))
print(ask_os("What are the conditions for a deadlock to occur?"))

Example Outputs

Q: What is the difference between a process and a thread?

A process is an independent program in execution with its own memory space, file handles, and system resources. A thread is a lightweight unit of execution within a process β€” multiple threads share the same memory space and resources but have their own stack and program counter. Threads are faster to create and context-switch than processes.

Q: What are the four conditions for deadlock?

The four necessary conditions for deadlock (Coffman conditions) are: (1) Mutual Exclusion β€” at least one resource must be held in a non-shareable mode; (2) Hold and Wait β€” a process holds at least one resource while waiting to acquire additional resources; (3) No Preemption β€” resources cannot be forcibly taken from a process; (4) Circular Wait β€” a set of processes exist such that each is waiting for a resource held by the next process in the cycle.

Training Details

Parameter Value
Base Model Phi-3 Mini 4K Instruct
Quantization 4-bit (NF4) via bitsandbytes
LoRA Rank (r) 16
LoRA Alpha 32
LoRA Dropout 0.05
Target Modules q_proj, v_proj
Training Examples 200
Epochs 3
Batch Size 4 (with gradient accumulation)
Learning Rate 2e-4
Optimizer paged_adamw_32bit
Hardware Google Colab (T4 GPU)

Limitations

  • Trained on a small dataset (200 examples) β€” best suited for standard OS exam-style questions
  • May not generalize well to advanced or highly niche OS topics outside the syllabus
  • Minor numerical imprecision from 4-bit weight merging (harmless, expected with QLoRA)
  • English only

Intended Use

This model is intended for educational purposes β€” helping students revise OS concepts, practice exam questions, and understand core theory. It is not intended for production systems or authoritative technical reference.

Citation / Credits

Built by Prithvi Aithal as a portfolio project demonstrating LLM fine-tuning with QLoRA.

Downloads last month
26
Safetensors
Model size
4B params
Tensor type
F32
Β·
F16
Β·
U8
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for Prithvi-Aithal/phi3-mini-os-finetuned

Adapter
(854)
this model