42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
from __future__ import annotations
|
||
|
||
from app.features.personalized_reco.rerank_freqcap.types import RerankConfig, Scene
|
||
|
||
|
||
_DEFAULTS: dict[Scene, RerankConfig] = {
|
||
# Feed:MMR λ=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())
|
||
|