Page MenuHomePhabricator

Instrument AG topic matching to measure how long each search path takes and how often each path occurs
Closed, ResolvedPublic4 Estimated Story Points

Assigned To
Authored By
GGalofre-WMF
Jul 14 2026, 3:33 PM
Referenced Files
F102923289: image.png
Mon, Sep 14, 4:51 PM
F102923178: image.png
Mon, Sep 14, 4:51 PM
F102922880: image.png
Mon, Sep 14, 4:51 PM
F102922677: image.png
Mon, Sep 14, 4:51 PM
F101113435: image.png
Aug 31 2026, 7:46 PM
F101107520: image.png
Aug 31 2026, 7:46 PM
F101104117: image.png
Aug 31 2026, 7:46 PM
F101103699: image.png
Aug 31 2026, 7:46 PM

Description

Summary

Instrument Article Guidance topic matching to measure how long each search path takes and how often each path occurs.

Background

When a user types an article title in the Article Guidance search box, the system tries to find a matching Wikidata topic.
When T424641 is implemented, there will be three possible paths:

  • Path A: User input → Wikidata search → results returned
  • Path C: User input → Wikidata search → no match → MinT translates query → Wikidata search → results returned
  • Path D: User input → Wikidata search → no match → MinT translates query → Wikidata search → no results

Goals

Being able to:

  • Measure the total time from when the user submits a search to when results (or a no-results message) appear
  • Break that time down by which path was taken
  • Know how often each path happens
  • Know how often users go through the full pipeline and still get no results (Path C)

Data to collect

For each topic matching attempt, log:

  • Which path was taken. Example: wikidata_direct, mint_fallback_success, or mint_fallback_no_results [these may need refinement]
  • Total time from search to result shown (ms)
  • Time spent on the Wikidata request (ms)
  • Time spent on the MinT request (ms), only applies to Path B and C

Questions this should answer

  • How long does each path typically take?
  • What share of searches take Path A vs B vs C?
  • What share of searches end with no results at all?

Acceptance criteria

  • Existing instrumentation reviewed and gaps identified
  • Path and timing data logged per topic matching attempt
  • There is a system to query this data
  • A query exists showing path breakdown and wait times per wiki

Related

  • T424641 (MinT fallback implementation)

Event Timeline

GGalofre-WMF renamed this task from Instrument Article Guidance topic matching to measure how long each search path takes and how often each path occurs to Instrument AG topic matching to measure how long each search path takes and how often each path occurs.Jul 14 2026, 3:33 PM
Nikerabbit set the point value for this task to 4.Jul 16 2026, 1:13 PM
Nikerabbit moved this task from Needs refinement to Refined on the LPL sprints board.

Q: do we need to log whether it is Latin script / non-Latin script query?
Latin script queries do not have the step that includes MinT;

after reading the suggestion from @abi_ https://gerrit.wikimedia.org/r/c/mediawiki/extensions/ArticleGuidance/+/1320830

Q: Why are we instrumenting this?

Why don’t we just run both queries and decide which result to use per case to minimize user wait time? What do we actually learn from counting how many times each path is taken, if we always have to run the Wikidata query first anyway?

The only benefit I can see is for a new Path E: ‎User input → MinT translates query → Wikidata search → results returned, which skips the initial Wikidata query step. IMO, that first query is already stable and fast enough that it isn’t really a problem.

cc @GGalofre-WMF

There is suggestion that we keep the search in parallel to save user waiting time, here some notes


Given the current approach, the search behaviour for Non-Lain script are parallel in

(1) Wikidata search
(2) MinT translation then Wikidata search

This is the current instrument event:

actionTriggeraction_sourceaction_subtypeaction_context
write_titleDebounced Wikidata search fires (query ≥ 1 character)——{"query":"<search query>","result_count":<n>}

we can add "via" in action_context,

"wikidata_direct" : meaning no MinT translation used, or no data from (2)
"mint_fallback_success": meaning only (2) has data, (1) has no data
"wikidata_and_mint" / need better naming: (1) + (2) both have data, and we merge it

the data collect

Time spent on the Wikidata request (ms)
Time spent on the MinT request (ms), only applies to Path B and C

