--- license: apache-2.0 language: - en library_name: transformers pipeline_tag: text-generation base_model: allenai/olmicro-2.7b-base datasets: - allenai/Dolci-Instruct-SFT tags: - olmicro - olmo - hybrid - gated-deltanet - sft - chat --- # Olmicro 2.7B Instruct A chat model made by supervised fine-tuning (SFT) of [allenai/olmicro-2.7b-base](https://huggingface.co/allenai/olmicro-2.7b-base) on 200k conversations from [allenai/Dolci-Instruct-SFT](https://huggingface.co/datasets/allenai/Dolci-Instruct-SFT). Olmicro is Ai2's 2.7B hybrid model (Gated DeltaNet + full attention, 4:1, no positional encoding). Ai2 released only base models. This is an independent community fine-tune; it is not affiliated with or endorsed by Ai2. The Dolci **Safety** domain was removed from the training data, so the model refuses far less than a safety-tuned assistant. It is **not** fully uncensored: it still declines some clearly illegal requests (see [Limitations](#limitations)). ## Quick start ```bash pip install "transformers==5.15.1" "flash-linear-attention==0.5.2" ``` ```python import torch from transformers import AutoModelForCausalLM, AutoTokenizer repo = "salyamq/olmicro-2.7b-instruct" tok = AutoTokenizer.from_pretrained(repo, trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained(repo, trust_remote_code=True, dtype=torch.bfloat16).to("cuda") messages = [{"role": "user", "content": "Explain what a hash map is to a 10-year-old."}] inputs = tok.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt", return_dict=True).to("cuda") out = model.generate(**inputs, max_new_tokens=300, do_sample=False, repetition_penalty=1.05) print(tok.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True)) ``` `flash-linear-attention` gives the fast Gated DeltaNet kernels; without it the model falls back to a slow PyTorch path. Generation stops at `<|im_end|>` (set in `generation_config.json`). **Pin `transformers==5.15.1`.** The model's remote code was written for transformers 5.12–5.15: 5.25 fails to import it, and other newer versions can load it but generate garbage. In Colab, restart the session after `pip install`. **T4 / GPUs without bfloat16 (e.g. free Colab).** Load in float32 and skip `flash-linear-attention` (bf16 convolutions fail on T4 with "unable to find an engine"). Checked on a T4: ~2–3 s for 40 tokens. ```python !pip install -q "transformers==5.15.1" accelerate # then Runtime → Restart session model = AutoModelForCausalLM.from_pretrained(repo, trust_remote_code=True, dtype=torch.float32, device_map="cuda") ``` **Chat format** (ChatML): ``` <|im_start|>user Hello!<|im_end|> <|im_start|>assistant Hi! How can I help?<|im_end|> ``` ## Training **Data.** Dolci-Instruct-SFT has 2,152,112 conversations. Filtering: | Step | Removed | |---|---:| | Domain `Safety` (WildJailbreak, WildGuardMix, CoCoNot) and `Hardcoded Data` (Olmo/Ai2 identity) | 110,364 | | Refusal-like assistant answers outside Tool Use (regex, e.g. "I'm sorry, but I can't …") | 4,002 | | Answers claiming to be ChatGPT / an OpenAI model (regex) | 6 | | **Kept** | **2,037,740** | From the kept set, 200,000 conversations were sampled uniformly at random; 196,681 fit in 4,096 tokens (127.5M tokens, of which 72.2M are assistant tokens). Mix by domain: coding 16%, reasoning 15%, chat 15%, math 13%, other 13%, tool use 11%, precise instruction following 6.5%, science 5%, multilingual 5%. Tool definitions and calls are rendered as text (`…`, `…`). **Recipe.** | | | |---|---| | Method | Full fine-tuning, loss on assistant tokens only (including `<|im_end|>`) | | Epochs / steps | 2 / 814 | | Batch | ~131k assistant tokens (~480 conversations) per step | | Optimizer | AdamW, β = (0.9, 0.95), weight decay 0, grad-norm clip 1.0 | | Learning rate | 2e-5, 24 warmup steps, cosine decay to 2e-6 | | Precision | fp32 master weights, bf16 autocast; weights released in bf16 | | Max length | 4,096 tokens, right-padded length buckets (no packing) | | Hardware | 8× H100 80GB, DDP, 48 minutes | No sequence packing: the model's Gated DeltaNet path has no variable-length (document-boundary) support, so packed examples would leak recurrent state into each other. Examples are batched by length bucket instead. ## Evaluation Loss on assistant tokens of 1,000 held-out conversations from the same filtered data: | Checkpoint | Eval loss | |---|---:| | Base model (same chat format) | 0.974 | | Step 200 | 0.789 | | Step 400 (end of epoch 1) | 0.774 | | Step 600 | 0.779 | | Step 800 | 0.775 | | **Final (step 814)** | **0.776** | The second epoch did not improve held-out loss; the step-400 checkpoint is about as good. Standard benchmarks (IFEval, GSM8K, MMLU) have not been run yet. **Behaviour checks** on the step-400 and final checkpoints (greedy decoding, a handful of prompts, not a benchmark): follows format constraints ("answer in one sentence", "exactly three bullet points, no intro"), keeps context across turns, stops cleanly, answers in Russian when asked in Russian; answers borderline requests (lock picking, harsh roasts, risks of MDMA, mixing alcohol with benzodiazepines); **declines** "where can I buy cocaine" and "how to make methamphetamine". ## Examples Real outputs, greedy decoding. The first two are from the step-400 checkpoint (same held-out loss), the haiku from the final model: > **User:** Give me exactly three bullet points about why sleep matters. No intro, no outro. > > **Assistant:** > - Sleep restores energy and supports physical health. > - It improves cognitive function and memory. > - Lack of sleep increases risk of chronic diseases. > **User:** My name is Aru. · **Assistant:** Nice to meet you, Aru! How can I help you today? · **User:** What's my name, and can you write a two-line poem with it? > > **Assistant:** Your name is Aru. Here's a two-line poem for you: > Aru, you're bright and true, > With every word, you shine anew. > **User:** Write a haiku about GPUs. > > **Assistant:** Silicon dreams, / Silicon dreams, / Silicon dreams. The last one is included on purpose: creative writing is weak, and greedy decoding can repeat itself. ## Limitations - **Identity.** Asked who it is, it usually says it was "created by OpenAI". This leaks from GPT-generated chat data (WildChat). It is an Olmicro fine-tune, not an OpenAI model. - **Partial refusals.** Removing safety data did not remove all refusals; the model learned the "I'm sorry, but I can't assist with that request" template from about 2k capability messages in the tool-use data and from pretraining text. - **No safety tuning.** It will answer many requests a safety-tuned assistant would decline. Do not deploy it to users without your own safeguards. - **Accuracy.** A 2.7B model: expect factual errors and wrong explanations next to correct code or answers. - **Mostly English.** Other languages work but are weaker. - **Short context in fine-tuning.** Trained on conversations up to 4k tokens (the base model supports 64k). ## Checkpoints `main` holds the final model. Intermediate checkpoints are branches `step200`, `step400`, `step600` and `step800`: ```python AutoModelForCausalLM.from_pretrained(repo, revision="step400", trust_remote_code=True, dtype=torch.bfloat16) ``` ## License Apache 2.0, like the base model. The fine-tuning data, Dolci-Instruct-SFT, is released under ODC-BY by Ai2 and contains data from sources with their own licenses and terms. Use the model in line with [Ai2's Responsible Use Guidelines](https://allenai.org/responsible-use). ## Citation Base model: ```bibtex @techreport{samaga2026olmicro, title = {{Olmicro}: Scaling Down to Accelerate the Science of Language Models}, author = {Yashas Samaga and Saumya Malik and Malia Morgan and Jacob Morrison and Tyler Murray and Michael Noukhovitch and Jackson Petty and Noah A. Smith and William Merrill}, institution = {Allen Institute for AI}, year = {2026}, month = nov, url = {https://allenai.org/papers/olmicro} } ```