Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ニホンゴ⾷べません。 LLMで敬語コンパイラを作ってみた

Avatar for Sau Sau
August 25, 2026

ニホンゴ⾷べません。 LLMで敬語コンパイラを作ってみた

Presented at PyCon JP 2026

Avatar for Sau

Sau

August 25, 2026

More Decks by Sau

Other Decks in Technology

Transcript

  1. トーンについて 「敬語のレベル」の概念(Liu, ⼩林 (2022) 『社会的関係を考慮した⽇本語敬語コーパスの構築への取り組み』より) 尊敬度 RESPECT Level 1: ⾮常にフォーマル

    ご自分でお調べになっては いかがでしょうか Level 2 ご自分でお調べください Level 3 自分で調べて Level 4: カジュアル、ネット⽤語など ググって 13
  2. トーンについて 「敬語のレベル」の概念(Liu, ⼩林 (2022) 『社会的関係を考慮した⽇本語敬語コーパスの構築への取り組み』より) 尊敬度 RESPECT ビジネスメールの 敬語 イメージ:

    1.5 メガバンク 2.2 スタートアップ Level 1: ⾮常にフォーマル ご自分でお調べになっては いかがでしょうか Level 2 ご自分でお調べください Level 3 自分で調べて Level 4: カジュアル、ネット⽤語など ググって 14
  3. 敬語コンパイラのアーキテクチャ DSPyを使⽤ (Declarative Self-improving Python)  INPUT JUDGE ⼊⼒ LLM

    Judge - ⾔いたいこと - 状況説明 - トーン 4つの独⾃評価軸 OPTIMIZER OUTPUT DSPy 最適化 ビジネスメール プロンプトを⾃動 最適化 完璧な敬語メール 16 16
  4. プロンプト(seed) Code モデルに送られたプロンプト (抜粋) class RewriteBusinessJapanese(dspy.Signature): System Message: """Rewrite simple

    Japanese into natural business Japanese following the tone_instruction. Output only the body. Do not include greetings such as お世話になっており ます。 Do not include closing phrases such as よろしくお願 いいたします。 """ source_text: str = dspy.InputField() situation: str = dspy.InputField() tone_instruction: str = dspy.InputField( default=DEFAULT_TONE ) business_japanese: str = dspy.OutputField() Your input fields are: 1. `source_text` (str): 2. `situation` (str): 3. `tone_instruction` (str): Your output fields are: 1. `reasoning` (str): 2. `business_japanese` (str): All interactions will be structured in the following way, with the appropriate values filled in. {...} In adhering to this structure, your objective is: Rewrite simple Japanese into natural business Japanese following the tone_instruction. Output only the body. Do not include greetings such as お世話になっておりま す。 Do not include closing phrases such as よろしくお願い いたします。 17
  5. LLM-as-a-judgeの4つの評価軸 01 意味の忠実性 • 原⽂の意図や重要な事実を正しく維持できているか • 原⽂にない重要情報を付け加えたりしていないか 03 ⽂の⾃然さ ⾃然で読みやすい⽇本語になっているか

    02 状況‧トーンの適切さ メールの状況や指定されたトーンに合った表現に なっているか 04 空気を読む能⼒ NEW 意味を伝えるだけでなく、謝意‧配慮‧婉曲表現‧ 関係維持など、その場⾯で期待されるビジネス上のコ ミュニケーションができているか 18
  6. LLM-as-a-judgeの4つの評価軸 01 意味の忠実性 ✔ 02 状況‧トーンの適切さ ✖ 03 ⽂の⾃然さ ✖

    ビジネスメールでの変換表現 04 空気を読む能⼒ ✖ 挨拶 お世話になっております。 ⾔いたいこと 名乗り Sakana AIのSauと申します。 「No」 本題 いいえ。 結び よろしくお願いいたします。 20
  7. LLM-as-a-judgeの4つの評価軸 01 意味の忠実性 ✔ 02 状況‧トーンの適切さ ✔ 03 ⽂の⾃然さ ✔

    04 空気を読む能⼒ NEW ⾔いたいこと 「本件は予算⾯で発注できない。 残念だけどサカナ商事にする予定」 状況 発注⾒送り(丁寧) ビジネスメールでの変換表現 1 誠に恐縮ではございますが、今回の件につきましては予算の都 合上、発注を⾒送らせていただきたく存じます。⼤変残念では ございますが、今回はサカナ商事様にお願いする予定でござい ます。 ビジネスメールでの変換表現 2 このたびは、ご多⽤のところ丁寧なご提案をいただき、誠にありがとうござい ました。 社内にて慎重に検討を重ねましたが、今回はご提⽰いただいた条件が弊社の予 算枠を上回る結果となり、誠に残念ながら本件のご発注は⾒送らせていただく こととなりました。 つきましては、⼼苦しい限りではございますが、今回はサカナ商事様にお願い する運びとなりましたこと、何卒ご容赦いただけますようお願い申し上げま す。 ご提案の内容⾃体は⼤変魅⼒的で、社内でも⾼く評価しておりました。またご 縁がございました際には、改めてご相談させていただければ幸いに存じます。 21
  8. Judge class BusinessJapaneseJudge(dspy.Signature): """Evaluate a Japanese business-email rewrite. Score along

    four axes: - meaning_faithfulness: preserves source intent, no reversed decisions, no invented specifics. Generic softening framing is NOT invention. - situation_and_tone_fit: register matches situation and requested tone. Keigo correctness is part of this axis. - naturalness: reads like a competent Japanese businessperson wrote it. - social_appropriateness: does situation-appropriate rhetorical work beyond bare meaningful transfer (acknowledgement, softening, relationship maintenance). Score each 0-4: 0=broken, 1=noticeable failures, 2=acceptable with issues, 3=solid, 4=excellent. {...} """ source_text: str = dspy.InputField() situation: str = dspy.InputField() tone_instruction: str = dspy.InputField() candidate: str = dspy.InputField() meaning_faithfulness: float = dspy.OutputField(desc="0-4") situation_and_tone_fit: float = dspy.OutputField(desc="0-4") naturalness: float = dspy.OutputField(desc="0-4") social_appropriateness: float = dspy.OutputField(desc="0-4") feedback: str = dspy.OutputField(desc="2-3 sentences in English") 22
  9. Rewrite + Judge rewriter = dspy.ChainOfThought(RewriteBusinessJapanese) # use Haiku 申し訳ございませんが、その際は都合がつかず、参加いたしかね

    ます。 judge = dspy.ChainOfThought(BusinessJapaneseJudge) # use strong model e.g. Opus # 1. Rewriter produces a candidate prediction = rewriter( source_text="いいえ ", dspy.Prediction( meaning_faithfulness=3.5, situation_and_tone_fit=3.5, naturalness=3.0, social_appropriateness=3.5, reasoning='The source is a bare 「いいえ」that must become a polite refusal of an event invitation. The candidate does exactly that: an apology opener 申し ( 訳ございませんが), a face-saving generic reason (都合が つかず), and a softened refusal verb (参加いたしかねま す)...' situation="イベントの誘いを断る ", ) # 2. Judge scores the candidate result = judge( source_text="いいえ ", feedback='A solid, sendable refusal: it converts a blunt "no" into apology + generic scheduling reason + softened decline... Adding a brief closing line would strengthen relationship maintenance.' situation="イベントの誘いを断る ", candidate=prediction.business_japanese, # 申し訳ご ざいませんが、その際は都合がつかず、参加いたしかねます ) ) Weighted averageで総合点数を算出 23
  10. LLMモデルのスコア⽐較 Leaderboard — 評価モデル(Judge)の切り替えによるスコア変化の⽐較 モデル名 (Judge: Claude Opus 5) スコア

    判定 モデル名 (Judge: GPT-5.6 Sol) スコア 判定 Claude Opus 5 94.2 BEST Fugu Ultra (Sakana) 98.3 BEST Claude Fable 5 94.1 BEST Fugu (Sakana) 97.1 BEST Fugu Ultra (Sakana) 92.1 HIGH GPT-5.6 Sol 96.6 BEST Gemini 3.1 Pro 90.5 HIGH Claude Fable 5 96.3 HIGH Fugu (Sakana) 90.3 GOOD Gemini 3.1 Pro 94.6 HIGH Gemini 3.5 Flash 89.6 GOOD GPT-5.6 Terra 94.1 HIGH Claude Sonnet 5 87.7 GOOD Gemini 3.5 Flash 93.6 GOOD GPT-5.6 Sol 84.7 GOOD Claude Sonnet 5 92.1 GOOD GPT-5.6 Terra 83.7 NORMAL Claude Opus 5 92.0 GOOD 24
  11. GEPAを⽤いたプロンプト⾃動最適化 GEPA (Genetic Pareto) 1. 実⾏ ‧ 判定モデルが「なぜダメだったか」を⾃然⾔語で説明 判定モデルがスコア+フィード バック⽂を返す

    ‧ Reflection LMがその説明を読み、改良プロンプトを提案 ‧ 良かった候補群をParetoで保持しながら進化を続ける ‧ DSPy 標準搭載 (dspy.GEPA) GEPA 最適化の対象モデル モデル固有のバイアスや特性を最⼤限に引き出すプロ ンプトを個別にパーソナライズ OPTIMIZER 3. Pareto保持 2. 反省 & 改良 良かった候補を保存し、単⼀戦略 への収束を防ぐ トレースとフィードバックを読 み、改善版プロンプトを提案 Fable 5 25
  12. プロンプト(GEPA最適化後) モデルに送られたプロンプト (抜粋) # Task You are a Japanese business-writing

    assistant. You receive a short, casual/blunt/fragmentary Japanese utterance plus a context label, and you rewrite it as natural, polished business Japanese that could be pasted straight into an email body and sent unchanged. ## Input format - `source_text`: a short, casual or fragmentary Japanese sentence — e.g. 「本件の進捗どう」「みます」 - `situation`: a brief noun-phrase description of the business context — e.g. 催促, 打ち合わせの調整 - `tone_instruction`: "Use natural, polished, and professional business Japanese. Match the register to the situation." ## Output format (Produce two fields) 1. `reasoning`: short analysis of literal meaning, audience, and keigo transformations. 2. `business_japanese`: the rewritten body only (no greetings, no bare sign-off, compact 2-3 sentences). ## How to rewrite (strategy & Keigo rules) 1. **Recover implicit structure** (e.g., 「メール来てない」 + 未受領 → お見積書のご送付 ) | 2. **Preserve concrete details verbatim** 3. **Say each thing exactly once** (avoid redundancy) | 4. **Split distinct acts into distinct clauses** 5. **Add one natural next action** | 6. **Insert one cushion word before requests/refusals** ( 恐れ入りますが , etc.) 7. **Add face-saving hedges** ( 行き違いでしたら等 ) | 8. **Match closing verbs and register to relationship** (internal vs external) 9. **Own actions → 謙譲語 ** (拝見いたします , 伺います ) | **Their actions → 尊敬語 ** (ご調整いただけますでしょうか ) ## Model answers (target quality) - 催促 /「本件の進捗どう」 → 本件の進捗につきまして、その後いかがでしょうか。ご多忙のところ恐れ入りますが ... - 発注完了 /「本件できた。ありがとう」 → 本件につきまして、発注手続きが完了いたしました。誠にありがとうございました。 - 打ち合わせの調整 /「15:00-16:00 でどう」 → 打ち合わせにつきましては、 8月20日(木) 15:00 ~16:00 でご都合いかがでしょうか。 {...} 26
  13. 問 1「PyCon⾏ってきます」 どちらがより⾃然で、適切に書けていると思いますか? 投票してください! 上司への報告 A 上司への報告 B 次週広島にて開催されるPyConJPへ登壇予定です。 来週はPyCon

    JP登壇のため広島に⾏ってきます! そのため、8⽉21⽇〜22⽇は終日不在となります。 そのため、8⽉21⽇〜22⽇は不在となりますので、 ご承知おきください。 Source: https://businessmail.or.jp/examination/about2/grade2_question/ 28
  14. 問 2「対応無理」 どちらがより⾃然で、適切に書けていると思いますか? 投票してください! 受けられない仕事を断るメール C 受けられない仕事を断るメール D 大変恐縮ですが、いただいたお仕事についてこのたび はお断りさせていただければと思います。

    せっかくお声がけいただいたのに恐縮ですが、今 回はお引き受けが難しい状況です。 弊社内のリソース不足が解消され次第、再度ご連絡さ せていただきたいと思います。 ご期待に沿えず申し訳ありません。 またの機会にぜひお願いできればうれしいです! Source: https://businessmail.or.jp/examination/about2/grade2_question/ 29