Files
group_xinghuo_jinrong/docs/course/jinrong-module-customer/modules/06-profile-l0.html
T
zhanghongyu_0626 4b8e11c9bd feat(threshold): Implement customer loss threshold configuration and notification system
- Added `ThresholdRepository` for managing customer loss threshold configurations and notifications.
- Introduced `threshold_service` to handle loss threshold alerts based on customer portfolio performance.
- Enhanced `customer_prompts` to include new intent for querying product net values.
- Updated `customer_service` to integrate new threshold alert functionality into existing workflows.
- Implemented `sanitize_postprocess` for improved compliance handling in customer interactions.
- Enhanced course documentation to reflect updates in advisor training modules and interactive elements.

This update significantly improves the customer experience by providing proactive loss threshold notifications and enhancing the overall service framework.
2026-09-10 10:57:40 +08:00

100 lines
6.2 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<section class="module" id="module-6">
<div class="module-inner">
<p class="eyebrow animate-in">模块 6 · L0 与 L1 画像</p>
<h1 class="module-title animate-in">正式风评 vs 抽槽画像<br>Top-K 怎么注入 prompt?</h1>
<p class="module-lead animate-in">
客户线除了查 Core 真账,还有后台<strong>画像抽槽</strong>(L1)调措辞。
拍板铁律:<strong>L0 永远优先</strong>——正式 C1~C5、持仓数字、适当性判定听 Core,L1 不能覆盖。
偏好类槽位注入 prompt 时走 <strong>Top-K + 时间衰减</strong>(R1),不是全量平铺。
</p>
<div class="screen animate-in">
<h2>L0 vs L1:谁说了算?</h2>
<div class="pattern-cards">
<div class="pattern-card">
<h3>L0 · Core 正式数据</h3>
<p>风评 C1~C5、持仓/流水数字、适当性矩阵判定——100% 来自 Core 只读查询 Tool(<code>core_ro_tool.py</code>)的 <code>fact_text</code>。LLM 只解读,不能改写。</p>
</div>
<div class="pattern-card">
<h3>L1 · 对话 enrich 画像</h3>
<p>登录客户每 5 轮节流,后台线程跑画像抽槽与合并(<code>profile_service.py</code>)→ 写入 MySQL <code>style_tags</code> + Redis 热缓存。只影响 generate/chitchat 的措辞语境,<strong>不能</strong>替代正式风评。</p>
</div>
<div class="pattern-card">
<h3>撞车规则</h3>
<p>抽槽若与 L0 字段冲突(例如用户口述「我是 R5」但 Core 是 R3)→ <strong>永远听 L0</strong>。合并规则 D7:用户显式 <code>user_declared</code> 不被 <code>inferred</code> 覆盖。</p>
</div>
</div>
</div>
<div class="screen animate-in">
<h2>13 槽位 + confidence 门槛</h2>
<p>槽位表唯一来源:画像槽位定义(<code>profile_slots.py</code>)——13 个 path(含 C-08 <code>investment.allocation_target</code>),含 merge_mode 与 sensitivity。</p>
<div class="step-cards">
<div class="step-card">
<span class="step-num">①</span>
<p><strong>归一</strong> · <code>normalize_value</code><br>
例如「我喜欢货币基金」→ 映射到 9 类 <code>PRODUCT_TYPE_VOCAB</code>(不是具体 SKU 代码)。</p>
</div>
<div class="step-card">
<span class="step-num">②</span>
<p><strong>阈值</strong> · confidence ≥0.7(默认)/ ≥0.9(高敏)才写入;高敏 <code>inferred</code> 一律丢弃。</p>
</div>
<div class="step-card">
<span class="step-num">③</span>
<p><strong>合并</strong> · <code>merge_candidates</code><br>
单值 latest 覆盖;偏好/排除类 set_union 并集,并写 <code>items_meta</code>(R1)。</p>
</div>
</div>
<div class="callout callout-accent">
<strong>谁写 L1:</strong> 仅<strong>登录</strong>客户线(<code>customer_service.profile_maybe_extract</code>);游客试聊不写画像。<br>
<strong>C-04 阈值槽:</strong> <code>threshold_pref_summary</code> → <code>customer_threshold_config</code>;达线提醒仅在查持仓时 inline。
</div>
</div>
<div class="screen animate-in">
<h2>R1 · 偏好 Top-K 注入</h2>
<div class="translation-block">
<div class="translation-code">
<span class="translation-label">注入前筛选 · 画像上下文渲染(profile_service.py)</span>
<pre><code><span class="code-line"><span class="code-comment"># settings 默认:top_k=3 · ttl=90d · half_life=30d</span></span>
<span class="code-line">score = confidence × decay × (1 + log(mention_count))</span>
<span class="code-line"><span class="code-comment"># 超 TTL 的偏好不进 prompt;取得分 Top-K 条</span></span></code></pre>
</div>
<div class="translation-english">
<span class="translation-label">白话</span>
<div class="translation-lines">
<p class="tl">客户说过很多偏好类型,但 prompt 里只带<strong>最近、反复提到</strong>的前几条,避免画像越积越长带偏 LLM。</p>
<p class="tl">很久没提过的偏好(超过 90 天)不再注入,但 MySQL 里仍保留,下次提到会刷新。</p>
<p class="tl">改 K 或 TTL → 动环境配置(<code>settings.py</code> 的 <code>profile_preference_*</code>),别在 prompt 里硬编码。</p>
</div>
</div>
</div>
<div class="quiz-container" id="quiz-customer-m6">
<div class="quiz-question-block"
data-correct="option-b"
data-explanation-right="对。L1 偏好只 enrich 措辞;持仓数字、正式风评、适当性结论必须来自 Core L0,画像不能覆盖。"
data-explanation-wrong="L0 正式数据优先级高于 L1 抽槽——这是合规硬阀门。">
<h3 class="quiz-question">客户口述「我是激进型 R5」,但 Core 风评是 R3,持仓查询应信谁?</h3>
<div class="quiz-options">
<button class="quiz-option" data-value="option-a" onclick="selectOption(this)">
<div class="quiz-option-radio"></div><span>信 L1 抽槽,按 R5 解读</span>
</button>
<button class="quiz-option" data-value="option-b" onclick="selectOption(this)">
<div class="quiz-option-radio"></div><span>信 Core L0 的 R3;L1 最多调闲聊措辞</span>
</button>
<button class="quiz-option" data-value="option-c" onclick="selectOption(this)">
<div class="quiz-option-radio"></div><span>取两者平均</span>
</button>
</div>
<div class="quiz-feedback"></div>
</div>
<button class="quiz-check-btn" onclick="checkQuiz('quiz-customer-m6')">检查答案</button>
<button class="quiz-reset-btn" onclick="resetQuiz('quiz-customer-m6')">重做</button>
</div>
<p class="module-footer-note">相关文件:画像抽槽与合并(<code>app/service/profile_service.py</code>)· 槽位表(<code>app/config/profile_slots.py</code>)· 环境配置(<code>app/config/settings.py</code>)</p>
</div>
</div>
</section>