NewsCrawler.org

How the Two-Tower search model works: training, inference and serving

仕組み編:Two-Towerによる検索システム(学習・推論・配信)
Two-Tower によるページ検索の例。検索ワード・位置情報・閲覧履歴と、ページのタイトル・カテゴリ・本文を別々のタワーで埋め込みに変換し、内積で関連度のスコアを計算する。
事前処理ではアイテムの特徴量をアイテムタワーに入力し、出力された埋め込みを保存する。リクエスト時にはクエリの特徴量をクエリタワーに入力し、出力された埋め込みと保存済みのアイテム埋め込みを使い、ANN などでクエリと関連度の高いアイテムを取得してユーザーに返す。
Image: zenn.dev

The article explains the Two-Tower[1] model used in search and recommendation. Two separate neural networks turn a query and an item into vectors, and relevance is scored by the dot product of the two vectors. Item vectors can be computed in advance, so large candidate sets can be searched quickly.

Training raises the score of the correct item above the scores of negative items. The basic method is in-batch negatives[2], where the correct items of other pairs in the same mini-batch serve as negatives, and the loss is softmax cross-entropy. The article also covers the logQ correction from Yi et al., which reduces the bias toward popular items, and Mixed Negative Sampling from Yang et al., which adds uniformly random items so that items absent from click logs are also compared.

Hard negative mining[3] selects negatives that the model scores highly. Huang et al. at Facebook used this method and reported the best recall when negatives were taken from ranks 101 to 500. For serving, item embeddings are stored in advance, query embeddings are computed per request, and approximate nearest neighbor search (ANN)[4] is used when there are many items, which trades some accuracy for speed.

Read the original zenn.dev

Sources

  • Zenn JA

    仕組み編:Two-Towerによる検索システム(学習・推論・配信)

    29 likes6 bookmarks0 comments

Published: First seen: Читать по-русски

Open as a page