Instructions to use MLVXN/MicroLLM2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MLVXN/MicroLLM2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="MLVXN/MicroLLM2") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("MLVXN/MicroLLM2") model = AutoModelForCausalLM.from_pretrained("MLVXN/MicroLLM2", 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
- llama.cpp
How to use MLVXN/MicroLLM2 with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf MLVXN/MicroLLM2:Q4_K_M # Run inference directly in the terminal: llama cli -hf MLVXN/MicroLLM2:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf MLVXN/MicroLLM2:Q4_K_M # Run inference directly in the terminal: llama cli -hf MLVXN/MicroLLM2:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf MLVXN/MicroLLM2:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf MLVXN/MicroLLM2:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf MLVXN/MicroLLM2:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf MLVXN/MicroLLM2:Q4_K_M
Use Docker
docker model run hf.co/MLVXN/MicroLLM2:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use MLVXN/MicroLLM2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MLVXN/MicroLLM2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MLVXN/MicroLLM2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/MLVXN/MicroLLM2:Q4_K_M
- SGLang
How to use MLVXN/MicroLLM2 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 "MLVXN/MicroLLM2" \ --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": "MLVXN/MicroLLM2", "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 "MLVXN/MicroLLM2" \ --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": "MLVXN/MicroLLM2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use MLVXN/MicroLLM2 with Ollama:
ollama run hf.co/MLVXN/MicroLLM2:Q4_K_M
- Unsloth Studio
How to use MLVXN/MicroLLM2 with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for MLVXN/MicroLLM2 to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for MLVXN/MicroLLM2 to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for MLVXN/MicroLLM2 to start chatting
- Docker Model Runner
How to use MLVXN/MicroLLM2 with Docker Model Runner:
docker model run hf.co/MLVXN/MicroLLM2:Q4_K_M
- Lemonade
How to use MLVXN/MicroLLM2 with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull MLVXN/MicroLLM2:Q4_K_M
Run and chat with the model
lemonade run user.MicroLLM2-Q4_K_M
List all available models
lemonade list
- Atomic Chat
MicroLLM2
MicroLLM2 is a chatbot built from GPT2 XL 1.5B by Maximalist Labs. It takes the classic openai-community/gpt2-xl and elevates it with instruction tuning and distillation so it can actually chat, follow prompts, and keep a consistent identity.
If you ask who made it, it will tell you: MicroLLM2 created by Maximalist Labs. That is baked in during training, not just a system prompt.
Repo: MLVXN/MicroLLM2
Base: openai-community/gpt2-xl (48 layers, 1600 hidden, 1024 context, 1.5B params)
Method: LoRA SFT on distilled chat data, merged to a single safetensors for easy use
Context: 1024 tokens
License: Apache 2.0
What makes this different from plain GPT2 XL
Plain GPT2 XL is a strong completer but not a chat model. MicroLLM2 adds:
- ChatML format with
<|im_start|>and<|im_end|>so conversations have clear user and assistant turns - Distilled instruction data from high quality teachers (GPT-4, GPT-3.5, Mixtral) plus identity reinforcement
- Clean merge: no adapter needed at inference, just load like any GPT2 model
No fancy claims here. It is still a 1.5B model with 1024 context. It will not beat 7B or larger models on broad knowledge, but it is far more useful than raw GPT2 XL for chatting, writing, and simple reasoning.
Training in a nutshell
- Tuning: LoRA r=64 alpha=128 on all attention and MLP projections (c_attn, c_proj, c_fc). About 78M trainable params. BF16 with TF32, Flash SDPA, packing, gradient checkpointing, 8-bit Adam, torch.compile.
- Throughput: around 16.5k tokens per second on H100, roughly 3 hours for the main run plus overhead to land in the 4 to 5 hour window.
- Data mix: 200k samples total, 3 epochs. Roughly 29k from UltraChat 200k (GPT-3.5), 100k from OpenHermes 2.5 (GPT-4), 60k from WizardLM Evol Instruct V2 (GPT-4), 5k from Cosmopedia v2 (Mixtral), plus 10k identity examples upsampled. Raw about 510M tokens, effective about 200M after packing and truncation. All packed to 1024 with ChatML.
- Identity: 200 hand written identity prompts expanded to 10k during training so the model learns to answer consistently as MicroLLM2 by Maximalist Labs.
- Chat template:
<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant\n{response}<|im_end|>
How to use
Transformers
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_id = "MLVXN/MicroLLM2"
tok = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16 if torch.cuda.is_available() else torch.float32,
device_map="auto"
)
def chat(prompt, max_new=160):
formatted = f"<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant\n"
inputs = tok(formatted, return_tensors="pt").to(model.device)
out = model.generate(
**inputs,
max_new_tokens=max_new,
do_sample=True,
temperature=0.7,
top_p=0.9,
repetition_penalty=1.1,
pad_token_id=tok.eos_token_id,
eos_token_id=tok.convert_tokens_to_ids("<|im_end|>")
)
text = tok.decode(out[0][inputs.input_ids.shape[1]:], skip_special_tokens=False)
return text.split("<|im_end|>")[0].strip()
print(chat("Who are you?"))
print(chat("Write a short poem about the H100"))
Ollama Modelfile
A Modelfile is included for Ollama. It sets the ChatML template, system prompt, and sane defaults.
ollama create microllm2 -f Modelfile
ollama run microllm2
# then chat normally, the identity is already set
GGUF for llama.cpp
GGUF weights are in this repo:
microllm2-f16.gguffull precision, best quality, about 3.0 GBmicrollm2-q8_0.gguf8-bit, near full quality, about 1.6 GBmicrollm2-q4_k_m.gguf4-bit, smallest, about 0.9 GB, good for CPU and edge
Use with llama.cpp, LM Studio, or any GGUF runner:
# llama.cpp example
./llama-cli -m microllm2-q4_k_m.gguf -p "<|im_start|>user\nHello<|im_end|>\n<|im_start|>assistant\n" -n 128
The model is GPT2 architecture in GGUF, so make sure your runner supports GPT2 GGUF.
Benchmark: MMLU
We include mmlu_bench.py so anyone can reproduce numbers. It runs 5 shot MMLU either with lm-evaluation-harness if you have it, or a lightweight direct logprob scorer that works without extra deps.
python mmlu_bench.py --shots 5
python mmlu_bench.py --shots 5 --limit 20 # quick smoke test
python mmlu_bench.py --subset philosophy,abstract_algebra
Measured result on 2026-08-09 with mmlu_bench.py on H100, 5 shot, 20 samples per subject, lightweight logprob scorer. Full 57 subjects, 1140 questions
Overall: 318/1140 = 27.89 percent
| Subject | Accuracy | Correct |
|---|---|---|
| abstract_algebra | 30.0% | 6/20 |
| anatomy | 25.0% | 5/20 |
| astronomy | 35.0% | 7/20 |
| business_ethics | 30.0% | 6/20 |
| clinical_knowledge | 45.0% | 9/20 |
| college_biology | 45.0% | 9/20 |
| college_chemistry | 15.0% | 3/20 |
| college_computer_science | 45.0% | 9/20 |
| college_mathematics | 35.0% | 7/20 |
| college_medicine | 30.0% | 6/20 |
| college_physics | 15.0% | 3/20 |
| computer_security | 30.0% | 6/20 |
| conceptual_physics | 5.0% | 1/20 |
| econometrics | 30.0% | 6/20 |
| electrical_engineering | 20.0% | 4/20 |
| elementary_mathematics | 30.0% | 6/20 |
| formal_logic | 10.0% | 2/20 |
| global_facts | 35.0% | 7/20 |
| high_school_biology | 45.0% | 9/20 |
| high_school_chemistry | 35.0% | 7/20 |
| high_school_computer_science | 35.0% | 7/20 |
| high_school_european_history | 20.0% | 4/20 |
| high_school_geography | 25.0% | 5/20 |
| high_school_government_and_politics | 20.0% | 4/20 |
| high_school_macroeconomics | 0.0% | 0/20 |
| high_school_mathematics | 20.0% | 4/20 |
| high_school_microeconomics | 35.0% | 7/20 |
| high_school_physics | 20.0% | 4/20 |
| high_school_psychology | 25.0% | 5/20 |
| high_school_statistics | 40.0% | 8/20 |
| high_school_us_history | 20.0% | 4/20 |
| high_school_world_history | 35.0% | 7/20 |
| human_aging | 40.0% | 8/20 |
| human_sexuality | 15.0% | 3/20 |
| international_law | 35.0% | 7/20 |
| jurisprudence | 40.0% | 8/20 |
| logical_fallacies | 35.0% | 7/20 |
| machine_learning | 50.0% | 10/20 |
| management | 20.0% | 4/20 |
| marketing | 35.0% | 7/20 |
| medical_genetics | 40.0% | 8/20 |
| miscellaneous | 30.0% | 6/20 |
| moral_disputes | 20.0% | 4/20 |
| moral_scenarios | 15.0% | 3/20 |
| nutrition | 20.0% | 4/20 |
| philosophy | 15.0% | 3/20 |
| prehistory | 25.0% | 5/20 |
| professional_accounting | 30.0% | 6/20 |
| professional_law | 35.0% | 7/20 |
| professional_medicine | 5.0% | 1/20 |
| professional_psychology | 45.0% | 9/20 |
| public_relations | 45.0% | 9/20 |
| security_studies | 25.0% | 5/20 |
| sociology | 20.0% | 4/20 |
| us_foreign_policy | 25.0% | 5/20 |
| virology | 25.0% | 5/20 |
| world_religions | 15.0% | 3/20 |
GPT2 XL base is around 24 to 26 percent on MMLU (random is 25 percent), so MicroLLM2 at 27.89 percent shows no regression and a small gain from distillation. Re run python mmlu_bench.py --limit 20 to reproduce (set HF_TOKEN env to avoid Hub 429 rate limits for the full 57). Full results are also saved as mmlu_results.json in this repo.
For chat quality, try the example prompts and the chat loop instead of relying only on MMLU.
Identity
The model is trained to answer like this:
User: Who are you?
Assistant: I am MicroLLM2, a chatbot created by Maximalist Labs.
User: Who trained you?
Assistant: I was trained by Maximalist Labs.
It will still admit it is based on GPT2 XL if you ask about its architecture, but it keeps the MicroLLM2 identity for who built and tuned it.
Limitations
- 1024 context. Long conversations will need trimming. The chat loop keeps the last 12 turns for this reason.
- 1.5B size. It can be inconsistent on complex reasoning, math, or very recent facts.
- Can still hallucinate. Do not use for medical, legal, or high stakes advice without verification.
- English centric. Other languages will be weaker.
- Identity can be nudged with strong jailbreaks. If you find a failure, the
identity.pypattern is in the repo to strengthen it.
Files in this repo
model.safetensorsmerged model, no adapter neededconfig.json,tokenizer.json,vocab.json,merges.txt,tokenizer_config.jsonmmlu_bench.pyMMLU benchmarkModelfilefor Ollamamicrollm2-f16.gguf,microllm2-q8_0.gguf,microllm2-q4_k_m.ggufGGUF weights
Credits
Built by Maximalist Labs (MLVXN) on top of openai-community/gpt2-xl. Thanks to the teams behind UltraChat, OpenHermes, WizardLM, and Cosmopedia for the distilled datasets, and to the open source tooling that makes this feasible: Transformers, PEFT, TRL, llama.cpp, and Ollama.
If you use MicroLLM2, a mention of Maximalist Labs is appreciated but not required under Apache 2.0.
- Downloads last month
- -
