Commit 639bee0af0613b5ba8699443e1d0c98edeca04f4

Authored by tangwang
1 parent 41345271

issues整理(评估框架&LTR日志准备&FM拟合效果初探)

Showing 18 changed files with 488 additions and 0 deletions   Show diff stats
docs/image-dress2.png deleted

27.3 KB

docs/image-shoes1.png deleted

85.2 KB

docs/image-dress1.png renamed to docs/image-spu-specifications.png

125 KB

docs/issue-2026-03-21-ES能力提升.md renamed to docs/issues/issue-2026-03-21-ES能力提升.md
docs/issue-2026-03-21-意图判断-done03-24.md renamed to docs/issues/issue-2026-03-21-意图判断-done03-24.md
docs/issue-2026-03-26-ES文本搜索-补充多模态knn放入should-done-0327.md renamed to docs/issues/issue-2026-03-26-ES文本搜索-补充多模态knn放入should-done-0327.md
docs/issue-2026-03-27-keywords限定-done-0327.txt renamed to docs/issues/issue-2026-03-27-keywords限定-done-0327.txt
docs/issue-2026-03-27-添加粗排精排-第2轮-done-0327.txt renamed to docs/issues/issue-2026-03-27-添加粗排精排-第2轮-done-0327.txt
docs/issue-2026-03-27-添加粗排精排-第3轮-done-0327.txt renamed to docs/issues/issue-2026-03-27-添加粗排精排-第3轮-done-0327.txt
docs/issue-2026-03-27-添加粗排精排-第一轮-done-0327.txt renamed to docs/issues/issue-2026-03-27-添加粗排精排-第一轮-done-0327.txt
docs/issue-2026-03-28-添加粗排精排-第4轮-done-0328.txt renamed to docs/issues/issue-2026-03-28-添加粗排精排-第4轮-done-0328.txt
docs/issue-2026-03-29-索引修改-done-0330.md renamed to docs/issues/issue-2026-03-29-索引修改-done-0330.md
docs/issue-2026-03-30-query分析性能优化-done-0331.md renamed to docs/issues/issue-2026-03-30-query分析性能优化-done-0331.md
docs/issue-2026-03-31-评估框架-done-0331.md renamed to docs/issues/issue-2026-03-31-评估框架-done-0331.md
docs/issues/issue-2026-04-01-评估框架-四级label-done-0402.md 0 → 100644
... ... @@ -0,0 +1,335 @@
  1 +_QUERY_INTENT_ANALYSIS_TEMPLATE_EN = """You are an intent analysis expert for a fashion e-commerce search system.
  2 +
  3 +Given a user's search query, analyze the shopping intent behind the query in the context of fashion and apparel e-commerce, and summarize the user's core search need in one concise sentence.
  4 +Also provide the Chinese translation and English translation of the query.
  5 +
  6 +Requirements:
  7 +- Keep the intent analysis concise and easy to understand, using 1 to 3 short sentences.
  8 +- Stay grounded in the original query and summarize the user's likely shopping intent without adding unnecessary context.
  9 +- When the query is vague or ambiguous, take a conservative approach and keep the analysis close to the original wording.
  10 +- Chinese translation: if the original query is already in Chinese, keep it unchanged.
  11 +- English translation: if the original query is already in English, keep it unchanged.
  12 +- Do not output anything other than the required three-line format.
  13 +
  14 +Output format (strictly exactly three lines):
  15 +Intent: concise analysis of the user's search intent
  16 +Query中文翻译: Chinese translation of the query
  17 +Query English translation: English translation of the query
  18 +
  19 +Now analyze the following query:
  20 +
  21 +Query: {query}
  22 +"""
  23 +
  24 +_QUERY_INTENT_ANALYSIS_RESULT_TEMPLATE_ZH = """
  25 +你是一个服装品类电商搜索意图分析专家。
  26 +
  27 +给定用户输入的搜索词,请在服装品类电商场景下,分析该搜索词背后的购物意图,并用一句话简要描述用户的核心搜索需求。
  28 +同时,提供该搜索词的中文翻译和英文翻译。
  29 +
  30 +要求:
  31 +- 意图分析应简洁易懂,用 1 到 3 句短句概括用户的搜索意图。
  32 +- 结合 query 本身,尽量贴近用户原始搜索需求进行总结,不添加不必要的背景、延伸或臆测。
  33 +- 如果 query 不够明确或有歧义,应保守处理,尽量保持与原词表达一致。
  34 +- 中文翻译:如果原始 query 本身就是中文,则按原样输出。
  35 +- 英文翻译:如果原始 query 本身就是英文,则按原样输出。
  36 +- 除指定格式外,不要输出任何额外说明。
  37 +
  38 +输出格式(严格按三行输出):
  39 +Intent: 对用户搜索意图的简洁分析
  40 +Query中文翻译: query 的中文翻译
  41 +Query English translation: query 的英文翻译
  42 +
  43 +现在请分析以下搜索词:
  44 +
  45 +Query: {query}
  46 +"""
  47 +
  48 +_CLASSIFY_TEMPLATE_EN = """You are a relevance judgment assistant for a fashion e-commerce search system.
  49 +Given a user query and the information for each product, assign a relevance label to each product.
  50 +
  51 +Your goal is to judge relevance from the perspective of e-commerce search ranking.
  52 +The key question is whether the user would view the product as the intended item, or as an acceptable substitute.
  53 +
  54 +## Relevance Labels
  55 +
  56 +### Exact Match
  57 +The product satisfies the user’s core shopping intent: the core product type matches, and all explicitly stated key attributes in the query are supported by the product information, with no obvious conflict.
  58 +
  59 +Typical use cases:
  60 +- The query contains only a product type, and the product is exactly that type.
  61 +- The query contains “product type + attributes”, and the product matches both the type and all explicitly stated attributes.
  62 +
  63 +### High Relevant
  64 +The product satisfies the user’s main intent: the core product type matches, but some explicitly requested attributes are missing from the product information, cannot be confirmed, or show minor / non-critical deviations. The product is still a good substitute for the user’s core need.
  65 +
  66 +Use “High Relevant” in the following cases:
  67 +- The core product type matches, but some requested attributes are missing, not mentioned, or cannot be verified.
  68 +- The core product type matches, but attributes such as color, material, style, fit, or length have minor deviations, as long as the deviation does not materially undermine the user’s main shopping intent.
  69 +- The product is not the user’s ideal target, but in an e-commerce shopping context, it would still be considered an acceptable and strong substitute.
  70 +
  71 +Typical examples:
  72 +- Query: “red slim-fit T-shirt”
  73 + Product: “women’s T-shirt”
  74 + → Color and fit cannot be confirmed.
  75 +- Query: “red slim-fit T-shirt”
  76 + Product: “blue slim-fit T-shirt”
  77 + → Product type and fit match, but the color is different.
  78 +
  79 +Detailed case:
  80 +- Query: “cotton long-sleeve shirt”
  81 +- Product: “J.VER Men's Linen Shirt Casual Button Down Long Sleeve Solid Plain Collar Summer Beach Shirt with Pocket”
  82 +
  83 +Analysis:
  84 +- Material mismatch: the query explicitly requires “cotton”, while the product is “linen”, so it cannot be labeled as “Exact Match”.
  85 +- However, the core category still matches: both are long-sleeve shirts.
  86 +- In e-commerce search, users may still click this item because the style and wearing scenario are similar.
  87 +- Therefore, it should be labeled as “High Relevant”: not the exact target, but a good substitute.
  88 +
  89 +Detailed case:
  90 +- Query: “black mid-length skirt”
  91 +- Product: “New spring autumn loose slimming full long floral skirt pleated skirt”
  92 +
  93 +Analysis:
  94 +- Category match: the product is a skirt, so the category matches.
  95 +- Color mismatch: the product description does not indicate black and explicitly mentions “floral”, which is substantially different from plain black.
  96 +- Length deviation: the user asks for “mid-length”, while the product title emphasizes “long skirt”, which is somewhat longer.
  97 +- However, the core category “skirt” still matches, and style features such as “slimming” and “full skirt” may still fit some preferences of users searching for a mid-length skirt. Also, “long” versus “mid-length” is a deviation, but not a severe contradiction.
  98 +- Therefore, this should be labeled as “High Relevant”: the core type matches, but there are several non-fatal attribute deviations.
  99 +
  100 +### Low Relevant
  101 +The product has a noticeable gap from the user’s core target, but still shares some similarity with the query in style, scenario, function, or broader category. A small portion of users may still view it as a barely acceptable substitute. It is not the intended item, but still has some relevance.
  102 +
  103 +Use “Low Relevant” in the following cases:
  104 +- The core product type does not match, but the two types are still very close in style, wearing scenario, or function, so there is still some substitutability.
  105 +- The core product type matches, but the product differs from the user’s ideal target on multiple attributes; it still has some relevance, but is no longer a strong substitute.
  106 +- An important query requirement is clearly violated, but the product still retains a limited reason to be clicked.
  107 +
  108 +Typical cases:
  109 +- Query: “black mid-length skirt”
  110 + Product: “New high-waisted V-neck mid-length dress elegant printed black sexy dress”
  111 + → The core product type differs (“skirt” vs “dress”), but both belong to closely related apparel types and share a similar mid-length style, so it is “Low Relevant”.
  112 +
  113 +- Query: “jeans”
  114 + Product: “casual pants”
  115 + → The core product type is different, but both belong to the broader pants category, and the style / wearing scenario may still be close enough to be a weak substitute.
  116 +
  117 +### Irrelevant
  118 +The product does not satisfy the user’s main shopping intent, and the likelihood of user engagement is very low.
  119 +
  120 +Typical situations:
  121 +- The core product type does not match the query and is not a close substitute in style, scenario, or function.
  122 +- The product belongs to a roughly related broader category, but not to an interchangeable subtype explicitly requested in the query, and the style or usage scenario differs significantly.
  123 +- The core product type matches, but the product clearly violates an explicit and important requirement in the query, with little or no acceptable substitutability.
  124 +
  125 +Typical examples:
  126 +
  127 +1. **Different core product type with no substitutability**
  128 +- Query: "pants", Product: "shoes"
  129 +- Query: "boots", Product: "sneakers"
  130 +
  131 +2. **Close core product type but clear conflict on key attributes**
  132 +- Query: "slim-fit pants", Product: "loose wide-leg pants"
  133 +- Query: "sleeveless dress", Product: "long-sleeve dress"
  134 +- Query: "loose-fitting hoodie", Product: "slim-fit T-shirt"
  135 +
  136 +3. **Same broad category but significant difference in style or usage scenario**
  137 +- Query: "jeans", Product: "sweatpants / dress pants"
  138 +
  139 +## Judgment Principles
  140 +
  141 +1. **Product type is the highest-priority factor.**
  142 + If the query explicitly specifies a concrete product type, the result must match that product type in order to be labeled as “Exact Match” or “High Relevant”.
  143 + Different product types should usually be labeled as “Low Relevant” or “Irrelevant”.
  144 +
  145 + - **Low Relevant**: use only when the two product types are very close in style, scenario, or function, and the user may still treat one as a barely acceptable substitute for the other.
  146 + - **Irrelevant**: all other product type mismatch cases.
  147 +
  148 +2. **Similar or related product types are usually not directly interchangeable when the query is explicit, but their closeness should determine whether the label is “Low Relevant” or “Irrelevant”.**
  149 + For example:
  150 + - **May be Low Relevant due to strong similarity in style / scenario**: dress vs skirt, long skirt vs mid-length skirt, jeans vs casual pants, sneakers vs skate shoes.
  151 + - **Should be Irrelevant due to substantial difference in style / scenario**: pants vs shoes, T-shirt vs hat, boots vs sneakers, jeans vs suit pants, backpack vs handbag.
  152 +
  153 +3. **Once the core product type matches, evaluate attributes.**
  154 + - All explicit attributes match → **Exact Match**
  155 + - Some attributes are missing, not mentioned, cannot be verified, or show only minor deviations → **High Relevant**
  156 + - There are multiple attribute deviations, or an important attribute is clearly violated, but the product still retains some substitutability → **Low Relevant**
  157 + - There is a clear and important hard conflict, and substitutability is extremely low → **Irrelevant**
  158 +
  159 +4. **Strictly distinguish among “not mentioned / cannot confirm”, “minor deviation”, and “explicit contradiction”.**
  160 + - If an attribute is not mentioned or cannot be verified, prefer **High Relevant**.
  161 + - If an attribute shows a minor deviation, such as different color, different material, or slightly different length, it should usually be labeled **High Relevant**.
  162 + - If an attribute is explicitly opposite to the query requirement, such as sleeveless vs long-sleeve or slim-fit vs loose wide-leg, decide between **Low Relevant** and **Irrelevant** based on the severity of the conflict and practical substitutability.
  163 + - If the conflict directly breaks the user’s main shopping goal, it should usually be labeled **Irrelevant**.
  164 +
  165 +5. **Substitutability should be judged from real shopping intent, not just surface-level textual similarity.**
  166 + The question is whether the user would realistically accept the product in a shopping scenario.
  167 + - Good substitute → **High Relevant**
  168 + - Barely acceptable substitute → **Low Relevant**
  169 + - Hardly substitutable at all → **Irrelevant**
  170 +
  171 +6. **When product information is insufficient, do not treat “cannot confirm” as “conflict”.**
  172 + If a product does not mention an attribute, that does not mean the attribute is definitely violated.
  173 + Therefore:
  174 + - If the attribute is not mentioned or cannot be confirmed, prefer **High Relevant**;
  175 + - Only treat it as a conflict when the product information clearly shows the opposite of the query requirement.
  176 +
  177 +Query: {query}
  178 +{intent_suffix}
  179 +
  180 +Products:
  181 +{lines}
  182 +
  183 +## Output Format
  184 +Output exactly {n} lines.
  185 +Each line must be exactly one of the following:
  186 +Exact Match
  187 +High Relevant
  188 +Low Relevant
  189 +Irrelevant
  190 +
  191 +Now, assign a relevance label to each result with respect to the query "{query}".
  192 +The output lines must correspond to the products above in the same order.
  193 +Do not output anything else.
  194 +"""
  195 +
  196 +_CLASSIFY_TEMPLATE_ZH = """你是一个服饰电商搜索系统中的相关性判断助手。
  197 +给定用户查询词以及每个商品的信息,请为每个商品分配一个相关性标签。
  198 +
  199 +你的目标是从电商搜索排序的角度,判断商品是否满足用户的购物意图。
  200 +判断时应优先考虑“用户是否会把该商品视为目标商品,或可接受的替代品”。
  201 +
  202 +## 相关性标签
  203 +
  204 +### 完全相关
  205 +商品满足用户的核心购物意图:核心商品类型匹配,且查询中所有明确提及的关键属性均有商品信息支持。
  206 +
  207 +典型适用场景:
  208 +- 查询仅包含商品类型,商品即为该类型。
  209 +- 查询包含“商品类型 + 属性”,商品在类型及所有明确属性上均符合。
  210 +
  211 +### 基本相关
  212 +商品满足用户的主要意图:核心商品类型匹配,但查询中明确提出的部分要求未在商品信息中体现、无法确认,或存在轻微偏差 / 非关键偏差。该商品仍是满足用户核心需求的良好替代品。
  213 +
  214 +在以下情况使用“基本相关”:
  215 +- 核心商品类型匹配,但部分属性缺失、未提及或无法确认。
  216 +- 核心商品类型匹配,但颜色、材质、风格、版型、长度等属性存在轻微偏差,只要这种偏差不会明显破坏用户的主要购买意图。
  217 +- 商品不是用户最理想的目标,但在电商购物场景下仍可能被视为可接受、且较优的替代品。
  218 +
  219 +典型情况:
  220 +- 查询:“红色修身T恤”,商品:“女士T恤”
  221 + → 颜色、版型无法确认。
  222 +- 查询:“红色修身T恤”,商品:“蓝色修身T恤”
  223 + → 商品类型和版型匹配,但颜色不同。
  224 +
  225 +详细案例:
  226 +- 查询:“棉质长袖衬衫”
  227 +- 商品:“J.VER男式亚麻衬衫休闲纽扣长袖衬衫纯色平领夏季沙滩衬衫带口袋”
  228 +
  229 +分析:
  230 +- 材质不符:Query 明确指定“棉质”,而商品为“亚麻”,因此不能判为“完全相关”。
  231 +- 但核心品类仍然匹配:两者都是“长袖衬衫”。
  232 +- 在电商搜索中,用户仍可能因为款式、穿着场景相近而点击该商品。
  233 +- 因此应判为“基本相关”,即“非精确目标,但属于良好替代品”。
  234 +
  235 +详细案例:
  236 +- 查询:“黑色中长半身裙”
  237 +- 商品:“春秋季新款宽松显瘦大摆长裙碎花半身裙褶皱设计裙”
  238 +
  239 +分析:
  240 +- 品类匹配:商品是“半身裙”,品类符合。
  241 +- 颜色不匹配:商品描述未提及黑色,且明确包含“碎花”,与纯黑差异较大。
  242 +- 长度存在偏差:用户要求“中长”,而商品标题强调“长裙”,长度偏长。
  243 +- 但核心品类“半身裙”匹配,“显瘦”“大摆”等风格特征仍可能符合部分搜索“中长半身裙”用户的潜在偏好;同时“长裙”和“中长”虽有偏差,但不构成严重对立。
  244 +- 因此应判为“基本相关”:核心品类匹配,但存在若干非致命属性偏差。
  245 +
  246 +### 弱相关
  247 +商品与用户的核心目标存在明显差距,但仍与查询在风格、场景、功能或大类上具有一定相似性,可能被少量用户视为勉强可接受的替代品。属于“非目标,但仍有一定关联”。
  248 +
  249 +在以下情况使用“弱相关”:
  250 +- 核心商品类型不一致,但两者在风格、穿着场景或功能上非常接近,仍具有一定替代性。
  251 +- 核心商品类型匹配,但在多个属性上与用户理想目标差距较大,虽仍有一定关联性,但已不是高质量替代品。
  252 +- 查询要求中的某个重要属性被明显违背,但商品仍保留少量被点击的理由。
  253 +
  254 +典型情况:
  255 +- 查询:“黑色中长半身裙”,商品:“新款高腰V领中长款连衣裙 优雅印花黑色性感连衣裙”
  256 + → 核心商品类型“半身裙”与“连衣裙”不同,但两者同属裙装,且款式上均为“中长款”,在穿搭场景上接近,因此属于“弱相关”。
  257 +
  258 +- 查询:“牛仔裤”,商品:“休闲裤”
  259 + → 核心商品类型不同,但同属裤装大类,风格和穿着场景可能接近,可作为较弱替代品。
  260 +
  261 +### 不相关
  262 +商品未满足用户的主要购物意图,用户点击动机极低。
  263 +
  264 +主要表现为以下情形之一:
  265 +- 核心商品类型与查询不匹配,且不属于风格 / 场景 / 功能接近的可替代品。
  266 +- 商品虽属于大致相关的大类,但与查询明确指定的具体子类不可互换,且风格或场景差异大。
  267 +- 核心商品类型匹配,但商品明显违背了查询中一个明确且重要的要求,且几乎不具备可接受的替代性。
  268 +
  269 +典型情况:
  270 +
  271 +**1. 核心品类不同,且无替代性**
  272 +- 查询:“裤子”,商品:“鞋子”
  273 +- 查询:“靴子”,商品:“运动鞋”
  274 +
  275 +**2. 核心品类相近,但关键属性明显冲突**
  276 +- 查询:“紧身裤”,商品:“阔腿裤”
  277 +- 查询:“无袖连衣裙”,商品:“长袖连衣裙”
  278 +- 查询:“宽松卫衣”,商品:“修身T恤”
  279 +
  280 +**3. 核心品类同属大类,但风格、场景差异巨大**
  281 +- 查询:“牛仔裤”,商品:“运动裤 / 西裤”
  282 +
  283 +## 判断原则
  284 +
  285 +1. **商品类型是最高优先级因素。**
  286 + 如果查询明确指定了具体商品类型,那么结果必须匹配该商品类型,才可能判为“完全相关”或“基本相关”。
  287 + 不同商品类型通常应判为“弱相关”或“不相关”。
  288 +
  289 + - **弱相关**:仅当两种商品类型在风格、场景、功能上非常接近,用户有一定概率将其视为勉强可接受的替代品时使用。
  290 + - **不相关**:其他所有商品类型不匹配的情况。
  291 +
  292 +2. **相似或相关的商品类型,在查询明确时通常不可直接互换,但要根据接近程度区分“弱相关”与“不相关”。**
  293 + 例如:
  294 + - **风格 / 场景高度接近,可判为弱相关**:连衣裙 vs 半身裙、长裙 vs 中长裙、牛仔裤 vs 休闲裤、运动鞋 vs 板鞋。
  295 + - **风格 / 场景差异大,应判为不相关**:裤子 vs 鞋子、T恤 vs 帽子、靴子 vs 运动鞋、牛仔裤 vs 西装裤、双肩包 vs 手提包。
  296 +
  297 +3. **当核心商品类型匹配后,再评估属性。**
  298 + - 所有明确属性都匹配 → **完全相关**
  299 + - 部分属性缺失、未提及、无法确认,或存在轻微偏差 → **基本相关**
  300 + - 存在多个属性偏差,或某个重要属性被明显违背,但商品仍保留一定替代性 → **弱相关**
  301 + - 存在明确且重要的强冲突,且替代性极低 → **不相关**
  302 +
  303 +4. **要严格区分“未提及 / 无法确认”“轻微偏差”“明确冲突”。**
  304 + - 如果某属性没有提及,或无法验证,优先判为“基本相关”。
  305 + - 如果某属性存在轻微偏差,如颜色不同、材质不同、长度略有差异,通常判为“基本相关”。
  306 + - 如果某属性与查询要求明确相反,如无袖 vs 长袖、修身 vs 宽松阔腿,则要根据冲突严重性与替代性,在“弱相关”与“不相关”之间判断。
  307 + - 若该冲突会直接破坏用户的主要购买目标,通常判为“不相关”。
  308 +
  309 +5. **“是否可替代”应从真实电商购物意图出发判断。**
  310 + 不是只看字面相似,而要看用户在购物场景下是否可能接受该商品。
  311 + - 良好替代品 → **基本相关**
  312 + - 勉强替代品 → **弱相关**
  313 + - 几乎不可替代 → **不相关**
  314 +
  315 +6. **若商品信息不足,不要把“无法确认”误判为“冲突”。**
  316 + 商品未写明某属性,不等于该属性一定不符合。
  317 + 因此:
  318 + - 未提及 / 无法确认,优先按“基本相关”处理;
  319 + - 只有当商品信息明确显示与查询要求相反时,才视为属性冲突。
  320 +
  321 +查询:{query}
  322 +{intent_suffix}
  323 +
  324 +商品:
  325 +{lines}
  326 +
  327 +## 输出格式
  328 +严格输出 {n} 行,每行只能是以下四者之一:
  329 +完全相关
  330 +基本相关
  331 +弱相关
  332 +不相关
  333 +
  334 +现在请根据 query“{query}”,为每个结果标注相关性标签。输出行必须与上方商品顺序一一对应,不要输出任何其他内容。
  335 +"""
