|
@@ -13,11 +13,6 @@ import com.tzld.piaoquan.recommend.server.service.rank.RankParam;
|
|
|
import com.tzld.piaoquan.recommend.server.service.rank.RankResult;
|
|
import com.tzld.piaoquan.recommend.server.service.rank.RankResult;
|
|
|
import com.tzld.piaoquan.recommend.server.service.rank.bo.UserShareReturnProfile;
|
|
import com.tzld.piaoquan.recommend.server.service.rank.bo.UserShareReturnProfile;
|
|
|
import com.tzld.piaoquan.recommend.server.service.rank.extractor.ExtractVideoMergeCate;
|
|
import com.tzld.piaoquan.recommend.server.service.rank.extractor.ExtractVideoMergeCate;
|
|
|
-import com.tzld.piaoquan.recommend.server.service.rank.extractor.RankExtractorItemTags;
|
|
|
|
|
-import com.tzld.piaoquan.recommend.server.service.rank.processor.RankProcessorBoost;
|
|
|
|
|
-import com.tzld.piaoquan.recommend.server.service.rank.processor.RankProcessorDensity;
|
|
|
|
|
-import com.tzld.piaoquan.recommend.server.service.rank.processor.RankProcessorInsert;
|
|
|
|
|
-import com.tzld.piaoquan.recommend.server.service.rank.processor.RankProcessorTagFilter;
|
|
|
|
|
import com.tzld.piaoquan.recommend.server.service.rank.tansform.FeatureV6;
|
|
import com.tzld.piaoquan.recommend.server.service.rank.tansform.FeatureV6;
|
|
|
import com.tzld.piaoquan.recommend.server.service.recall.strategy.*;
|
|
import com.tzld.piaoquan.recommend.server.service.recall.strategy.*;
|
|
|
import com.tzld.piaoquan.recommend.server.service.score.ScorerUtils;
|
|
import com.tzld.piaoquan.recommend.server.service.score.ScorerUtils;
|
|
@@ -28,7 +23,6 @@ import org.apache.commons.collections4.MapUtils;
|
|
|
import org.apache.commons.lang3.RandomUtils;
|
|
import org.apache.commons.lang3.RandomUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -38,11 +32,11 @@ import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * V536 实验(2026-05-27 复写):基于 V565 召回 + DNN 打分,fusion 后续做减法
|
|
|
|
|
|
|
+ * V536 实验(2026-05-27 复写):基于 V565 召回 + DNN 打分,fusion 只保留"流量池相关 + 兜底相关"
|
|
|
*
|
|
*
|
|
|
- * 当前状态(基线 commit):mergeAndSort 完整等同 Basic.mergeAndSort(含 boost/filter/insert/festive/density 后处理)
|
|
|
|
|
- * 后续 commit 会做减法:删除 rov boost / 强插 / 标签 filter / 品类降权 / 节日降权 / 密度控制,
|
|
|
|
|
- * 只保留"流量池按比例强插 + rov 兜底"机制。
|
|
|
|
|
|
|
+ * 与 V565 唯一差异在 fusion 阶段(mergeAndSort):
|
|
|
|
|
+ * - 保留:rov 空兜底 + 流量池按比例强插(topK 头部锁 + flowPoolP/newFlowPoolSelectRate 概率门 + 一侧用光兜底回填)
|
|
|
|
|
+ * - 删除:标签 filter / rov boost / 强插 / 品类降权 / 节日降权 / 密度控制(Basic 的段 2/3/4/5/6/8)
|
|
|
*
|
|
*
|
|
|
* Apollo key 保留 ${rank.score.merge.weightv536},召回/打分逻辑与 V565 同源但参数独立可调,仅 fusion 策略不同。
|
|
* Apollo key 保留 ${rank.score.merge.weightv536},召回/打分逻辑与 V565 同源但参数独立可调,仅 fusion 策略不同。
|
|
|
* 注意:召回侧需要在 RecallService 里加 isHit536Exp 块,镜像 V565 的 strategies 增删(all_rov 系列 + 9 路老召回剔除)。
|
|
* 注意:召回侧需要在 RecallService 里加 isHit536Exp 块,镜像 V565 的 strategies 增删(all_rov 系列 + 9 路老召回剔除)。
|
|
@@ -304,9 +298,18 @@ public class RankStrategy4RegionMergeModelV536 extends RankStrategy4RegionMergeM
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * V536 fusion 基线 — 整段照搬 Basic.mergeAndSort(boost/filter/insert/festive/density 全保留)
|
|
|
|
|
- * 后续 commit 会在这里做减法:删除标签 filter / rov boost / 强插 / 品类降权 / 节日降权 / 密度控制,
|
|
|
|
|
- * 只保留"流量池按比例强插 + rov 兜底"机制。
|
|
|
|
|
|
|
+ * V536 fusion: 只保留"流量池相关 + 兜底相关"逻辑
|
|
|
|
|
+ * 1. rov 空兜底:rov 池为空时流量池直接顶上 (Basic 段 1)
|
|
|
|
|
+ * 7. 流量池按比例强插:topK 头部锁 rov + topK..size 按 flowPoolP / newFlowPoolSelectRate 概率门
|
|
|
|
|
+ * 混入 flowVideos / douHotFlowPoolVideos,否则用 rov 中段;一侧用光时另一侧兜底回填 (Basic 段 7)
|
|
|
|
|
+ *
|
|
|
|
|
+ * 删除(相对 Basic):
|
|
|
|
|
+ * - 段 2: Apollo 实验参数解析 (filterRules / rankReduceConfig) — 解析出来只给 boost/filter 用,不需要了
|
|
|
|
|
+ * - 段 3: 标签读取 RankExtractorItemTags
|
|
|
|
|
+ * - 段 4: 时间卡控 RankProcessorTagFilter
|
|
|
|
|
+ * - 段 5: rov 池提权 RankProcessorBoost.boostByTag
|
|
|
|
|
+ * - 段 6: rov 池强插 RankProcessorInsert.insertByTag + 品类降权 boostByMergeCate + 节日降权 boostByFestive
|
|
|
|
|
+ * - 段 8: 密度控制 RankProcessorDensity.mergeDensityControl
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public RankResult mergeAndSort(RankParam param, List<Video> rovVideos, List<Video> flowVideos, List<Video> douHotFlowPoolVideos) {
|
|
public RankResult mergeAndSort(RankParam param, List<Video> rovVideos, List<Video> flowVideos, List<Video> douHotFlowPoolVideos) {
|
|
@@ -320,56 +323,6 @@ public class RankStrategy4RegionMergeModelV536 extends RankStrategy4RegionMergeM
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 2 根据实验号解析阿波罗参数。
|
|
|
|
|
- Set<String> abExpCodes = param.getAbExpCodes();
|
|
|
|
|
- Map<String, Map<String, String>> rulesMap = Collections.emptyMap();
|
|
|
|
|
-
|
|
|
|
|
- Map<String, List<Map<String, String>>> rankReduceRulesMap = Collections.emptyMap();
|
|
|
|
|
-
|
|
|
|
|
- if (CollectionUtils.isNotEmpty(abExpCodes)) {
|
|
|
|
|
- for (Map.Entry<String, Map<String, Map<String, String>>> entry : this.filterRules.entrySet()) {
|
|
|
|
|
- if (abExpCodes.contains(entry.getKey())) {
|
|
|
|
|
- rulesMap = entry.getValue();
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- for (Map.Entry<String, Map<String, List<Map<String, String>>>> entry : this.rankReduceConfig.entrySet()) {
|
|
|
|
|
- if (abExpCodes.contains(entry.getKey())) {
|
|
|
|
|
- rankReduceRulesMap = entry.getValue();
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- // 3 标签读取
|
|
|
|
|
- if (rulesMap != null && !rulesMap.isEmpty()) {
|
|
|
|
|
- RankExtractorItemTags extractorItemTags = new RankExtractorItemTags(this.redisTemplate);
|
|
|
|
|
- extractorItemTags.processor(rovVideos, flowVideos, douHotFlowPoolVideos);
|
|
|
|
|
- }
|
|
|
|
|
- // 6 合并结果时间卡控
|
|
|
|
|
- if (rulesMap != null && !rulesMap.isEmpty()) {
|
|
|
|
|
- RankProcessorTagFilter.processor(rovVideos, flowVideos, douHotFlowPoolVideos, rulesMap);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- // if (MapUtils.isNotEmpty(rankReduceRulesMap)) {
|
|
|
|
|
- // ExtractVideoMergeCate.addMergeCate(rovVideos, flowVideos);
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
- // 4 rov池提权功能
|
|
|
|
|
- RankProcessorBoost.boostByTag(rovVideos, rulesMap);
|
|
|
|
|
-
|
|
|
|
|
- // 5 rov池强插功能
|
|
|
|
|
- RankProcessorInsert.insertByTag(param, rovVideos, rulesMap);
|
|
|
|
|
-
|
|
|
|
|
- // 6.品类降权
|
|
|
|
|
- RankProcessorBoost.boostByMergeCate(rovVideos, rankReduceRulesMap);
|
|
|
|
|
-
|
|
|
|
|
- // 节日视频降权
|
|
|
|
|
- RankProcessorBoost.boostByFestive(param, rovVideos, rankReduceByFestiveConfig);
|
|
|
|
|
-
|
|
|
|
|
// 7 流量池按比例强插
|
|
// 7 流量池按比例强插
|
|
|
FunnelContext funnelCtx = param.getFunnelContext();
|
|
FunnelContext funnelCtx = param.getFunnelContext();
|
|
|
List<Video> result = new ArrayList<>();
|
|
List<Video> result = new ArrayList<>();
|
|
@@ -418,24 +371,7 @@ public class RankStrategy4RegionMergeModelV536 extends RankStrategy4RegionMergeM
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 8 合并结果密度控制
|
|
|
|
|
- Map<String, Integer> densityRules = new HashMap<>();
|
|
|
|
|
- if (rulesMap != null && !rulesMap.isEmpty()) {
|
|
|
|
|
- for (Map.Entry<String, Map<String, String>> entry : rulesMap.entrySet()) {
|
|
|
|
|
- String key = entry.getKey();
|
|
|
|
|
- Map<String, String> value = entry.getValue();
|
|
|
|
|
- if (value.containsKey("density")) {
|
|
|
|
|
- densityRules.put(key, Integer.valueOf(value.get("density")));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- Set<Long> videosSet = result.stream().map(Video::getVideoId).collect(Collectors.toSet());
|
|
|
|
|
- List<Video> rovRecallRankNew = rovVideos.stream().filter(r -> !videosSet.contains(r.getVideoId())).collect(Collectors.toList());
|
|
|
|
|
- List<Video> flowPoolRankNew = flowVideos.stream().filter(r -> !videosSet.contains(r.getVideoId())).collect(Collectors.toList());
|
|
|
|
|
- List<Video> resultWithDensity = RankProcessorDensity.mergeDensityControl(result,
|
|
|
|
|
- rovRecallRankNew, flowPoolRankNew, densityRules);
|
|
|
|
|
-
|
|
|
|
|
- return new RankResult(resultWithDensity);
|
|
|
|
|
|
|
+ return new RankResult(result);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private UserShareReturnProfile parseUserProfile(Map<String, Map<String, String>> userOriginInfo) {
|
|
private UserShareReturnProfile parseUserProfile(Map<String, Map<String, String>> userOriginInfo) {
|