do we need to rethink the data collection here if we keep parallell search?

If this helps:

What we want to do is:

  • measure how much time on average x wiki each path takes:

Path A: User input → Wikidata search → results returned
Path C: User input → Wikidata search → no match → MinT translates query → Wikidata search → results returned
Path D: User input → Wikidata search → no match → MinT translates query → Wikidata search → no results

Being able to compare between paths.

  • Success rate of the MinT path: % of tries when usin MinT provides a results and % when using MinT still does not provide a result. This only for non latin scripts which is the ones that should trigger mint.

If we can check there via a query that's completely fine.

The search logic has been changed to in T435129: Search optimization for Non-Latin script

Fire a cxserver-translated search in parallel. If the native search
yields fewer than 8 (MAX_RESULT) valid results, we merge in the
translated results.

This implements the following execution paths:

  • Path A: User input -> Wikidata search -> >= 8 filtered results found -> results returned (translation ignored)
  • Path C: User input -> Wikidata search -> < 8 filtered results found -> translation results (parallel) fetched, deduplicated, and filtered -> combined results returned
  • Path D: User input -> Wikidata search -> < 8 filtered results found -> translation results (parallel) fetched, deduplicated, and filtered -> no new results found -> original results returned

Change #1328159 had a related patch set uploaded (by Huei Tan; author: Huei Tan):

[mediawiki/extensions/ArticleGuidance@master] instrumentation: add "duration" and "path" into logWriteTitle method

https://gerrit.wikimedia.org/r/1328159

Change #1328159 merged by jenkins-bot:

[mediawiki/extensions/ArticleGuidance@master] instrumentation: add "duration" and "path" into logWriteTitle method

https://gerrit.wikimedia.org/r/1328159

The initial patch that has already been merged is set to ride the train this week. Starting with some initial QA locally, I can see the following events being logged, each one with a single duration property:

path: wikidata_directpath: wikdata_and_mintpath: mint_fallback_success
image.png (3,680×2,380 px, 1 MB)
image.png (3,680×2,380 px, 1 MB)
image.png (3,680×2,380 px, 1 MB)

However I don't see a distinct path label name within action_context for when there are no results. The task description says mint_fallback_no_results for example, but looks like the code is logging wikidata_direct. @hueitan can you confirm and update if needed?

no results
image.png (3,680×2,380 px, 1 MB)

yes, let's add that as the another path

Change #1333709 had a related patch set uploaded (by Huei Tan; author: Huei Tan):

[mediawiki/extensions/ArticleGuidance@master] instrumentation: add "mint_fallback_no_results" for 0 results

https://gerrit.wikimedia.org/r/1333709

Here's the updated of the instrumentation action_context

patch: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/ArticleGuidance/+/1333709

action_contextdescription
wikidata_directNative search results only (no MinT translation used or needed).
mint_fallback_successNative search returned 0 results, MinT translation returned results.
mint_fallback_no_resultsNative search returned 0 results, and MinT translation also returned 0 results.
wikidata_and_mintBoth native search and MinT translation returned results and were merged.

Change #1333709 merged by jenkins-bot:

[mediawiki/extensions/ArticleGuidance@master] instrumentation: add "mint_fallback_no_results" for 0 results

https://gerrit.wikimedia.org/r/1333709

Now that the follow up changes have been merged and that all related changes are live in prod, I have tested again in simple.wikipedia.org to verify all four paths along with duration are being emitted from the browser. They are all testing well, see table below for each case:

wikidata_directwikidata_and_mintmint_fallback_successmint_fallback_no_results
image.png (3,680×2,392 px, 1 MB)
image.png (3,680×2,392 px, 1 MB)
image.png (3,680×2,392 px, 1 MB)
image.png (3,680×2,392 px, 1 MB)

@GGalofre-WMF I'm moving this to owner acceptance for your review. I think the missing piece now is a dashboard or some way to visualize and consume the data, it's unclear to me if there's a ticket for that already, let me know if you have any questions

Thanks both! this task in complete, for now, we'd want to be able to query this data to obtain specific information for a time range (will create a task for it). In the long run, this data would be included in a broader Article Guidance dashboard where metrics and these data could be consulted as well.