Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
PLaMo 3.0 Primeの構造化出力サポート
Search
Preferred Networks
PRO
July 30, 2026
Technology
290
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
Rustuna: Rustによる高速なOptuna実装
pfn
PRO
0
200
Optunaの最新リリースv5.0について
pfn
PRO
0
120
OptunaHub: ブラックボックス最適化のためのプラットフォーム
pfn
PRO
0
140
Conditional PED-ANOVA: Hyperparameter Importance in Hierarchical & Dynamic Search Spaces
pfn
PRO
0
140
AI を支えるクラウドネイティブエコシステム
pfn
PRO
0
53
MN-Core™ について語りたい - 第59回 情報科学若手の会
pfn
PRO
1
910
User Namespaces in Production: Enabling Root in Containers with RWX
pfn
PRO
0
120
世界最先端の研究を製品へ~PFNでのプロダクトマネジメントの難しさとその醍醐味~
pfn
PRO
0
81
PLaMo 3.0 Primeの事後学習
pfn
PRO
0
430
Other Decks in Technology
See All in Technology
フィンテック養成勉強会#68
finengine
0
170
AIがコードを書く時代に、エンジニアは何で自分の価値を証明するのか / In an era where AI writes code how do engineers prove their value
carta_engineering
3
1.2k
ウォンテッドリーの最近のプロダクトと技術の紹介
stomk
0
240
AIカンパニーへの転換を支えた、エンジニアの仕事の再定義
kworkdev
PRO
2
1.4k
10年後、Engineering 行為を剥奪されるとして、わたしたちは、どう、何を創ればいいだろうか。 / If Engineering Is Taken Away in 10 Years, How and What Should We Create?
bitkey
PRO
1
210
WasmをRustにする
sansantech
PRO
0
300
大型犬好きによるPugの紹介
yamanoku
1
160
二歩目のフロントエンド・ウェブアクセシビリティ
camiha
2
690
Webの常識が通じないHTMLメールのダークモード
teamlab
PRO
0
140
スプシの手作業からの解脱 ~更新はClaude Codeに、見せ方と使い方はGASアプリに任せる~
kentarofujii
0
160
初海外で注意すべきこと12選!!!安全快適なre:invent生活にするために
yuuuuuuu168
1
180
Metadata - Section 1: HTML Basics
mohab1
0
130
Featured
See All Featured
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.8k
Everyday Curiosity
cassininazir
0
360
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
330
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
Product Roadmaps are Hard
iamctodd
55
13k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.6k
Designing Experiences People Love
moore
143
24k
Accessibility Awareness
sabderemane
1
250
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
203
77k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.9k
Producing Creativity
orderedlist
PRO
348
41k
Making Projects Easy
brettharned
120
6.8k
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