0 336 \ No newline at end of file
... ...
docs/issues/issue-2026-04-02-LTR日志准备&FM拟合效果初探-done-0402.md 0 → 100644
... ... @@ -0,0 +1,153 @@
  1 +一、主指标改为:
  2 +NDCG@20 + NDCG@50 + ERR@10 + Strong_Precision@10 + Strong_Precision@20 + Useful_Precision@50 + Avg_Grade@10 + Gain_Recall@20
  3 +
  4 +二、完善日志,阅读代码 理解rank漏斗,梳理重要信号,为LTR做准备
  5 +
  6 +三、然后进行调参(最新的一版报告batch_20260402T054003Z_00b6a8aa3d.md是基线):
  7 +只针对重排融合公式(config.yaml):
  8 + fusion:
  9 + es_bias: 10.0
  10 + es_exponent: 0.05
  11 + rerank_bias: 0.1
  12 + rerank_exponent: 1.15
  13 + fine_bias: 0.1
  14 + fine_exponent: 1.0
  15 + text_bias: 0.1
  16 + text_exponent: 0.25
  17 + text_translation_weight: 0.8
  18 + knn_text_weight: 1.0
  19 + knn_image_weight: 2.0
  20 + knn_tie_breaker: 0.3
  21 + knn_bias: 0.6
  22 + knn_exponent: 0.4
  23 +
  24 +主要考虑方向有:
  25 +各项bias调整(调大)
  26 +提高knn_image_weight
  27 +提高knn_exponent
  28 +提高es_exponent和降低text_exponent
  29 +
  30 +四、选择几条关键query,仔细观察日志,基于你的理解,进行优化。包括但不限于文本、图片knn召回的条数的调参。
  31 +tassel maxi skirt
  32 +minimalist top
  33 +sock boots(有很多高相关的未召回)
  34 +图案连身衣
  35 +
  36 +过程中要站在更高的视角理解rank体系,遇到不合理的地方可以重新设计和优化,积累的经验和工作流程要沉淀为文档。
  37 +
  38 +
  39 +
  40 +
  41 +
  42 +排序日志补强了rerank_client.py 和 searcher.py, 现在会输出 retrieval_plan、ltr_summary、以及 doc/stage 级 ltr_features,方便直接看 funnel,也方便后续做 LTR。参考_build_ltr_feature_block、_summarize_ltr_features等函数。做一版离线LTR拟合的工作(离线脚本验证)。
  43 +思路是查看和解析特征日志./logs/backend_verbose.log 中正好有且只有评估框架最新跑的一轮特征日志,仔细思考rank体系、查看数据、提炼线索,做一版特征工程,label为4个级别,参考 [framework.py](scripts/evaluation/eval_framework/framework.py) ,损失使用RankNet Pairwise Loss(不需要deltandcg权重,先简单点,大体思路是一个query内任意两个label不同的组pair形成一个有效pair做二分类样本,请你找到简易的RankNet Pairwise Loss实现)。拟合函数考虑FM(要做一些简单的特征工程比如对每个数值型特征都做多种pow log等非线性映射发散出多个特征)
  44 +
  45 +
  46 +
  47 +
  48 +
  49 +需求:
  50 +[检索调参与LTR工作流.md](docs/检索调参与LTR工作流.md)
  51 +The ranking logs have enhanced `rerank_client.py` and `searcher.py`, and now output `retrieval_plan`, `ltr_summary`, and doc/stage-level `ltr_features`, making it easy to view the funnel and facilitate subsequent LTR. Refer to functions such as `_build_ltr_feature_block` and `_summarize_ltr_features`. Perform an offline LTR fitting task (offline script validation).
  52 +
  53 +The idea is to inspect and parse the feature logs in `./logs/backend_verbose.log`, which contains exactly and only the latest round of feature logs from the evaluation framework. Carefully consider the ranking system, examine the data, extract insights, and perform feature engineering. The labels have 4 levels. Refer to `[framework.py](scripts/evaluation/eval_framework/framework.py)`. Use the RankNet Pairwise Loss (no need for deltaNDCG weight; keep it simple first. The general idea is to form a valid pair for each pair of items with different labels within a query as a binary classification sample. Find a simple implementation of RankNet Pairwise Loss). Consider FM as the fitting function (do some simple feature engineering, such as applying various nonlinear transformations like pow, log, etc., to each numerical feature to expand into multiple features).
  54 +
  55 +
  56 +
  57 +回答:
  58 +Implemented an offline LTR fitter in [offline_ltr_fit.py](/data/saas-search/scripts/evaluation/offline_ltr_fit.py) that:
  59 +
  60 +- parses `logs/backend_verbose.log` `search_response` events
  61 +- joins per-query `spu_id` rows with 4-level labels from `artifacts/search_evaluation/search_eval.sqlite3`
  62 +- builds engineered features from `ltr_features`, stage scores, ranks, and nonlinear transforms like `log1p`, `sqrt`, square, inverse, plus a few ratio/cross features
  63 +- trains an FM with RankNet-style pairwise logistic loss
  64 +- runs query-group 5-fold offline validation
  65 +- saves the fitted model and predictions as artifacts
  66 +
  67 +I validated it end-to-end with:
  68 +```bash
  69 +./.venv/bin/python scripts/evaluation/offline_ltr_fit.py
  70 +```
  71 +
  72 +Latest run artifacts are in [summary.json](/data/saas-search/artifacts/search_evaluation/ltr_runs/offline_ltr_20260402T074937Z/summary.json) and [fm_ranknet_model.json](/data/saas-search/artifacts/search_evaluation/ltr_runs/offline_ltr_20260402T074937Z/fm_ranknet_model.json).
  73 +
  74 +Key result: cross-validated `Primary_Metric_Score` improved from `0.641844` for current fused ranking to `0.654043` for the FM model. On the full-data refit, the model reaches `0.752009`, which is optimistic in-sample but shows the signal is learnable. The training set used `54` queries, `5400` docs, and `154592` valid label-different pairs.
  75 +
  76 +
  77 +
  78 +
  79 +需求:
  80 +1. The essence of FM is the weights of second-order interactions. Please output the visualized feature names (including interaction features) and their corresponding weights, sorted by importance (you can decide how to measure the importance of weights; don't make it too complicated. If no better method, simply use the absolute value of the weight).
  81 +2. It is necessary to split 10 results as a test set to measure generalization performance, so as to determine whether overfitting has occurred.
  82 +
  83 +
  84 +回答:
  85 +Updated [offline_ltr_fit.py](/data/saas-search/scripts/evaluation/offline_ltr_fit.py) to do both:
  86 +
  87 +- export FM feature importance
  88 +- reserve a dedicated 10-query holdout test set for generalization
  89 +
  90 +I interpreted “10 results as a test set” as `10 queries`, because ranking generalization should be measured at the query-group level, not by splitting docs from the same query across train/test.
  91 +
  92 +Artifacts from the latest run are under:
  93 +- [summary.json](/data/saas-search/artifacts/search_evaluation/ltr_runs/offline_ltr_20260402T080116Z/summary.json)
  94 +- [feature_importance_linear.csv](/data/saas-search/artifacts/search_evaluation/ltr_runs/offline_ltr_20260402T080116Z/feature_importance_linear.csv)
  95 +- [feature_importance_interactions.csv](/data/saas-search/artifacts/search_evaluation/ltr_runs/offline_ltr_20260402T080116Z/feature_importance_interactions.csv)
  96 +- [fm_ranknet_model.json](/data/saas-search/artifacts/search_evaluation/ltr_runs/offline_ltr_20260402T080116Z/fm_ranknet_model.json)
  97 +
  98 +Key results:
  99 +- Cross-validation `Primary_Metric_Score`: `0.654043`
  100 +- Current fused baseline: `0.641844`
  101 +- 10-query holdout FM: `0.53056`
  102 +- 10-query holdout current fused baseline: `0.5674`
  103 +
  104 +So the FM looks promising in CV, but the 10-query holdout is worse than the current baseline, which is a real overfitting/generalization warning.
  105 +
  106 +Top linear features by absolute weight:
  107 +- `text_knn_score__square` → `0.9936`
  108 +- `knn_primary_score__square` → `0.9529`
  109 +- `has_translation_match` → `-0.9309`
  110 +- `knn_score__square` → `0.9224`
  111 +- `text_support_score__square` → `0.8481`
  112 +
  113 +Top interaction features by absolute weight:
  114 +- `text_score_fallback_to_es * initial_rank__log` → `0.7099`
  115 +- `text_support_score__log1p * initial_rank__log` → `0.6814`
  116 +- `text_knn_score__square * initial_rank__log` → `-0.6419`
  117 +- `has_text_knn * initial_rank__log` → `0.5879`
  118 +- `translation_share * source_share` → `0.5509`
  119 +
  120 +The 10 holdout queries were:
  121 +- `date night dress`
  122 +- `skiing trip insulated base layer`
  123 +- `streetwear t-shirt`
  124 +- `swim dress`
  125 +- `tall slim fit trousers`
  126 +- `tassel maxi skirt`
  127 +- `чёрное летнее платье`
  128 +- `فستان أسود متوسط الطول`
  129 +- `图案连身衣`
  130 +- `宽松开襟羊毛衫`
  131 +
  132 +Next useful step is pruning the feature space and reducing the heavy dependence on rank-derived interactions like `initial_rank__log`, then rerunning the same holdout test.
  133 +
  134 +
  135 +
  136 +已把 LTR 相关内容系统性补充进 [检索调参与LTR工作流.md](/data/saas-search/docs/检索调参与LTR工作流.md)。
  137 +
  138 +把文档扩成了更适合正式立项的版本,重点补了这些层面:
  139 +
  140 +- LTR 项目的数据闭环:日志特征、离线标签、样本构造、训练、验证、上线前判断
  141 +- 当前日志结构如何支撑 LTR:`retrieval_plan`、`ltr_features`、`ranking_funnel` 分别提供什么信息
  142 +- 样本定义:为什么基础单元是 `query-doc`,训练时再转成 pair
  143 +- label 获取与边界:`search_eval.sqlite3`、4 档标签语义、当前标签体系的适用范围和风险
  144 +- 特征工程思路:原始特征、非线性变换、比例特征、交叉前的人工组合特征
  145 +- 模型与 loss 选择:为什么第一版用 FM + RankNet Pairwise Loss
  146 +- 当前离线实验结果解读:CV 提升、10-query holdout 掉分、这意味着什么
  147 +- FM 权重如何解释:一阶权重、二阶交互权重、如何用 importance 指导后续特征裁剪
  148 +- 正式开展 LTR 项目的建议路线:数据资产固化、feature ablation、模型升级、上线节奏
  149 +
  150 +如果你愿意,我下一步可以继续把这份文档再往“可执行方案”推进一步,补一节:
  151 +- `训练样本落盘格式设计`
  152 +- `线上/离线特征一致性约束`
  153 +- `LTR 服务接入 searcher/rerank 的上线方案`
... ...
docs/issue.md renamed to docs/issues/issue.md
docs/issue.txt renamed to docs/issues/issue.txt