関連性とは何か

読了まで約66 分分、11 節 節の 10 例 例。

第2026.11.10版 2026年11月19日時点で例が通過 132 例中 132 例が合格 変更点

AIによる翻訳。英語版は人による検証済みである。 当社の書籍の作り方

英語版の書籍(版2026.11.10)から翻訳した。 原文を読む

この章を読み終えると、関連性判定の集合を批判的に読めるようになる。各グレードが商品について何を主張しているかを説明でき、判定の出どころと欠落の所在を突き止め、そこから計算されたスコアをどこまで信頼できるかを判断できる。

ここまでのスコアはいずれも、ストアの判定を事実として扱ってきた。第1章では、13,077件の判定に対して2つのランカーを採点した。判定とは、ストアで入力されたクエリと、そこで販売されている商品の組に人が付けたグレードである。テストクエリでは、BM25のnDCG@10の平均は0.725である。セマンティック検索は0.830である。これらの数値はいずれも、判定が暗黙のうちに行っている選択の上に成り立っている。誰の関連性の考え方を記録しているのか、惜しい結果にどれだけの価値を与えるのか、誰も判定しなかった商品がどう扱われるのか、という選択である。

この章では、ストアの判定を詳しく読む。ランカーには手を加えないので、訓練クエリとテストクエリの両方を読む。判定を読むことはチューニングではなく、本書のあらゆる修正は引き続き訓練クエリだけで選ぶ。テストクエリで行う少数の検定は探索的なものであり、判定の性質を記述するにとどまって、差の存在を立証するものではない(本書の規則)。BM25とセマンティック検索の差の検定は、第3章で事前に計画した比較として行う。

この部分はまだ翻訳されていないため、英語で表示している。

Judge relevance against the shopper's need

最終変更:版2026.11.8

A search system returns products that match a query in the way the system defines a match: shared words for lexical retrieval, nearby vectors for semantic retrieval. Information science calls that system relevance. It separates that from topical relevance, whether a product is about the query's subject, and situational relevance, whether it helps with the task at hand (Saracevic, 2007). Some argue that system relevance is always perfect, because the system retrieved what the query asked for. Saracevic's answer is "Not so."

A judgment is a verdict, and this chapter asks what each grade claims. The store's judgments come from WANDS, a public product-search dataset, through a sample of its queries and products (Load the store's data). WANDS's judges label each pair exact, partial or irrelevant, which the book grades 2, 1 and 0. Exact means the product is the kind of thing the query asks for and has every attribute the query names. Partial means it is the right kind of thing but misses an attribute. Irrelevant means it isn't the kind of thing asked for (Read intent as a product and its modifiers). The judge grades the product against the information need behind the query's words, the thing the shopper wanted, not against the words. Manning et al. define a document as relevant when it addresses the stated information need, not merely because it contains the query's words (Manning et al., 2008, chapter 8). Evaluation then makes a bargain. It fixes a set of documents, a set of need statements and their judgments, and abstracts away the real users (Voorhees, 2007). The judgments stand in for shoppers here, and every score in this book inherits that bargain.

If matching words were the same as relevance, a product whose text holds every word of the query would be exact. You can test that on every judged pair in the store: for each pair, ask whether the product's name, class, category and description contain every word of the query, with the sample's descriptions cut to about 400 characters.

Of the judged pairs whose text holds every query word, what share did the judges call exact? Hold a number in mind.

word-match-versus-judgment.py Python 3.12.15 · numpy 2.5.5 · pandas 3.1.1 合格
"""Checks whether a full word match makes a judged pair exact, and how many exact pairs have a text that misses aquery word, with and without attributes. The prose's point rests on the `of them exact` line and the`of them, still missing one with attributes added` line."""import refrom lib.store import load_labels, load_products, load_queries, product_textdef words(text):    """Lowercase word tokens: a rough stand-in for what lexical search matches."""    return set(re.findall(r"\w+", text.lower()))products, queries, labels = load_products(), load_queries(), load_labels()text_words = {product_id: words(text) for product_id, text in product_text(products).items()}attribute_words = {product_id: words(text) for product_id, text in products["attributes"].items()}query_words = {query_id: words(query) for query_id, query in queries["query"].items()}pairs = list(zip(labels["query_id"], labels["product_id"]))# on sets, <= asks whether every query word is in the product's textlabels["in text"] = [query_words[query_id] <= text_words[product_id] for query_id, product_id in pairs]# | is set union: the product's text words with its attribute words addedlabels["in text or attributes"] = [query_words[query_id] <= text_words[product_id] | attribute_words[product_id]                                   for query_id, product_id in pairs]matched = labels[labels["in text"]]print(f"exact share of all judged pairs: {(labels['label'] == 'exact').mean():.3f}")print(f"judged pairs whose text has every query word: {len(matched):,}")for label in ["exact", "partial", "irrelevant"]:    print(f"of them {label}: {(matched['label'] == label).mean():.3f}")exact = labels[labels["label"] == "exact"]print(f"exact pairs: {len(exact):,}")print(f"exact pairs whose text misses a query word: {(~exact['in text']).sum():,}")print(f"of them, still missing one with attributes added: {(~exact['in text or attributes']).sum():,}")curtains = list(exact.loc[exact["query_id"] == 246, "product_id"])                 # query 246: clear shower curtainunsaid = [product_id for product_id in curtains if "clear" not in text_words[product_id]]print("exact products for clear shower curtain:", len(curtains))print("of them without the word clear in their text:", len(unsaid))print("of those, with clear in their attributes:", sum("clear" in attribute_words[product_id] for product_id in unsaid))
出力python word-match-versus-judgment.py
exact share of all judged pairs: 0.249
judged pairs whose text has every query word: 1,177
of them exact: 0.777
of them partial: 0.211
of them irrelevant: 0.012
exact pairs: 3,252
exact pairs whose text misses a query word: 2,337
of them, still missing one with attributes added: 2,251
exact products for clear shower curtain: 12
of them without the word clear in their text: 8
of those, with clear in their attributes: 4

A full word match is a strong signal, but it doesn't settle the question. Of the 1,177 judged pairs whose text holds every query word, 0.777 are exact, 0.211 partial and 0.012 irrelevant, against an exact share of 0.249 over all judged pairs. The words can be present without the product being what the shopper meant, so the judges decide, not the words. A share near 1 would mean matching words is relevance, and the judges say it isn't.

The other direction is more striking. Most exact pairs, 2,337 of the 3,252, have a product text that misses at least one query word. Adding the attributes still leaves 2,251 of those missing a word, so attributes explain few misses overall.

Some misses are word forms and spelling, such as chairs against chair (chapter 1) or the query ligth bulb. Chapter 5 and chapter 8 take those up. Others are attributes the text doesn't state. WANDS records attributes such as color, material and size apart from the text (Chen et al., 2022, Table 1), and the store keeps a few of them in an attributes column, for example color: clear; material: vinyl (data card). The text the store's search reads, lib.store.product_text, leaves that column out.

For some queries, though, the attributes hold the answer. For clear shower curtain, 8 of the 12 exact products never say clear in their text, and 4 of those carry clear in their attributes, where the store's text search never looks. Chapter 5 tests adding attributes to lexical search. The rest of those curtains say clear nowhere, in their text or their attributes.

The judges had more to go on. WANDS's annotation guidelines show them each product's name, image and web page (guidelines). The photo or the page may be what told them, but that is our guess, because the data doesn't record which evidence a judge used.

Working rule: Treat a judgment as a person's verdict about a need, not a property of the product. Before you blame a ranker for missing an exact product, check whether any field the ranker reads says what the judges saw, and look at the fields it doesn't read, such as attributes. When your judges see more than your ranker does, give the ranker the same evidence where you can, or accept that some exact products will rank low for reasons no change to the ranking can fix.

判定者は一部のペアで意見が分かれると想定する

