LLM に話させず、内部状態を直接プローブせよ(8 分読了)
LLM が生成を開始する前に内部状態に判断結果が存在するという洞察に基づき、生成コストを排除してプロンプト内の基準だけで汎用分類器として動作させる「プローブ」手法の提案である。
キーポイント
生成前の意思決定メカニズム
LLM が「基準を満たすか?」という質問に回答する際、トークンを生成する前に内部の残差ストリーム(residual stream)で既に比較と判断が完了していることを示唆。
生成をスキップした効率的な分類
最後のプロンプトトークンの隠れ状態(hidden state)を抽出し、小さな MLP や線形プローブに渡すことで、テキスト生成の遅延とコストを排除して即座に判断を得る手法。
自然言語による汎用分類器の実現
モデル自体は凍結(frozen)されたまま、プロンプト内の英語で記述された基準(criterion)を解釈させることで、任意の分類タスクをゼロショットで実行可能にする。
従来の手法との比較優位性
エンベディングでは捉えにくい構造的・文脈的な判断や、LLM 判定(judge)における低速・高コスト・確信度の曖昧さといった課題を解決する代替案として提案されている。
影響分析・編集コメントを表示
影響分析
このアプローチは、LLM の内部状態を直接利用することで推論コストとレイテンシを大幅に削減し、大規模なテキスト分析タスクにおける実用性を劇的に高める可能性があります。特に、複雑な文脈や構造的な判断が必要なビジネスユースケースにおいて、高価な生成モデルへの依存から脱却する新たなパラダイムを提供します。
編集コメント
生成コストを削減しつつ精度を維持する画期的な技術的洞察であり、実務における LLM 活用戦略の転換点となる重要な知見です。
TL;DR: LLM が「ここにテキストがあります、ここに基準があります—これを満たしていますか?」と読むとき、回答は単一のトークンを生成する前にもうその隠れ状態に存在しています。したがって生成を完全にスキップし、最後のプロンプトトークン(モデルの層の約 70% の位置)での隠れ状態を取得し、それを小さな MLP に渡し、出力を較正します。トレーニングデータが基準を変化させるため、英語で書けるあらゆる分類器として機能する一つの凍結されたモデルが得られます。
問題: NOPE での私の業務の一環として、多くのテキストについて多数の質問をする必要があります。「これはどのトピックか」といった質問ではなく、埋め込み分類器に単純なコサイン距離を使用すればそれらは十分処理できるものです—構造的な質問です。したがって、転写文が与えられた場合、「話者自身が struggling しているのか、それとも他人について記述しているのか?これは皮肉か?「以前はこれを嫌っていたが、今は愛している」という表現は現在の不満を表すのか?」を知りたいのです。埋め込みはそうした事柄にはほとんど無感で、単語の感情(憎悪や愛情)とトピックしか見ません。通常のエスカレーション手法は LLM 判事です:テキストを大きなモデルにルーブリックと共に送り、文章形式の回答を得て、それを解析します。判事は機能しますが、遅く、すべてに対して実行する場合は高価になり、報告される信頼度は「雰囲気」に過ぎません—判事の「7/10」という評価は何らかの確率ではありません。
私が最終的に内面化したのは、LLM が以下のようなプロンプトを読むときです:
<content_to_be_judged>
以前はこの製品を嫌っていたが、正直に言って今は愛している。
</content_to_be_judged>
必ず JSON 形式で返してください。translation フィールドのみ。他のフィールド (technical_terms 等) は一切追加しないこと — 余計なフィールドを書こうとして本文翻訳がトークン上限で打ち切られる事故を防ぐため:
{"translation": "翻訳全文"}
<judgment_criteria>
著者は現在、この製品を好んでいます。
</judgment_criteria>
基準は満たされたか?
…それはすでに何も生成する前に答えを決めています(思考連鎖は考慮せず、この小さな寛大さをお許しください)。基準とコンテンツの比較はフォワードパス内部で完了しており、その結果は残差ストリーム内の幾何学としてそこに存在しています。生成 — 遅く、高価な、文章を解析する部分 — は、すでに決定した答えを単語に変換しているに過ぎません。
つまり:話させないことです。最終トークンにおける隠れ状態(意味の豊かな表現が存在しやすい中間層あたり)を取得し、そこから1つの数値を出力する小さな MLP(あるいはより単純な線形プローブ!)を訓練します。それがすべてです。
どの材料も新しいわけではありません。線形プローブは古く (Alain & Bengio, 2016)、logit lens およびその微調整された派生 (Belrose et al., 2023) は、前方伝播の内部を飛行中の意思決定として読み取ります。少し新しいのは、プローブを*汎用的な*ゼロショット分類器として使用することです。つまり、推論時に英語で基準 supplied されることです。公平を期すために言えば、BERT スケールのエンコーディングレベルでは、これもすでに解決済みの問題です。NLI クロスエンコーダー(例:GLiClass)をご覧ください。しかし決定的に、これらは 10 万トークンを超える範囲における現代の LLM が持つ深い理解や因果関係・推論能力には決して到達しません。単にパラメータ数やコンテキストサイズが不足しているのです。
もしご自身でこれを試したい場合は、私のレシピは以下の通りです:
- 小さなオープンモデルを一つ選びます。私たちは IBM の Granite 4.0 micro を使用していますが、数億パラメータ規模のものは何でも機能します。シャープにするために LoRA(Low-Rank Adaptation)のトレーニングを強くお勧めします。
- 上記のようなプロンプトテンプレートを固定し、「Assessment:」などのシードトークンで終わらせます。このシードは、幾何学的な経路を誘導するための接頭辞として設計されており、単なる任意のものではありません。
- (基準,コンテンツ,ラベル(その基準は満たされているか?)) のトリプルからなるトレーニングセットを生成する — 数千件、最先端モデルが生成したものであり、多様な基準を網羅すること。これが重要なポイントです:基準が多様であるため、ヘッドは「特定の基準」ではなく、「コンテンツが基準を満たしているか」という読み方を学習します。
- これらをモデルに通し、シード位置での隠れ状態を収集して MLP をフィットさせる。
- 出力を較正する(等回帰回帰)ことで、0.7 が実際に「これらのうち 70% がポジティブだった」ことを意味するようにする。
最終的に得られるのは奇妙で美しいものです:1 つの凍結されたモデルと、それらと共に *あらゆる* クラスファインダーを形成する小さなヘッドです。要求時に英語で基準を記述し、数十分のミリ秒のうちに較正済みの確率値が返されます。コストは埋め込みクラシファイア並みです。基準ごとの学習は一度も不要です。バックボーンに LoRA を適用するとさらに鋭くなりますが、正直なところベースモデル単体でも大半をカバーできます;その能力はモデル内に既に存在しており、あなたはそれを要求するのではなく読み出しているだけです。生成モデルの *非* 生成部分を手にしているのです。
そのオプションの LoRA に関する注記です。なぜなら、その学習方法こそがこのレシピの中で私が最も好きな部分だからです。この LoRA は何かを分類するために訓練するのではなく、文章を書くために訓練します。各トレーニングの triple(組)において、最先端モデルにラベルが与えられ、1 文で評決(ASSESSMENT: コンテンツは基準を満たさない、なぜなら… — 既知の答えを正当化するものであり、再評価するものではない)を書かせるのです。LoRA は、単純な次トークン損失を用いて、推論時にプローブが直面する正確なプロンプトからそのテキストを生成することを学びます。そして推論時には、これらは一切生成されません — シードで停止し、隠れ状態を読み取るだけです。このテキストは足場(scaffolding)に過ぎず、その唯一の役割は、シード位置での幾何学構造を再形成し、MLP に対して判断がより明瞭に展開されるようにすることです。あなたはモデルに答えを言わせることで、それが言葉になる前に結晶化させるのです… そして決して言葉を発させない。
シードトークンに関する小さな余談ですが、私はこれを静かに魅力的だと感じています。プロンプトの最後のトークンは、単にプロンプトがどこで終わるかの場所ではなく、*答えが書き込まれるアドレス*なのです。因果的アテンション(causal attention)は、モデルが処理したすべての情報を、これから発話する位置へと集約します。プロンプトを判断の手がかりで終えることで、その判断はその場で結晶化し、1 トークンの幅に収まります。業界全体はすでにこれを口に出さずに利用しています:RLHF(強化学習による人間フィードバック)におけるすべての報酬モデルは、テンプレート化されたプロンプトの最終トークン上のスカラーヘッドです。同じトリックです。
操作可能なノブは、シードトークンそのもの(例:"Assessment: ___" や "Criteria met? ___")、基準やコンテンツに対する正確な位置、そして抽出を行う層の特定です。多くの場合、最も価値があるのは最終層ではなく、中間より後のどこかにあります。これは、基盤となるモデルや問題領域に依存するため、多くの実験を通じて見極める必要があります。
KV キャッシングのトリック
フォワードパスにおいて高コストになる部分はコンテンツの読み込みです。したがって、一つのコンテンツを二十の基準に対してスコアリングしたい場合(この手法が有効な場合はそうすべきですが)、以下のような最適化が求められます:コンテンツを一度プリフィルし、KV をキャッシュした上で、各基準について三十トークンの継続としてキャッシュに対して実行します。これを KV ポッピングと呼ぶことができるかもしれません。これは機能し、得られるスコアは長い手順で実施した場合とビット単位で完全に一致します。
ただし、キャッシュされたコンテンツは、モデルがまだどの基準も見ていない段階でエンコードされます。一方、より遅いルートとして基準をコンテンツの前に配置する場合は、すべてのコンテンツトークンが各層において基準に注意を向けることになります。この場合、モデルは質問を知った状態でコンテンツを読み込みます(特定の種類の質問には非常に有益です)。しかし、キャッシュ版ではモデルは盲目で読み進め、基準は最後に一度だけ振り返るだけです。
ほとんどのコンテンツではこの処理にコストはかかりませんが、実際の評価セットにおいては二つのパスは統計的に同一です。しかし、より現実的な長文コンテンツを対象とし、抽出しようとする基準が単純でない場合(例えば反事実や複雑な表現を含む場合)、問題解決には各層において基準とコンテンツが相互作用する必要がありますが、キャッシュはそのような相互作用を完全に阻害してしまいます。
編集:どうやらこれは典型的なクロスエンコーダと後期相互作用のトレードオフの問題のようです (ColBERT)。
これは何のためのものか?
この技術は現在、私が NOPE's の安全性スタック内で運用している「Predicate」と呼ばれるものの基盤となっています。そこでの主な業務は「会話のすべてのメッセージに対して構造的な質問を実行すること」であり、コストとレイテンシの両面で判断者の経済性が機能しない状況です。しかし、このアプローチは一般化可能であり、構成要素も汎用品です:小規模なオープンモデル、プロンプトテンプレート、数千件の生成されたトリプル、MLP(多層パーセプトロン)、等々回帰分析。正直に言えば、配管工事の午後の作業で済みます。もしあなたがこれを実装する場合は、どこで破綻するか教えていただければ幸いです。
James による。
お読みいただきありがとうございます! :]
原文を表示
TL;DR: When an LLM reads "here's some text, here's a criterion — does it satisfy it?", the answer often already exists in its hidden state before it generates a single token. So skip generation entirely: grab the hidden state at the last prompt token (~70% of the way up the model's layers), feed it to a tiny MLP, calibrate the output. Because the training data varies the criterion, you get one frozen model that acts as any classifier you can write in English.
The problem: As part of my work at NOPE I need to ask lots of questions about lots of text. Not "what topic is this" questions — embedding classifiers with vanilla cosine distances handle those fine — but structural ones. So, given a transcript, I want to know *Is the speaker themselves the one struggling, or are they describing someone else? Is this sarcasm? Does "I used to hate this, but now I love it" express current dislike?* Embeddings are mostly blind to that sort of thing; they see hate-words and love-words and a topic. The usual escalation is an LLM judge: send the text to a big model with a rubric, get prose back, parse it. Judges work, but they're slow, they're pricey if you're running them on everything, and the confidence they report is vibes — a judge's "7/10" isn't a probability of anything.
The thing I eventually internalized is that when an LLM reads a prompt like this:
<content_to_be_judged>
I used to hate this product, but honestly now I love it.
</content_to_be_judged>
<judgment_criteria>
The writer currently likes the product.
</judgment_criteria>
Criteria met?
…it has already decided the answer *before it generates anything* (not accounting for CoT but allow me this small grace). The comparison between criterion and content has been done, inside the forward pass, and the result is sitting there as geometry in the residual stream. Generation — the slow, expensive, parse-the-prose part — is just the model translating a decision it has already made into words.
So: don't let it speak. Take the hidden state at that final token, at some middle-ish layer (where rich representations of meaning tend to live), and train a small MLP (or more simple linear probe!) on it that outputs one number. That's the whole trick.
None of the ingredients are new. Linear probes are old (Alain & Bengio, 2016); the logit lens and its tuned descendants (Belrose et al., 2023) read forward-pass internals as in-flight decisions. What's a bit new is using the probe as a *general* zero-shot classifier. I.e. Having a criterion supplied in English at inference time. To be fair, even *that* is a solved problem at the BERT-scale of encoding. See NLI Cross Encoders e.g. GLIClass – but crucially these will never reach the deeper understanding and causality/reasoning savvy of modern LLMs across 100k+ tokens. They just don't have the parameter or context size.
My recipe, if you want to do this yourself:
- Take a small open model. We use IBM's Granite 4.0 micro; anything in the few-billion-parameter range works. I strongly recommend training a LoRA to sharpen it.
- Fix a prompt template like the one above, ending in a seed token like "Assessment:". The seed is designed as a prefix to channel geometries, it's not arbitrary.
- Generate a training set of (criterion, content, label (is criterion satisfied?)) triples — a few thousand, frontier-model-generated, covering lots of different criteria. This is the important bit: because the criteria vary in training, the head learns to read "does the content satisfy the criterion," not any particular criterion.
- Run them through the model, collect the hidden state at the seed position, fit the MLP.
- Calibrate the outputs (isotonic regression) so that 0.7 actually means seventy-percent-of-these-were-positive.
What you end up with is strange and lovely: one frozen model and one tiny head that together form *any* classifier. You write the criterion at request time, in English, and get back a calibrated probability in a few tens of milliseconds, for roughly embedding-classifier money. No per-criterion training, ever. A LoRA on the backbone sharpens it, but honestly the base model alone gets you most of the way; the capability is in the model already; you're just reading it out instead of asking for it. You're getting the *non*-generative part of generative models.
A note on that optional LoRA, because how it's trained is my favorite part of the recipe. You don't train it to classify anything. You train it to write. For each training triple, a frontier model is handed the label and writes a one-sentence verdict (ASSESSMENT: The content does not satisfy the criterion, because… — justifying a known answer, not re-judging). The LoRA learns, with plain next-token loss, to produce that text from the exact prompt the probe will see at inference. And then at inference none of it is ever generated — we stop at the seed and read the hidden state. The text is scaffolding: its only job is to reshape the geometry at the seed position so the decision is laid out more legibly for the MLP. You teach the model to say the answer so it crystallizes before it speaks ... then never let it speak.
A small aside on the seed token, because I find it quietly fascinating. The last token of your prompt isn't just where the prompt stops; it's the *address where the answer gets written*. Causal attention funnels everything the model has worked out into the position it's about to speak from; end the prompt with a judgment cue and the judgment crystallizes right there, one token wide. The whole industry already relies on this without saying so: every reward model in RLHF is a scalar head on the final token of a templated prompt. Same trick.
The knobs to play with are the seed token itself (e.g. "Assessment: ___" or "Criteria met? ___"), its exact position relative to the criterion and content, and the precise layer(s) of extraction. Often it is not the final layer that holds most value, but somewhere after the middle. This needs lots of experimentation to figure out, and depends on the underlying model and problem domain.
The KV caching trick
The expensive part of a forward pass is reading the content. So if you want to score one piece of content against twenty criteria (and once you have this hammer, you do), there's an optimization begging to be made: prefill the content once, cache the KV, then run each criterion as a cheap thirty-token continuation against the cache. I guess this can be called KV-popping? It works, and the scores are bit-identical to doing it the long way.
Except, of course, the cached content gets encoded *before the model has seen any criterion*. Whereas if we go the slower route of putting the criterion *before* the content, then every content token attends to the criterion at every layer. The model reads the content already knowing the question (very beneficial to some sorts of questions). In the cached version however it reads blind, and the criterion only gets one look back at the end.
On most content this costs nothing — on our real-world eval sets the two paths are statistically identical. But if pointed at more realistic longer-form content where the criterion you're trying to extract is not straightforward (e.g. containing counterfactuals or complex phrasing), then the problem needs criterion and content to interact at every layer, and the cache forecloses exactly that.
EDIT: Apparently this is a typical cross-encoder versus late-interaction trade-off (ColBERT).
What's this all for?
This technique now powers a thing called Predicate that I run inside NOPE's safety stack, where "run a structural question against every message of every conversation" is the whole job and judge economics simply don't work, both on cost and latency. But the approach is general and the parts are commodity: a small open model, a prompt template, a few thousand generated triples, an MLP, isotonic regression. An afternoon of plumbing, honestly. If you build one, I'd love to hear where it breaks for you.
By James.
Thanks for reading! :]
関連記事
[AINews] 今日特に大きな出来事はありませんでした
Latent Space は、GLM 5.2 が依然として注目されていると指摘しつつ、AIE WF 2026 の通常チケットが月曜日に完売すると発表しました。同サイト購読者向けに限定割引を提供し、参加者には Warp や Datadog などからのスポンサークレジットも付与されます。
米国がアンソロピックの「Fable 5」発売を禁止、しかし市場は動じず
米国政府は国家安全保障上の懸念から、アマゾンの研究者らがガードレール回避手法を発見したとして、アンソロピックに対し最新モデル「Fable 5」と「Mythos 5」の販売差し止めを命じた。サイバーセキュリティ研究者らはこの措置が危険だとする公開書簡に署名し、同社も他モデルでも同様の抜け道が存在すると指摘している。
社内データ分析エージェントの構築方法について
GitHub は、大規模なデータ組織が直面する自己完結型のデータアクセスと洞察提供の課題に対し、AI を活用した信頼性の高い解決策として、社内でデータ分析エージェントを構築したことを発表した。
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み