Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
PLaMo 3.0 Primeの構造化出力サポート
Search
Preferred Networks
PRO
July 30, 2026
Technology
52
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
PLaMo 3.0 Primeの構造化出力サポート
2026年7月30日に開催された「PFN LLMオープンハウス」での講演資料です。
Preferred Networks
PRO
July 30, 2026
More Decks by Preferred Networks
See All by Preferred Networks
PLaMo 3.0 Primeの事後学習
pfn
PRO
0
65
plamo-3-translateの開発
pfn
PRO
0
110
PLaMoを毎日の開発で使い育てていく
pfn
PRO
0
60
The Making of AI Chips
pfn
PRO
1
1k
国産生成AI PLaMoを支える事後学習と推論最適化
pfn
PRO
13
5.4k
Japanese SimpleQA: 日本語における事実に基づいた回答能力の評価ベンチマーク
pfn
PRO
1
420
Headlampと独自プラグインを活用したKubernetesダッシュボードの機能拡張
pfn
PRO
2
430
AI/MLのマルチテナント基盤を支えるコンテナ技術
pfn
PRO
6
1.9k
単一Kubernetesクラスタで実現する AI/ML 向けクラウドサービス
pfn
PRO
1
1k
Other Decks in Technology
See All in Technology
最新IoT事例11選に学ぶ!現場の成功パターンと実践のコツ【SORACOM Discovery 2026】
soracom
PRO
0
120
新たなDBアーキテクチャ「LTAP」にDeep Dive!!
inoutk
0
150
インシデント事例と パッケージの全量解析に学ぶ ソフトウェアサプライチェーンの守り方 / supply-chain-attack-defense
flatt_security
0
1.2k
なぜ、あなたのAPIは使われないのか? AX時代の設計原則、ガードレール、運用体制
yokawasa
1
260
現場との対話から始める “作る前に問い直す”業務改善
mochico50
2
330
【5分でわかる】セーフィー エンジニア向け会社紹介
safie_recruit
0
53k
AI時代におけるテストの基礎の再定義 / Rethinking the Fundamentals of Testing in the AI Era
mineo_matsuya
15
6.1k
「休む」重要さ
smt7174
7
1.8k
AIとハーネスで育てるトランスコンパイラ / 20260722 Yasushi Katayama
shift_evolve
PRO
4
1.1k
論語・武士道・産業革命から見る かわるもの、かわらないもの
ichimichi
8
1.5k
CloudWatchから始めるAWS監視
butadora
0
280
文字起こし基盤の信頼性
abnoumaru
0
150
Featured
See All Featured
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
440
Building AI with AI
inesmontani
PRO
1
1.1k
Designing Experiences People Love
moore
143
24k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
880
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
430
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
120k
Code Review Best Practice
trishagee
74
20k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
The Invisible Side of Design
smashingmag
301
52k
Leo the Paperboy
mayatellez
8
1.9k
Transcript
PLaMo 3.0 Primeの 構造化出力サポート 2026/07/30 PLaMo LLMセミナー LLM推論最適化チーム Shintarou Okada(GitHub:
@okdshin)
構造化出力 使ってますか? 2
構造化出力 使ってますか? Structured outputとも言う 3
構造化出力 多分みなさん使っている 使ってますか? Structured outputとも言う 4
構造化出力はAIエージェントのカナメ AIエージェントが具体的な仕事をするには外部のシステムと情報をやり取り する必要がある 5
構造化出力はAIエージェントのカナメ AIエージェントが具体的な仕事をするには外部のシステムと情報をやり取り する必要がある 情報をスムーズにやり取りするには決まったフォーマットでデータを用意す る必要がある 6
構造化出力はAIエージェントのカナメ AIエージェントが具体的な仕事をするには外部のシステムと情報をやり取り する必要がある 情報をスムーズにやり取りするには決まったフォーマットでデータを用意す る必要がある {JSON} {JSON} {JSON} {JSON} 7
構造化出力はAIエージェントのカナメ AIエージェントが具体的な仕事をするには外部のシステムと情報をやり取り する必要がある 情報をスムーズにやり取りするには決まったフォーマットでデータを用意す る必要がある 構造化出力 8 の出番
PLaMo 3.0 Primeは構造化出力をサポート 指定したJSONSchemaに従うJSON文字列を必ず出力させることができる "response_format": { "type": "json_schema", "json_schema": {
"name": "company", "schema": { "type": "object", "properties": { "name": {"type": "string"}, "founded_year": {"type": "integer"}, "location": {"type": "string"}, "employees": {"type": "integer"} }, "required": ["name", "founded_year", "location", "employees"], "additionalProperties": false } } } 9
PLaMo 3.0 Primeは構造化出力をサポート 指定したJSONSchemaに従うJSON文字列を必ず出力させることができる "response_format": { "type": "json_schema", "json_schema": {
"name": "company", "schema": { "type": "object", "properties": { "name": {"type": "string"}, "founded_year": {"type": "integer"}, "location": {"type": "string"}, "employees": {"type": "integer"} }, "required": ["name", "founded_year", "location", "employees"], "additionalProperties": false } } 10 } chat-completionsのリクエストの一部
PLaMo 3.0 Primeは構造化出力をサポート 指定したJSONSchemaに従うJSON文字列を必ず出力させることが "response_format": { できる "type": "json_schema", "json_schema":
{ "name": "company", "schema": { "type": "object", "properties": { "name": {"type": "string"}, "founded_year": {"type": "integer"}, "location": {"type": "string"}, "employees": {"type": "integer"} }, "required": ["name", "founded_year", "location", "employees"], "additionalProperties": false } } } 11
PLaMo 3.0 Primeは構造化出力をサポート 指定したJSONSchemaに従うJSON文字列を必ず出力させることができる リクエスト "response_format": { "type": "json_schema", "json_schema":
{ "name": "company", "schema": { "type": "object", "properties": { "name": {"type": "string"}, "founded_year": {"type": "integer"}, "location": {"type": "string"}, "employees": {"type": "integer"} }, "required": ["name", "founded_year", "location", "employees"], "additionalProperties": false } } } 12 "model": "plamo-3.0-prime", "response_format": (省略), "messages": [{"role": "user", "content": "次の文から情報を抽出 してください : 「ほしぞら書店株式会 社は2011年5月に横浜市中区で設 立された。従業員は約 120名。」"}],
PLaMo 3.0 Primeは構造化出力をサポート 指定したJSONSchemaに従うJSON文字列を必ず出力 "response_format": { させることができる "type": "json_schema", "json_schema":
{ "model": "plamo-3.0-prime", "name": "company", {"name": "ほしぞら書店株式会社 ", "response_format": (省略), "schema": { "founded_year": 2011, "type": "object", "location": "横浜市中区 ", "messages": [{"role": "user", "properties": { "employees": 120} "name": {"type": "string"}, "content": "次の文から情報を抽出 "founded_year": {"type": "integer"}, "location": {"type": "string"}, してください : 「ほしぞら書店株式会 "employees": {"type": "integer"} レスポンス 社は2011年5月に横浜市中区で設 }, "required": ["name", "founded_year", "location", "employees"], 立された。従業員は約 120名。」"}], "additionalProperties": false } } } 13
構造化出力の仕組み 1. 与えられた文法からステートマシン を構築 2. ステートマシンがボキャブラリマスク を生成 ボキャブラリマスクは文法に沿うトークンだけ を抜き 出す
3. トークンをサンプル する 4. サンプルしたトークンでステートマシンを更新 5. 完了状態になるまで2~4を繰り返し PFN Confidential
構造化出力の仕組み 1. 与えられた文法からステートマシンを構築 2. ステートマシンがボキャブラリマスクを生成 ボキャブラリマスクは文法に沿うトークンだけを抜き 出す 3. トークンをサンプルする 4.
サンプルしたトークンでステートマシンを更新 5. 完了状態になるまで2~4を繰り返し ※ステートマシンのイメージ図 PFN Confidential
構造化出力の仕組み 1. 与えられた文法からステートマシンを構築 2. ステートマシンがボキャブラリマスクを生成 ボキャブラリマスクは文法に沿うトークンだけ を抜き abcde 出す ,
3. トークンをサンプルする ボキャブラリ hoge 4. サンプルしたトークンでステートマシンを更新 {(中括弧開き) 5. 完了状態になるまで2~4を繰り返し bar {"comment": "OK PFN Confidential 次どうする "(ダブルクオート) ...
構造化出力の仕組み 1. 与えられた文法からステートマシンを構築 2. ステートマシンがボキャブラリマスクを生成 ボキャブラリマスクは文法に沿うトークン だけを抜き abcde 出す マスク
XXXXXXXXXX 3. トークンをサンプルする 生成! hoge 4. サンプルしたトークンでステートマシンを更新 XXXXXXXXXX 5. 完了状態になるまで2~4を繰り返し bar {"comment": "OK PFN Confidential 次どうする "(ダブルクオート) ...
構造化出力の仕組み abcde XXXXXXXXXX hoge 1. 与えられた文法からステートマシンを構築 XXXXXXXXXX 2. ステートマシンがボキャブラリマスクを生成 bar
ボキャブラリマスクは文法に沿うトークンだけを抜き XXXXXXXXXX "(ダブルクオート) 出す ... 3. トークンをサンプルする 4. サンプルしたトークンでステートマシンを更新 今回はこちらをサンプル 5.{"comment": 完了状態になるまで2~4を繰り返し "OK" PFN Confidential
構造化出力の仕組み 1. 与えられた文法からステートマシンを構築 "(ダブルクオート) 2. ステートマシンがボキャブラリマスクを生成 サンプル状態に更新 ボキャブラリマスクは文法に沿うトークンだけを抜き 出す 3.
トークンをサンプルする 4. サンプルしたトークンでステートマシンを更新 5. 完了状態になるまで2~4を繰り返し PFN Confidential
構造化出力の仕組み 1. 与えられた文法からステートマシンを構築 XXXXXXXXXX 新しいボキャブラリマスクを生成 2. ステートマシンがボキャブラリマスク,(カンマ) を生成 XXXXXXXXXX ボキャブラリマスクは文法に沿うトークンだけ
を抜き XXXXXXXXXX 出す XXXXXXXXXX 3. トークンをサンプル する XXXXXXXXXX 4.{"comment": サンプルしたトークンでステートマシンを更新 "OK" 次どうする 5. 完了状態になるまで 2~4を繰り返し ↺ PFN Confidential
PLaMo 3.0 Primeは構造化出力をサポート 指定したJSONSchemaに従うJSON文字列を必ず出力 "response_format": { させることができる "type": "json_schema", "json_schema":
{ "model": "plamo-3.0-prime", "name": "company", {"name": "ほしぞら書店株式会社 ", "response_format": (省略), "schema": { "founded_year": 2011, "type": "object", "location": "横浜市中区 ", "messages": [{"role": "user", "properties": { "employees": 120} "name": {"type": "string"}, "content": "次の文から情報を抽出 "founded_year": {"type": "integer"}, "location": {"type": "string"}, してください : 「ほしぞら書店株式会 "employees": {"type": "integer"} レスポンス 社は2011年5月に横浜市中区で設 }, "required": ["name", "founded_year", "location", "employees"], 立された。従業員は約 120名。」"}], "additionalProperties": false } } } 21
PLaMo 3.0 Primeは構造化出力をサポート 指定したJSONSchemaに従うJSON文字列を必ず出力 "response_format": { させることができる "type": "json_schema", "json_schema":
{ "model": "plamo-3.0-prime", "name": "company", {"name": "ほしぞら書店株式会社 ", 実は内部ではJSONSchemaだけではなく "messages": "schema": { [{"role": "user", "founded_year": 2011, "type": "object", "location": "横浜市中区 ", "content": "次の文から情報を抽出 「推論」と「ツール呼出し」でも "properties": { "employees": 120} "name":: {"type": "string"}, してください 「ほしぞら書店株式会 構造化出力を利用している "founded_year": {"type": "integer"}, "location": {"type": "string"}, 社は2011年5月に横浜市中区で設 "employees": {"type": "integer"} 立された。従業員は約 120名。」"}], }, "required": ["name", "founded_year", "location", "employees"], "additionalProperties": false } } } 22
Chat-completions リクエスト 構造化 出力 推論 を設定 パーサー 入出力上書きプロキシ PFN Confidential
g n i n lls ent a c t o _ n s l o c ea oo . r t . . e g ge ge a a a s ss ss mes e e m m PLaMo推論時のデータの流れ 23 ツール 呼出 パーサー 後処理 レスポンス
Chat-completions リクエスト 構造化 出力 推論 を設定 パーサー 入出力上書きプロキシ PFN Confidential
g n i n lls ent a c t o _ n s l o c ea oo . r t . . e g ge ge a a a s ss ss mes e e m m PLaMo推論時のデータの流れ 24 ツール 呼出 パーサー 後処理 レスポンス
Chat-completions リクエスト 構造化 出力 推論 を設定 パーサー 入出力上書きプロキシ PFN Confidential
g n i n lls ent a c t o _ n s l o c ea oo . r t . . e g ge ge a a a s ss ss mes e e m m PLaMo推論時のデータの流れ 25 ツール 呼出 パーサー 後処理 レスポンス
Chat-completions リクエスト 構造化 出力 推論 を設定 パーサー 入出力上書きプロキシ PFN Confidential
g n i n lls ent a c t o _ n s l o c ea oo . r t . . e g ge ge a a a s ss ss mes e e m m PLaMo推論時のデータの流れ 26 ツール 呼出 パーサー 後処理 レスポンス
Chat-completions リクエスト 構造化 出力 推論 を設定 パーサー 入出力上書きプロキシ PFN Confidential
g n i n lls ent a c t o _ n s l o c ea oo . r t . . e g ge ge a a a s ss ss mes e e m m PLaMo推論時のデータの流れ 27 ツール 呼出 パーサー 後処理 レスポンス
入力部分 <|plamo:tag|>system ... <|plamo:tag|>tool_definitions<|plamo:constrain|>json<|plamo:msg|> ...tool definitions... <|plamo:tag|>user<|plamo:msg|> ... <|plamo:tag|>assistant ...PFML3
annotations... <|plamo:msg|> <|plamo:begin_think:plamo|> ...reasoning_content... <|plamo:end_think:plamo|> ...free text... OR/AND ```json ...JSON_text... ``` <|plamo:begin_tool_requests:plamo|> <|plamo:begin_tool_request:plamo|> <|plamo:begin_tool_name:plamo|> ...tool_name... <|plamo:end_tool_name:plamo|> <|plamo:begin_tool_arguments:plamo|> <|plamo:constrain|>json <|plamo:msg|>...tool_arguments... <|plamo:end_tool_arguments:plamo|> <|plamo:end_tool_request:plamo|> ...other tool_request... <|plamo:end_tool_requests:plamo|> PLaMo 3.0 Primeの 入出力フォーマット 推論 コンテント 出力部分 ツール呼出し ※読みやすさのために改行・空白を入れていますが、実際はありません PFN Confidential 28
入力部分 <|plamo:tag|>system ... <|plamo:tag|>tool_definitions<|plamo:constrain|>json<|plamo:msg|> ...tool definitions... <|plamo:tag|>user<|plamo:msg|> ... <|plamo:tag|>assistant ...PFML3
annotations... <|plamo:msg|> <|plamo:begin_think:plamo|> ...reasoning_content... <|plamo:end_think:plamo|> ...free text... OR/AND ```json ...JSON_text... ``` <|plamo:begin_tool_requests:plamo|> <|plamo:begin_tool_request:plamo|> <|plamo:begin_tool_name:plamo|> ...tool_name... <|plamo:end_tool_name:plamo|> <|plamo:begin_tool_arguments:plamo|> <|plamo:constrain|>json <|plamo:msg|>...tool_arguments... <|plamo:end_tool_arguments:plamo|> <|plamo:end_tool_request:plamo|> ...other tool_request... <|plamo:end_tool_requests:plamo|> PLaMo 3.0 Primeの 入出力フォーマット 推論 コンテント <|plamo:begin_think:plamo|> 出力部分 ツール呼出し ...reasoning_content... (tool_calls) <|plamo:end_think:plamo|> PFN Confidential 29
入力部分 <|plamo:tag|>system ... <|plamo:tag|>tool_definitions<|plamo:constrain|>json<|plamo:msg|> ...tool definitions... <|plamo:tag|>user<|plamo:msg|> ... <|plamo:tag|>assistant ...PFML3
annotations... <|plamo:msg|> <|plamo:begin_think:plamo|> ...reasoning_content... <|plamo:end_think:plamo|> ...free text... OR/AND ```json ...JSON_text... ``` <|plamo:begin_tool_requests:plamo|> <|plamo:begin_tool_request:plamo|> <|plamo:begin_tool_name:plamo|> ...tool_name... <|plamo:end_tool_name:plamo|> <|plamo:begin_tool_arguments:plamo|> <|plamo:constrain|>json <|plamo:msg|>...tool_arguments... <|plamo:end_tool_arguments:plamo|> <|plamo:end_tool_request:plamo|> ...other tool_request... <|plamo:end_tool_requests:plamo|> PLaMo 3.0 Primeの 入出力フォーマット 推論 コンテント <|plamo:begin_think:plamo|> 出力部分 ツール呼出し ...reasoning_content... (tool_calls) <|plamo:end_think:plamo|> PFN Confidential 30
推論 / ツール呼出し パーサー 推論 / ツール呼出し パーサーは モデルからの生の出力をパース →
OpenAI APIのレスポンス形式に変換 する ❌推論パーサーなし : choices[0].message.content == “<|plamo:begin_think:plamo|>I say hello<|plamo:end_think:plamo|>hello...” ⭕推論パーサーあり : choices[0].message.reasoning == “I say hello” choices[0].message.content == “hello...” PFN Confidential 31 ※ツール呼出し パーサーも同様
Chat-completions リクエスト 構造化 出力 推論 を設定 パーサー 入出力上書きプロキシ PFN Confidential
g n i n lls ent a c t o _ n s l o c ea oo . r t . . e g ge ge a a a s ss ss mes e e m m PLaMo推論時のデータの流れ 32 ツール 呼出 パーサー 後処理 レスポンス
Chat-completions リクエスト 構造化 出力 推論 を設定 パーサー 入出力上書きプロキシ PFN Confidential
g n i n lls ent a c t o _ n s l o c ea oo . r t . . e g ge ge a a a s ss ss mes e e m m PLaMo推論時のデータの流れ 33 ツール 呼出 パーサー 後処理 レスポンス
推論 / ツール呼出し / コンテントのための構造化出力 推論 / ツール呼出し / コンテント
に パースできることを保証する 構造化 出力 を設定 それに加えて、 コンテントのJSONSchema サポート PFN Confidential 34
推論 / ツール呼出し / コンテントのための構造化出力 推論 / ツール呼出し / コンテント
に 構造化 パースできることを保証する それに加えて、 JSONじゃない! コンテントのJSONSchema サポート <|plamo:begin_think:plamo|> ...reasoning_content... <|plamo:end_think:plamo|> PFN Confidential 35 出力 を設定
推論 / ツール呼出し / コンテントのための構造化出力 推論 / ツール呼出し / コンテント
に 構造化 パースできることを保証する それに加えて、 JSONじゃない! コンテントのJSONSchema サポート <|plamo:begin_think:plamo|> 出力 を設定 Lark formatで指定 ...reasoning_content... <|plamo:end_think:plamo|> PFN Confidential 36
PLaMo 3.0 Primeの構造化出力バックエンド : llguidance OpenAI API公式も使っているllguidanceを採用 • 他のバックエンドより高速: outlines,
xgrammar... • JSONSchemaだけでなく文脈自由文法のLark formatをサポート PFN Confidential 37 引用元: https://raw.githubusercontent.com/guidance-ai/jsonschemabench/main/maskbench/plots/hero.png
PLaMo 3.0 Primeの構造化出力バックエンド : llguidance OpenAI API公式も使っているllguidanceを採用 ※Rust製のllguidanceに • 他のバックエンドより高速:
outlines, xgrammar... PLaMoサポートを追加するために • JSONSchemaだけでなく文脈自由文法のLark formatをサポート plamo3 tokenizerのRust移植を実施 PFN Confidential 38 引用元: https://raw.githubusercontent.com/guidance-ai/jsonschemabench/main/maskbench/plots/hero.png
Lark formatによる構造化出力の文法定義 太字部分 はリクエストごとに設定される部分 start: assistant_message assistant_message: reasoning content_and_function_calling reasoning:
<|plamo:begin_ "think" :plamo|> REASONING_CONTENT <|plamo:end_ "think" :plamo|> REASONING_CONTENT: /[\s\S]{1,}/ content_and_function_calling: content function_calling content: "```json\n" %json {"type": "object", "properties": {"answer": {"type": "string"}, "score": {"type": "integer"}}, "required": ["answer", "score"]} "\n```" ( <|plamo:begin_ "tool_requests" :plamo|> | <|plamo:tag|> ) function_calling: tool_requests tool_requests: tool_request <|plamo:end_ "tool_requests" :plamo|> <|plamo:tag|> tool_request: <|plamo:begin_ "tool_request" :plamo|> ( <|plamo:begin_ "tool_name" :plamo|> "get_weather" <|plamo:end_ "tool_name" :plamo|> <|plamo:begin_ "tool_arguments" :plamo|> <|plamo:constrain|> "json" <|plamo:msg|> %json {"type": "object", "properties": {"location": {"type": "string"}, "unit": {"type": "string", "enum": ["c", "f"]}}, "required": ["location"], "additionalProperties": false} <|plamo:end_ "tool_arguments" :plamo|> ) <|plamo:end_ "tool_request" :plamo|> ※この文法定義は「 JSONSchema指定あり」「reasoning有効」「tool_choice=auto」の場合のもの PFN Confidential 39
Lark formatによる構造化出力の文法定義 太字部分 はリクエストごとに設定される部分 start: assistant_message assistant_message: reasoning content_and_function_calling reasoning:
<|plamo:begin_ "think" :plamo|> REASONING_CONTENT <|plamo:end_ "think" :plamo|> REASONING_CONTENT: /[\s\S]{1,}/ content_and_function_calling: content function_calling content: "```json\n" %json {"type": "object", "properties": {"answer": {"type": "string"}, "score": {"type": "integer"}}, "required": ["answer", "score"]} "\n```" ( <|plamo:begin_ "tool_requests" :plamo|> | <|plamo:tag|> ) function_calling: tool_requests tool_requests: tool_request <|plamo:end_ "tool_requests" :plamo|> <|plamo:tag|> tool_request: <|plamo:begin_ "tool_request" :plamo|> ( <|plamo:begin_ "tool_name" :plamo|> "get_weather" <|plamo:end_ "tool_name" :plamo|> <|plamo:begin_ "tool_arguments" :plamo|> <|plamo:constrain|> "json" <|plamo:msg|> %json {"type": "object", "properties": {"location": {"type": "string"}, "unit": {"type": "string", "enum": ["c", "f"]}}, "required": ["location"], "additionalProperties": false} <|plamo:end_ "tool_arguments" :plamo|> ) <|plamo:end_ "tool_request" :plamo|> ※この文法定義は「 JSONSchema指定あり」「reasoning有効」「tool_choice=auto」の場合のもの PFN Confidential 40
Lark formatによる構造化出力の文法定義 start: assistant_message assistant_message: reasoning content_and_function_calling reasoning: <|plamo:begin_ "think"
:plamo|> REASONING_CONTENT <|plamo:end_ "think" :plamo|> REASONING_CONTENT: /[\s\S]{1,}/ content_and_function_calling: content function_calling content: "```json\n" %json {"type": "object", "properties": {"answer": {"type": "string"}, "score": {"type": "integer"}}, "required": ["answer", "score"]} "\n```" ( <|plamo:begin_ "tool_requests" :plamo|> | <|plamo:tag|> ) function_calling: tool_requests tool_requests: tool_request <|plamo:end_ "tool_requests" :plamo|> <|plamo:tag|> ※この文法定義は「 JSONSchema指定あり」「reasoning有効」「tool_choice=auto」の場合のもの tool_request: <|plamo:begin_ "tool_request" :plamo|> ( <|plamo:begin_ "tool_name" :plamo|> "get_weather" <|plamo:end_ "tool_name" :plamo|> <|plamo:begin_ "tool_arguments" :plamo|> <|plamo:constrain|> "json" PFN Confidential 41 <|plamo:msg|> %json {"type": "object", "properties": {"location": {"type": "string"}, "unit": {"type":
Lark formatによる構造化出力の文法定義 start: assistant_message assistant_message: reasoning content_and_function_calling reasoning: <|plamo:begin_ "think"
:plamo|> REASONING_CONTENT <|plamo:end_ "think" :plamo|> 出力を保証 REASONING_CONTENT: /[\s\S]{1,}/ content_and_function_calling: content function_calling content: "```json\n" %json {"type": "object", "properties": {"answer": {"type": "string"}, "score": {"type": "integer"}}, "required": ["answer", "score"]} "\n```" ( <|plamo:begin_ "tool_requests" :plamo|> | <|plamo:tag|> ) function_calling: tool_requests tool_requests: tool_request <|plamo:end_ "tool_requests" :plamo|> <|plamo:tag|> ※この文法定義は「 JSONSchema指定あり」「reasoning有効」「tool_choice=auto」の場合のもの tool_request: <|plamo:begin_ "tool_request" :plamo|> ( <|plamo:begin_ "tool_name" :plamo|> "get_weather" <|plamo:end_ "tool_name" :plamo|> <|plamo:begin_ "tool_arguments" :plamo|> <|plamo:constrain|> "json" PFN Confidential 42 <|plamo:msg|> %json {"type": "object", "properties": {"location": {"type": "string"}, "unit": {"type": <|plamo:begin_think:plamo|> ...reasoning_content... <|plamo:end_think:plamo|>
Lark formatによる構造化出力の文法定義 太字部分 はリクエストごとに設定される部分 start: assistant_message assistant_message: reasoning content_and_function_calling reasoning:
<|plamo:begin_ "think" :plamo|> REASONING_CONTENT <|plamo:end_ "think" :plamo|> REASONING_CONTENT: /[\s\S]{1,}/ content_and_function_calling: content function_calling content: "```json\n" %json {"type": "object", "properties": {"answer": {"type": "string"}, "score": {"type": "integer"}}, "required": ["answer", "score"]} "\n```" ( <|plamo:begin_ "tool_requests" :plamo|> | <|plamo:tag|> ) function_calling: tool_requests tool_requests: tool_request <|plamo:end_ "tool_requests" :plamo|> <|plamo:tag|> tool_request: <|plamo:begin_ "tool_request" :plamo|> ( <|plamo:begin_ "tool_name" :plamo|> "get_weather" <|plamo:end_ "tool_name" :plamo|> <|plamo:begin_ "tool_arguments" :plamo|> <|plamo:constrain|> "json" <|plamo:msg|> %json {"type": "object", "properties": {"location": {"type": "string"}, "unit": {"type": "string", "enum": ["c", "f"]}}, "required": ["location"], "additionalProperties": false} <|plamo:end_ "tool_arguments" :plamo|> ) <|plamo:end_ "tool_request" :plamo|> ※この文法定義は「 JSONSchema指定あり」「reasoning有効」「tool_choice=auto」の場合のもの PFN Confidential 43
Lark formatによる構造化出力の文法定義 太字部分 はリクエストごとに設定される部分 start: assistant_message assistant_message: reasoning content_and_function_calling reasoning:
<|plamo:begin_ "think" :plamo|> REASONING_CONTENT <|plamo:end_ "think" :plamo|> REASONING_CONTENT: /[\s\S]{1,}/ content_and_function_calling: content function_calling content: "```json\n" %json {"type": "object", "properties": {"answer": {"type": "string"}, "score": {"type": "integer"}}, "required": ["answer", "score"]} "\n```" ( <|plamo:begin_ "tool_requests" :plamo|> | <|plamo:tag|> ) function_calling: tool_requests tool_requests: tool_request <|plamo:end_ "tool_requests" :plamo|> <|plamo:tag|> tool_request: <|plamo:begin_ "tool_request" :plamo|> ( <|plamo:begin_ "tool_name" :plamo|> "get_weather" <|plamo:end_ "tool_name" :plamo|> <|plamo:begin_ "tool_arguments" :plamo|> <|plamo:constrain|> "json" <|plamo:msg|> %json {"type": "object", "properties": {"location": {"type": "string"}, Lark format中でJSONSchemaを記述 "unit": {"type": "string", "enum": ["c", "f"]}}, "required": ["location"], "additionalProperties": false} <|plamo:end_ "tool_arguments" :plamo|> ) <|plamo:end_ "tool_request" :plamo|> ※この文法定義は「 JSONSchema指定あり」「reasoning有効」「tool_choice=auto」の場合のもの PFN Confidential 44
構造化出力の限界 構造化出力はLLMからの出力が特定のフォーマットに沿うように強制する しかしこれはモデルが出力する内容の精度には無関係 構造化出力によってLLMの出力が壊滅するパターン 1. JSON文字列内で文字列を引用しようとして「"」を書く {"comment": "面白い感想だと思います。特に冒頭の" 2. JSON文字列が完結してしまう(本当は「\"」にする必要があった)
3. 構造化出力がJSON文法に沿う続きの出力を強制 4. LLMはJSON文法としては合法な「空白文字」を無限に連続出力する → 破綻 45
構造化出力の限界 構造化出力はLLMからの出力が特定のフォーマットに沿うように強制する しかしこれはモデルが出力する内容の精度には無関係 構造化出力によってLLMの出力が壊滅するパターン 1. JSON文字列内で文字列を引用しようとして「"」を書く {"comment": "面白い感想だと思います。特に冒頭の" 2. JSON文字列が完結してしまう(本当は「\"」にする必要があった)
3. 構造化出力がJSON文法に沿う続きの出力を強制 4. LLMはJSON文法としては合法な「空白文字」を無限に連続出力する → 破綻 46
構造化出力の限界 構造化出力はLLMからの出力が特定のフォーマットに沿うように強制する しかしこれはモデルが出力する内容の精度には無関係 構造化出力によってLLMの出力が壊滅するパターン 1. JSON文字列内で文字列を引用しようとして「"」を書く {"comment": "面白い感想だと思います。特に冒頭の " 2.
JSON文字列が完結してしまう(本当は「\"」にする必要があった) 3. 構造化出力がJSON文法に沿う続きの出力を強制 4. LLMはJSON文法としては合法な「空白文字」を無限に連続出力する → 破綻 47
構造化出力の限界 構造化出力はLLMからの出力が特定のフォーマットに沿うように強制する しかしこれはモデルが出力する内容の精度には無関係 構造化出力によってLLMの出力が壊滅するパターン 1. JSON文字列内で文字列を引用しようとして「"」を書く {"comment": "面白い感想だと思います。特に冒頭の" 2. JSON文字列が完結してしまう(本当は「\"
」にする必要があった) 3. 構造化出力がJSON文法に沿う続きの出力を強制 4. LLMはJSON文法としては合法な「空白文字」を無限に連続出力する → 破綻 48
構造化出力の限界 構造化出力はLLMからの出力が特定のフォーマットに沿うように強制する しかしこれはモデルが出力する内容の精度には無関係 構造化出力によってLLMの出力が壊滅するパターン 1. JSON文字列内で文字列を引用しようとして「"」を書く 2. JSON文字列が完結してしまう(本当は「\"」にする必要があった) 3. 構造化出力がJSON文法に沿う続きの出力を強制(戻れない)
{"comment": "面白い感想だと思います。特に冒頭の", 4. LLMはJSON文法としては合法な「空白文字」を無限に連続出力する → 破綻 49
構造化出力の限界 構造化出力はLLMからの出力が特定のフォーマットに沿うように強制する しかしこれはモデルが出力する内容の精度には無関係 構造化出力によってLLMの出力が壊滅するパターン 1. JSON文字列内で文字列を引用しようとして「"」を書く 2. JSON文字列が完結してしまう(本当は「\"」にする必要があった) 3. 構造化出力がJSON文法に沿う続きの出力を強制(戻れない)
4. LLMはJSON文法としては合法な「空白文字」を無限に連続出力する {"comment": "面白い感想だと思います。特に冒頭の",▢▢▢... → 破綻 50
構造化出力の限界 構造化出力はLLMからの出力が特定のフォーマットに沿うように強制する しかしこれはモデルが出力する内容の精度には無関係 構造化出力によってLLMの出力が壊滅するパターン 1. JSON文字列内で文字列を引用しようとして「"」を書く 2. JSON文字列が完結してしまう(本当は「\"」にする必要があった) 3. 構造化出力がJSON文法に沿う続きの出力を強制(戻れない)
4. LLMはJSON文法としては合法な「空白文字」を無限に連続出力する → 破綻、max_tokensを使い切る {"comment": "面白い感想だと思います。特に冒頭の",▢▢▢ ▢▢▢▢▢▢▢▢▢▢▢▢▢▢▢▢▢▢... 51
構造化出力の限界 構造化出力はLLMからの出力が特定のフォーマットに沿うように強制する しかしこれはモデルが出力する内容の精度には無関係 無限空白 /改行問題 として 構造化出力によってLLMの出力が壊滅するパターン 1. JSON文字列内で文字列を引用しようとして「"」を書く 2.
JSON文字列が完結してしまう(本当は「\"」にする必要があった) 3. 構造化出力がJSON文法に沿う続きの出力を強制(戻れない) 4. LLMはJSON文法としては合法な「空白文字」を無限に連続出力する → 破綻、max_tokensを使い切る 構造化出力でよく発生する {"comment": "面白い感想だと思います。特に冒頭の",▢▢▢ ▢▢▢▢▢▢▢▢▢▢▢▢▢▢▢▢▢▢... 52
構造化出力で解決できない問題の回避策 • 入力プロンプトに『「"」ではなく「'」を使え』という指示を入れる • JSONのfield間に入れられる空白文字の個数を制限する 構造化出力は強力だが 銀の弾丸ではない あくまでモデルの出力を 補助する仕組み 出力内容の精度は
モデルの性能に依存する 53
構造化出力で解決できない問題の回避策 • 入力プロンプトに『「"」ではなく「'」を使え』という指示を入れる • JSONのfield間に入れられる空白文字の個数を制限する 構造化出力は強力だが 銀の弾丸ではない 構造化出力 あくまでモデルの出力を 補助する仕組み
出力内容の精度は モデルの性能に依存する 54
We’re Hiring! LLM推論最適化チームでは、 PLaMoの性能向上に一緒に取り組む仲間を募集しています! • LLMのコスト効率改善(スループット向上・レイテンシ改善・省GPUメモリ化) ◦ 重み/KV Cache量子化、CUDAカーネル実装、推論フレームワーク の改善など
◦ 最新の手法を実際にサービスとしてデプロイできるようにする • 構造化出力など推論レイヤの技術開発 • vLLMのオープンソース開発 55