最終変更:版2026.11.8

2人の人間が異なる判定に至ることはある。WANDS の各ラベルは、最大3人のアノテーターによる多数決の結果である(Chen et al., 2022, section 5)。アノテーターは中程度の一致から出発し、訓練によって次第に一致度を高めた。偶然による一致を割り引く Cohen の kappa は、最初の2か月の 0.467 から3か月目の 0.664、4か月目の 0.826 へと上昇した(Table 2)。kappa の計算は第4章で扱う。

WANDS のファイルには、ストアのペアの一部が複数回掲載されている。各行は多数決の結果であり、少数のペアでは行ごとに票が異なる。ストアのサンプルはペアごとに1行だけを残し、exact を 2、partial を 1、irrelevant を 0 として採点する。行の判定が異なる場合は、低いほうの評点を残す(Load the store's data)。行の判定が異なるペアを、サンプルが残した評点とともに次に示す。

conflicting-judgments.py Python 3.12.15 · numpy 2.5.5 · pandas 3.1.1 合格
"""Lists the pairs WANDS labelled two ways, with the label the sample kept, and counts the conflicts by kind. Theprose's point rests on the `conflicts between neighbouring grades` line."""import pandas as pdfrom lib.store import DATA, load_labels, load_products, load_queriesGRADES = {"exact": 2, "partial": 1, "irrelevant": 0}products, queries, labels = load_products(), load_queries(), load_labels()conflicts = pd.read_csv(DATA / "label_conflicts.csv")       # pairs WANDS lists more than once, with different labels# the sample's kept label for each pair, which is the lower grade wherever WANDS's rows differkept = labels.set_index(["query_id", "product_id"])["label"]for row in conflicts.itertuples():    print(f"{queries.at[row.query_id, 'query']:<32} {products.at[row.product_id, 'name'][:40]:<41} "          f"{row.labels:<19} kept: {kept[(row.query_id, row.product_id)]}")# each conflicting pair's two labels, from the column where "|" separates thempairs = conflicts["labels"].str.split("|")# a spread of 1 means neighbouring grades: exact and partial, or partial and irrelevantspread = pairs.apply(lambda both: max(GRADES[label] for label in both) - min(GRADES[label] for label in both))print()print("pairs with conflicting labels:", len(conflicts))# frozensets ignore which of the two labels comes firstprint("exact against partial:", (pairs.apply(frozenset) == frozenset(["exact", "partial"])).sum())print("partial against irrelevant:", (pairs.apply(frozenset) == frozenset(["partial", "irrelevant"])).sum())print(f"conflicts between neighbouring grades: {(spread == 1).sum()} of {len(conflicts)}")
出力python conflicting-judgments.py
whimsical solar lights           solar powered led pathway light pack      exact|partial       kept: partial
indoor multi tiered plant stand  taranto multi-tiered plant stand          exact|partial       kept: partial
clear shower curtain             shower curtain hooks                      irrelevant|partial  kept: irrelevant
breakfast bar table              counter height dining table               exact|partial       kept: partial
wood floor protector mat         hard floor straight rectangular chair ma  exact|partial       kept: partial
malachi sled                     sled coffee table                         irrelevant|partial  kept: irrelevant
kohler purist brushed bronze     purist widespread bathroom faucet with d  exact|partial       kept: partial

pairs with conflicting labels: 7
exact against partial: 5
partial against irrelevant: 2
conflicts between neighbouring grades: 7 of 7

判定済みのペアのうち、7 が矛盾している。内訳は、exact と partial の対立が 5、partial と irrelevant の対立が 2 である。矛盾はすべて隣り合う評点の間にあり、7 of 7 となっている。したがって、弱点は exact と irrelevant の隔たりではなく、2つの評点の境界線にある。breakfast bar table の行はそのような事例の1つである。counter height dining table がそのクエリに完全に合致するかどうかは、修飾語をめぐる妥当な問いであり、1人の票がタスクを読み違えた徴候ではない。

実践ルール: ペアごとに評点を1つだけ残し、それを選んだ規則を書き留めておく。サンプルと同じく、低いほうの評点を採ることを勧める。そうすれば、誤りはその商品を順位付けするランカーに不利な側に出て、ランカーに有利な側には出ない。判定者の意見が exact と irrelevant のように2段階にわたって分かれる場合は、判定者とともにガイドラインを読み直す。両者が同じ定義を共有していないからである。

この部分はまだ翻訳されていないため、英語で表示している。

最終変更:版2026.11.10

Every judgment starts from a reading of what the query asks for. A shopper's intent is what they want to do. A widely cited taxonomy of web search sorts intent into navigational (reach a particular site), informational (find information) and transactional (do something on the web), and its author makes no assumption that intent can be inferred from the query with any certainty (Broder, 2002). Product search reshapes those kinds. Tsagkias et al. describe navigational product queries as ones that name a serial number or a product, and informational ones as usually mapping to a leaf in the inventory taxonomy or asking about specific attributes. They add that "there is no single taxonomy for eCommerce customer intent", because it depends on the store's business and inventory (Tsagkias et al., 2020, section 2).

WANDS writes intent into its labels. A query names a target entity, the kind of product, and the query's modifiers are the attributes the shopper asked for. Exact satisfies both. Partial matches only the target entity and fails the modifiers (Chen et al., 2022, section 3.2). The guidelines' worked example is a query for a kids' chair: a product that is a chair but not for kids is partial (guidelines). Even with that rule, a broad query can be hard to judge. The authors' own example is a shopper who wants an induction cooktop and types cooktop (section 1).

The store's queries cover the range. ines shag rug w003096809 and kohler whitehaven farmhouse kitchen sink name a product line or a model, which makes them navigational. outdoor light fixtures names a category. clear shower curtain and 48 inch kitchen hood add a modifier to an entity. The store's queries also carry query_class, WANDS's predicted class for each query (Table 1). It is a guess at the entity, says nothing about modifiers, and isn't a judgment. Check how often it agrees with the products the judges called exact:

predicted-class-check.py Python 3.12.15 · numpy 2.5.5 · pandas 3.1.1 合格
"""For each query, measures how many of its exact products carry the predicted class, and lists the queries where nonedoes. The prose's point rests on the `queries where most exact products have the query_class` line and the`queries where no exact product has the query_class` line."""import pandas as pdfrom lib.store import load_labels, load_products, load_queriesproducts, queries, labels = load_products(), load_queries(), load_labels()exact = labels[labels["label"] == "exact"].join(products["product_class"], on="product_id")rows = []for query_id, group in exact.groupby("query_id"):    predicted = queries.at[query_id, "query_class"]    classes = group["product_class"].str.split("|")                 # a product can have several classes    # the commonest product_class value, which can join several classes, comes first in value_counts(); a missing class is an empty string, which prints as (none)    rows.append({"query": queries.at[query_id, "query"], "query_class": predicted,                 "share of exact products in it": classes.apply(lambda names: predicted in names).mean(),                 "commonest class of exact products": group["product_class"].value_counts().index[0] or "(none)"})check = pd.DataFrame(rows)print("queries:", len(check))print("queries without a query_class:", check["query_class"].isna().sum())# most means more than half of a query's exact products carry the predicted classprint("queries where most exact products have the query_class:",      (check["share of exact products in it"] > 0.5).sum())missed = check[(check["share of exact products in it"] == 0) & check["query_class"].notna()]print("queries where no exact product has the query_class:", len(missed))print()print(missed.drop(columns="share of exact products in it").to_string(index=False))
出力python predicted-class-check.py
queries: 80
queries without a query_class: 1
queries where most exact products have the query_class: 63
queries where no exact product has the query_class: 6

                   query               query_class commonest class of exact products
foutains with brick look                 Wallpaper                         Fountains
  70s inspired furniture                  Wall Art                            (none)
         7qt slow cooker Crock Pots & Slow Cookers                      Slow Cookers
 sheffield home bath set          Bath Rugs & Mats                          Vanities
      luau string lights             String Lights                  Holiday Lighting
             rustic twig     Faux Plants and Trees             Wall & Accent Mirrors

The predicted class usually agrees with the exact products. For 63 of the 80 queries, most exact products carry it, and for 6 queries, none does, and 1 query has no class at all. Read each row the example prints before counting it as an error. foutains with brick look is classed as Wallpaper, while its exact products are fountains, so the classifier went wrong. 7qt slow cooker is a naming mismatch instead: the query classes and the product classes use different names for the same thing.

Working rule: Read each query as an entity plus modifiers, and check that your ranker gets the entity right before you tune it for modifiers. Use query_class as a hint, for a feature or a filter you check against the judgments, and never as a label. When intent is ambiguous, as with cooktop, judge against the guidelines' reading and write that reading down.

二値ではなく段階で関連性を評価する

最終変更:版2026.11.8

二値ラベルは、関連があるかないかだけを示す。これに対し、WANDS の exact、partial、irrelevant のような段階付きラベルは、どの程度関連があるかを示す。検索結果は有用さの度合いが異なるため、最も関連性の高いものを見つけて最上位に並べるべきである。Järvelin と Kekäläinenは2002年に段階評価の意義を論じた。店舗では、惜しい結果が次善の選択肢として十分に通用することが多い。透明ではないシャワーカーテンは、尋ねられた属性を欠くものの商品の種類としては正しいため、WANDS では partial と評価される(意図を商品とその修飾語として読み取る)。このシャワーカーテンは、シャワーカーテン用フックよりも買い物客の求めるものに近い。二値ラベルでは、段階の間に1本の線を引くことを強いられる。exact だけを関連ありと数えれば、惜しい結果の価値はフックと同じく小さくなる。exact と partial を関連ありと数えれば、その価値は透明なカーテンと同じになる。

この店舗のクエリ clear shower curtain は、どちらの失敗も示している。その判定から、3つの上位10件ランキングを作る。exact の商品10件、partial と判定されたシャワーカーテン10件、irrelevant と判定されたシャワーカーテン用フック10件である。次に、3通りのラベル付けのもとで、それぞれを nDCG@10 で採点する(1つのランキングを採点する)。3通りとは、exact を関連ありとする二値、exact または partial を関連ありとする二値、そして本書の段階(exact を2、partial を1、irrelevant を0とし、これを利得として用いる)である。利得とは、位置による割引を適用する前に、ある位置の結果がスコアに加える値のことである。

binary-labels-hide-partial.py Python 3.12.15 · numpy 2.5.5 · pandas 3.1.1 合格
"""Scores three rankings of one query's judged products under three labelings, to show what each labeling counts asrelevant. The prose's point rests on the `grades` lines, since only the grades separate the three rankings."""from lib.metrics import ndcg_at_kfrom lib.store import load_products, qrelsclasses = load_products()["product_class"]judgments = qrels()[246]                                     # clear shower curtain: {product_id: grade}def first_ten(grade, product_class=None):    """Ten products judged with this grade for the query, in product_id order."""    # sorted(judgments) takes product_id order as the tie-break; None for product_class means any class    return [product_id for product_id in sorted(judgments) if judgments[product_id] == grade            and product_class in (None, classes[product_id])][:10]rankings = {"clear curtains": first_ten(2),                                   # exact            "other curtains": first_ten(1, "Shower Curtains"),               # partial: not clear            "hooks": first_ten(0, "Shower Curtain Hooks and Accessories")}   # irrelevantlabelings = {"exact only": {2: 1, 1: 0, 0: 0},              # binary: relevant means exact             "exact or partial": {2: 1, 1: 1, 0: 0},        # binary: relevant means exact or partial             "grades": {2: 2, 1: 1, 0: 0}}                  # graded: the book's grades as gainsprint("exact products for this query:", sum(grade == 2 for grade in judgments.values()))# the ideal top 10 holds the ten highest grades, so counting the 2s counts the exact products in itprint("exact products in the ideal top 10:", sorted(judgments.values(), reverse=True)[:10].count(2))for labeling, gain in labelings.items():    gains = {product_id: gain[grade] for product_id, grade in judgments.items()}    for name, ranking in rankings.items():        print(f"{name}, {labeling}: {ndcg_at_k(ranking, gains, 10):.3f}")
出力python binary-labels-hide-partial.py
exact products for this query: 12
exact products in the ideal top 10: 10
clear curtains, exact only: 1.000
other curtains, exact only: 0.000
hooks, exact only: 0.000
clear curtains, exact or partial: 1.000
other curtains, exact or partial: 1.000
hooks, exact or partial: 0.000
clear curtains, grades: 1.000
other curtains, grades: 0.500
hooks, grades: 0.000

3つのランキングを区別できるのは、段階付きラベルだけである。exact のみのラベルでは、その他のカーテンはフックと同じスコアとなり、それぞれ 0.000 と 0.000 である。exact または partial のラベルでは、その他のカーテンのスコアは 1.000 となり、1.000 の透明なカーテンと同じになる。段階付きラベルでは、透明なカーテンが 1.000、その他のカーテンが 0.500、フックが 0.000 となる。理想的な上位10件がすべて exact である場合、ここでは exact の商品が 10 件含まれているが、partial の商品10件のランキングのスコアは、exact の利得に対する partial の利得の比になる。

実践ルール: 商品検索では段階付きの判定を推奨する。そうすれば、指標は惜しい結果を一致と取り違えることなく評価できる。二値の指標も報告する場合であっても、段階は集めておくこと。段階を「はい」か「いいえ」にまとめることはいつでもできるが、その逆はできない。二値ラベルを使うのは、惜しい結果がユーザーにとって無価値な場合に限る。クエリが型番であり、その型番の商品しか役に立たない場合がその例である。

ゲインを意図して選ぶ

最終変更:版2026.11.8

グレードはラベルである。ゲインは、指標の中で各ラベルがどれだけの価値を持つかを表すものであり、その決め方は選択の問題である。本書では各グレードをそのままゲインとして用いるため、partial の価値は exact の半分になる。WANDS の論文自身も、exact、partial、irrelevant にそれぞれ 1.0、0.5、0 の重みを与えている(Chen et al., 2022, Table 3)。比率は同じであり、したがって nDCG も同じになる。Shopping Queries Dataset、通称 ESCI(Reddy et al., 2022)は、13万件の一意なクエリに対して、人手でラベル付けされた260万件のクエリと商品の判定を持ち、異なる方式でグレードを付ける。ESCI は、機能的な代替品として使える商品である substitute(セーター検索に対するフリースなど)と、exact な商品と併用できる商品である complement を区別する。そのゲインは、exact が 1.0、substitute が 0.1、complement が 0.01、irrelevant が 0.0 である(Reddy et al., 2022, section 3.1)。WANDS の partial は ESCI の substitute と同じではないが、最も近い対応物である。

第1章で用いたストアの2つのテスト実行、すなわち全テストクエリに対する BM25 とセマンティック検索のランキングを、次の各方式で採点する。二値ではなくグレードで関連性を評価するで扱った2通りの二値ラベル付け、本書のグレード、そして ESCI の考え方に沿った 0.1 の partial ゲインである。この例では、各方式のもとでセマンティック検索のリードに対し、第3章の並べ替え検定と対応のある t 検定も実行し、両方の p 値を表示する。本書のすべての検定と同様に、どちらのリードも記述的なものである。セマンティック検索の実行では、オープンモデル Snowflake/snowflake-arctic-embed-m-v1.5 の記録済み埋め込みを読み込む(意味で検索する)。

gain-choice-changes-ndcg.py Python 3.12.15 · bm25s 0.3.16 · numpy 2.5.5 · pandas 3.1.1 · scipy 1.18.1 合格
"""Scores BM25 and semantic retrieval on the test queries under four gain schemes, with exploratory paired tests onsemantic retrieval's lead. The prose's point rests on the `semantic minus bm25` lines, which keep one sign across theschemes while their size changes."""from lib.lexical import LexicalSearchfrom lib.metrics import evaluatefrom lib.semantic import SemanticSearchfrom lib.significance import comparefrom lib.store import load_products, load_queries, qrelsqueries, judgments = load_queries("test"), qrels("test")# each run keeps the top 100 products per query; the scores below read only the top 10 of eachruns = {"bm25": LexicalSearch(load_products()).run(queries, k=100), "semantic": SemanticSearch().run(queries, k=100)}for name, run in runs.items():    # an unjudged product gives None here, which the count of 1 does not include    grades = [judgments[query_id].get(product_id) for query_id, ranking in run.items() for product_id in ranking[:10]]    print(f"partial share of the {name} top 10: {grades.count(1) / len(grades):.3f}")# each scheme turns a grade into the gain it is worthschemes = {"exact only": {2: 1, 1: 0, 0: 0},           "exact or partial": {2: 1, 1: 1, 0: 0},           "grades 2, 1, 0": {2: 2, 1: 1, 0: 0},       # the book's choice; WANDS's 1, 0.5, 0 gives the same nDCG           "partial gain 0.1": {2: 1, 1: 0.1, 0: 0}}   # close to the gains ESCI chose for its substitutesleads = 0for scheme, gain in schemes.items():    gains = {query_id: {product_id: gain[grade] for product_id, grade in per_query.items()}             for query_id, per_query in judgments.items()}    scores = {name: evaluate(run, gains)["ndcg@10"] for name, run in runs.items()}    test = compare(scores["semantic"], scores["bm25"])  # exploratory paired tests (chapter 3): no planned comparisons    print(f"bm25, {scheme}: {scores['bm25'].mean():.3f}")    print(f"semantic, {scheme}: {scores['semantic'].mean():.3f}")    print(f"semantic minus bm25, {scheme}: {test['mean difference']:.3f}")    print(f"permutation p, {scheme}: {test['permutation p']:.3f}")    print(f"t-test p, {scheme}: {test['t-test p']:.3f}")    print(f"tied queries, {scheme}: {test['ties']}")    # a lead is a positive mean difference, semantic minus BM25    leads += test["mean difference"] > 0print(f"schemes where semantic leads: {leads} of {len(schemes)}")
出力python gain-choice-changes-ndcg.py
partial share of the bm25 top 10: 0.403
partial share of the semantic top 10: 0.380
bm25, exact only: 0.519
semantic, exact only: 0.648
semantic minus bm25, exact only: 0.130
permutation p, exact only: 0.000
t-test p, exact only: 0.002
tied queries, exact only: 3
bm25, exact or partial: 0.903
semantic, exact or partial: 0.983
semantic minus bm25, exact or partial: 0.080
permutation p, exact or partial: 0.010
t-test p, exact or partial: 0.026
tied queries, exact or partial: 19
bm25, grades 2, 1, 0: 0.725
semantic, grades 2, 1, 0: 0.830
semantic minus bm25, grades 2, 1, 0: 0.105
permutation p, grades 2, 1, 0: 0.001
t-test p, grades 2, 1, 0: 0.003
tied queries, grades 2, 1, 0: 2
bm25, partial gain 0.1: 0.564
semantic, partial gain 0.1: 0.688
semantic minus bm25, partial gain 0.1: 0.125
permutation p, partial gain 0.1: 0.000
t-test p, partial gain 0.1: 0.002
tied queries, partial gain 0.1: 2
schemes where semantic leads: 4 of 4

セマンティック検索がリードするのは 4 of 4 の方式であるが、そのリードの大きさは選択に左右される。partial の商品は、BM25 の上位10件の 0.403 を占め、セマンティック検索の上位10件の 0.380 を占めるため、partial のゲインは両者のスコアを大きく動かす。BM25 のスコアは、exact のみのラベルでは 0.519、exact または partial のラベルでは 0.903 である。ESCI 風の 0.1 の partial ゲインでは、BM25 は 0.564、セマンティック検索は 0.688 となる。リードは、exact のみのラベルでは 0.130、ESCI 風のゲインでは 0.125、グレードでは 0.105、exact または partial のラベルでは 0.080 である。これらのリードが互いに異なるかどうかは、この例では検定していない。したがって 30 件のテストクエリでは、リード間の差はノイズである可能性があるものとして扱う。

exact または partial のラベルは飽和もしやすく、ランカーを分けられるクエリが減る。このラベルでは 19 件のテストクエリが同点になるのに対し、グレードでは 2 件である。

実践ルール: 商品検索の既定値としては、グレード 2、1、0 による線形のゲインを用いる。ニアミスの価値が買い物客にとって小さい場合は、より低い partial ゲインを選ぶ。どのように選ぶにせよ、ランカーを比較する前に決めて固定し、すべてのスコアとともに報告し、異なるゲインで計算した nDCG どうしを比較してはならない。

クエリごとのラベル構成を読む

最終変更:版2026.11.8

ゲインは各グレードの価値を決めるが、各種類のグレードがクエリにいくつあるかまでは決めない。判定セットは一つの母集団ではない。クエリごとに、判定された商品の集まりとグレードの構成が異なり、その構成が、そのクエリにとって完全な順位付けがどのようなものかを決める。多くの商品が満たすカテゴリを指す広いクエリには、exact の商品が多い。修飾語がいくつも付く具体的なクエリでは、exact の商品が数個しかないこともある。クエリ全体の平均は、こうした性質の異なる問題を混ぜてしまう。したがって、何かを平均する前に構成を読む。

ストアのクエリは WANDS からの無作為抽出ではない。それぞれ、判定された商品が 60 件から 300 件あり、exact の判定が 3 件以上、partial の判定が 20 件以上あり、予測クラスが他の選ばれたクエリと重複しないという条件で選ばれている(データカード)。条件の範囲外のクエリはストアに入らないため、この件数は WANDS 全体ではなく標本を表す。80 件のクエリそれぞれについてラベルを数え、exact の商品の割合でクエリをグループ化する。

count-labels-per-query.py Python 3.12.15 · numpy 2.5.5 · pandas 3.1.1 合格
"""Counts each query's judgments by label, and groups the queries by their share of exact products. The prose's pointrests on the `queries with an exact share of 0.1 or less` line and on the histogram below it."""import pandas as pdfrom lib.store import load_labels, load_queriesqueries, labels = load_queries(), load_labels()counts = pd.crosstab(labels["query_id"], labels["label"])[["exact", "partial", "irrelevant"]]shares = counts.div(counts.sum(axis=1), axis=0).join(queries[["query", "split"]])print(f"partial share of all judgments: {(labels['label'] == 'partial').mean():.3f}")print(f"median exact share: {shares['exact'].median():.3f}")print(f"median irrelevant share: {shares['irrelevant'].median():.3f}")for label, which in [("exact", "lowest"), ("exact", "highest"), ("irrelevant", "highest")]:    query_id = shares[label].idxmin() if which == "lowest" else shares[label].idxmax()    print(f"{which} {label} share: {shares.at[query_id, label]:.3f}")    print(f"query with the {which} {label} share: {shares.at[query_id, 'query']}")print("queries with no irrelevant judgment:", (counts["irrelevant"] == 0).sum())print("fewest exact products for a query:", counts["exact"].min())print("most exact products for a query:", counts["exact"].max())# 10 is the size of a top 10: a query with fewer exact products can't fill a perfect top 10 with exact onesfew = counts["exact"] < 10print("queries with fewer than 10 exact products:", few.sum())print("test queries with fewer than 10 exact products:", (few & (shares["split"] == "test")).sum())print("queries with an exact share of 0.1 or less:", (shares["exact"] <= 0.1).sum())print()print("exact share  queries")bins = pd.cut(shares["exact"], [tenth / 10 for tenth in range(11)])     # no share is 0: each query has 3 or more exactfor interval, number in bins.value_counts(sort=False).items():    print(f"{interval.left:.1f} to {interval.right:.1f}  {number:>3}  {'#' * number}".rstrip())
出力python count-labels-per-query.py
partial share of all judgments: 0.610
median exact share: 0.207
median irrelevant share: 0.060
lowest exact share: 0.014
query with the lowest exact share: 48 in entry table with side by side drawer
highest exact share: 0.749
query with the highest exact share: outdoor light fixtures
highest irrelevant share: 0.776
query with the highest irrelevant share: podium with locking cabinet
queries with no irrelevant judgment: 9
fewest exact products for a query: 3
most exact products for a query: 193
queries with fewer than 10 exact products: 23
test queries with fewer than 10 exact products: 7
queries with an exact share of 0.1 or less: 29

exact share  queries
0.0 to 0.1   29  #############################
0.1 to 0.2   10  ##########
0.2 to 0.3   12  ############
0.3 to 0.4   11  ###########
0.4 to 0.5    9  #########
0.5 to 0.6    1  #
0.6 to 0.7    7  #######
0.7 to 0.8    1  #
0.8 to 0.9    0
0.9 to 1.0    0

partial は最も多いラベルで、全判定の 0.610 を占める。その理由はおそらく WANDS が候補を集めた方法にあり、これは判定がどこから来たかを知るで扱う。exact の割合はクエリごとに大きく異なり、48 in entry table with side by side drawer の 0.014 から outdoor light fixtures の 0.749 までの幅があり、中央値は 0.207 である。例が出力するヒストグラムは低い側が最も高く、29 件のクエリで exact の割合が 0.1 以下である。

irrelevant の判定は、ほとんどのクエリでは少ないが、すべてではない。irrelevant の割合の中央値は 0.060 だが、podium with locking cabinet では 0.776 に達し、irrelevant の判定がまったくないクエリが 9 件ある。

このばらつきは nDCG@10 が測るものを変える。クエリごとの exact の商品数は、抽出条件の下限である 3 から 193 までに及び、exact の商品が 10 件に満たないクエリは 23 件あり、そのうち 7 件がテストクエリである。これらのクエリでは、理想の上位 10 件に partial の商品が含まれるため、上位 10 件に partial の商品があっても順位付けは満点を取りうる。outdoor light fixtures のような広いクエリでは、満点を取るには exact の商品が 10 件必要である。同じ nDCG@10 でも、クエリごとに意味が異なる。

実践ルール: 指標を平均する前に、クエリごとのラベル構成を出力し、両端を確認する。exact の商品が少ないクエリでの低いスコアは、広いクエリでの低いスコアとは別の問題として読む。平均値にはつねにクエリごとのスコアを併記する。平均が何を隠すかは第 3 章で示す。

クリックは偏った証拠として扱う

最終変更:版2026.11.10

ストアはすべてのクリックを記録しており、クリックは収集に費用がかからないため、無料の判定のように見える。しかし、そうではない。クリックが示すのは、買い物客がその商品を見ることを選んだという事実だけである。その商品が必要を満たしたかどうかは示さない。しかも、買い物客がそもそもクリックするかどうかは、商品がどこに、どのように表示されたかに左右される。

クリックが誤解を招く仕組みについての証拠は、ウェブ検索に由来する。Joachims らは、コーネル大学の学部生が Google を使って10個の設定された質問に答える際の視線とクリックを、2段階に分けて追跡した。第1段階は34人、第2段階は22人であった。第2段階では、上位2件の結果を入れ替えた画面や、リスト全体を逆順にした画面を見た学生もいた(Joachims et al., 2005)。彼らは、クリックは「有益だが偏りがある」と結論づけた。

第1の偏りは位置バイアスである。人は上位の結果ほど多くクリックするが、これは一つにはランキングを信頼するためである。Joachims らはこの効果を「信頼バイアス」と呼んでいる。これは、ユーザーが目にした他の概要のほうが関連性が高い場合でも、上位のリンクにクリックを引き寄せる。著者らはまた、クリックされた結果がその上でスキップされた結果より好まれるといった相対的な選好は、平均すればかなり正確であることも見いだした。

Craswell らは、あるウェブ検索エンジンでの大規模な実験で、上位における位置バイアスを最もよく説明したのはカスケードモデルであることを見いだした。カスケードモデルでは、ユーザーは結果を上から下へ読み、最初に価値のある文書に出会った時点で離脱する(Craswell et al., 2008)。

提示バイアスは位置を超えて働く。クリックは、結果がどこに表示されるかだけでなく、どのように表示されるかにも左右される。Google のウェブ検索トラフィックの一部では、より魅力的なタイトル、すなわちクエリの語がより多く太字になっているタイトルを持つ結果が、位置と人間が判定した関連性を統制した後でも、より多くのクリックを集めた(Yue et al., 2010)。ストアでは、画像と価格がタイトルに最も近い対応物である。これは測定結果ではなく、私たちの推論である。

WANDS にはクリックデータがないため、ストアでこれらの偏りを測定することはできない。それでも、クリックログに何が記録されるかは確かめられる。clear shower curtainに対するストアの判定を取り、カスケードモデルを最も厳密な形で適用する。買い物客は上から読み、最初の exact の商品をクリックして離脱する。この思考実験は固定された1つの規則を用いるものであり、現実の買い物客のモデルではない。第11章では、確率を用いてクリックをシミュレートする。この思考実験を BM25 のランキングと意味検索のランキングのそれぞれに実行し、2つのクリックログを並べて読む。

cascade-clicks.py Python 3.12.15 · bm25s 0.3.16 · numpy 2.5.5 · pandas 3.1.1 · scipy 1.18.1 合格
"""Reads the top 10 of BM25 and of semantic retrieval for `clear shower curtain` as a cascade of clicks, which stops atthe first exact product. The prose's point rests on the `clicked rank` lines and on the `exact products shown below theclick` lines."""from lib.lexical import LexicalSearchfrom lib.semantic import SemanticSearchfrom lib.store import load_products, qrelsproducts = load_products()judgments = qrels()[246]                                     # clear shower curtain: {product_id: grade}# search returns scores indexed by product_id, so .index is the ranking; semantic search takes the query's id, 246rankings = {"bm25": list(LexicalSearch(products).search("clear shower curtain", k=10).index),            "semantic": list(SemanticSearch().search(246, k=10).index)}for name, ranking in rankings.items():    grades = [judgments.get(product_id, 0) for product_id in ranking]     # an unjudged product counts as grade 0    rank = grades.index(2) + 1             # cascade: read from the top, click the first exact product, stop    print(f"{name} grades, ranks 1 to 10: {' '.join(map(str, grades))}")    print(f"{name} clicked rank: {rank}")    # rank counts from 1 and the list from 0, so the clicked product sits at index rank - 1    print(f"{name} clicked product: {products.at[ranking[rank - 1], 'name']}")    # grades[rank:] starts just after the click, since rank is the clicked product's position counted from 1    print(f"{name} exact products shown below the click: {grades[rank:].count(2)}")
出力python cascade-clicks.py
bm25 grades, ranks 1 to 10: 1 2 2 2 2 1 1 0 0 0
bm25 clicked rank: 2
bm25 clicked product: woolley vinyl single shower curtain
bm25 exact products shown below the click: 3
semantic grades, ranks 1 to 10: 2 2 1 1 2 1 2 2 1 1
semantic clicked rank: 1
semantic clicked product: woolley vinyl solid color single shower curtain
semantic exact products shown below the click: 4

クリックログには、買い物客が望んだものと同じくらい、ランカーが最初に表示したものが記録される。BM25のランキングでは、買い物客は順位2のwoolley vinyl single shower curtainをクリックし、その下にある3件の exact の商品には到達しない。クリックログ上では、これらの exact の商品は、BM25 の順位8から10に並ぶ、無関連と判定されたシャワーカーテンフック(BM25 で商品を順位付けする)と同じに見える。それらのフックも、誰にもクリックされていない。

意味検索のランキングでは、クリックは順位1のwoolley vinyl solid color single shower curtainに落ちる。同じカタログから得た2つのランキングが、異なる商品に手柄を与える2つのクリックログを生み出す。

WANDS の著者らも、位置バイアスを理由として、ログからデータセットを構築しなかった(結果を判定と照らし合わせる)。それでも、クリックには情報が含まれている。WANDS では、クリックログから取られた候補の62.47%が exact と判定されたのに対し、オープンソースのランキングシステムから取られた候補では30.95%であった(Chen et al., 2022, Table 4)。

クリックの偏りを補正することは、バイアス除去学習順位付け(unbiased learning to rank)という独立した研究分野をなしている。Baidu が公開した大規模な検索データセットでは、これらの手法はクリック予測を改善したが、専門家による判定で評価したランキング性能については「ランキング性能を一貫して改善するのに苦労する」という結果であった(Hager et al., 2024)。

実践ルール: オフライン評価の基準には、クリックではなく判定を用いる。クリックは、クリックされた商品がその上位でスキップされた商品より好まれたという相対的な証拠として用い、クリックがないことを商品が無関連である印と読んではならない。クリックで学習する場合は、その結果を判定と照らし合わせて確認する。

判定の出どころを確認する

最終変更:版2026.11.10

すべてのクエリについてすべての商品を判定する者はいない。そのためテストコレクションは、クエリごとに集めた候補の集合であるプールを判定する。TREC(Text REtrieval Conference の共有評価)では、あるトピックのプールは各参加者が検索した上位文書の和集合であり、通常は上位 100 件である。プールの外にある文書はすべて関連なしとして扱われる。Voorhees は、プールに関連文書が十分に含まれているため、未判定の文書をすべて関連なしと扱っても、システム間の比較は公平に行えると論じている。同じ論文は、プール方式では任意に大きな文書集合に対して再利用可能なテストコレクションを作れないとも述べている(Voorhees, 2007)。Zobel はこの公平性の主張を検証した。プールによる判定を用いると、システムの相対的な性能は信頼できるように見えるが、多くの関連文書がおそらく一度も発見されていないため、再現率は過大に見積もられる(Zobel, 1998)。

WANDS は 2 段階でプールを構築した(Chen et al., 2022, sections 4.2 and 4.3)。第 1 段階では、買い物客がクリックした商品やカートに入れた商品に加え、オープンソースの語彙検索エンジンである Solr の結果と、ニューラル検索システムの結果を取り上げた。第 2 段階では、同じ 2 つのシステムでカタログ全体を改めて探索し、さらに、クエリ分類モデルがそのクエリに対して予測したクラスに属するすべての商品を加えた。この第 2 段階が WANDS のラベルの大半を生み、その多くは惜しい結果(近似的な一致)であった。ラベルのうち exact は 4.12%、partial は 63.99% であった(Table 5)。partial は、このストアのサンプルでも最も多いラベルである(各クエリのラベル構成を読む)。著者らは、商品検索では網羅性が重要だと論じており、その理由を「商品検索データセットの不完全性は、評価の識別力に悪影響を及ぼす」と述べている(section 3.1)。

プールはクエリに属する。あるクエリに対して判定のない商品は、そのクエリについて未判定であり、あるクエリで判定された商品が、似たクエリでは未判定であることもある。ストアの 2 つのクエリがこれを示している。学習用クエリ trundle daybed と、テスト用クエリ full bed with trundle である。前者で exact と判定された商品のうち、後者に判定がないものを数え、判定がある商品については判定者がどう評価したかを見る。

trundle-daybeds-unjudged.py Python 3.12.15 · numpy 2.5.5 · pandas 3.1.1 合格
"""Counts the products judged exact for the train query `trundle daybed` that have no judgment for the test query `fullbed with trundle`, and grades the ones that do. The prose's point rests on the `of them unjudged for full bed withtrundle` line and the `judged partial` line."""from collections import Counterfrom lib.store import load_products, load_queries, qrelsproducts, queries, judgments = load_products(), load_queries(), qrels()LABELS = {2: "exact", 1: "partial", 0: "irrelevant"}# 433 is the train query trundle daybed, and its exact products come out in product_id orderdaybeds = sorted(product_id for product_id, grade in judgments[433].items() if grade == 2)full_bed = judgments[436]                                    # {product_id: grade} for "full bed with trundle"print(f"433: {queries.at[433, 'query']} ({queries.at[433, 'split']})")print(f"436: {queries.at[436, 'query']} ({queries.at[436, 'split']})")print("exact for trundle daybed:", len(daybeds))unjudged = [product_id for product_id in daybeds if product_id not in full_bed]print("of them unjudged for full bed with trundle:", len(unjudged))print("of them judged for full bed with trundle:", len(daybeds) - len(unjudged))judged = Counter(LABELS[full_bed[product_id]] for product_id in daybeds if product_id in full_bed)for label in LABELS.values():    print(f"judged {label}: {judged[label]}")# daybeds is in product_id order, so the first two unjudged are the two lowest product_ids among themprint("first unjudged daybed:", products.at[unjudged[0], "name"])print("second unjudged daybed:", products.at[unjudged[1], "name"])
出力python trundle-daybeds-unjudged.py
433: trundle daybed (train)
436: full bed with trundle (test)
exact for trundle daybed: 113
of them unjudged for full bed with trundle: 77
of them judged for full bed with trundle: 36
judged exact: 5
judged partial: 31
judged irrelevant: 0
first unjudged daybed: daybed with trundle
second unjudged daybed: pattonsburg daybed with trundle

未判定の商品を 0 点と採点する指標は、その商品について推測していることになり、ここではその推測が結果を左右する。ガイドラインの規則を私たちが読んだ限りでは、トランドルを備えたデイベッドは、クエリが求めるサイズではないものの、種類としては適切なベッドであることが多い。trundle daybed で exact と判定された 113 件の商品のうち、full bed with trundle に対して判定がないものは 77 件あり、商品番号が最も小さい 2 件の daybed with trundle と pattonsburg daybed with trundle もそこに含まれる。判定がある 36 件については、判定者は 5 件を exact、31 件を partial、0 件を irrelevant とした。未判定のデイベッドが判定済みのものと似ているなら、その大半も partial になるはずだが、指標はそれぞれにグレード 0 を与える。

Zobel は、プールの構築に寄与しなかったシステムは、プールによる判定では過小評価されうると警告している(Zobel, 1998)。このため、判定はプールを構築したシステムに似たランカーに最も公平になる。WANDS の場合、そのシステムとは、買い物客のクリック、語彙検索エンジン、ニューラル検索器、クエリ分類器である。ただしこれは傾向であって法則ではない。ここでは、WANDS の語彙検索エンジンに最も近いランカーである BM25 のほうが、2 つのランカーのうち judged@10 が低い(未判定商品を数える)。私たちの推測では、ストアの BM25 は、プールを作ったエンジンとは異なるフィールドを読むため、異なる商品を上位に順位づけている。

実践ルール: 比較を信頼する前に、プールの出どころを調べること。プールを構築したシステムとは異なるランカーを評価する場合は、誰も判定していない商品が上位に現れることを想定し、それらを判定する計画を立てること。

この部分はまだ翻訳されていないため、英語で表示している。

Count unjudged products before you compare scores

最終変更:版2026.11.10

A product nobody judged for a query is unjudged: its grade is unknown, not 0. Standard metrics can't tell the difference. They score an unjudged product exactly as they score one judged irrelevant, and Buckley and Voorhees warn that such metrics become unreliable when judgments are very incomplete (Buckley and Voorhees, 2004). Two diagnostics are standard in evaluation tools (ir-measures). Judged@k is the share of the top k that has a judgment of any grade:

judged@k = (number of the top k products that have a judgment for the query) / k

The second diagnostic is the condensed list, a ranking with its unjudged products dropped before scoring, so the judged ones move up. ir-measures offers it as the judged_only option. Buckley and Voorhees's bpref measure works in the same spirit: it uses judged documents only, and they found it more robust to incomplete judgments.

In chapter 1, BM25's mean judged@10 on the test queries is 0.927. The mean for semantic retrieval is 0.990. One property of the store's data keeps those numbers high. Its catalog is almost all judged: 11,917 of 12,000 products have a judgment for at least one query (Load the store's data). Expect a full catalog to put more unjudged products in the top 10s.

Build judged@10 by hand, check it against lib.metrics, and list where BM25's unjudged products are:

unjudged-in-bm25-top-10.py Python 3.12.15 · bm25s 0.3.16 · numpy 2.5.5 · pandas 3.1.1 · scipy 1.18.1 合格
"""Builds judged@10 by hand for BM25's test rankings, checks it against lib.metrics, and lists where BM25's unjudgedproducts sit in the top 10s. The prose's point rests on the `unjudged products in the top 10s` line and on the`irrelevant judgments` line for pull out sleeper loveseat."""import pandas as pdfrom lib.lexical import LexicalSearchfrom lib.metrics import evaluatefrom lib.store import load_products, load_queries, qrelsproducts, queries, judgments = load_products(), load_queries("test"), qrels("test")# 100 products per query are kept; this example reads only the top 10 of eachrun = LexicalSearch(products).run(queries, k=100)def judged_at_k(ranking, judged, k):    """The share of the top k that has a judgment of any grade."""    return sum(product_id in judged for product_id in ranking[:k]) / krows = []for query_id, ranking in run.items():    unjudged = [product_id for product_id in ranking[:10] if product_id not in judgments[query_id]]    # the name is cut to 45 characters so that the table fits on the page    rows.append({"query": queries.at[query_id, "query"], "judged@10": judged_at_k(ranking, judgments[query_id], 10),                 "unjudged": len(unjudged), "first unjudged product": products.at[unjudged[0], "name"][:45] if unjudged else ""})table = pd.DataFrame(rows)print(f"mean judged@10: {table['judged@10'].mean():.3f}")# lib.metrics' judged@10 per query, indexed by query_idlibrary = evaluate(run, judgments)["judged@10"]# 1e-12 allows for floating-point rounding when the two judged@10 values are comparedagree = sum(abs(row["judged@10"] - library[query_id]) < 1e-12 for query_id, row in zip(run, rows))print(f"queries where the hand-built judged@10 equals lib.metrics: {agree} of {len(rows)}")print("unjudged products in the top 10s:", table["unjudged"].sum())print("test queries with an unjudged product in the top 10:", (table["judged@10"] < 1).sum())sleeper = list(judgments[244].values())                      # pull out sleeper loveseatprint("judgments for pull out sleeper loveseat:", len(sleeper))print("irrelevant judgments for pull out sleeper loveseat:", sleeper.count(0))  # grade 0 is irrelevantprint()# judged@10 below 1 means the query has at least one unjudged product in its top 10print(table[table["judged@10"] < 1].sort_values("judged@10").to_string(index=False))
出力python unjudged-in-bm25-top-10.py
mean judged@10: 0.927
queries where the hand-built judged@10 equals lib.metrics: 30 of 30
unjudged products in the top 10s: 22
test queries with an unjudged product in the top 10: 7
judgments for pull out sleeper loveseat: 143
irrelevant judgments for pull out sleeper loveseat: 0

                    query  judged@10  unjudged                        first unjudged product
   outdoor light fixtures        0.2         8  60 watt equivalent e12 led candle light bulb
     beach blue headboard        0.5         5 lemon frosting indoor/outdoor , removable cov
pull out sleeper loveseat        0.6         4    country oxford 87.75 '' rolled arm sleeper
    full bed with trundle        0.8         2 abel staircase twin over full bunk bed with t
   whimsical solar lights        0.9         1 luciole 0.12-watt led solar power dusk to daw
  bistro table and chairs        0.9         1              drayton patio 5 piece bistro set
     wooden chair outdoor        0.9         1 osterley 31.5 '' w writing desk and chair set

The hand-built judged@10 equals lib.metrics on 30 of 30 test queries, with a mean of 0.927. Unjudged products fill 22 of BM25's top-10 places, spread over 7 queries. By our reading, some are plainly irrelevant: light bulbs for outdoor light fixtures, an outdoor pillow for beach blue headboard. Others look like near misses or matches: a bunk bed with a trundle for full bed with trundle, a bistro set for bistro table and chairs, a sleeper sofa for pull out sleeper loveseat, which by the entity-and-modifier rule is probably a near miss: the judges called 0 of that query's 143 judged products irrelevant.

Score both rankers with condensed lists, which drop the unjudged products, to see how far the scores move:

condensed-ndcg.py Python 3.12.15 · bm25s 0.3.16 · numpy 2.5.5 · pandas 3.1.1 · scipy 1.18.1 合格
"""Scores BM25 and semantic retrieval on the test queries with standard and condensed nDCG@10, and runs exploratorytests on the change in the lead. The prose's point rests on the `semantic minus bm25` lines and the `share of bm25'sgain` line."""from lib.lexical import LexicalSearchfrom lib.metrics import evaluatefrom lib.semantic import SemanticSearchfrom lib.significance import comparefrom lib.store import load_products, load_queries, qrelsqueries, judgments = load_queries("test"), qrels("test")runs = {"bm25": LexicalSearch(load_products()).run(queries, k=100), "semantic": SemanticSearch().run(queries, k=100)}standard, condensed = {}, {}for name, run in runs.items():    # condensed: drop every unjudged product, so the judged ones move up into the top 10    judged_only = {query_id: [product_id for product_id in ranking if product_id in judgments[query_id]]                   for query_id, ranking in run.items()}    standard[name] = evaluate(run, judgments)["ndcg@10"]    condensed[name] = evaluate(judged_only, judgments)["ndcg@10"]    print(f"{name} ndcg@10: {standard[name].mean():.3f}")    print(f"{name} condensed ndcg@10: {condensed[name].mean():.3f}")gain = condensed["bm25"] - standard["bm25"]                   # bm25's change, per test query# the scores are indexed by query_id: 133 is outdoor light fixtures, and 46 is beach blue headboardprint(f"bm25 ndcg@10 for outdoor light fixtures: {standard['bm25'][133]:.3f}")print(f"bm25 condensed ndcg@10 for outdoor light fixtures: {condensed['bm25'][133]:.3f}")print(f"share of bm25's gain from outdoor light fixtures and beach blue headboard: {gain[[133, 46]].sum() / gain.sum():.3f}")lead, condensed_lead = standard["semantic"] - standard["bm25"], condensed["semantic"] - condensed["bm25"]change = compare(condensed_lead, lead)                       # is the change in the lead more than noise? (exploratory)print(f"semantic minus bm25: {lead.mean():.3f}")print(f"semantic minus bm25, condensed: {condensed_lead.mean():.3f}")print(f"change in the lead: {change['mean difference']:.3f}")print(f"95% interval for the change: {change['ci low']:.3f} to {change['ci high']:.3f}")print(f"t-test p for the change: {change['t-test p']:.3f}")print(f"permutation p for the change: {change['permutation p']:.3f}")condensed_test = compare(condensed["semantic"], condensed["bm25"])   # the condensed lead itself (exploratory)print(f"t-test p for the condensed lead: {condensed_test['t-test p']:.3f}")print(f"permutation p for the condensed lead: {condensed_test['permutation p']:.3f}")
出力python condensed-ndcg.py
bm25 ndcg@10: 0.725
bm25 condensed ndcg@10: 0.778
semantic ndcg@10: 0.830
semantic condensed ndcg@10: 0.834
bm25 ndcg@10 for outdoor light fixtures: 0.286
bm25 condensed ndcg@10 for outdoor light fixtures: 1.000
share of bm25's gain from outdoor light fixtures and beach blue headboard: 0.612
semantic minus bm25: 0.105
semantic minus bm25, condensed: 0.056
change in the lead: -0.049
95% interval for the change: -0.138 to -0.015
t-test p for the change: 0.073
permutation p for the change: 0.036
t-test p for the condensed lead: 0.011
permutation p for the condensed lead: 0.009

Condensing lifts BM25 mostly by forgiving bad results, not by undoing a penalty on good ones. BM25 goes from 0.725 to 0.778, and semantic retrieval from 0.830 to 0.834. Of BM25's gain, a share of 0.612 comes from outdoor light fixtures and beach blue headboard, the two queries whose unjudged products are plainly irrelevant. For outdoor light fixtures, BM25 goes from 0.286 to 1.000: once the bulbs drop out, the judged lights below them move up.

Semantic retrieval's lead falls from 0.105 to 0.056 once the lists are condensed. Whether that change is more than noise is unsettled. Chapter 3's paired t-test gives p = 0.073 for the change, and its permutation test gives 0.036. The 95% bootstrap interval runs from -0.138 to -0.015. Both checks are exploratory. With the change carried by a few queries, treat it as possibly noise.

The condensed lead itself gets p = 0.009 from the permutation test and 0.011 from the t-test. Neither the standard score nor the condensed one is the truth. The standard score punishes unjudged products that may be good, and the condensed score hides unjudged products that are bad.

Working rule: Report judged@10 next to every nDCG@10, and compute condensed scores as a diagnostic, never as the headline. When two rankers' judged@10 differ, have the unjudged products in their top 10s judged before you compare them. That is the dependable cure, and on this sample it is a small job: 22 judgments for BM25's test run. On a full catalog, expect more.

本番環境で何がうまくいかなくなるか

最終変更:版2026.11.8

判定は古くなる。 ストアのカタログも買い物客も変化し続け、関連性はクエリだけでは決まらない。Tsagkias らは、ユーザー、時間、クエリ、文脈を挙げ、ジャケットというクエリでは冬と夏とで関連する商品が異なるという例を示している(Tsagkias et al., 2020, section 3.1.1)。商品は未判定のままカタログに加わり、カタログから外れた商品は判定セットに残り続ける。本番のランカーについて judged@10 を継続的に追跡し、値が下がったときには判定をやり直す。

クリックラベルは現在のランキングを追認する。 現行のランキングのもとで記録されたクリックで学習したランカーは、買い物客の好みとともに、そのランキングの順序まで学習してしまう。人手による判定を基準として保持し、クリックはそれと照らして検証する(Treat clicks as biased evidence)。

ガイドラインが判定を形づくる。 WANDS のアノテーターは、ほぼ完全な一致に達するまでに4か月を要した(Chen et al., 2022, Table 2)。ガイドラインの小さな選択が、セット全体を形づくる。WANDS はアノテーターに、スペルミスを無視してクエリ例を書かれたとおりに判定するよう指示しており(guidelines)、その判定は ligth bulb を理解できる読み手を前提としている。それができないランカーはこうしたクエリで低いスコアになるが、これは買い物客の立場からは妥当である。8章ではスペル訂正器を構築し、それでもなお誤る点を示す。

ランカーは判定者より少ない情報しか見ていない。 判定者は画像と商品ページを見たが、ストアのランカーは属性を含まないテキストを読んでいた(5章で属性の追加を検証する)。同じテキストから判定するよう求められた大規模言語モデル(LLM)も、ランカーと同じものしか見ない。このようなシステムと人手の判定との不一致の一部は、システムではなくこの差から生じる。ランカーを責める前に、判定者が評価した属性がどのフィールドに入っているかを確認する。

モデルで穴を埋める場合も、人手の判定は必要である。 Gienapp らは、クエリごとに小さな分類器を、そのクエリの人手判定でファインチューニングし、未判定の商品の判定に用いる。TREC Robust04 と、2019年および2020年の TREC Deep Learning コレクションについて、トピックあたり128件ほどの初期の人手判定でもモデル間の比較可能性が向上し、この手法はプロンプトで動かす LLM 判定者より信頼できると報告している(Gienapp et al., 2025)。LLM に関する Soboroff の助言はさらに率直で、「TREC 形式の評価のために、LLM を使って関連性判定を作成してはならない」と述べている(Soboroff, 2025)。4章では、LLM の判定を信頼する前に、ストアの人手判定と照らして測定する。

実践ルール: 判定には日付を付け、本番で judged@10 を追跡し、判定のやり直しのための予算を確保する。

この章で下した決定

最終変更:版2026.11.8

以降の章では、train クエリでの測定が別の結果を示さない限り、これらの決定を維持する。

  • 人手による判定を基準とする。 本書のすべての主要スコアは人手の判定に基づいて計算する。LLM を用いて構築したランカーのスコアも同様である。クリックは買い物客に関する証拠ではあるが、順位や表示方法による偏りを含むため、ラベルとしては用いない。
  • グレード 2、1、0 をそのままゲインとする。 したがって partial の価値は exact の半分であり、WANDS 自身の 1.0、0.5、0 と同じ比率である。二値の指標では exact のみを数える。
  • ペアごとに 1 つのグレードを割り当てる。 WANDS が同じペアを異なるラベルで複数回掲載している場合、サンプルは低いほうのグレードを採用する。これはランカーにとって不利になる側に誤る選択である。
  • query_class はヒントであり、 ラベルでも意図の尺度でもない。その値の一部は誤っている。
  • 未判定はグレード 0 として扱い、すべての nDCG@10 に judged@10 を併記する。 未判定を除外した condensed スコアは診断用にとどめる。上位 10 件に含まれる未判定の商品への対処は、それらを判定してもらうことである。
  • ランカーは属性ではなく商品テキストを読む。 第 5 章では属性をフィールドとして追加する場合を検証し、BM25 のテキストには含めない。判定者は画像や商品ページも見ていたため、テキストのみを使うランカーにとっては、照合できる手がかりがほとんどない exact の商品も存在する。
  • 判定は自由に読んでよいが、チューニングは train で行う。 test の判定を読んでもランカーは変わらない。しかし、それをもとに修正を選べば変わってしまう。
  • この章が示したこと: スコアの質は、その元になる判定の質を超えない。

この版における本章

第2026.11.10版2026年11月19日時点で例が通過この章の10 例件のうち10件が合格

英語版の書籍(版2026.11.10)から翻訳した。

この節を引用する

形式

いずれの形式も、本訳書が従う英語版の書籍を出典として示す。

いずれの形式もこの版を明示している。そのリンクは現行版を開き、節の見出しには本文が最後に変更された日付が示される。アクセス日と取得日は、これを開いた日である。

このページの内容

全11章中の第2章: 関連性とは何か

  1. Judge relevance against the shopper's need
  2. 判定者は一部のペアで意見が分かれると想定する
  3. Read intent as a product and its modifiers
  4. 二値ではなく段階で関連性を評価する
  5. ゲインを意図して選ぶ
  6. クエリごとのラベル構成を読む
  7. クリックは偏った証拠として扱う
  8. 判定の出どころを確認する
  9. Count unjudged products before you compare scores
  10. 本番環境で何がうまくいかなくなるか
  11. この章で下した決定

ページの先頭に戻るすべての章