Files
mindfulness/server/app/features/personalized_reco/rerank_freqcap/defaults.py
2026-02-02 16:47:37 +08:00

42 lines
1.1 KiB
Python
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.
from __future__ import annotations
from app.features.personalized_reco.rerank_freqcap.types import RerankConfig, Scene
_DEFAULTS: dict[Scene, RerankConfig] = {
# FeedMMR λ=0.7;冷却参数不强制使用
"feed": RerankConfig(
mmr_lambda=0.7,
top_n_for_mmr=200,
cooldown_sentence_days=0,
cooldown_author_days=0,
cooldown_template_days=0,
),
# Push工程默认来自算法规则的建议参数
"push": RerankConfig(
mmr_lambda=0.7,
top_n_for_mmr=200,
cooldown_sentence_days=14,
cooldown_author_days=7,
cooldown_template_days=7,
),
# Widget工程默认
"widget": RerankConfig(
mmr_lambda=0.7,
top_n_for_mmr=200,
cooldown_sentence_days=7,
cooldown_author_days=7,
cooldown_template_days=7,
),
}
def get_default_config(scene: Scene) -> RerankConfig:
"""
获取指定场景的默认参数(返回副本,避免被意外修改)。
"""
base = _DEFAULTS[scene]
return RerankConfig.model_validate(base.model_dump())