feat: 変換ペルソナ(persona をモデル左コンテキストに前置) - #92
Open
togatoga wants to merge 8 commits into
Open
Conversation
config.toml の [conversion] profile に自由なテキスト(例:
"田中太郎/エンジニア")を設定すると、run_kana_kanji_conversion で
モデルへ渡す左コンテキストの先頭に
「プロフィール:{p}・発言:{ctx}」の形で毎回付与される。
末尾25文字まで使用、空で無効。単一の入口で注入するため
ライブ変換のチャンクと Space 変換の両方に効き、変換キャッシュの
キー(lctx)にも自然に含まれる。azooKey の zenz-v2 方式に倣った
平文注入(jinen モデルは専用トークン未学習のため)。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
profile はモデル・学習履歴・ユーザー辞書・ペルソナをプロフィール単位で 切り替える将来機能の名前として空けておく。モデルへ注入するラベルは 自然な日本語の「プロフィール:」のまま。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ペルソナは意図的に lctx 表示へ出していないため、効いているかが 画面から分からなかった。モード表示(例: ⚡[あ]P)で一目で分かる ようにする。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
P の印だけでは何が効いているか分からないため、モデルが受け取る 実効値(trim後の末尾25文字)をそのまま表示する。表示とモデル入力は effective_persona で共有し、常に一致する。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
このサイズのかな漢字モデルは「プロフィール:」「発言:」のような 擬似構造化プロンプトを理解しないため、キーワード(建築、programming など)が直前の文章として見えるだけの単純な形にする。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- キャッシュキー構築後は key.lctx を借用し、余分な clone を削除 - 却下した設計(ラベル方式)への言及をコメント・ドキュメントから削除 - mode_indicator の二重 format を整理 - effective_persona 経由で重複していた末尾切詰めテストを1本に統合 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
azooKey-Desktop の「変換プロフィール」に相当する機能(karukan では persona)を追加します。config.toml に自分についての短いテキストを設定すると、それがモデルへ渡す左コンテキストの先頭に毎回付与され、プロフィールに合わせた変換(自分の名前の読みなど)が出やすくなります。
azooKey の実装調査(要約)
U+EE03を持つ独立フィールドとして左文脈タグより前に注入。zenz-v2 では平文でプロフィール:{p}・発言:{左文脈}と文脈に混ぜる方式jinen モデルは専用トークンを学習しておらず、また「プロフィール:」「発言:」のような擬似構造化ラベルを理解できる規模でもないため、本PRは ラベルなしの単純前置(キーワードが直前の文章として見えるだけ)を採用しています。
実装
[conversion] persona(既定""= 無効)を追加run_kana_kanji_conversion内の単一の入口(persona_lctx)で行う:{persona}{ctx}(ラベルも区切り文字もなしの純粋な連結。persona は trim 後の末尾25文字)max_context_length切詰めの後に前置するため、プロフィールが切詰めで消えることはない⚡[あ]P:プログラミング)。表示とモデル入力はeffective_personaを共有するので常に一致。lctx:行はチャンク文脈のままテスト
プロフィール:…・発言:{先行チャンクの変換}になること(キャッシュキー経由で検証)cargo test -p karukan-im/-p karukan-fcitx5全通過、clippy / fmt クリーン備考
jinen モデルはこの注入形式で学習していないため効果は実験的です(azooKey も「実験的な機能のため、精度が不十分な場合があります」と案内)。本命は将来のモデル学習での専用トークン化(zenz-v3 方式)です。
命名について
設定キーは
profileではなくpersonaです。profileはモデル・学習履歴・ユーザー辞書・ペルソナをプロフィール単位(プライベート/仕事など)で切り替える将来機能の名前として予約しています。🤖 Generated with Claude Code