Instructions to use nareshmeena12/fluxion-370m-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nareshmeena12/fluxion-370m-instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nareshmeena12/fluxion-370m-instruct") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("nareshmeena12/fluxion-370m-instruct") model = AutoModelForCausalLM.from_pretrained("nareshmeena12/fluxion-370m-instruct") 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 nareshmeena12/fluxion-370m-instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nareshmeena12/fluxion-370m-instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nareshmeena12/fluxion-370m-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/nareshmeena12/fluxion-370m-instruct
- SGLang
How to use nareshmeena12/fluxion-370m-instruct 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 "nareshmeena12/fluxion-370m-instruct" \ --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": "nareshmeena12/fluxion-370m-instruct", "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 "nareshmeena12/fluxion-370m-instruct" \ --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": "nareshmeena12/fluxion-370m-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use nareshmeena12/fluxion-370m-instruct with Docker Model Runner:
docker model run hf.co/nareshmeena12/fluxion-370m-instruct
β‘ Fluxion-370M-Instruct
Trained on 0.227T tokens. Competing with models trained on 28T.
What is Fluxion?
Fluxion-370M-Instruct is a 370M-parameter instruction-tuned language model built from scratch, focused on mathematical reasoning and code generation. Its core design philosophy is simple: do more with less.
Trained on just 227B tokens β a fraction of what comparable models consume β Fluxion achieves competitive performance on math and coding benchmarks against models that have seen 18β28Γ more data. On token efficiency (MATH-500 score per trillion training tokens), Fluxion ranks 1st across all models in its class by a dominant margin.
The model went through three training stages: large-scale pretraining, supervised fine-tuning for instruction following, and GRPO reinforcement learning specifically targeting mathematical reasoning with rule-based rewards.
β‘ Token Efficiency β The Core Story
| Model | Training Tokens | MATH-500 | MATH-500 / Trillion Tokens |
|---|---|---|---|
| Fluxion-370M | 0.227T | 17.40% | π₯ 76.7Γ |
| MobileLLM-R1-360M | 4.2T | 25.60% | 6.1Γ |
| Gemma3-270M | 6T | 8.20% | 1.4Γ |
| Granite-350M | 11T | 19.20% | 1.7Γ |
| Qwen2.5-0.5B | 18T | 29.80% | 1.7Γ |
| LFM2.5-350M | 28T | 13.40% | 0.5Γ |
| SmolLM2-360M | 4T | 3.40% | 0.9Γ |
Fluxion delivers 76.7Γ higher MATH-500 score per trillion training tokens than any other model in this comparison. This is a structural advantage from architecture choices, custom tokenization, and a high-signal data pipeline β not a measurement artifact.
ποΈ Architecture
Fluxion is a clean, modern decoder-only transformer. No hybrid layers, no custom operators β just well-chosen standard components assembled deliberately.
FluxionForCausalLM
βββ Embedding (vocab_size=50,000 Β· hidden_size=1024)
βββ 26 Γ DecoderBlock
β βββ RMSNorm (Ξ΅ = 1e-6)
β βββ GroupedQueryAttention
β β βββ 16 Query heads Β· 8 KV heads (GQA 2:1)
β β βββ RoPE (ΞΈ = 500,000) + NTK scaling
β βββ RMSNorm (Ξ΅ = 1e-6)
β βββ SwiGLU FFN (hidden β 3072 β hidden)
βββ RMSNorm β LM Head (weight-tied to embedding)
Hyperparameters
| Parameter | Value |
|---|---|
| Total Parameters | ~370M |
| Layers | 26 |
| Hidden Size | 1024 |
| FFN Intermediate Size | 3072 |
| Attention Heads (Q) | 16 |
| KV Heads (GQA) | 8 |
| GQA Group Ratio | 2 : 1 |
| Head Dimension | 64 |
| Context Length | 4096 |
| Vocabulary Size | 50,000 |
| RoPE Base ΞΈ | 500,000 |
| RoPE Scaling | NTK |
| Normalization | RMSNorm (Ξ΅ = 1e-6) |
| Activation | SwiGLU |
| Attention | Flash Attention |
| Weight Tying | Yes (embed β lm_head) |
| Attention Bias | No |
| FFN Bias | No |
| dtype | bfloat16 |
Design Choices & Rationale
Grouped Query Attention (16Q / 8KV): Halves KV cache memory vs standard MHA with no meaningful quality loss at this scale. Larger effective batch sizes at both training and inference time.
RoPE with ΞΈ = 500,000 + NTK scaling: High base frequency improves length generalisation beyond the training window. NTK scaling further stabilises attention patterns at longer sequences without fine-tuning.
SwiGLU activation: Consistently stronger than GeLU/ReLU on reasoning tasks. The gated structure gives the FFN richer expressiveness per parameter.
Custom BPE tokenizer (50k vocab): Trained from scratch on 100GB of domain-focused text β a curated subset of the pretraining corpus weighted toward mathematics, code, and English prose. A smaller, domain-tuned vocabulary means fewer tokens per math expression and code snippet, directly improving effective context utilisation and reducing sequence lengths vs generic 128k tokenizers.
Weight tying (embed β lm_head): Saves ~50M parameters, keeps the model compact, and forces the input and output representation spaces to align.
Flash Attention: Full Flash Attention used throughout training for memory efficiency and throughput. TF32 enabled for matrix multiplications.
π Benchmarks
All results are 0-shot unless noted. Evaluation is strict.
Math & Code
| Model | Tokens | GSM8K | MATH-500 | HumanEval | MBPP | Avg |
|---|---|---|---|---|---|---|
| Qwen2.5-0.5B | 18T | 43.44% | 29.80% | 30.49% | 38.91% | 35.66% |
| Granite-350M | 11T | 31.69% | 19.20% | 29.88% | 42.02% | 30.70% |
| LFM2.5-350M | 28T | 32.68% | 13.40% | 10.37% | 5.45% | 15.48% |
| MobileLLM-R1-360M | 4.2T | 23.81% | 25.60% | 19.51% | 17.51% | 21.61% |
| Fluxion-370M | 0.227T | 29.57% | 17.40% | 16.46% | 20.23% | 20.92% |
| SmolLM2-360M | 4T | 8.87% | 3.40% | 17.68% | 35.02% | 16.24% |
| Gemma3-270M | 6T | 7.58% | 8.20% | 11.59% | 19.07% | 11.61% |
General Reasoning
| Model | ARC | PIQA | OBQA | CSQA | MMLU | Wino | IFEval | Avg |
|---|---|---|---|---|---|---|---|---|
| Qwen2.5-0.5B | 50.9% | 70.1% | 36.2% | 42.3% | 45.9% | 51.1% | 74.1% | 52.9% |
| Granite-350M | 51.8% | 68.9% | 37.8% | 40.5% | 33.8% | 53.8% | 83.2% | 52.8% |
| LFM2.5-350M | 49.4% | 67.0% | 31.6% | 33.4% | 42.2% | 52.0% | 88.3% | 52.0% |
| SmolLM2-360M | 45.9% | 71.5% | 35.2% | 29.0% | 24.9% | 54.8% | 77.5% | 48.4% |
| Gemma3-270M | 43.7% | 66.6% | 30.6% | 36.9% | 24.7% | 49.7% | 71.5% | 46.2% |
| MobileLLM-R1-360M | 39.1% | 58.6% | 26.2% | 27.6% | 26.7% | 50.8% | 71.2% | 42.9% |
| Fluxion-370M | 36.3% | 61.6% | 29.4% | 27.3% | 25.3% | 51.9% | 66.9% | 42.7% |
Rankings Summary
| Category | Score | Rank |
|---|---|---|
| Math Average (GSM8K + MATH-500) | 23.49% | 4th |
| Code Average (HumanEval + MBPP) | 18.35% | 5th |
| Math + Code Combined | 20.92% | 4th |
| General Average | 39.19% | 7th |
| Token Efficiency (MATH-500 / T tokens) | 76.7Γ | π₯ 1st |
Fluxion's design target is math and code under tight data constraints. On general benchmarks like IFEval and MMLU it trails models trained on significantly more diverse data β this is expected and intentional. On token efficiency it has no close competitor.
π¬ Chat Template & Tokenizer
Fluxion-Instruct uses the ChatML format:
<|im_start|>system
You are a helpful assistant.<|im_end|>
<|im_start|>user
{your prompt here}<|im_end|>
<|im_start|>assistant
Special Tokens
| Token | ID | Role |
|---|---|---|
<|im_start|> |
100278 | Turn start marker |
<|im_end|> |
100279 | Turn end marker |
<|pad|> |
β | Padding token |
Stopping Token IDs
Always pass eos_token_id=[1, 4] during generation. Without these, the model may continue generating beyond the intended response boundary:
output = model.generate(
**inputs,
eos_token_id=[1, 4],
...
)
Token ID 1 is the primary EOS token and token ID 4 is the <|im_end|> marker. Including both ensures clean turn termination in all inference scenarios.
Tokenizer
Fluxion uses a custom BPE tokenizer trained from scratch on ~100GB of domain-focused text β a curated subset of the pretraining corpus weighted toward mathematics, code, and English prose. With a 50,000 token vocabulary, it is significantly more compact than general-purpose tokenizers (32kβ128k). This means:
- Fewer tokens per math expression and code snippet
- Better effective context utilisation within the 4096 token window
- Faster embedding lookups and a smaller lm_head projection
π Quick Start
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model = AutoModelForCausalLM.from_pretrained(
"nareshmeena12/fluxion-370m-instruct",
torch_dtype=torch.bfloat16,
device_map="auto",
)
tokenizer = AutoTokenizer.from_pretrained(
"nareshmeena12/fluxion-370m-instruct"
)
messages = [
{"role": "system", "content": "You are a helpful assistant that solves math problems step by step."},
{"role": "user", "content": "What is the sum of the first 100 natural numbers?"}
]
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=512,
eos_token_id=[1, 4],
do_sample=True,
top_p=0.9,
)
response = tokenizer.decode(
output[0, inputs["input_ids"].shape[1]:],
skip_special_tokens=True
)
print(response)
Note: Always include
eos_token_id=[1, 4]in allgenerate()calls regardless of quantization mode.
ποΈ Training
Fluxion was trained in three stages.
Stage 1 β Pretraining
Large-scale unsupervised pretraining on a curated mix of math, code, and English text.
| Parameter | Value |
|---|---|
| Total Tokens | ~227B (0.227T) |
| Steps | 264,000 |
| Batch Size | 10 sequences |
| Gradient Accumulation | 21 steps |
| Effective Batch | ~860K tokens/step |
| Learning Rate | 3e-4 |
| Min Learning Rate | 9e-5 |
| LR Schedule | Cosine decay |
| Warmup Steps | 2,000 |
| Sequence Length | 4,096 |
| Optimizer | AdamW |
| Precision | bfloat16 + TF32 |
| Attention | Flash Attention |
| Positional Encoding | RoPE (ΞΈ=500k) + NTK scaling |
Pretraining data: (to be added)
Stage 2 β Supervised Fine-Tuning (SFT)
Instruction tuning using ChatML format to teach the model to follow user instructions across math, code, and general tasks.
| Parameter | Value |
|---|---|
| Format | ChatML |
| Data | (to be added) |
Stage 3 β GRPO (Math Reasoning)
Group Relative Policy Optimisation applied specifically to strengthen mathematical reasoning.
| Parameter | Value |
|---|---|
| Algorithm | GRPO |
| Reward Signal | Rule-based answer correctness |
| Target Domain | Mathematics |
| Data | (to be added) |
Rule-based rewards verify final answer correctness against ground truth β no LLM judge, no model-in-the-loop. This keeps the reward signal clean, fast, and free from reward hacking through verbosity or style.
π― Intended Use
Fluxion-370M-Instruct is designed for:
- Mathematical problem solving and step-by-step reasoning
- Code generation and explanation (Python, general purpose)
- Instruction-following tasks in math and code domains
- Fine-tuning base for domain-specific math/code applications
- Efficient deployment β capable performance on modest hardware
- Research into token-efficient pretraining and RL for reasoning
Fluxion-370M-Instruct is NOT designed for:
- Knowledge-intensive QA requiring broad world knowledge
- Long-document tasks beyond 4096 tokens
- Multilingual use cases
- Safety-critical production deployments without additional alignment
β οΈ Limitations
- Narrow training data scope. 0.227T tokens is intentionally small and domain-focused. The model has limited world knowledge outside math, code, and general English.
- Context length is 4096 tokens. Not suitable for long-document tasks without chunking strategies.
- General benchmarks lag. IFEval (66.9%) and MMLU (25.3%) reflect that the model was not optimised for instruction following diversity or broad knowledge recall β this is a deliberate trade-off.
- Custom tokenizer. The 50k BPE vocabulary is domain-tuned. Rare tokens, non-English text, and highly specialised symbols outside the training distribution may tokenise suboptimally.
- Small scale. At 370M parameters, the model is outperformed by larger models on complex multi-step reasoning chains requiring deep world knowledge.
- Always set
eos_token_id=[1, 4]. Without explicit stopping token IDs the model may continue generating past the intended response boundary.
π° News
<!-- ADD DATE -->β Fluxion-370M-Instruct released on Hugging Face<!-- ADD DATE -->β Training code released on GitHub<!-- ADD DATE -->β Technical report available on arXiv
π Citation
@misc{fluxion2025,
title = {Fluxion-370M: Token-Efficient Pretraining and Reinforcement Learning for Mathematical and Code Reasoning},
author = {Meena, Naresh},
year = {2025},
note = {<!-- ADD: arXiv link or report URL -->}
}
π¬ Contact
Less data. Less compute. More signal.
π€ Model Β· π» Code Β· π Paper
- Downloads last month
- 1,433
