Repository navigation
Measure strength against generated tokens; one BOS per prompt - #13
Merged
Merged
Conversation
The degeneration detector split on spaces only, so loops like "sau-sau-sau-..." (Mistral-7B) and "tss-tss-tss-..." (OLMo-2) counted as one long word and got through. Mistral's tokenizer needs sentencepiece and protobuf to load. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
residual_norm averaged the calibration prompt's positions, which include attention-sink tokens with norms hundreds of times the usual (14,411 against ~70 on Qwen2.5-7B). The strength scale was off by a different factor on each model: 6.4x on Qwen2.5-7B, 1.7x on Llama-3.1-8B. It is now the median norm over an unsteered greedy reply, and strength 15 (FULL_TOKEN_STRENGTH) is a push as large as that norm. 15 keeps Qwen2.5-7B's strengths within ~1% of before; on Llama-3.1-8B each unit is 3.7x what it was. With the new scale, steered output breaks down at about strength 13-17 on Qwen2.5-7B, Llama-3.1-8B, OLMo-2-7B and Mistral-7B-v0.3 (11 starter vectors each), so MAX_STRENGTH and the default ranges hold across those families. Rendered chat templates already contain the model's special tokens, so prompts are now tokenized without adding them again (Llama-3 and Mistral got a second BOS, which was another attention sink). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
residual_normaveraged the calibration prompt's positions, and those include attention-sink tokens whose norms are hundreds of times the usual: 14,411 against ~70 on Qwen2.5-7B. So the strength scale was off by a different factor on each model, 6.4× on Qwen2.5-7B and 1.7× on Llama-3.1-8B. The same strength number meant a very different push on each, and withMAX_STRENGTH15, Llama could never be steered harder than about a quarter of the useful range.What changed
residual_normis now the median norm over an unsteered greedy reply (48 tokens) to the calibration prompt. Strength 15 (FULL_TOKEN_STRENGTH) is a push as large as that norm. 15 was chosen so Qwen2.5-7B's strengths keep their meaning (one unit is ×1.01 the old push). Existing ranges,MAX_STRENGTHand the verifiedassistant_axisrange stay valid. On Llama-3.1-8B, one unit is now ×3.70 the old push.modulo.chat.encode()without adding them again. Llama-3 and Mistral used to get a second BOS, which was another attention sink. Llama vectors extracted before this are worth re-extracting.sentencepieceandprotobufare added, because Mistral's tokenizer needs them.full_token_strengthwith the other rail settings.Evidence (RTX 4090)
I swept the 11 starter vectors on each model: 4 prompts per vector, pushes in both directions, greedy decoding, 80 tokens. "Breaks down" means mean unsteered NLL above 2, a repetition loop, or very low word diversity. That's cautious: samples often stay readable a step further.
So
MAX_STRENGTH15 sits near the breakdown point on all four families, and the default ranges (±10 for starters, ±8 for imports) stay inside the coherent region. I also tried measuring strength in units of each vector's own natural spread along its axis. It was less consistent, both across vectors and across models.Tests
🤖 Generated with Claude Code