feat: 通过FastScorer与批处理功能增强关联兴趣计算器

- 集成FastScorer用于优化评分,绕过sklearn以提升性能。
- 新增批量处理功能,以应对高频聊天场景。
- 实现了一个全局线程池以避免重复创建执行器。
- 将评分操作的超时时间缩短至2秒。
- 重构了ChatterActionPlanner以利用新的利息计算器。
- 引入了一个基准测试脚本,用于比较原始sklearn与FastScorer之间的性能差异。
开发了一款优化后的评分器,具备权重剪枝和异步评分等功能。
This commit is contained in:
Windpicker-owo
2025-12-12 12:14:21 +08:00
parent ef0c569348
commit 9d01b81cef
14 changed files with 1476 additions and 1550 deletions

View File

@@ -16,14 +16,19 @@ class TfidfFeatureExtractor:
"""TF-IDF 特征提取器
使用字符级 n-gram 策略,适合中文/多语言场景
优化说明2024.12
- max_features 从 20000 降到 10000减少计算量
- ngram_range 默认 (2, 3),对于兴趣任务足够
- min_df 提高到 3过滤低频噪声
"""
def __init__(
self,
analyzer: str = "char", # type: ignore
ngram_range: tuple[int, int] = (2, 4),
max_features: int = 20000,
min_df: int = 5,
ngram_range: tuple[int, int] = (2, 3), # 优化:缩小 n-gram 范围
max_features: int = 10000, # 优化:减少特征数量,矩阵大小和 dot product 减半
min_df: int = 3, # 优化:过滤低频 n-gram
max_df: float = 0.95,
):
"""初始化特征提取器