An Experimental 500M Parameter Causal Language Model Architected, Pretrained & SFT Aligned from Scratch
Engineered by Mohamed Usaid
Interactive Chat Space • GGUF Quants (llama.cpp) • GitHub Source Code
Usaid AI (500M) is an independent, autoregressive causal language model containing 500,136,960 parameters. It was designed, architected, pretrained, and aligned from scratch by Mohamed Usaid.
This model was initialized completely from random Gaussian weights (mean 0, std 0.02 with scaled residual projections). It is NOT a fine-tune, merge, distillation, or adaptation of any pre-existing model. Every single parameter—from the 50,257 token embeddings across all 30 attention and feed-forward layers to the untied language modeling head—was learned directly from raw token data.
Unlike Mixture-of-Experts (MoE) architectures where only a subset of parameters activate per token, Usaid AI is a fully dense model: all 500,136,960 parameters and all 30 Transformer layers actively participate in computing representations for every single token.
The model incorporates modern frontier causal Transformer innovations:
| Architectural Component | Value | Technical Description |
|---|---|---|
| Model Type | Causal LM | Autoregressive decoder-only Transformer |
| Total Parameters | 500,136,960 |
Exact count (+0.027% delta from 500M target) |
| Active Parameters | 500,136,960 |
100% dense (all parameters active per token) |
| Hidden Dimension (d_model) | 1,024 |
Power-of-2 dimension (2^10 = 1024) for optimal Tensor Core tiling |
| Transformer Layers (L) | 30 |
Deep hierarchical reasoning depth |
| Query Attention Heads (H_q) | 16 |
Head dimension d_head = 64 (16 x 64 = 1024) |
| Key/Value Attention Heads (H_kv) | 4 |
Grouped-Query Attention (GQA 4:1 ratio) |
| KV Cache Compression | 75% |
4 KV heads shared across 16 Q heads for fast generation |
| Feed-Forward Network (FFN) | SwiGLU | 3-matrix gated formulation (d_ff = 3,456 ~ 3.375 x d_model) |
| Positional Encoding | RoPE | Vectorized Rotary Position Embeddings (theta = 10,000, 0 static params) |
| Normalization | RMSNorm | Pre-normalization with learnable scale gamma (zero-mean, bias-free) |
| LM Head Tying | False | Untied embeddings (51.46M input embed + 51.46M output LM head) |
| Attention Kernel | SDPA | PyTorch native scaled_dot_product_attention |
| Vocabulary Size (V) | 50,257 |
Byte-Pair Encoding (tiktoken / GPT-2 standard) |
| Context Length | 1,024 |
Native training context (extensible to 2,048) |
3.6849 | Val Loss 3.5274 | Val PPL 34.043.1250 | Val Loss 3.0410 | Val PPL 20.932.9623 | Val Loss 2.9091 | Val PPL 18.342.9091)User: ... are labeled with target = -100 so gradient updates occur exclusively on assistant responses)2.93022.52992.20361.3938 (>52% convergence drop)1.4715| Dataset / Source | Site / URL | Exact Split | Exact Row Range | HF Viewer Page Range | Samples Taken |
|---|---|---|---|---|---|
| SmolTalk: Everyday Conversations | Hugging Face SmolTalk | train |
Row 1 to Row 2,260 (100% of entire split) | Page 1 to Page 23 | 2,260 |
| SmolTalk: OpenHermes-100k | Hugging Face OpenHermes-100k | train |
Row 1 to Row 2,260 (out of 95,000) | Page 1 to Page 23 | 2,260 |
| Curated Identity & Creator Persona | Local in scripts/download_sft_data.py |
Custom | 34 distinct questions (4x repeats) | N/A | 136 |
| Curated Multi-Language Code | Local in scripts/download_sft_data.py |
Custom | 5 distinct questions (15x repeats) | N/A | 75 |
| TOTAL SFT TRAINING SET | — | — | — | — | 4,731 |
gradio-app/trackio)The complete training logs for both Pretraining (2,000 steps) and SFT Alignment (441 steps) are fully integrated with Trackio (the open-source, local-first experiment tracker by Hugging Face & Gradio).
You can explore the interactive step-by-step cross-entropy loss curves, gradient norms, learning rate schedules, and hardware throughput directly from the GitHub repository:
# Install Trackio
pip install trackio
# Launch the interactive local Gradio dashboard
python scripts/view_trackio.py
# Or launch directly with the Trackio CLI:
trackio show --project "UsaidAI-500M"
Evaluated using length-normalized completion log-likelihood over 4 candidate choices:
| Domain Category | Pre-SFT Base Model | Post-SFT Aligned Model | Empirical Delta |
|---|---|---|---|
| ML & Transformer Architecture | 40% | 60% | +20% |
| World Knowledge & Science | 40% | 60% | +20% |
| Python & Software Engineering | 20% | 20% | Baseline |
| Logic & Arithmetic | 20% | 20% | Baseline |
| OVERALL ACCURACY | 30% | 40% | +10% |
During SFT, the model was aligned strictly on direct conversational dialogue turns without any System: tokens:
User: {your question or instruction}
Assistant:
[!IMPORTANT] Do not inject a
System:prefix. Prepending an unrecognizedSystem:token degrades the 500M model's attention conditioning. Always use the nativeUser: ...\n\nAssistant:format.
Load and query the model directly using Hugging Face:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "Usaidddddddddddddd/UsaidAI-500M"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
device_map="auto"
)
prompt = "User: Who created you and what is your architecture?\n\nAssistant:"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=120,
temperature=0.6,
top_p=0.9,
repetition_penalty=1.15,
eos_token_id=tokenizer.eos_token_id,
)
response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
print(response.strip())
llama.cpp & Local Deployment)Thanks to open-source contributor mradermacher, static GGUF quantizations for Usaid AI (500M) are available at:
👉 mradermacher/UsaidAI-500M-GGUF
This makes Usaid AI (500M) runnable locally on consumer laptops, Macs, phones, and edge hardware in under 400MB RAM using llama.cpp or Ollama:
llama.cpp:# 1. Run terminal CLI inference directly from Hugging Face:
llama cli -hf mradermacher/UsaidAI-500M-GGUF:Q4_K_M -p "User: What is machine learning?\n\nAssistant:"
# 2. Or start a local OpenAI-compatible API server with Web UI:
llama serve -hf mradermacher/UsaidAI-500M-GGUF:Q4_K_M --port 8080
Available quantizations include Q4_K_M (recommended, ~0.4 GB), Q5_K_M (~0.5 GB), Q8_0 (~0.6 GB), and Q2_K (~0.3 GB).
The official repository (mohamedusaid/TinyGPT) includes dedicated interpretability tools:
python scripts/run_chat_loop.py (live token streaming, multi-turn sliding memory, optional RAG grounding).python scripts/run_token_probs.py (step through token generation one token at a time, inspect top candidate distributions, and explore counterfactual branches).python scripts/visualize_embeddings.py --open (interactive TensorFlow-Projector-style orbital 3D browser for exploring the 1024-D embedding space via PCA, t-SNE, and nearest neighbors).To support ongoing academic exploration, scaling-law analysis, and open-source mechanistic interpretability, the following intermediate training artifacts are preserved:
best_tinygpt_500m.pt (1.86 GB):2.9091 / PPL 18.34) prior to supervised fine-tuning.checkpoint_step_002000.pt (5.59 GB):data_shards (~131M Tokens):If you are an academic researcher, AI engineer, or student interested in exploring these artifacts, investigating mechanistic interpretability on 500M-scale GQA/RoPE architectures, or collaborating on compute-efficient scaling research:
@misc{usaid_ai_2026,
author = {Mohamed Usaid},
title = {Usaid AI: A 500M Parameter Causal Language Model with Grouped-Query Attention},
year = {2026},
publisher = {Hugging Face / GitHub},
howpublished = {\url{https://huggingface.co/Usaidddddddddddddd/UsaidAI-500M}}
}