better:优化了表达模型的预测,和表达方式的学习逻辑
This commit is contained in:
@@ -60,13 +60,8 @@ class QuestionMaker:
|
||||
|
||||
# 如果没有 raise_time==0 的项,则仅有 5% 概率抽样一个
|
||||
conflicts_with_zero = [c for c in conflicts if (getattr(c, "raise_time", 0) or 0) == 0]
|
||||
if not conflicts_with_zero:
|
||||
if random.random() >= 0.01:
|
||||
return None
|
||||
# 以均匀概率选择一个(此时权重都等同于 0.05,无需再按权重)
|
||||
chosen_conflict = random.choice(conflicts)
|
||||
else:
|
||||
# 权重规则:raise_time == 0 -> 1.0;raise_time >= 1 -> 0.05
|
||||
if conflicts_with_zero:
|
||||
# 权重规则:raise_time == 0 -> 1.0;raise_time >= 1 -> 0.01
|
||||
weights = []
|
||||
for conflict in conflicts:
|
||||
current_raise_time = getattr(conflict, "raise_time", 0) or 0
|
||||
@@ -77,12 +72,9 @@ class QuestionMaker:
|
||||
chosen_conflict = random.choices(conflicts, weights=weights, k=1)[0]
|
||||
|
||||
# 选中后,自增 raise_time 并保存
|
||||
try:
|
||||
chosen_conflict.raise_time = (getattr(chosen_conflict, "raise_time", 0) or 0) + 1
|
||||
chosen_conflict.save()
|
||||
except Exception:
|
||||
# 静默失败不影响流程
|
||||
pass
|
||||
|
||||
|
||||
return chosen_conflict
|
||||
|
||||
|
||||
@@ -288,7 +288,7 @@ class ConflictTracker:
|
||||
if existing_conflict:
|
||||
# 检查raise_time是否大于3且没有答案
|
||||
current_raise_time = getattr(existing_conflict, "raise_time", 0) or 0
|
||||
if current_raise_time > 1 and not existing_conflict.answer:
|
||||
if current_raise_time > 0 and not existing_conflict.answer:
|
||||
# 删除该条目
|
||||
await self.delete_conflict(original_question, tracker.chat_id)
|
||||
logger.info(f"追踪结束后删除条目(raise_time={current_raise_time}且无答案): {original_question}")
|
||||
|
||||
Reference in New Issue
Block a user