Commit 73b21d67 authored by Charles Zhao's avatar Charles Zhao Committed by Commit Bot

Update Tab Ranker model.

(1) Update native_inference.h, native_inference.cc,
example_preprocessor_config.pb to be the newest model.

(2) Update tab_score_predictor_unittest.cc

(3) Add amoylan as extra owner of this directory.

Change-Id: Iffb2f84e5cbf65ae20d864fccc2edface051055e
Reviewed-on: https://chromium-review.googlesource.com/1068952
Commit-Queue: Charles . <charleszhao@chromium.org>
Reviewed-by: default avatarMichael Giuffrida <michaelpg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561352}
parent 849d5f90
set noparent set noparent
amoylan@chromium.org
michaelpg@chromium.org michaelpg@chromium.org
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
namespace tab_ranker { namespace tab_ranker {
namespace tfnative_model { namespace tfnative_model {
constexpr int DNN_WEIGHTS_SIZE = 29040; constexpr int DNN_WEIGHTS_SIZE = 29160;
constexpr int DNN_RANK = 2; constexpr int DNN_RANK = 2;
constexpr int FEATURES_SIZE = 726; constexpr int FEATURES_SIZE = 729;
constexpr int DNN_BIASES_SIZE = 40; constexpr int DNN_BIASES_SIZE = 40;
struct alignas(16) FixedAllocations { struct alignas(16) FixedAllocations {
......
...@@ -135,7 +135,7 @@ TEST_F(TabScorePredictorTest, KnownScore) { ...@@ -135,7 +135,7 @@ TEST_F(TabScorePredictorTest, KnownScore) {
window.tab_count = 27; window.tab_count = 27;
// Pre-calculated score using the generated model outside of Chrome. // Pre-calculated score using the generated model outside of Chrome.
EXPECT_FLOAT_EQ(7.5816331, ScoreTab(tab, window, mru)); EXPECT_FLOAT_EQ(8.0287771, ScoreTab(tab, window, mru));
} }
// Checks the score for a different example that we have calculated a known // Checks the score for a different example that we have calculated a known
...@@ -164,7 +164,7 @@ TEST_F(TabScorePredictorTest, KnownScoreMissingOptionalFeatures) { ...@@ -164,7 +164,7 @@ TEST_F(TabScorePredictorTest, KnownScoreMissingOptionalFeatures) {
window.tab_count = 127; window.tab_count = 127;
// Pre-calculated score using the generated model outside of Chrome. // Pre-calculated score using the generated model outside of Chrome.
EXPECT_FLOAT_EQ(12.989228, ScoreTab(tab, window, mru)); EXPECT_FLOAT_EQ(10.577342, ScoreTab(tab, window, mru));
} }
TEST_F(TabScorePredictorTest, InactiveDuration) { TEST_F(TabScorePredictorTest, InactiveDuration) {
...@@ -195,12 +195,12 @@ TEST_F(TabScorePredictorTest, NumReactivationBefore) { ...@@ -195,12 +195,12 @@ TEST_F(TabScorePredictorTest, NumReactivationBefore) {
float no_reactivations_score = ScoreTab(example); float no_reactivations_score = ScoreTab(example);
// A tab with reactivations is more likely to be reactivated than one without. // A tab with reactivations is more likely to be reactivated than one without.
example.num_reactivations = 4; example.num_reactivations = 10;
float reactivations_score = ScoreTab(example); float reactivations_score = ScoreTab(example);
ASSERT_GT(reactivations_score, no_reactivations_score); ASSERT_GT(reactivations_score, no_reactivations_score);
// A tab with more reactivations is more likely to be reactivated. // A tab with more reactivations is more likely to be reactivated.
example.num_reactivations = 10; example.num_reactivations = 20;
float more_reactivations_score = ScoreTab(example); float more_reactivations_score = ScoreTab(example);
ASSERT_GT(more_reactivations_score, reactivations_score); ASSERT_GT(more_reactivations_score, reactivations_score);
} }
...@@ -220,7 +220,7 @@ TEST_F(TabScorePredictorTest, PageTransitionTypes) { ...@@ -220,7 +220,7 @@ TEST_F(TabScorePredictorTest, PageTransitionTypes) {
TEST_F(TabScorePredictorTest, SiteEngagementScore) { TEST_F(TabScorePredictorTest, SiteEngagementScore) {
TabFeatures example = GetTabFeatures(kUnseenHost, true /*user_activity*/); TabFeatures example = GetTabFeatures(kUnseenHost, true /*user_activity*/);
example.site_engagement_score = 0; example.site_engagement_score.reset();
float engagement_score_0 = ScoreTab(example); float engagement_score_0 = ScoreTab(example);
// A site with low engagement ranks higher than one with no engagement. // A site with low engagement ranks higher than one with no engagement.
...@@ -233,7 +233,7 @@ TEST_F(TabScorePredictorTest, SiteEngagementScore) { ...@@ -233,7 +233,7 @@ TEST_F(TabScorePredictorTest, SiteEngagementScore) {
float engagement_score_medium = ScoreTab(example); float engagement_score_medium = ScoreTab(example);
ASSERT_GT(engagement_score_medium, engagement_score_low); ASSERT_GT(engagement_score_medium, engagement_score_low);
example.site_engagement_score = 100; example.site_engagement_score = 80;
float engagement_score_high = ScoreTab(example); float engagement_score_high = ScoreTab(example);
ASSERT_GT(engagement_score_high, engagement_score_medium); ASSERT_GT(engagement_score_high, engagement_score_medium);
} }
...@@ -249,12 +249,11 @@ TEST_F(TabScorePredictorTest, TopURLHigherScore) { ...@@ -249,12 +249,11 @@ TEST_F(TabScorePredictorTest, TopURLHigherScore) {
} }
TEST_F(TabScorePredictorTest, TopURLLowerScore) { TEST_F(TabScorePredictorTest, TopURLLowerScore) {
// Expect Wikipedia tabs to be less likely to be reactivated. // Expect www.google.com tabs to be less likely to be reactivated.
// See also: https://xkcd.com/214/
TabFeatures unseen_example = TabFeatures unseen_example =
GetTabFeatures(kUnseenHost, true /*user_activity*/); GetTabFeatures(kUnseenHost, true /*user_activity*/);
TabFeatures lower_example = TabFeatures lower_example =
GetTabFeatures("en.wikipedia.org", true /*user_activity*/); GetTabFeatures("www.google.com", true /*user_activity*/);
ASSERT_LT(ScoreTab(lower_example), ScoreTab(unseen_example)); ASSERT_LT(ScoreTab(lower_example), ScoreTab(unseen_example));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment