Skip to content

Commit 340ef1d

Browse files
taku910hiroyuki-komatsu
authored andcommitted
Removed the Mendel flag user_history_cache_full_sentence.
This flag is now only enabled on canary and has never been pushed to prod. We found that this model makes the suggestion pretty aggressive, which is inconsistent with the fact that users prefer exact match results. We will merge this flag to the upcoming model to remember inner segment boundary information. PiperOrigin-RevId: 820500823
1 parent f7c0c21 commit 340ef1d

File tree

3 files changed

+60
-75
lines changed

3 files changed

+60
-75
lines changed

src/prediction/user_history_predictor.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,13 +2024,9 @@ void UserHistoryPredictor::InsertHistoryForConversionSegments(
20242024
const ConversionRequest& request, bool is_suggestion_selected,
20252025
uint64_t last_access_time, const SegmentsForLearning& learning_segments,
20262026
UserHistoryPredictor::RevertEntries* revert_entries) {
2027-
const commands::DecoderExperimentParams& params =
2028-
request.request().decoder_experiment_params();
2029-
20302027
// Inserts all_key/all_value.
20312028
// We don't insert it for mobile.
2032-
if ((params.user_history_cache_full_sentence() ||
2033-
!IsMixedConversionEnabled(request)) &&
2029+
if (!IsMixedConversionEnabled(request) &&
20342030
learning_segments.conversion_segments.size() > 1) {
20352031
Insert(request, 0, 0, learning_segments.conversion_segments_key,
20362032
learning_segments.conversion_segments_value, "",

src/prediction/user_history_predictor_test.cc

Lines changed: 59 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -3434,78 +3434,72 @@ TEST_F(UserHistoryPredictorTest, GetInputKeyFromSegmentsKana) {
34343434
}
34353435

34363436
TEST_F(UserHistoryPredictorTest, RealtimeConversionInnerSegment) {
3437-
for (bool cache_full_sentence : {true, false}) {
3438-
for (bool mixed_conversion : {true, false}) {
3439-
UserHistoryPredictor* predictor =
3440-
GetUserHistoryPredictorWithClearedHistory();
3441-
3442-
SegmentsProxy segments_proxy;
3443-
std::vector<Result> results;
3444-
3445-
request_.set_mixed_conversion(mixed_conversion);
3446-
request_.mutable_decoder_experiment_params()
3447-
->set_user_history_cache_full_sentence(cache_full_sentence);
3448-
3449-
const bool cache_full_sentence_expected =
3450-
(!mixed_conversion || cache_full_sentence);
3451-
3452-
{
3453-
constexpr absl::string_view kKey = "わたしのなまえはなかのです";
3454-
constexpr absl::string_view kValue = "私の名前は中野です";
3455-
const ConversionRequest convreq1 =
3456-
SetUpInputForPrediction(kKey, &composer_, &segments_proxy);
3457-
segments_proxy.AddCandidate(0, kValue);
3458-
// "わたしの, 私の", "わたし, 私"
3459-
segments_proxy.PushBackInnerSegmentBoundary(0, 0, 12, 6, 9, 3);
3460-
// "なまえは, 名前は", "なまえ, 名前"
3461-
segments_proxy.PushBackInnerSegmentBoundary(0, 0, 12, 9, 9, 6);
3462-
// "なかのです, 中野です", "なかの, 中野"
3463-
segments_proxy.PushBackInnerSegmentBoundary(0, 0, 15, 12, 9, 6);
3464-
predictor->Finish(convreq1, segments_proxy.MakeLearningResults(),
3465-
kRevertId);
3437+
for (bool mixed_conversion : {true, false}) {
3438+
UserHistoryPredictor* predictor =
3439+
GetUserHistoryPredictorWithClearedHistory();
34663440

3467-
UserHistoryPredictorTestPeer predictor_peer(*predictor);
3468-
auto* entry = predictor_peer.dic_()->MutableLookupWithoutInsert(
3469-
UserHistoryPredictor::Fingerprint(kKey, kValue));
3470-
if (cache_full_sentence_expected) {
3471-
EXPECT_TRUE(entry);
3472-
} else {
3473-
EXPECT_FALSE(entry);
3474-
}
3475-
}
3476-
segments_proxy.Clear();
3441+
SegmentsProxy segments_proxy;
3442+
std::vector<Result> results;
34773443

3478-
const ConversionRequest convreq2 =
3479-
SetUpInputForPrediction("なかの", &composer_, &segments_proxy);
3480-
results = predictor->Predict(convreq2);
3481-
EXPECT_FALSE(results.empty());
3482-
EXPECT_TRUE(FindCandidateByValue("中野", results));
3483-
EXPECT_FALSE(FindCandidateByValue("中野です", results));
3484-
segments_proxy.Clear();
3444+
request_.set_mixed_conversion(mixed_conversion);
3445+
const bool cache_full_sentence_expected = !mixed_conversion;
34853446

3486-
const ConversionRequest convreq3 =
3487-
SetUpInputForPrediction("なかので", &composer_, &segments_proxy);
3488-
results = predictor->Predict(convreq3);
3489-
EXPECT_FALSE(results.empty());
3490-
EXPECT_TRUE(FindCandidateByValue("中野です", results));
3447+
{
3448+
constexpr absl::string_view kKey = "わたしのなまえはなかのです";
3449+
constexpr absl::string_view kValue = "私の名前は中野です";
3450+
const ConversionRequest convreq1 =
3451+
SetUpInputForPrediction(kKey, &composer_, &segments_proxy);
3452+
segments_proxy.AddCandidate(0, kValue);
3453+
// "わたしの, 私の", "わたし, 私"
3454+
segments_proxy.PushBackInnerSegmentBoundary(0, 0, 12, 6, 9, 3);
3455+
// "なまえは, 名前は", "なまえ, 名前"
3456+
segments_proxy.PushBackInnerSegmentBoundary(0, 0, 12, 9, 9, 6);
3457+
// "なかのです, 中野です", "なかの, 中野"
3458+
segments_proxy.PushBackInnerSegmentBoundary(0, 0, 15, 12, 9, 6);
3459+
predictor->Finish(convreq1, segments_proxy.MakeLearningResults(),
3460+
kRevertId);
34913461

3492-
segments_proxy.Clear();
3493-
const ConversionRequest convreq4 =
3494-
SetUpInputForPrediction("なまえ", &composer_, &segments_proxy);
3495-
results = predictor->Predict(convreq4);
3496-
EXPECT_FALSE(results.empty());
3497-
EXPECT_TRUE(FindCandidateByValue("名前", results));
3498-
// Do not suggest the phrase ends with [content_word + function_word].
3499-
EXPECT_FALSE(FindCandidateByValue("名前は", results));
3500-
EXPECT_FALSE(FindCandidateByValue("名前は中野です", results));
3501-
if (mixed_conversion) {
3502-
// prefer exact match.
3503-
EXPECT_FALSE(FindCandidateByValue("名前は中野", results));
3462+
UserHistoryPredictorTestPeer predictor_peer(*predictor);
3463+
auto* entry = predictor_peer.dic_()->MutableLookupWithoutInsert(
3464+
UserHistoryPredictor::Fingerprint(kKey, kValue));
3465+
if (cache_full_sentence_expected) {
3466+
EXPECT_TRUE(entry);
35043467
} else {
3505-
// prefer prediction.
3506-
EXPECT_TRUE(FindCandidateByValue("名前は中野", results));
3468+
EXPECT_FALSE(entry);
35073469
}
35083470
}
3471+
segments_proxy.Clear();
3472+
3473+
const ConversionRequest convreq2 =
3474+
SetUpInputForPrediction("なかの", &composer_, &segments_proxy);
3475+
results = predictor->Predict(convreq2);
3476+
EXPECT_FALSE(results.empty());
3477+
EXPECT_TRUE(FindCandidateByValue("中野", results));
3478+
EXPECT_FALSE(FindCandidateByValue("中野です", results));
3479+
segments_proxy.Clear();
3480+
3481+
const ConversionRequest convreq3 =
3482+
SetUpInputForPrediction("なかので", &composer_, &segments_proxy);
3483+
results = predictor->Predict(convreq3);
3484+
EXPECT_FALSE(results.empty());
3485+
EXPECT_TRUE(FindCandidateByValue("中野です", results));
3486+
3487+
segments_proxy.Clear();
3488+
const ConversionRequest convreq4 =
3489+
SetUpInputForPrediction("なまえ", &composer_, &segments_proxy);
3490+
results = predictor->Predict(convreq4);
3491+
EXPECT_FALSE(results.empty());
3492+
EXPECT_TRUE(FindCandidateByValue("名前", results));
3493+
// Do not suggest the phrase ends with [content_word + function_word].
3494+
EXPECT_FALSE(FindCandidateByValue("名前は", results));
3495+
EXPECT_FALSE(FindCandidateByValue("名前は中野です", results));
3496+
if (mixed_conversion) {
3497+
// prefer exact match.
3498+
EXPECT_FALSE(FindCandidateByValue("名前は中野", results));
3499+
} else {
3500+
// prefer prediction.
3501+
EXPECT_TRUE(FindCandidateByValue("名前は中野", results));
3502+
}
35093503
}
35103504
}
35113505

src/protocol/commands.proto

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -642,11 +642,6 @@ message DecoderExperimentParams {
642642
// This parameter is only used in mixed conversion mode.
643643
optional int32 user_history_suppress_min_length = 130 [default = 0];
644644

645-
// Caches full sentences consisting of multiple segments in user history
646-
// learning. This mode is enabled on desktop, but we want to enable it on all
647-
// devices to unify and simplify the implementation.
648-
optional bool user_history_cache_full_sentence = 131 [default = false];
649-
650645
// Demotes the partial candidates so that the top_n results must
651646
// be non-partial candidates.
652647
optional int32 demote_partial_candidate_top_n = 126 [default = 0];

0 commit comments

Comments
 (0)