Lion Cipher Lab

Write your own softmax, temperature, top-k, top-p and seeded sampler in plain Python, point them at an alert-severity pipeline whose answers you already know, and find out that the log-probability of the label it emitted is a real confidence number while the "confidence: 0.90" it writes about itself is a generated string

Why it matters

Every team that puts a language model into a detection pipeline meets the same two problems in the same order, and almost nobody meets them on purpose. The first is that the pipeline gives a different answer on Tuesday than it gave on Monday, on a log line that did not change - which means the daily diff is noise, the on-call analyst stops reading it, and the audit trail says nothing about why an alert was closed. The second is that somebody needs a confidence number to route work by, so the prompt is amended to end with 'and state your confidence from 0 to 1', and from that day forward a…

What you'll learn

Steps in this lab

  1. The words first: logit, softmax, temperature, top-k, top-p, greedy, seed, log-probability, Brier score, calibration error - and the fact that the model here is a stub
  2. Open a terminal and make a scratch folder (all three operating systems)
  3. The corpus: 900 alerts whose correct severity you already know
  4. Write the decoder from scratch: softmax, temperature, top-k, top-p, greedy and a seeded sampler
  5. The model is a STUB, and here is its entire error model in writing
  6. The pipeline: one alert in, one structured verdict out - and three ways to score it without sampling
  7. Decode one alert with every intermediate number on screen
  8. The measurement that gets a pipeline distrusted: 337 of 600 rows changed between two identical runs
  9. What top-k and top-p actually buy, and the place top-p is weakest
  10. The punchline: a logprob is a measurement, a self-reported confidence is a string
  11. The bias nobody mentions: an un-normalised sequence logprob quietly prefers short labels
  12. Testing the folklore: does sampling several times and voting beat one greedy decode?
  13. Temperature 0 is not a promise of a bit-identical answer, and here is how far from one it actually is
  14. When to reach for each of these, when not to, and the way a pro sets it up
  15. Ship it: the decoder configuration to run in a detection pipeline, and what to write down

Open the full interactive lab →