feat: 提升语义兴趣评分与拼写错误生成
- 为中文拼写生成器实现了背景预热功能,以提升首次使用时的性能。 - 更新了MessageStorageBatcher以支持可配置的提交批次大小和间隔,优化数据库写入性能。 - 增强版数据集生成器,对样本规模设置硬性限制并提升采样效率。 - 将AutoTrainer中的最大样本数增加至1000,以优化训练数据利用率。 - 对亲和兴趣计算器进行了重构,以避免并发初始化并优化模型加载逻辑。 - 引入批量处理机制用于语义兴趣评分,以应对高频聊天场景。 - 更新了配置模板以反映新的评分参数,并移除了已弃用的兴趣阈值。
This commit is contained in:
20
bot.py
20
bot.py
@@ -567,6 +567,7 @@ class MaiBotMain:
|
||||
|
||||
def __init__(self):
|
||||
self.main_system = None
|
||||
self._typo_prewarm_task = None
|
||||
|
||||
def setup_timezone(self):
|
||||
"""设置时区"""
|
||||
@@ -663,6 +664,25 @@ class MaiBotMain:
|
||||
async def run_async_init(self, main_system):
|
||||
"""执行异步初始化步骤"""
|
||||
|
||||
# 后台预热中文错别字生成器,避免首次使用阻塞主流程
|
||||
try:
|
||||
from src.chat.utils.typo_generator import get_typo_generator
|
||||
|
||||
typo_cfg = getattr(global_config, "chinese_typo", None)
|
||||
self._typo_prewarm_task = asyncio.create_task(
|
||||
asyncio.to_thread(
|
||||
get_typo_generator,
|
||||
error_rate=getattr(typo_cfg, "error_rate", 0.3),
|
||||
min_freq=getattr(typo_cfg, "min_freq", 5),
|
||||
tone_error_rate=getattr(typo_cfg, "tone_error_rate", 0.2),
|
||||
word_replace_rate=getattr(typo_cfg, "word_replace_rate", 0.3),
|
||||
max_freq_diff=getattr(typo_cfg, "max_freq_diff", 200),
|
||||
)
|
||||
)
|
||||
logger.debug("已启动 ChineseTypoGenerator 后台预热任务")
|
||||
except Exception as e:
|
||||
logger.debug(f"启动 ChineseTypoGenerator 预热失败(可忽略): {e}")
|
||||
|
||||
# 初始化数据库表结构
|
||||
await self.initialize_database_async()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user