|
@@ -31,6 +31,7 @@ public class RankStrategy4RegionMergeModelV563 extends RankStrategy4RegionMergeM
|
|
|
@Autowired
|
|
|
private FeatureService featureService;
|
|
|
|
|
|
+
|
|
|
@Value("${similarity.concurrent: true}")
|
|
|
private boolean similarityConcurrent;
|
|
|
|
|
@@ -69,6 +70,18 @@ public class RankStrategy4RegionMergeModelV563 extends RankStrategy4RegionMergeM
|
|
|
v1 = v1.subList(0, Math.min(mergeWeight.getOrDefault("v1", 5.0).intValue(), v1.size()));
|
|
|
rovRecallRank.addAll(v1);
|
|
|
setVideo.addAll(v1.stream().map(Video::getVideoId).collect(Collectors.toSet()));
|
|
|
+ //-------------------scene cf rovn------------------
|
|
|
+ List<Video> sceneCFRovn = extractAndSort(param, SceneCFRovnRecallStrategy.PUSH_FORM);
|
|
|
+ sceneCFRovn = sceneCFRovn.stream().filter(r -> !setVideo.contains(r.getVideoId())).collect(Collectors.toList());
|
|
|
+ sceneCFRovn = sceneCFRovn.subList(0, Math.min(mergeWeight.getOrDefault("sceneCFRovn", 5.0).intValue(), sceneCFRovn.size()));
|
|
|
+ rovRecallRank.addAll(sceneCFRovn);
|
|
|
+ setVideo.addAll(sceneCFRovn.stream().map(Video::getVideoId).collect(Collectors.toSet()));
|
|
|
+ //-------------------scene cf rosn------------------
|
|
|
+ List<Video> sceneCFRosn = extractAndSort(param, SceneCFRosnRecallStrategy.PUSH_FORM);
|
|
|
+ sceneCFRosn = sceneCFRosn.stream().filter(r -> !setVideo.contains(r.getVideoId())).collect(Collectors.toList());
|
|
|
+ sceneCFRosn = sceneCFRosn.subList(0, Math.min(mergeWeight.getOrDefault("sceneCFRosn", 5.0).intValue(), sceneCFRosn.size()));
|
|
|
+ rovRecallRank.addAll(sceneCFRosn);
|
|
|
+ setVideo.addAll(sceneCFRosn.stream().map(Video::getVideoId).collect(Collectors.toSet()));
|
|
|
|
|
|
//-------------------排-------------------
|
|
|
//-------------------序-------------------
|
|
@@ -311,7 +324,6 @@ public class RankStrategy4RegionMergeModelV563 extends RankStrategy4RegionMergeM
|
|
|
userFeatureMap.put(name, String.valueOf(scoreNew));
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
for (RankItem item : rankItems) {
|
|
|
Map<String, String> featureMap = new HashMap<>();
|
|
|
Map<String, Double> featureMapDouble = item.featureMapDouble;
|
|
@@ -329,57 +341,32 @@ public class RankStrategy4RegionMergeModelV563 extends RankStrategy4RegionMergeM
|
|
|
}
|
|
|
item.featureMap = featureMap;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- // vovh24特征
|
|
|
- String partition = redisTemplate.opsForValue().get("redis:vid_vovh24pred_time:partition");
|
|
|
- Map<String, Map<String, String>> vid2VovFeatureMap = this.getVideoRedisFeature(vids, "redis:vid_vovh24pred_time:" + partition + ":");
|
|
|
- for (RankItem rankItem : rankItems) {
|
|
|
- if (vid2VovFeatureMap.containsKey(String.valueOf(rankItem.getVideoId()))) {
|
|
|
- rankItem.getFeatureMap().putAll(vid2VovFeatureMap.get(String.valueOf(rankItem.getVideoId())));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
// 4 排序模型计算
|
|
|
Map<String, String> sceneFeatureMap = new HashMap<>(0);
|
|
|
- if (null != partition && partition.length() > 2) {
|
|
|
- sceneFeatureMap.put("weightKey", partition.substring(partition.length() - 2));
|
|
|
- }
|
|
|
- List<RankItem> items = ScorerUtils.getScorerPipeline("feeds_score_config_20241107.conf").scoring(sceneFeatureMap, userFeatureMap, rankItems);
|
|
|
+ List<RankItem> items = ScorerUtils.getScorerPipeline("feeds_score_config_20240807.conf").scoring(sceneFeatureMap, userFeatureMap, rankItems);
|
|
|
// 5 排序公式特征
|
|
|
- Map<String, Map<String, String>> vid2MapFeature = this.getVideoRedisFeature(vids, "redis:vid_hasreturn_rov:");
|
|
|
- double alpha_vov = mergeWeight.getOrDefault("alpha_vov", 0.1);
|
|
|
- double func = mergeWeight.getOrDefault("func", 1.0);
|
|
|
+ Map<String, Map<String, String>> vid2MapFeature = this.getVideoRedisFeature(vids, "redis:vid_hasreturn_vor:");
|
|
|
List<Video> result = new ArrayList<>();
|
|
|
for (RankItem item : items) {
|
|
|
- item.getScoresMap().put("alpha_vov", alpha_vov);
|
|
|
- double score = 0.0;
|
|
|
+ double score;
|
|
|
double fmRovOrigin = item.getScoreRov();
|
|
|
item.getScoresMap().put("fmRovOrigin", fmRovOrigin);
|
|
|
double fmRov = restoreScore(fmRovOrigin);
|
|
|
item.getScoresMap().put("fmRov", fmRov);
|
|
|
- double hasReturnRovScore = Double.parseDouble(vid2MapFeature.getOrDefault(item.getVideoId() + "", new HashMap<>()).getOrDefault("rate_n", "0"));
|
|
|
+ double hasReturnRovScore = Double.parseDouble(vid2MapFeature.getOrDefault(item.getVideoId() + "", new HashMap<>()).getOrDefault("rov", "0"));
|
|
|
item.getScoresMap().put("hasReturnRovScore", hasReturnRovScore);
|
|
|
- double vovScore = item.getVovScore();
|
|
|
- item.getScoresMap().put("vovScore", vovScore);
|
|
|
- if (func == 1) {
|
|
|
- score = fmRov * (1 + hasReturnRovScore) + alpha_vov * vovScore;
|
|
|
- } else {
|
|
|
- score = fmRov * (1 + hasReturnRovScore) * (1.0 + alpha_vov * vovScore);
|
|
|
- }
|
|
|
-
|
|
|
+ double vor = Double.parseDouble(vid2MapFeature.getOrDefault(item.getVideoId() + "", new HashMap<>()).getOrDefault("vor", "0"));
|
|
|
+ item.getScoresMap().put("vor", vor);
|
|
|
+ score = fmRov * (0.1 + hasReturnRovScore) * (0.1 + vor);
|
|
|
Video video = item.getVideo();
|
|
|
video.setScore(score);
|
|
|
video.setSortScore(score);
|
|
|
video.setScoresMap(item.getScoresMap());
|
|
|
video.setAllFeatureMap(item.getAllFeatureMap());
|
|
|
- if (feature != null
|
|
|
- && MapUtils.isNotEmpty(feature.getVideoFeature())
|
|
|
- && MapUtils.isNotEmpty(feature.getVideoFeature().get(item.getVideoId() + ""))) {
|
|
|
+ if (MapUtils.isNotEmpty(feature.getVideoFeature()) && MapUtils.isNotEmpty(feature.getVideoFeature().get(item.getVideoId() + ""))) {
|
|
|
video.getMetaFeatureMap().putAll(feature.getVideoFeature().get(item.getVideoId() + ""));
|
|
|
}
|
|
|
- if (feature != null
|
|
|
- && MapUtils.isNotEmpty(feature.getUserFeature())) {
|
|
|
+ if (MapUtils.isNotEmpty(feature.getUserFeature())) {
|
|
|
video.getMetaFeatureMap().putAll(feature.getUserFeature());
|
|
|
}
|
|
|
result.add(video);
|