Instructions to use smshahbaj/Rifa-Nano-0.5B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use smshahbaj/Rifa-Nano-0.5B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="smshahbaj/Rifa-Nano-0.5B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("smshahbaj/Rifa-Nano-0.5B") model = AutoModelForCausalLM.from_pretrained("smshahbaj/Rifa-Nano-0.5B", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use smshahbaj/Rifa-Nano-0.5B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "smshahbaj/Rifa-Nano-0.5B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "smshahbaj/Rifa-Nano-0.5B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/smshahbaj/Rifa-Nano-0.5B
- SGLang
How to use smshahbaj/Rifa-Nano-0.5B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "smshahbaj/Rifa-Nano-0.5B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "smshahbaj/Rifa-Nano-0.5B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "smshahbaj/Rifa-Nano-0.5B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "smshahbaj/Rifa-Nano-0.5B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use smshahbaj/Rifa-Nano-0.5B with Docker Model Runner:
docker model run hf.co/smshahbaj/Rifa-Nano-0.5B
๐ RIFA Nano 0.5B
A compact, multilingual AI assistant โ built for speed, efficiency, and everyday usefulness.
Developed by SM Shahbaj
๐ Overview
RIFA Nano is the smallest and fastest model in the RIFA series โ a family of language models built to run efficiently across a wide range of hardware, from low-end mobile devices to modern GPUs. Nano is fine-tuned on top of Qwen2.5-0.5B-Instruct using LoRA, combining a strong identity, multilingual fluency, and lightweight coding ability in a package small enough to run almost anywhere.
| Model | Parameters | Best For |
|---|---|---|
| RIFA Nano โญ | 0.5B | Low-end / mobile devices, fast responses |
| RIFA Flash | 1.5B | Balanced performance and speed |
| RIFA Pro | 3B | Complex reasoning, heavier workloads |
โจ Capabilities
- ๐ Multilingual โ fluent in English, Bengali (เฆฌเฆพเฆเฆฒเฆพ), and Banglish
- ๐ฌ General assistant โ Q&A, everyday writing, summarization, explanations
- ๐ป Basic coding โ short scripts, debugging help, code explanations
- ๐งญ Honest by design โ responds "Sorry, I don't have the answer for that right now" instead of making things up
- ๐ชช Stable identity โ consistently identifies as RIFA Nano, resistant to prompts trying to make it claim another identity
๐ Quick Start
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model_id = "smshahbaj/Rifa-Nano-0.5B"
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.float16,
device_map="auto",
)
tokenizer = AutoTokenizer.from_pretrained(model_id)
messages = [
{"role": "user", "content": "Who are you?"}
]
text = tokenizer.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True
)
inputs = tokenizer([text], return_tensors="pt").to(model.device)
with torch.no_grad():
output = model.generate(
**inputs,
max_new_tokens=200,
temperature=0.5,
top_p=0.9,
repetition_penalty=1.15,
)
response = tokenizer.decode(
output[0][inputs["input_ids"].shape[-1]:],
skip_special_tokens=True
)
print(response)
๐๏ธ Training Details
| Base model | Qwen/Qwen2.5-0.5B-Instruct |
| Method | LoRA (r=16, ฮฑ=32, dropout=0.05) |
| Identity dataset | 308 samples (English, Bangla, Banglish, adversarial/jailbreak-resistant, 5x repeated) |
| General data | Bangla Alpaca + English Alpaca + CodeAlpaca |
| Epochs | 4 |
| Hardware | Kaggle GPU (T4 x2) |
| Precision | 4-bit (NF4) training, merged to FP16 |
โ ๏ธ Limitations
- As the smallest model in the RIFA series, Nano is not built for long, multi-step reasoning โ use RIFA Flash or RIFA Pro for complex tasks.
- Knowledge has a training cutoff and the model has no internet access.
- No persistent memory between conversations by default.
- Best suited for lightweight, everyday tasks rather than deep technical or research-grade work.
๐ License
Released under the Apache 2.0 license, consistent with the base model.
๐ค Developer
Built and fine-tuned by SM Shahbaj โ full-stack developer, founder of Smart Web BD and Risha Apps, independent music producer, and author of the sci-fi novel Micro Mayhem (2023).
- ๐ Website: smshahbaj.com
- ๐ป GitHub: github.com/smshahbaj
- ๐ค HuggingFace: huggingface.co/smshahbaj
Part of the RIFA model series โ Nano ยท Flash ยท Pro
- Downloads last month
- -