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
280
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
MN-Core™ について語りたい - 第59回 情報科学若手の会
pfn
PRO
1
720
User Namespaces in Production: Enabling Root in Containers with RWX
pfn
PRO
0
110
世界最先端の研究を製品へ~PFNでのプロダクトマネジメントの難しさとその醍醐味~
pfn
PRO
0
63
PLaMo 3.0 Primeの事後学習
pfn
PRO
0
400
plamo-3-translateの開発
pfn
PRO
0
460
PLaMoを毎日の開発で使い育てていく
pfn
PRO
0
270
The Making of AI Chips
pfn
PRO
1
1.2k
国産生成AI PLaMoを支える事後学習と推論最適化
pfn
PRO
13
5.9k
Japanese SimpleQA: 日本語における事実に基づいた回答能力の評価ベンチマーク
pfn
PRO
1
510
Other Decks in Technology
See All in Technology
雪かき部 #7 もう怖くない!SELECT文!
foursue
0
220
Confitura 2026
logico_jp
0
110
IR Today: Theory, Practice, and Agents
dtunkelang
0
270
DORA_Metrics.pdf
wagnerfusca
1
140
AWS FinOps Agent 結局何が得意なの?
siromi
0
220
20260929_AmazonGuardDutyの検出通知メールにAWS DevOpsAgentの調査結果を追加する
yhana
1
380
【ゲームメーカーズスクランブル2026】『Shadowverse: Worlds Beyond』UIとアニメーションで実現する最高のユーザー体験を叶えるプロトタイピング
cygames
PRO
1
700
猫でもわかるKiro Web
kentapapa
1
160
覗いてみよう 関数型ビジュアル言語×2Dグラフィックスの世界
yohyamasaki
0
150
OpenClawでAzure DevOpsのWiki更新を自動化する - クラウドAIだけでは届かない場所へ
yutakaosada
0
130
データ品質を壊しながらSnowflakeのAIに分析させてみた
kawanago
0
320
AIエージェントを安全で速い現場監督にする:Jev・Obsidian・メタハーネス
x5gtrn
PRO
0
140
Featured
See All Featured
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
350
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
840
Building a Scalable Design System with Sketch
lauravandoore
464
34k
Into the Great Unknown - MozCon
thekraken
41
2.7k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
450
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
290
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
850
Crafting Experiences
bethany
1
360
Art, The Web, and Tiny UX
lynnandtonic
304
22k
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