Переглянути джерело

ctcvr_model_v3_calibration

jch 1 місяць тому
батько
коміт
e1a5258270

+ 9 - 6
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/score/strategy/RankStrategyBy833.java

@@ -16,6 +16,7 @@ import com.tzld.piaoquan.recommend.feature.domain.ad.base.AdRankItem;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.collections4.MapUtils;
+import org.apache.commons.lang.math.NumberUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
@@ -52,9 +53,8 @@ public class RankStrategyBy833 extends RankStrategyBasic {
     @Value("${word2vec.exp:694}")
     private String word2vecExp;
 
-    @Value("${view.833.limit:3000}")
-    private Integer viewLimit;
-
+    @ApolloJsonValue("${rank.score.params.833:{}}")
+    private Map<String, String> paramsMap;
 
     // FIXME(zhoutian): 可能需要独立配置
     @ApolloJsonValue("${rank.score.weight.680:{}}")
@@ -304,6 +304,7 @@ public class RankStrategyBy833 extends RankStrategyBasic {
             log.error("scoring result is empty");
         }
         long time5 = System.currentTimeMillis();
+        int viewLimit = NumberUtils.toInt(paramsMap.getOrDefault("viewLimit", "3000"));
         // calibrate score for negative sampling or cold start
         for (AdRankItem item : result) {
             double originalScore = item.getLrScore();
@@ -319,7 +320,7 @@ public class RankStrategyBy833 extends RankStrategyBasic {
                 double smoothCxr = NumUtil.divSmoothV1(conver, view, 1.64);
                 //模型打分和统计计算取打分更低的
                 item.getScoreMap().put("cvcvrItemValue", 1.0);
-                if(smoothCxr <= calibratedScore){
+                if (smoothCxr <= calibratedScore) {
                     calibratedScore = smoothCxr;
                     item.getScoreMap().put("cvcvrItemValue", 2.0);
                 }
@@ -330,7 +331,8 @@ public class RankStrategyBy833 extends RankStrategyBasic {
             item.getScoreMap().put("ctcvrScore", calibratedScore);
         }
 
-        calculateCtcvrScore(result, request, scoreParam, "dnnV2", reqFeature);
+        String calibModelName = paramsMap.getOrDefault("calibModelName", "dnnV3");
+        calculateCtcvrScore(result, request, scoreParam, calibModelName, reqFeature);
         if (CollectionUtils.isEmpty(result)) {
             log.error("calculateCtcvrScore result is empty");
         }
@@ -379,6 +381,7 @@ public class RankStrategyBy833 extends RankStrategyBasic {
 
         result.sort(ComparatorUtil.equalsRandomComparator());
 
+        String logModelName = paramsMap.getOrDefault("logModelName", "dnnV3");
         if (CollectionUtils.isNotEmpty(result)) {
             AdRankItem top1Item = result.get(0);
             List<String> participateCompetitionType = new ArrayList<>();
@@ -397,7 +400,7 @@ public class RankStrategyBy833 extends RankStrategyBasic {
                 top1Item.getExt().put("ecpm", modelCtcvrScore * top1Item.getCpa() * 1000);
             }
             putMetaFeature(top1Item, feature, reqFeature, sceneFeatureMap, request);
-            top1Item.getExt().put("model", "dnnV2");
+            top1Item.getExt().put("model", logModelName);
         }
         long time6 = System.currentTimeMillis();
         log.info("cost={}, getFeature={}, handleFeature={},  similar={}, bucketFeature={}, getScorerPipeline={}, " +