|
|
@@ -27,10 +27,12 @@ import java.util.stream.Collectors;
|
|
|
* 数据源: param.userNetworkSeqFeature 里的 s_z_y_s (元素列表) + zt_gyf (归一分列表)
|
|
|
* 上游 alg_user_network_seq_feature 已新增, 来自 user_element_profile_hot
|
|
|
* top_elements = UNION ALL(positive_ranked, negative_ranked), 所以归一分可能为负
|
|
|
- * 逻辑: (element, score) pair 按 score DESC 取前 topN 正向元素 -> 查 elements_ros_recall 倒排
|
|
|
+ *
|
|
|
+ * 逻辑: (element, score) pair 按 score DESC 取前 topN=30 正向元素 -> 一次 multiGet
|
|
|
+ * elements_ros_recall:{kw} 倒排 -> 同 vid 取 max score -> 排序 -> filter
|
|
|
* 只取正向 (score > 0), 避免召回用户厌恶元素
|
|
|
*
|
|
|
- * 跟 YearShareDkElementsRecallStrategy 共用 Redis 倒排 key, 仅用户兴趣源不同
|
|
|
+ * 跟 YearShareDkElementsRecallStrategy 共用 Redis 倒排 key, 仅用户兴趣源 + 取法不同
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@Component
|
|
|
@@ -45,7 +47,7 @@ public class UserProfileDkElementsRecallStrategy implements RecallStrategy {
|
|
|
|
|
|
private final String CLASS_NAME = this.getClass().getSimpleName();
|
|
|
|
|
|
- public static final int topN = 5;
|
|
|
+ public static final int topN = 30;
|
|
|
public static final String PUSH_FROM = "recall_user_profile_dk_elements";
|
|
|
public static final String redisKeyPrefix = "elements_ros_recall";
|
|
|
|
|
|
@@ -99,14 +101,14 @@ public class UserProfileDkElementsRecallStrategy implements RecallStrategy {
|
|
|
}
|
|
|
|
|
|
/** 组对 + 过滤负向 + 按归一分降序 + 取前 topN 个 element */
|
|
|
- private List<String> pickTopPositiveElements(List<String> elements, List<String> scoreStrs) {
|
|
|
+ private List<String> pickTopPositiveElements(List<String> elements, List<String> scores) {
|
|
|
List<Pair<String, Double>> pairs = new ArrayList<>();
|
|
|
for (int i = 0; i < elements.size(); i++) {
|
|
|
String element = elements.get(i);
|
|
|
if (StringUtils.isBlank(element)) {
|
|
|
continue;
|
|
|
}
|
|
|
- double score = NumberUtils.toDouble(scoreStrs.get(i), 0.0);
|
|
|
+ double score = NumberUtils.toDouble(scores.get(i), 0.0);
|
|
|
if (score <= 0) {
|
|
|
continue;
|
|
|
}
|