Anthropic finds over 10,000 vulnerabilities with Project GlasswingSynthID expands to Google Search and ChromeGoal mode now available across all Codex platformsCodex Thursday adds remote Mac controlAnthropic publishes early Project Glasswing resultsAnthropic updates vulnerability disclosure dashboardReleases new science-focused AI skills toolGemini 3.5 Flash released with enhanced research toolsGoogle launches ADK for Kotlin and Android 0.1.0Gemini 3.5 Flash officially launchedAI solves long-standing open math problem for first timeGoogle announces Gemini Omni for video creationUse multiple agents with Gemini OmniOpenAI Introduces Guaranteed Capacity for Long-Term ComputeGemini for Science assists with research tasksSynthID watermark and verification tool added to AI imagesGoogle I/O 2026 to unveil new AI breakthroughsOpenAI boosts image provenance and verificationKPMG rolls out Claude globally, starting with taxGoogle adds Managed Agents to the Gemini APIAnthropic finds over 10,000 vulnerabilities with Project GlasswingSynthID expands to Google Search and ChromeGoal mode now available across all Codex platformsCodex Thursday adds remote Mac controlAnthropic publishes early Project Glasswing resultsAnthropic updates vulnerability disclosure dashboardReleases new science-focused AI skills toolGemini 3.5 Flash released with enhanced research toolsGoogle launches ADK for Kotlin and Android 0.1.0Gemini 3.5 Flash officially launchedAI solves long-standing open math problem for first timeGoogle announces Gemini Omni for video creationUse multiple agents with Gemini OmniOpenAI Introduces Guaranteed Capacity for Long-Term ComputeGemini for Science assists with research tasksSynthID watermark and verification tool added to AI imagesGoogle I/O 2026 to unveil new AI breakthroughsOpenAI boosts image provenance and verificationKPMG rolls out Claude globally, starting with taxGoogle adds Managed Agents to the Gemini API
🔒 公式発表のみ掲載。噂・リーク・情報商材は載せません。
← Back to glossary

Stop Sequence

ストップシーケンス

すとっぷしいけんす

Definition

A stop sequence is a termination condition that stops generation when a specified string appears in the output. It is useful for controlling boundaries in formatted responses.

LLMに文章を生成させると、必要な情報を出力した後もだらだらと続きを書いてしまうことがあります。この問題を解決するのがストップシーケンスです。ストップシーケンスとは、LLMの生成を特定の文字列で強制的に停止させる仕組みで、出力の終端を正確に制御するために使われます。

基本的な仕組み

LLMはトークンを1つずつ順番に生成していきます。ストップシーケンスを設定すると、生成されたテキストの中にその文字列が出現した時点で、即座に生成が停止します。たとえばストップシーケンスに`\n\n`(空行)を設定すれば、最初の空行が出現した時点でモデルの出力が止まります。生成の「終わり」を開発者がプログラム的に制御できるのがポイントです。

活用パターン

ストップシーケンスが威力を発揮する場面はいくつかあります。構造化データの生成では、JSON出力時に`}`や`]`で停止させることで、余分なテキストの付与を防ぎます。会話形式の制御では、チャットボットで「User:」をストップシーケンスに設定し、モデルがユーザーの発言まで勝手に生成してしまうことを防ぎます。単一回答の抽出では、「\n」を設定して1行だけの回答を確実に取得します。

複数のストップシーケンス

ほとんどのAPIでは、複数のストップシーケンスを同時に設定できます。OpenAIのAPIでは最大4つまで、AnthropicのAPIでも複数の指定が可能です。いずれかのストップシーケンスが検出された時点で生成が停止します。たとえば`["\n\n", "---", "END"]`と設定すれば、空行、水平線、「END」のいずれかが出現した時点で停止します。

max_tokensとの関係

ストップシーケンスは`max_tokens`(最大出力トークン数)と併用して出力を制御します。`max_tokens`は出力の長さに上限を設けるもので、ストップシーケンスは内容に基づいて停止するものです。両方を設定した場合、どちらかの条件が先に満たされた時点で生成が停止します。安全策として`max_tokens`で上限を設けつつ、ストップシーケンスで意味的に適切な位置での停止を狙うのが実務的なパターンです。

エージェントやツール利用での重要性

関数呼び出しやエージェントの実装では、ストップシーケンスが特に重要です。モデルが「アクションを決定した」時点で生成を止め、そのアクションを実行し、結果をモデルに渡して次のステップに進むというループを構築するために使われます。出力の境界を正確に定義できるストップシーケンスは、LLMをプログラムの一部として組み込む際の基盤技術の一つです。

h
hayami

Stay on top of OpenAI, Google & Anthropic updates. An AI digest for business professionals.

Source Policy

We use only official sources. Each article links to the original announcement so you can verify it yourself.

© 2026 hayami. All rights reserved.