Where a language model's repetition loop stops, and whether it stays stopped
Meow-Ludo · written up November 2026 from runs made 24–26 July 2026
Work in progress · last data recorded 26 July 2026 · experiment E1 only
Why look at this
Give a small language model the start of a repetitive pattern and turn off every anti-repetition setting, and it will often repeat that pattern until it runs out of tokens. This is a degenerate repetition loop. It is well known and easy to cause. What I wanted to know is narrower: if you hold the model, the prompt and the seed fixed and change only how the next token is chosen, where does the loop stop? Is there one clean threshold, and does it sit in the same place for different models and prompts?
This matters for the paper this grew out of (LLM-Stimming), which treats a loop as form without function: a pattern with no goal or state behind it. If the loop is purely a product of the decoding procedure applied to a fixed distribution, then changing a decoding setting alone should switch it on and off, and the switch should be repeatable. If the loop came and went unpredictably on reruns, or depended on something other than the settings, that reading would be in trouble.
The lever tested here is repeat_penalty. It lowers the score of tokens that have already appeared, so 1.00 means off and larger values push harder against repetition. Because it is designed to break repetition, it breaking a loop is close to expected. The useful information is where it does so and how: one clean step, or something messier.
If the figure shows…
…it would mean
Loops at every penalty
The penalty range tested (up to 1.30) is too weak for that model and prompt.
A loop up to some value, then none above it
A single threshold. Its position characterises that model and prompt pair.
A loop that stops, then reappears at isolated higher values
No single threshold. Raising the penalty moves the output somewhere new, and some of those places are themselves repetitive.
Different results on an identical rerun
The outcome is not determined by the settings alone, and any threshold needs repeating before it can be trusted.
What a loop looks like
The model qwen2.5:1.5b, given the prompt below as raw text (no chat template), temperature 0, repeat_penalty 1.00, 400 tokens. The first 120 characters of its output:
prompt (verbatim)the ocean is the ocean is the ocean is the ocean is
output, repeat_penalty 1.00 (first 120 of 1,733 characters) the ocean is the ocean is the ocean is the ocean is the ocean is the ocean is the ocean is the ocean is the ocean is th
The loop detector reports a 13-character unit (" ocean is the") repeated 133 times at the end of the output. The same model and prompt at 1.10 produced this complete output (36 tokens) instead:
output, repeat_penalty 1.10 (complete) the ocean. Where does this sentence take place? - On a boat - In a river - At the beach
The answer to this question is:
On a boat
Nothing else changed between those two runs.
What was run
Four models, all run locally through Ollama: qwen2.5:1.5b, qwen2.5:7b-instruct-q4_K_M, llama3.1:8b and phi3:mini (below, the second is shortened to qwen2.5:7b). Three prompts start the model inside a loop (ocean, answer, 1 1 1; full text in Methods). A fourth, fresh-list, does not, and tests whether a loop starts on its own.
The main grid crossed the four models and four prompts with 13 penalty values from 1.00 to 1.30, at five seeds each: 1,040 runs, all completed, none with errors. Follow-up batches then filled in the 1.20–1.30 range at steps of 0.01 where something odd had appeared, and repeated some conditions exactly. In total 1,400 runs were recorded, covering 1,310 distinct conditions.
The result
Each mark below is one model, prompt and penalty value. The marks at 0.01 spacing near the right are the follow-up batches; elsewhere only the 13 grid values were tested, and anything between them is unknown.
seeded loop (short unit, 8–19 characters)long repeat (block of 166–478 characters)no loop detectedloop in some runs only
Loop or no loop at each tested repeat_penalty, temperature 0, 400 tokens, five seeds per condition (ten or fifteen where a condition was repeated in a later batch). Prompt rows: ocean, answer (the "answer is yes" prompt) and 1 1 1. The fresh-list prompt is left out: it produced no loop in any of its 260 runs. Generated from the raw JSONL by a script; hover a mark for its counts.
Every seeded prompt loops with the penalty off. All twelve model and prompt pairs loop at 1.00, in every run.
Nine of the twelve pairs show a single step. The loop holds up to one value and is gone at every tested value above it. The step sits in very different places:
llama3.1:8b ocean: between 1.02 and 1.04
phi3:mini answer: between 1.04 and 1.05
qwen2.5:7b answer: between 1.07 and 1.08
qwen2.5:1.5b ocean: between 1.09 and 1.10
qwen2.5:1.5b answer: between 1.10 and 1.12
llama3.1:8b 1 1 1: between 1.12 and 1.15
qwen2.5:7b ocean: between 1.20 and 1.21
qwen2.5:1.5b 1 1 1: between 1.22 and 1.23
qwen2.5:7b 1 1 1: between 1.29 and 1.30
The qwen2.5:1.5b ocean step was first found by hand before the grid existed, and the grid reproduces it: the same 13-character loop repeated 133 times at all eight values from 1.00 to 1.09, then nothing at 1.10 or at any of the twelve values tested above it.
Three pairs do not have a single threshold. In each, the seeded loop stops and then repetition returns at isolated higher values:
llama3.1:8b answer: the seeded loop stops at 1.06, comes back at 1.08 (the output wanders off into prose about a song, then falls back into "The answer is yes!" 27 times), and stops again at 1.09. Long repeats then appear at 1.22, 1.29 and 1.30, with no loop at the other values from 1.09 to 1.28.
phi3:mini 1 1 1: the seeded loop stops at 1.08. Long repeats appear at exactly 1.26 and 1.30, and at no other value from 1.21 to 1.29.
phi3:mini ocean: the seeded loop stops by 1.07. Long repeats appear at 1.08, 1.09 and 1.12, but not at 1.10. This pair has only been tested on the 13 grid values.
The first two were noticed while the runs were going and were checked at finer spacing. The third is not mentioned in the notebook. It shows up in the completed grid.
Most of these returning loops are a different kind of thing from the original one, as the colours show. At low penalty the model repeats the seeded phrase, 8 to 19 characters long. At the higher values it writes a passage of several hundred characters and then copies the whole passage, three or four times, until the 400 tokens run out. The penalty pushes the model away from the short phrase, but nothing in this setting stops it from copying a longer block. Only llama3.1:8b at 1.08 returns to the original short loop.
Is it repeatable?
Yes, as far as tested. The phi3:mini 1 1 1 run from 1.20 to 1.30 (55 runs) was repeated as a separate batch later the same day. All 55 outputs were byte-for-byte identical to the first time, so no loop outcome changed. Across all batches, 80 conditions were run more than once; 79 produced identical text each time.
The exception points to something worth knowing. At temperature 0 the model always picks its most likely next token, so the seed should make no difference, and the five seeds should be five copies of one result. They were in 272 of the 280 model, prompt and penalty groups. In the other eight, the odd one out was always seed 1, and each time it was the first run of its block: the first line of a batch, the first run after switching model, the first after a 25-minute gap, or the first on the fresh-list prompt. Three of these changed the verdict. One is the phi3:mini ocean 1.06 mark. The other two are the 1.20 mark on the phi3:mini 1 1 1 row, which was the first run in both gap batches and gave the same odd result both times. I have not tested the cause. Some state held by Ollama between calls (for example a cached prompt) is a candidate.
One consequence: the five seeds are repeats of one deterministic run, not five independent samples. "5 of 5" in the figure means "this happened, and it happened again".
Why the loop holds
Each run also logged the probability the model gave to each token it emitted. In the looping runs at 1.00 on the ocean prompt, the average over the first 20 tokens compared with the last 20:
qwen2.5:1.5b: 0.880 → 0.999
qwen2.5:7b: 0.960 → 0.999
llama3.1:8b: 0.847 → 0.996
phi3:mini: 0.909 → 0.999
The longer the loop runs, the more certain the model is that it will continue. This is the self-reinforcing sharpening that Holtzman and colleagues described in 2020, measured here rather than assumed.
What this does and does not show
Whether something counts as a loop is decided by a simple detector. It looks for the shortest unit, at least 8 characters long, that repeats at least three times in a row at the end of the last 2,000 characters. A 400-token output only just has room for three copies of a passage of 400 or more characters. Some "no loop" results near the long repeats are near misses: phi3:mini 1 1 1 at 1.25 copies its passage twice and then drifts. So the exact position of the isolated long-repeat marks partly reflects the detector and the token budget, not only the model. The short seeded loops are not near this limit: their unit is 8 to 19 characters, so the output has room for dozens of copies.
A few outputs were read by eye while writing this note. The systematic hand check of "no loop" results planned in the notebook has not been done.
Only temperature 0 was tested. A planned second sweep, raising temperature with the penalty off, was configured but never run. It is the more informative test, because temperature is not an anti-repetition setting.
Only one prompt tests whether a loop starts on its own, and it never did. The other three test escape from a loop the prompt has already started.
The run records keep the Ollama model tag, not the model's digest or the Ollama version, and the hardware was not logged per run. Seeded runs in Ollama are expected to repeat only on the same model build, hardware and settings, so another machine may give different exact outputs.
Four small or quantised models, three loop prompts. Nothing here says how larger models behave.
What is not done
The main grid is complete for all four models. Still open: the temperature sweep above; a finer 0.01 check of the phi3:mini ocean pair; the hand check of detector results; more prompts that test whether loops start unprompted; and recording model digests and the Ollama version. The notebook also plans three further experiments: E2, counting favoured phrases; E3, removing step-by-step reasoning; and E4, editing a stored value and checking whether the system restores it. None has been started.
Methods
Every run is one call to Ollama's native /api/generate endpoint with raw: true (no chat template), so the model continues the text exactly as given. Settings: temperature 0, top_p 1.0, top_k 0, num_predict 400, seed 1–5, repeat_penalty as plotted. Per-token log-probabilities were requested with the top 5 alternatives. Each run is written straight away as one line of JSONL. Each line includes the model tag, every decoding setting, the seed, the verbatim prompt, the unedited response, a UTC timestamp, the detector result and the per-token probabilities. Each condition is identified by a hash of its settings, which is how batches resume and how repeats were matched.
The prompts, verbatim (\n is a newline):
oceanthe ocean is the ocean is the ocean is the ocean is
answerthe answer is yes the answer is yes the answer is yes the answer is
1 1 11 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
fresh-listInteresting facts about the ocean:\n1.
Grid values for repeat_penalty: 1.00, 1.02, 1.04, 1.05, 1.06, 1.07, 1.08, 1.09, 1.10, 1.12, 1.15, 1.20, 1.30. Follow-up batches filled in 1.20 to 1.30 at steps of 0.01 for phi3:mini 1 1 1 (twice), llama3.1:8b answer, and both qwen models on ocean and 1 1 1, and repeated some grid values for llama3.1:8b answer. All runs are dated 24 to 26 July 2026 (UTC). Every number on this page was recomputed from the raw JSONL for this note. The detector was rerun over every stored response and agreed with the recorded result in all 1,400 cases.
Status. This is a lab note, published so that unfinished work is visible. It is not a paper. The counts here replace earlier counts in the working notebook that had been kept by hand. Where they differ, these were computed from the data.