Skip to content

Olmicro Behind a Script

Chapter 2's verdict was that a base model has no conversation manners. Chapter 5 showed the workaround for a human at a keyboard: few-shot examples and a firm stop. This chapter is the same idea with the human replaced by a program — and it is, in the lab's judgement, the most useful way to run Olmicro at all. A script supplies everything the base model lacks: the pattern, the stop condition, the checking of the result, and the decision about what happens when the result is nonsense.

The shape of every such job

your program
  ├─ builds a prompt: fixed examples + the new input
  ├─ runs the model, greedy, short output limit
  ├─ cuts the output at the stop marker
  ├─ validates it (a date? one of the allowed labels?)
  └─ uses it, or falls back to a safe default

Nothing in that list is new — it is chapter 5's skeleton with the cutting and checking done by code instead of eyeballs. Two properties make it work better than the interactive version:

  • Greedy decoding makes it a function. Same input, same output, every run. A script can be tested against yesterday's inputs and expected outputs like any other code. (Every transcript in this guide used greedy decoding for exactly this reason.)
  • Validation makes failure cheap. The chapter 5 classification that answered "sports" for a council story is a shrug at a keyboard. Inside a script, "is the answer one of the labels I defined?" is one line of code, and a failed check routes to a default instead of into your data.

Jobs that fit

Extraction from text you already have. Dates, names, reference numbers out of emails, letters, logs — the chapter 5 exercise, run over a folder instead of one sentence. The output is copied from the input, which keeps invention on a short leash, and a script can verify the extracted string actually appears in the source.

First-pass classification and sorting. Headlines, support messages, downloaded documents into a handful of buckets — with the chapter 5 lesson applied: a label set that covers the world, an other bucket, and code that rejects anything outside the set.

Summaries of things too long to read. Which brings us to the reason Olmicro specifically, rather than any small base model, earns this chapter.

The long-document trick

Summarising a long document with a small model usually dies on memory: the KV cache for tens of thousands of tokens can exceed the model itself (chapter 1). Olmicro's hybrid design caps that cost. From the model card's own table, the KV cache per token at 16-bit precision:

Model KV cache per token Cache at 65,536 tokens
Olmicro 275M 8 KiB 0.5 GiB
Olmicro 1.4B 16 KiB 1.0 GiB
Olmicro 2.7B 24 KiB 1.5 GiB
Llama 3.2 3B (all-attention, for contrast) — ≈7.0 GiB

So the 2.7B can hold a full 64K-token document — a long report, a book chapter, a fat log file — in about 1.5 GiB of context memory, on top of roughly 5.4 GB of weights at full precision (about half that quantised, when quantised builds exist). That is laptop territory, and small-server territory, for a job that would otherwise want a much larger machine or a cloud API.

Two honest qualifications. First, holding a document is not the same as understanding all of it: Ai2's own long-context results show Olmicro performing comparably to similar base models, ahead on long-document question answering, behind some newer hybrids on aggregate scores. Second, this guide's lab machine ran the 275M on short prompts; the 64K figures are Ai2's published arithmetic — checked against the model card's per-token numbers, which agree — and are documented, not lab-measured. The exercise below is written so you can measure it on your own machine.

The exercise. Take a long text you own — a manual, a project README collection, an exported log. Few-shot the model with two short passage→summary examples, then feed it a passage of a few thousand tokens and a hard output limit, and read the summary against the passage yourself. Grow the passage size until your machine complains; note where that was. That number, on your hardware, is the real content of this section.

The small sizes on small computers

The 275M and 450M are the size class of models that run on a single-board computer or a old laptop with no graphics card — slowly (the lab's shared CPU box managed 3–5 tokens a second at 275M), but usefully for jobs that are not conversations: a nightly script that reads the day's downloads and files them, a sorter that runs while nobody is waiting. Speed stops mattering when the reader is a cron job. What matters is that the whole thing — model, script, data — never leaves the machine, costs nothing per run, and behaves identically every night. A base model behind a script is not a worse chatbot. It is a component.

Check: olmicro-lab/t03_few_shot.py is the interactive version of this chapter's pattern. Wrapping its extraction example in a loop over a folder of text files, with a check that the extracted date appears in the file, is the whole step from exercise to tool — the lab leaves it as the reader's first build.