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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Preferred Networks
PRO
July 30, 2026
Technology
200
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
User Namespaces in Production: Enabling Root in Containers with RWX
pfn
PRO
0
52
世界最先端の研究を製品へ~PFNでのプロダクトマネジメントの難しさとその醍醐味~
pfn
PRO
0
43
PLaMo 3.0 Primeの事後学習
pfn
PRO
0
310
plamo-3-translateの開発
pfn
PRO
0
340
PLaMoを毎日の開発で使い育てていく
pfn
PRO
0
210
The Making of AI Chips
pfn
PRO
1
1.1k
国産生成AI PLaMoを支える事後学習と推論最適化
pfn
PRO
13
5.6k
Japanese SimpleQA: 日本語における事実に基づいた回答能力の評価ベンチマーク
pfn
PRO
1
470
Headlampと独自プラグインを活用したKubernetesダッシュボードの機能拡張
pfn
PRO
2
490
Other Decks in Technology
See All in Technology
モノリス Rails でも日中に rails db:migrate を走らせたい! / Daytime rails db:migrate on Monolithic Rails!
euglena1215
4
650
MulticaとPi Coding Agentで、小規模OSSを30本同時運用した流れ
eiei114
0
130
AIにブラウザを触らせて、E2EテストをPlaywrightで書く
koji_kawamura
0
190
ハーレムエンジニアリング
kazuma777777
0
190
生成 AI の基礎 〜 サンプル実装で学ぶ基本原理
enakai00
7
4.5k
【GCC2026】TrueHDRIを用いたルックデブ環境とライティングテクニック
bandainamcostudios
PRO
0
120
ホームラボ紹介
y_sera15
0
220
【GCC2026】鉄拳8でのVFX開発事例
bandainamcostudios
PRO
0
120
Software Supply Chain Attackからクラウド環境を守るためにできること
lhazy
2
280
老害フォレンジッカーはAI羊の夢を見るか?
tadmaddad
0
350
Apache Icebergインフラストラクチャ:ストレージ・カタログ・エンジンの選択肢とClouderaプラットフォームでの実装
tsugiyama
0
120
【GCC2026】大規模言語モデルを活用した内製検索サービスの社内展開や業務活用
bandainamcostudios
PRO
0
340
Featured
See All Featured
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
From π to Pie charts
rasagy
0
310
Ruling the World: When Life Gets Gamed
codingconduct
0
300
A better future with KSS
kneath
240
18k
Between Models and Reality
mayunak
4
400
Site-Speed That Sticks
csswizardry
13
1.5k
KATA
mclloyd
PRO
35
15k
Statistics for Hackers
jakevdp
799
230k
What does AI have to do with Human Rights?
axbom
PRO
1
2.3k
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