🧠 Qwen2.5-1.5B FastAPI Guardrails & RAG LoRA Adapter

A specialized Parameter-Efficient Fine-Tuned (PEFT / LoRA) adapter for Qwen/Qwen2.5-1.5B-Instruct tailored for FastAPI multi-tenant schema isolation, circuit breaker implementation, and grounded RAG citation alignment.

Developed by Harmehak Singh Khangura (Hugging Face Profile).


πŸ“Œ Model Description

This model adapter enhances Qwen2.5-1.5B-Instruct with domain-specific knowledge in:

  • FastAPI Backend Engineering: Dependency injection for multi-tenant schema isolation and JWT auth contracts.
  • Resiliency & Circuit Breakers: Degradation patterns and circuit breaker states for external LLM APIs.
  • Grounded RAG Systems: Citation alignment, quality gate similarity scoring, and hallucination reduction.

πŸš€ How to Use

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

BASE_MODEL = "Qwen/Qwen2.5-1.5B-Instruct"
LORA_ADAPTER = "harmehak0173/qwen2.5-1.5b-fastapi-guardrails-lora"

tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL)
base_model = AutoModelForCausalLM.from_pretrained(
    BASE_MODEL,
    torch_dtype=torch.float16,
    device_map="auto"
)

# Load LoRA Adapter
model = PeftModel.from_pretrained(base_model, LORA_ADAPTER)

prompt = "<|im_start|>user\nHow do you implement a Circuit Breaker for external LLM APIs in Python?<|im_end|>\n<|im_start|>assistant\n"
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")

outputs = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))

πŸ› οΈ Training Details
Base Model: Qwen/Qwen2.5-1.5B-Instruct
Fine-Tuning Method: LoRA (Rank r=16, lora_alpha=32)
Target Modules: q_proj, k_proj, v_proj, o_proj
Trainer: Hugging Face TRL SFTTrainer
Format: ChatML (<|im_start|> / <|im_end|>)
Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for harmehak0173/qwen2.5-1.5b-fastapi-guardrails-lora

Adapter
(1358)
this model