Commit d8c53e77 authored by adafang@google.com's avatar adafang@google.com Committed by Chromium LUCI CQ

[launcher-result-normalizer] Integrating into zero state providers and...

[launcher-result-normalizer] Integrating into zero state providers and experimenting with normalizers

Scores from providers have different distributions and ranges, this makes them difficult to compare. Here we have implemented a basic way to normalize ChromeSearchResults by subtracting the mean of the learned distribution. After experimentation with more complex normalization methods we will then update this normalization method.

Further details at go/cros-launcher-normalization

In this CL we have integrated the normalizer into the omnibox provider, drive zero state provider and zero state file provider

Bug: 1156930
Change-Id: Ic232efb0b31eb712959b6d386b39366ff4c38a54
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2601357Reviewed-by: default avatarTony Yeoman <tby@chromium.org>
Reviewed-by: default avatarRachel Wong <wrong@chromium.org>
Commit-Queue: Ada Fang <adafang@google.com>
Cr-Commit-Position: refs/heads/master@{#841361}
parent 30aa1a83
...@@ -101,6 +101,10 @@ DriveZeroStateProvider::DriveZeroStateProvider( ...@@ -101,6 +101,10 @@ DriveZeroStateProvider::DriveZeroStateProvider(
drive_service_->AddObserver(this); drive_service_->AddObserver(this);
} }
} }
if (base::FeatureList::IsEnabled(
app_list_features::kEnableLauncherSearchNormalization)) {
normalizer_.emplace("drive_zero_state_provider", profile);
}
} }
DriveZeroStateProvider::~DriveZeroStateProvider() { DriveZeroStateProvider::~DriveZeroStateProvider() {
...@@ -214,6 +218,12 @@ void DriveZeroStateProvider::OnFilePathsLocated( ...@@ -214,6 +218,12 @@ void DriveZeroStateProvider::OnFilePathsLocated(
} }
cache_results_.reset(); cache_results_.reset();
if (normalizer_.has_value()) {
normalizer_->Record(provider_results);
normalizer_->NormalizeResults(&provider_results);
}
SwapResults(&provider_results); SwapResults(&provider_results);
LogStatus(Status::kOk); LogStatus(Status::kOk);
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "base/sequence_checker.h" #include "base/sequence_checker.h"
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
...@@ -16,6 +17,7 @@ ...@@ -16,6 +17,7 @@
#include "chrome/browser/chromeos/drive/drive_integration_service.h" #include "chrome/browser/chromeos/drive/drive_integration_service.h"
#include "chrome/browser/ui/app_list/search/files/file_result.h" #include "chrome/browser/ui/app_list/search/files/file_result.h"
#include "chrome/browser/ui/app_list/search/files/item_suggest_cache.h" #include "chrome/browser/ui/app_list/search/files/item_suggest_cache.h"
#include "chrome/browser/ui/app_list/search/score_normalizer/score_normalizer.h"
#include "chrome/browser/ui/app_list/search/search_provider.h" #include "chrome/browser/ui/app_list/search/search_provider.h"
#include "chromeos/components/drivefs/mojom/drivefs.mojom.h" #include "chromeos/components/drivefs/mojom/drivefs.mojom.h"
...@@ -69,6 +71,9 @@ class DriveZeroStateProvider : public SearchProvider, ...@@ -69,6 +71,9 @@ class DriveZeroStateProvider : public SearchProvider,
// Whether the suggested files experiment is enabled. // Whether the suggested files experiment is enabled.
const bool suggested_files_enabled_; const bool suggested_files_enabled_;
// The normalizer normalizes the relevance scores of Results
base::Optional<ScoreNormalizer> normalizer_;
// Whether we have sent at least one request to ItemSuggest to warm up the // Whether we have sent at least one request to ItemSuggest to warm up the
// results cache. // results cache.
bool have_warmed_up_cache_ = false; bool have_warmed_up_cache_ = false;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "chrome/browser/ui/app_list/search/omnibox_provider.h" #include "chrome/browser/ui/app_list/search/omnibox_provider.h"
#include "ash/public/cpp/app_list/app_list_features.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h"
...@@ -37,6 +38,10 @@ OmniboxProvider::OmniboxProvider(Profile* profile, ...@@ -37,6 +38,10 @@ OmniboxProvider::OmniboxProvider(Profile* profile,
std::make_unique<ChromeAutocompleteProviderClient>(profile), std::make_unique<ChromeAutocompleteProviderClient>(profile),
AutocompleteClassifier::DefaultOmniboxProviders())) { AutocompleteClassifier::DefaultOmniboxProviders())) {
controller_->AddObserver(this); controller_->AddObserver(this);
if (base::FeatureList::IsEnabled(
app_list_features::kEnableLauncherSearchNormalization)) {
normalizer_.emplace("omnibox_provider", profile);
}
} }
OmniboxProvider::~OmniboxProvider() {} OmniboxProvider::~OmniboxProvider() {}
...@@ -87,6 +92,11 @@ void OmniboxProvider::PopulateFromACResult(const AutocompleteResult& result) { ...@@ -87,6 +92,11 @@ void OmniboxProvider::PopulateFromACResult(const AutocompleteResult& result) {
is_zero_state_input_)); is_zero_state_input_));
} }
if (normalizer_.has_value()) {
normalizer_->Record(new_results);
normalizer_->NormalizeResults(&new_results);
}
SwapResults(&new_results); SwapResults(&new_results);
} }
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#include <memory> #include <memory>
#include "base/macros.h" #include "base/macros.h"
#include "base/optional.h"
#include "chrome/browser/ui/app_list/search/score_normalizer/score_normalizer.h"
#include "chrome/browser/ui/app_list/search/search_provider.h" #include "chrome/browser/ui/app_list/search/search_provider.h"
#include "components/omnibox/browser/autocomplete_controller.h" #include "components/omnibox/browser/autocomplete_controller.h"
...@@ -50,6 +52,9 @@ class OmniboxProvider : public SearchProvider, ...@@ -50,6 +52,9 @@ class OmniboxProvider : public SearchProvider,
// eliminates the results as they come in. // eliminates the results as they come in.
std::unique_ptr<AutocompleteController> controller_; std::unique_ptr<AutocompleteController> controller_;
// The normalizer normalizes the relevance scores of Results
base::Optional<ScoreNormalizer> normalizer_;
DISALLOW_COPY_AND_ASSIGN(OmniboxProvider); DISALLOW_COPY_AND_ASSIGN(OmniboxProvider);
}; };
......
...@@ -79,6 +79,11 @@ ZeroStateFileProvider::ZeroStateFileProvider(Profile* profile) ...@@ -79,6 +79,11 @@ ZeroStateFileProvider::ZeroStateFileProvider(Profile* profile)
profile->GetPath().AppendASCII("zero_state_local_files.pb"), config, profile->GetPath().AppendASCII("zero_state_local_files.pb"), config,
chromeos::ProfileHelper::IsEphemeralUserProfile(profile)); chromeos::ProfileHelper::IsEphemeralUserProfile(profile));
} }
if (base::FeatureList::IsEnabled(
app_list_features::kEnableLauncherSearchNormalization)) {
normalizer_.emplace("zero_state_file_provider", profile);
}
} }
ZeroStateFileProvider::~ZeroStateFileProvider() = default; ZeroStateFileProvider::~ZeroStateFileProvider() = default;
...@@ -118,6 +123,11 @@ void ZeroStateFileProvider::SetSearchResults( ...@@ -118,6 +123,11 @@ void ZeroStateFileProvider::SetSearchResults(
} }
} }
if (normalizer_.has_value()) {
normalizer_->Record(new_results);
normalizer_->NormalizeResults(&new_results);
}
UMA_HISTOGRAM_TIMES("Apps.AppList.ZeroStateFileProvider.Latency", UMA_HISTOGRAM_TIMES("Apps.AppList.ZeroStateFileProvider.Latency",
base::TimeTicks::Now() - query_start_time_); base::TimeTicks::Now() - query_start_time_);
SwapResults(&new_results); SwapResults(&new_results);
......
...@@ -13,12 +13,14 @@ ...@@ -13,12 +13,14 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/scoped_refptr.h" #include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "base/scoped_observer.h" #include "base/scoped_observer.h"
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/browser/chromeos/file_manager/file_tasks_notifier.h" #include "chrome/browser/chromeos/file_manager/file_tasks_notifier.h"
#include "chrome/browser/chromeos/file_manager/file_tasks_observer.h" #include "chrome/browser/chromeos/file_manager/file_tasks_observer.h"
#include "chrome/browser/ui/app_list/search/score_normalizer/score_normalizer.h"
#include "chrome/browser/ui/app_list/search/search_provider.h" #include "chrome/browser/ui/app_list/search/search_provider.h"
class Profile; class Profile;
...@@ -62,6 +64,9 @@ class ZeroStateFileProvider : public SearchProvider, ...@@ -62,6 +64,9 @@ class ZeroStateFileProvider : public SearchProvider,
// empty query. // empty query.
std::unique_ptr<RecurrenceRanker> files_ranker_; std::unique_ptr<RecurrenceRanker> files_ranker_;
// The normalizer normalizes the relevance scores of Results
base::Optional<ScoreNormalizer> normalizer_;
base::TimeTicks query_start_time_; base::TimeTicks query_start_time_;
ScopedObserver<file_manager::file_tasks::FileTasksNotifier, ScopedObserver<file_manager::file_tasks::FileTasksNotifier,
......
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