Upload
yahoo
View
2.128
Download
0
Embed Size (px)
Citation preview
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
ランキングチューニングと定量評価
ヤフー株式会社 近藤司2015/5/13 第16回 Lucence/Solr勉強会 #SolrJP
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P2 自己紹介
• 近藤 司
• ヤフー株式会社
• 新卒 3年目
• Solr歴 半年
• 業務内容
• ヤフーの各種サービスへSolr導入やランキングチューニングのお手伝い
• 社内向けドキュメントの検索サービスの開発・運用
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P3 本日の話の概要
• 検索結果の質を定量的に評価する手法
• ↑と組み合わせてランキングチューニングをする方法についてお話します
• 時間があれば、Solrでドキュメントのスコアの内訳を見る方法を説明します
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P4 話の流れ
• ランキングチューニングについて
• 難しいところ
• 解決策
• 定量評価の手法
• NDCG
• 実際のチューニング作業の流れ
• (時間があれば)ドキュメントのスコアの見方
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P5 話の流れ
• ランキングチューニングについて
• 難しいところ
• 解決策
• 定量評価の手法
• NDCG
• 実際のチューニング作業の流れ
• (時間があれば)ドキュメントのスコアの見方
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P6 ランキングチューニングとは
• 検索結果の上位に質の高いドキュメントを持ってくる作業
• ex)
• q = “本田圭佑 試合”
• 「本田試合速報」
• 「本田圭佑2ゴール!!」
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P7 Solrでのチューニング作業
• Solrだと大体こんな感じ
• qf=title_ma^10 title_ng^2 body_ma^5 body_ng^1
• 各フィールドへの重みを変えたり
• bf=production(field(ctr),10)
• Boost functionでインデキシングしておいた定数を調整したり
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P8 チューニングの難しいところ
• フィールドへの重みをどう決めるのか
• とりあえず、Titleは強めの重み?
• MA(形態素解析)も大きめに?
• ランキングが良くなっているのか分かりにくい
• あるクエリでは良くなっているけど、別のクエリでは?
• そもそも、評価が主観
ランキングの良し悪しを判断する基準が無い
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P9 チューニングと定量評価
• チューニングと定量評価をセットで考える
• 重みを変えたら評価をする
• メリット
• 客観的にランキングを評価できる
• 最もランキングが良くなる重みを探しだせる
• チューニング作業の一部を自動化できる
• デメリット
• 導入コストが高い
• 定量評価の計算に時間がかかる場合がある
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P10 話の流れ
• ランキングチューニングについて
• 難しいところ
• 解決策
• 定量評価の手法
• NDCG
• 実際のチューニング作業の流れ
• (時間があれば)ドキュメントのスコアの見方
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P11 NDCG
• NDCG
• Normalized Discounted Cumulative Gain
• ランキングの並びの良さを評価する指標
• クエリとの適合度が高いドキュメントが上位に来ていればいるほど評価大
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P12 NDCG
• DCG … 順位と適合度をもとにしたスコア
• IDCG … 理論上ランキングの並びが最も良くなった場合のDCG
• i … 検索順位
• rel … i位に順位付けされたドキュメントのクエリとの適合度
NDCG =DCGIDCG
DCG =2reli −1log(1+ i)i
k
∑
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P13 NDCGの計算例
• あるクエリで検索した場合の検索結果上位3位の評価が下記の場合
4: very good 3: good 2: bad 1: very bad
順位 ドキュメント 評価
1 doc1 1
2 doc2 4
3 doc3 3
ドキュメントがクエリに マッチしているかどうかは人手で判断
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P14 DCG
DCG =21 −1log(1+1)
+24 −1
log(1+ 2)+
23 −1log(1+3)
DCG =11+151.58
+72
DCG =13.99
順位 ドキュメント 評価
1 doc1 1 2 doc2 4 3 doc3 3
NDCG =DCGIDCG
DCG =2reli −1log(1+ i)i
k
∑
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P15 IDCG
IDCG =24 −1log(1+1)
+23 −1
log(1+ 2)+
21 −1log(1+3)
IDCG =151+71.58
+12
IDCG =19.93
順位 ドキュメント 評価
1 doc1 1 2 doc2 4 3 doc3 3
NDCG =DCGIDCG
DCG =2reli −1log(1+ i)i
k
∑doc2,doc3,doc1の並びになった 仮定で計算
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P16 NDCG
DCG =13.99IDCG =19.93
NDCG =13.9919.93
= 0.7
順位 ドキュメント 評価
1 doc1 1 2 doc2 4 3 doc3 3
NDCG =DCGIDCG
DCG =2reli −1log(1+ i)i
k
∑
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P17 話の流れ
• ランキングチューニングについて
• 難しいところ
• 解決策
• 定量評価の手法
• NDCG
• 実際のチューニング作業の流れ
• (時間があれば)ドキュメントのスコアの見方
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P18 前準備
1. ランキングを評価するクエリを決める
• 検索数上位50位のクエリなど
2. 各評価用クエリでドキュメントの適合度を評価しておく(正解データの準備)
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P19 チューニングの進め方
1. 各フィールドへの重みを決める
• qf=title_ma^10 title_ng^2 body_ma^5 body_ng^1
2. 評価用クエリで検索+NDCGを計算
• 各クエリで算出したNDCGの平均を算出
3. 重みを変えて、手順1-2を繰り返す
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P20
Title_ma Title_ng Body_ma Body_ng NDCG
10 2 5 1 0.55 15 2 5 1 0.58 20 2 5 1 0.62
10 4 5 1 0.53 10 6 5 1 0.51 10 8 5 1 0.49
フィールドへの重みの組み合わせとNDCGの値
…
…
この重みの付け方が1番良さそう!
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P21 補足
• 定性評価について
• 必要なくなる訳ではない
• 検索結果に不適切なドキュメントが紛れていないか調査が必要
• NDCGが低いクエリの調査
• TopKに入って欲しくないドキュメントの調査
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P22
• 正解データを準備するコストが高い • 評価用クエリ100個 * 1クエリ当たりで評価するドキュメン
ト5件 = 500件分の評価が必要
• NDCGの計算に時間がかかる場合がある • フィールド数:4、調査する重みの範囲:1 – 10の場合、
10^4=10000通りの試行回数が必要
定量評価を組み合わせることのデメリット
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P23 話の流れ
• ランキングチューニングについて
• 難しいところ
• 解決策
• 定量評価の手法
• NDCG
• 実際のチューニング作業の流れ
• (時間があれば)ドキュメントのスコアの見方
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P24 Solrのスコアの確認方法
• Solrのスコアの内訳の確認方法
• 時間があればお話します
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P25 Solrのスコアの確認方法
• 検索時にdebugQueryを有効にする
• q=Solr AND 検索エンジン&defType=edismax&qf=tilte_ma^10 description_ma^5.0&debugQuery=true
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P26 Solrのスコアリング
• debugQueryを叩くと下記のような情報が見れます “1”: “
1.7210351 = (MATCH) max of: --省略-- 3.4420702 = (MATCH) weight(description_ma:solr^5.0 in 120322) [DefaultSimilarity],
result of: 3.4420702 = score(doc=120322,freq=4.0 = termFreq=4.0 ), product of: 0.86576945 = queryWeight, product of: 5.0 = boost 10.601961 = idf(docFreq=20, maxDocs=310669) 0.016332252 = queryNorm 3.9757354 = fieldWeight in 120322, product of: 2.0 = tf(freq=4.0), with freq of: 4.0 = termFreq=4.0 10.601961 = idf(docFreq=20, maxDocs=310669) 0.1875 = fieldNorm(doc=120322) 0.5 = coord(1/2)
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P27 Solrのスコアリング
“1”: “
1.7210351 = (MATCH) max of:
--省略--
3.4420702 = (MATCH) weight(description_ma:solr^5.0 in 120322) [DefaultSimilarity], result of:
3.4420702 = score(doc=120322,freq=4.0 = termFreq=4.0
), product of:
0.86576945 = queryWeight, product of:
5.0 = boost
10.601961 = idf(docFreq=20, maxDocs=310669)
0.016332252 = queryNorm
3.9757354 = fieldWeight in 120322, product of:
2.0 = tf(freq=4.0), with freq of:
4.0 = termFreq=4.0
10.601961 = idf(docFreq=20, maxDocs=310669)
0.1875 = fieldNorm(doc=120322)
0.5 = coord(1/2)
Unique key 当該ドキュメントのスコア
クエリがヒットしたフィールド
当該フィールドのスコア
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P28 Solrのスコアリング
1.7210351 = (MACTH) max of: --省略-- 3.4420702 = (MATCH) weight(description_ma:solr^5.0 in 120322)
[DefaultSimilarity], result of: 3.4420702 = score(doc=120322,freq=4.0 = termFreq=4.0 ), product of: 0.86576945 = queryWeight, product of: 5.0 = boost 10.601961 = idf(docFreq=20, maxDocs=310669) 0.016332252 = queryNorm 3.9757354 = fieldWeight in 120322, product of: 2.0 = tf(freq=4.0), with freq of: 4.0 = termFreq=4.0 10.601961 = idf(docFreq=20, maxDocs=310669) 0.1875 = fieldNorm(doc=120322) 0.5 = coord(1/2)
積になっている
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P29 Solrのスコアリング
0.86576945 = queryWeight, product of:
5.0 = boost
10.601961 = idf(docFreq=20, maxDocs=310669)
0.016332252 = queryNorm
3.9757354 = fieldWeight in 120322, product of:
2.0 = tf(freq=4.0), with freq of:
4.0 = termFreq=4.0
10.601961 = idf(docFreq=20, maxDocs=310669)
0.1875 = fieldNorm(doc=120322)
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P30 Solrのスコアリング
• 計算式は上記のようになります
– クエリがヒットしたフィールドに対して、スコアを計算していき、最もスコアが高いものをドキュメントのスコアとします
score(d,q) = queryWeight× fieldWeight× coordqueryWeight = boost× idf ×queryNormfieldWeight = tf × idf × fieldNorm
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P31 Solrのスコアリング
• boost : qfでフィールドに指定した重み
• idf : クエリのidf値
• queryNorm : 異なるクエリ同士でスコアを比較できるようにするための正規化係数
queryWeight = boost× idf ×queryNorm
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P32 Solrのスコアリング
• tf : クエリのtf値
• idf : クエリのidf値
• fieldNorm : 単語数の多いフィールドと少ないフィールドを比較するための正規化係数
fieldWeight = tf × idf × fieldNorm
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P33 Solrのスコアリング
• クエリが複数指定されて場合に、そのクエリがフィールドにいくつか出現したか
coord
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P34 まとめ
• ランキングチューニングについての説明
• チューニング作業の説明と難しいところ
• 定量評価を組み合わせることのメリット
• 評価指標に関する説明
• NDCG
• 実際のチューニング作業の流れ
• 定量評価を組み合わせた場合のデメリット
Copyright (C) 2015 Yahoo Japan Corpora5on. All Rights Reserved.
P35
ご静聴ありがとうございました