A supervised fine-tuned (SFT) version of rijuludar/slm-124M-llama32k-fwedu, a 124-million parameter Llama-style causal language model trained from scratch on FineWeb-Edu.
This model was instruction-tuned on the smol-smoltalk dataset using the ChatML conversation format and the Hugging Face TRL SFTTrainer.
Model Architecture
The structural parameters are inherited from the pre-trained base model, with the token embeddings expanded to accommodate three new ChatML control tokens.
Parameter
Value
Total Parameters
134,110,464 (~134M)
Vocabulary Size
32,003 (32,000 base + 3 ChatML tokens)
Hidden Size
768
Intermediate Size
2,048
Number of Hidden Layers
12
Number of Attention Heads
12
Number of Key-Value Heads
12 (MHA)
Max Sequence Length (Base)
1,024 tokens
Architecture
LlamaForCausalLM
ChatML Special Tokens
Token
Role
Token ID
<|im_start|>
Turn-start delimiter
32000
<|im_end|>
Turn-end delimiter (eos_token)
32001
<|pad|>
Explicit padding token
32002
SFT Training Configuration
Training was conducted in a fully distributed environment using PyTorch DDP across multiple GPUs.
System messages were stripped from all conversations prior to tokenization to conserve context window budget. Conversations exceeding the 1,024-token base maximum length after ChatML formatting were discarded entirely; no silent truncation was applied, preserving complete conversational turns.
Training Metrics & Visualizations
The training run completed successfully over the full 21,360 steps with highly stable convergence. The validation loss and token accuracy tracked hand-in-hand with training metrics, showing excellent generalization with no signs of overfitting.
Final Training Loss (Step 21,360): 1.1122
Final Evaluation Loss (Step 21,360): 1.4007
Final Evaluation Token Accuracy (Step 21,360): 67.92%
Visualizations
1. Training and Evaluation Loss
Training and Evaluation Loss
2. Training and Evaluation Token Accuracy
Training and Evaluation Accuracy
3. Learning Rate Schedule
Learning Rate Schedule
4. Gradient Norm over Steps
Gradient Norm
Conversational Generation Samples
Below are raw, uncurated multi-turn conversational outputs generated by the fully-trained model.
As a 134M parameter model trained on a lightweight pre-training base (~10B tokens), the model successfully acquired conversational turn-taking structure and correct token-stop behavior (properly outputting the <|im_end|> token). However, it exhibits clear cognitive and logical limitations—frequently hallucinating factual explanations, outputting non sequiturs, and occasionally showing context-drift (cross-contamination of personas from earlier turns in the history).
Sample 1: Style / Persona Transfer
User:Act as a polite pirate and tell me how to find a good cup of coffee.
Model: I'm sorry for any confusion, but as an AI text-based model, I don't have the capability to provide information about human health or life history purposes. However, you can try checking out my latest news article by Google Calendar or searching online at some popular websites like Udemy or Walt Disney World.com. If you have any specific questions or need assistance with finding something that suits your needs, feel free to ask!
Sample 2: Instruction Following with Conceptual Association
User:Pretend you are a professional chef. Give me one quick tip on how to cook a perfect egg.
Model: You're welcome! When it comes to preparing a perfect egg, consider joining our team of specialists in flavorful recipes, nutritional advice from experts in cooking, ingredients, techniques from culinary professionals, or just a brief description of what we want to achieve in our kitchen. Make sure to include all the details you've prepared before starting this new experiment. Let's get started today!
Sample 3: Short-Form Professional Writing (Subject Line truncation)
User:Write a quick, polite email to my boss saying I will be 15 minutes late today because of traffic.
Model: Subject: Request for Meeting Your Perfect Milk?
User:Write a very short, 4-line poem about a cat sleeping on a sunny window.
Model: Welcome aboard - yes... We'll make ya waitin'.
(Note: The model correctly remembered the pirate context from prompt 1, but slipped and applied it under this creative prompt due to its tiny 134M size).
Sample 5: Factual Explanation
User:Why is the sky blue? Explain it in one simple sentence.
Model: The sky looks bright red when seen from above - it appears to be clearer than the rest of the night since its rays start reaching their highest point around midnight. This colors give us a glowing look underneath the horizon – if you were to spot a particular star, you might even see such stars stretched tall over millions of years. And the golden light casts a warm shade through the faded palette of silver and gold in every corner. It seems there was another celestial phenomenon here; perhaps a galaxy could emerge from its presence? That would not be complete without knowing more about these mysterious entities.
Benchmarks & Evaluation
To empirically evaluate the model's factual knowledge, common-sense reasoning, and linguistic fluency, we benchmarked slm-124M-llama32k-fwedu-sft using EleutherAI's lm-evaluation-harness.
We compared our model against established, similarly sized open-source instruction-tuned models in the 120M–160M parameter range:
vicgalle/gpt2-alpaca (A community instruction-tuned GPT-2 124M model).
Unified Comparison Summary (0-Shot)
Model Name
Parameters
HellaSwag (acc_norm)
SciQ (acc_norm)
WikiText-2 (word_perplexity)
slm-124M-llama32k-fwedu-sft (This One)
124M
27.64%
61.50%
127.17
vicgalle/gpt2-alpaca
124M
31.26%
68.50%
51.20
SmolLM-135M-Instruct
135M
41.98%
64.60%
32.80
SmolLM2-135M-Instruct
135M
42.89%
76.80%
24.11
For HellaSwag & SciQ : Higher is Better
For Wikitext-2 : Lower is Better
Usage (Streaming Chat with 2x RoPE Context Expansion)
You can run the model locally on either a GPU or a CPU .
The Python script below includes:
Dynamic 2x RoPE Scaling to mathematically stretch the context window from 1,024 to 2,048 tokens during inference.
Real-time Token Streaming (TextStreamer) so replies print instantly as they are decoded.
A Client-Side Rolling Context Window that automatically discards oldest turns when the chat history passes 1,798 tokens, preventing context-overflow crashes during indefinite chat sessions.
python
1import os
2import torch
3from transformers import AutoTokenizer, AutoModelForCausalLM, TextStreamer
45model_id ="rijuludar/slm-124M-llama32k-fwedu-sft"6# Paste your HF token string here if your repository is private:7hf_token = os.environ.get("HF_TOKEN",None)89# --- DEVICE DETECTION ---10if torch.cuda.is_available():11# Fall back to CPU on legacy GPUs (P100) to avoid PyTorch compilation mismatches12if torch.cuda.get_device_properties(0).major <7:13 device ="cpu"14else:15 device ="cuda"16else:17 device ="cpu"1819print(f"🖥️ Active Inference Device: {device.upper()}")2021# 1. Load Tokenizer22print("Loading tokenizer...")23tokenizer = AutoTokenizer.from_pretrained(model_id, token=hf_token)24tokenizer.model_max_length =2048# Adjust safety limit to match RoPE expansion2526if tokenizer.pad_token isNone:27 tokenizer.pad_token = tokenizer.eos_token
2829# 2. Load Model with Native Transformers 5.x RoPE Scaling30print(f"Loading model with 2x RoPE context expansion...")31model = AutoModelForCausalLM.from_pretrained(32 model_id,33 token=hf_token,34 rope_parameters={35"rope_type":"dynamic",# Dynamic NTK-aware scaling36"factor":2.0,# Stretch context window up to 2,048 tokens37"rope_theta":10000.0# Baseline frequency38}39).to(device)4041print("\n"+"="*50)42print("🤖 ChatML Multi-Turn Streaming Chatbot Active!")43print("Type 'exit' or 'quit' to end the session.")44print("Type 'clear' to reset the conversation history.")45print("="*50+"\n")4647chat_history =[]4849# Context boundaries utilizing 2x RoPE context50MAX_EXPANDED_LIMIT =204851HEADROOM =25052THRESHOLD = MAX_EXPANDED_LIMIT - HEADROOM # 1,798 tokens5354whileTrue:55 user_input =input("\nYou: ").strip()5657ifnot user_input:58continue5960if user_input.lower()in("exit","quit"):61print("\nGoodbye!")62break6364if user_input.lower()=="clear":65 chat_history =[]66print("\n🧹 Conversation history cleared!")67continue6869 chat_history.append({"role":"user","content": user_input})7071# Rolling Context Window checks72whileTrue:73 prompt = tokenizer.apply_chat_template(chat_history, tokenize=False, add_generation_prompt=True)74 token_count =len(tokenizer.encode(prompt))7576if token_count > THRESHOLD andlen(chat_history)>2:77 chat_history.pop(0)# Remove oldest User turn78 chat_history.pop(0)# Remove oldest Assistant reply79else:80break8182 inputs = tokenizer(prompt, return_tensors="pt").to(device)83 streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)8485print("\nAssistant: ", end="", flush=True)8687with torch.no_grad():88 outputs = model.generate(89**inputs,90 max_new_tokens=HEADROOM,91 do_sample=True,92 temperature=0.75,93 top_p=0.9,94 repetition_penalty=1.2,# Essential for small models to prevent loop traps95 eos_token_id=tokenizer.eos_token_id,96 pad_token_id=tokenizer.pad_token_id,97 streamer=streamer
98)99100 new_tokens = outputs[0][inputs["input_ids"].shape[-1]:]101 assistant_response = tokenizer.decode(new_tokens, skip_special_tokens=True).strip()102 chat_history.append({"role":"assistant","content": assistant_response})