Page MenuHomePhabricator

Emit revision revert risk scores as a stream and expose in EventStreams API
Closed, ResolvedPublic

Description

In order to build efficient apps using the Revert Risk Model (T314385), we need to add revert risk scores to a revision/page change stream stream.

In T331401: Design event schema for ML scores/recommendations on current page state, we designed a mediawiki/page/prediction_classification_change schema based on page change. This is intended to be a generic mediawiki page prediction change data model, that can be used for any page based prediction, like revert risk scores.

This schema is already being used for the mediawiki.page_outlink_topic_prediction_change.v1 stream. The mediawiki.page_outlink_topic_prediction_change.v1 stream is not currently expose publicly via EventStreams, but it (and other ORES revision score streams) could be.

We'd like the revert risk model scores to be exposed via event streams too, to make it "usable by other tools (e.g. Huggle, SWViewer) on a global level, for cross-wiki patrolling"

Options

  1. Produce events to a new new mediawiki.page_revert_risk_prediction_change.v1 stream

Either via via changeprop + via LiftWing or via a Flink streaming enrichment job (T338792). This is the same approach currently being used for the various revision score (AKA ORES) models, and for mediawiki.page_outlink_topic_prediction_change.v1

Expose the stream publicly via EventStreams API

  1. Add the revert risk scores directly into the mediawiki.recentchange stream.

Pro: mediawiki.recentchange is widely used.

Con: mediawiki.recentchange does not have a deterministic schema, so it can't easily be used in SQL based systems, which means it would not be queryable along side of other MediaWiki data in the WMF Data Lake. It also could not be easily used to ingest revert risk scores into ElasticSearch, like outlink topic predictions are.

Related Objects

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

Hm, yes I think both could be done!

However, where should the 'fattening' of recentchange event data stop? Should we put all page/revision related scores in mediawiki.recentchange?

we address a wider variety of use cases.

My personal preference would be to encourage folks to stop using the mediawiki.recentchange stream. We'll be managing all public stream data interfaces as versioned data APIs, so we can better support more use cases.

I know it is not realistic to decommission mediawiki.recentchange; many bots would break so I'm not suggesting we do that. But I'd be reluctant to add new features to it that would encourage more bots and users to use it.

That said, I'm not opposed to adding it. We probably should consider the options (and our stance on this question going forward...I'm sure it will come up again :) with the ML, Research, and Data Products team.

I'm confused, I think in T374440 they are working just with dumps, nothing like Eventstreams.

FWIW, I believe that if this task had been done, investigatory work for tasks like T374440: SPIKE: Investigate why some tr.wiki edits with Revert Risk scores greater than 0.99 were not reverted by Automoderator [16H] would be much easier.

If revert risk scores were in event streams (lower case, not necessarily stream.wikimedia.org EventStreams service), they would automatically show up as event tables in Hive.

Every time a revision is scored, a record of that score would be available in Hive. We could choose to sanitize and keep that data indefinitely.

Ottomata renamed this task from Expose revision revert risk scores in EventStreams to Emit revision revert risk scores as a stream and expose in EventStreams.Mar 5 2025, 5:05 PM
Ottomata renamed this task from Emit revision revert risk scores as a stream and expose in EventStreams to Emit revision revert risk scores as a stream and expose in EventStreams API.
Ottomata updated the task description. (Show Details)
kevinbazira changed the task status from Stalled to In Progress.Mar 19 2025, 9:04 AM
kevinbazira claimed this task.
kevinbazira moved this task from Backlog/Lift Wing to In Progress on the Machine-Learning-Team board.

Change #1129201 had a related patch set uploaded (by Kevin Bazira; author: Kevin Bazira):

[machinelearning/liftwing/inference-services@main] RRLA: process inputs from source event stream

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

Change #1129201 merged by jenkins-bot:

[machinelearning/liftwing/inference-services@main] RRLA: process inputs from source event stream

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

Change #1129755 had a related patch set uploaded (by Kevin Bazira; author: Kevin Bazira):

[machinelearning/liftwing/inference-services@main] RRLA: send prediction results to output event stream

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

Change #1130349 had a related patch set uploaded (by Kevin Bazira; author: Kevin Bazira):

[operations/deployment-charts@master] changeprop: add liftwing revertrisk-language-agnostic stream to staging

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

Change #1129755 merged by jenkins-bot:

[machinelearning/liftwing/inference-services@main] RRLA: send prediction results to output event stream

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

Change #1130579 had a related patch set uploaded (by Kevin Bazira; author: Kevin Bazira):

[operations/deployment-charts@master] ml-services: update rrla staging image and env vars

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

Change #1130579 merged by jenkins-bot:

[operations/deployment-charts@master] ml-services: update rrla staging image and env vars

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

Change #1130349 merged by jenkins-bot:

[operations/deployment-charts@master] changeprop: add liftwing revertrisk-language-agnostic stream to staging

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

Change #1131287 had a related patch set uploaded (by Kevin Bazira; author: Kevin Bazira):

[machinelearning/liftwing/inference-services@main] RRLA: update predictions field to array as expected by event schema

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

Change #1131287 merged by jenkins-bot:

[machinelearning/liftwing/inference-services@main] RRLA: update predictions field to array as expected by event schema

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

Change #1131315 had a related patch set uploaded (by Kevin Bazira; author: Kevin Bazira):

[operations/deployment-charts@master] ml-services: update rrla staging image

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

Change #1131315 merged by jenkins-bot:

[operations/deployment-charts@master] ml-services: update rrla staging image

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

A model-server that supports publishing revert-risk language-agnostic (RRLA) scores into the prediction_classification_change event stream has been deployed on LiftWing staging and tested as shown below:

1. Producing a sample event in the RRLA Kafka topic

On stat1008, a sample mediawiki.page_change.v1 event was published, using data got from this stream: https://stream.wikimedia.org/v2/ui/#/?streams=mediawiki.page_change.v1

$ cat sample.mediawiki.page_change.v1.event.json | kafkacat -P -b kafka-main1006.eqiad.wmnet:9093 -t staging.liftwing.test-revertrisk-language-agnostic-events -X security.protocol=ssl -X ssl.ca.location=/etc/ssl/certs/wmf-ca-certificates.crt

and confirmed the event had been published:

$ kafkacat -C -b kafka-main1006.eqiad.wmnet:9093 -t staging.liftwing.test-revertrisk-language-agnostic-events -o -300 -e -X security.protocol=ssl -X ssl.ca.location=/etc/ssl/certs/wmf-ca-certificates.crt

{
  "changelog_kind": "update",
  "page_change_kind": "edit",
  "dt": "2025-03-25T05:17:16Z",
  "wiki_id": "enwiki",
  "page": {
    "page_id": 62070950,
    "page_title": "Snow_White_(2025_film)",
    "namespace_id": 0,
    "is_redirect": false
  },
  "performer": {
    "user_text": "Bicam3ralMind",
    "groups": [
      "extendedconfirmed",
      "*",
      "user",
      "autoconfirmed"
    ],
    "is_bot": false,
    "is_system": false,
    "is_temp": false,
    "user_id": 33565674,
    "registration_dt": "2018-04-19T14:48:23Z",
    "edit_count": 5202
  },
  "revision": {
    "rev_id": 1282236004,
    "rev_dt": "2025-03-25T05:17:16Z",
    "is_minor_edit": false,
    "rev_sha1": "sjz2msm2wlytfx3ulk09ix3jqccyrfq",
    "rev_size": 107233,
    "rev_parent_id": 1282235952,
    "comment": "/* Plot */",
    "editor": {
      "user_text": "Bicam3ralMind",
      "groups": [
        "extendedconfirmed",
        "*",
        "user",
        "autoconfirmed"
      ],
      "is_bot": false,
      "is_system": false,
      "is_temp": false,
      "user_id": 33565674,
      "registration_dt": "2018-04-19T14:48:23Z",
      "edit_count": 5202
    },
    "is_content_visible": true,
    "is_editor_visible": true,
    "is_comment_visible": true,
    "content_slots": {
      "main": {
        "slot_role": "main",
        "content_model": "wikitext",
        "content_sha1": "sjz2msm2wlytfx3ulk09ix3jqccyrfq",
        "content_size": 107233,
        "content_format": "text/x-wiki",
        "origin_rev_id": 1282236004
      }
    }
  },
  "prior_state": {
    "revision": {
      "rev_id": 1282235952,
      "rev_dt": "2025-03-25T05:16:30Z",
      "is_minor_edit": false,
      "rev_sha1": "s80mn7trxvqubdicmugh4op5px848lk",
      "rev_size": 107241,
      "rev_parent_id": 1282235932,
      "comment": "/* Plot */",
      "editor": {
        "user_text": "Bicam3ralMind",
        "groups": [
          "extendedconfirmed",
          "*",
          "user",
          "autoconfirmed"
        ],
        "is_bot": false,
        "is_system": false,
        "is_temp": false,
        "user_id": 33565674,
        "registration_dt": "2018-04-19T14:48:23Z",
        "edit_count": 5202
      },
      "is_content_visible": true,
      "is_editor_visible": true,
      "is_comment_visible": true,
      "content_slots": {
        "main": {
          "slot_role": "main",
          "content_model": "wikitext",
          "content_sha1": "s80mn7trxvqubdicmugh4op5px848lk",
          "content_size": 107241,
          "content_format": "text/x-wiki",
          "origin_rev_id": 1282235952
        }
      }
    }
  },
  "$schema": "/mediawiki/page/change/1.2.0",
  "meta": {
    "stream": "mediawiki.page_change.v1",
    "uri": "https://en.wikipedia.org/wiki/Snow_White_(2025_film)",
    "id": "6090d5b0-4df6-4e4f-8957-68f211a75ba4",
    "request_id": "fad9be17-0432-4566-93e7-7b4c30abb1ee",
    "domain": "en.wikipedia.org",
    "dt": "2025-03-25T05:17:16Z",
    "topic": "eqiad.mediawiki.page_change.v1",
    "partition": 0,
    "offset": 543393528,
    "key": {
      "wiki_id": "enwiki",
      "page_id": 62070950
    }
  }
}
2. Receiving the event in the RRLA model-server

On deploy2002, we verified that the RRLA inference service hosted on LiftWing received the event:

$ kube_env revertrisk ml-staging-codfw
$ kubectl get pods
$ kubectl logs revertrisk-language-agnostic-predictor-default-00024-deplo79sc2
3. Producing a prediction change event

On stat1008, we confirmed that the model-server published the RRLA prediction change event:

$ kafkacat -C -b kafka-main1006.eqiad.wmnet:9093 -t codfw.mediawiki.page_prediction_change.rc0 -o -1 -e -X security.protocol=ssl -X ssl.ca.location=/etc/ssl/certs/wmf-ca-certificates.crt | jq

{
  "changelog_kind": "update",
  "page_change_kind": "edit",
  "dt": "2025-03-25T05:17:16Z",
  "wiki_id": "enwiki",
  "page": {
    "page_id": 62070950,
    "page_title": "Snow_White_(2025_film)",
    "namespace_id": 0,
    "is_redirect": false
  },
  "performer": {
    "user_text": "Bicam3ralMind",
    "groups": [
      "extendedconfirmed",
      "*",
      "user",
      "autoconfirmed"
    ],
    "is_bot": false,
    "is_system": false,
    "is_temp": false,
    "user_id": 33565674,
    "registration_dt": "2018-04-19T14:48:23Z",
    "edit_count": 5202
  },
  "revision": {
    "rev_id": 1282236004,
    "rev_dt": "2025-03-25T05:17:16Z",
    "is_minor_edit": false,
    "rev_sha1": "sjz2msm2wlytfx3ulk09ix3jqccyrfq",
    "rev_size": 107233,
    "rev_parent_id": 1282235952,
    "comment": "/* Plot */",
    "editor": {
      "user_text": "Bicam3ralMind",
      "groups": [
        "extendedconfirmed",
        "*",
        "user",
        "autoconfirmed"
      ],
      "is_bot": false,
      "is_system": false,
      "is_temp": false,
      "user_id": 33565674,
      "registration_dt": "2018-04-19T14:48:23Z",
      "edit_count": 5202
    },
    "is_content_visible": true,
    "is_editor_visible": true,
    "is_comment_visible": true
  },
  "prior_state": {
    "revision": {
      "rev_id": 1282235952,
      "rev_dt": "2025-03-25T05:16:30Z",
      "is_minor_edit": false,
      "rev_sha1": "s80mn7trxvqubdicmugh4op5px848lk",
      "rev_size": 107241,
      "rev_parent_id": 1282235932,
      "comment": "/* Plot */",
      "editor": {
        "user_text": "Bicam3ralMind",
        "groups": [
          "extendedconfirmed",
          "*",
          "user",
          "autoconfirmed"
        ],
        "is_bot": false,
        "is_system": false,
        "is_temp": false,
        "user_id": 33565674,
        "registration_dt": "2018-04-19T14:48:23Z",
        "edit_count": 5202
      },
      "is_content_visible": true,
      "is_editor_visible": true,
      "is_comment_visible": true
    }
  },
  "$schema": "mediawiki/page/prediction_classification_change/1.1.0",
  "meta": {
    "stream": "mediawiki.page_prediction_change.rc0",
    "id": "c366437c-7501-4647-9570-1e75d3c2277b",
    "request_id": "fad9be17-0432-4566-93e7-7b4c30abb1ee",
    "domain": "en.wikipedia.org",
    "uri": "https://en.wikipedia.org/wiki/Snow_White_(2025_film)",
    "dt": "2025-03-27T07:18:13.654Z"
  },
  "predicted_classification": {
    "model_name": "revertrisk-language-agnostic",
    "model_version": "3",
    "predictions": [
      "true"
    ],
    "probabilities": {
      "true": 0.661365807056427,
      "false": 0.338634192943573
    }
  }
}

@Ottomata, please let us know whether we should proceed to production with this event.

Since we won't use mediawiki.page_prediction_change.rc0 in production, should we use mediawiki.article_revision_revertrisk_language_agnostic_prediction_change.v1 following T382295#10518032 and T366273#10492412?

We need to decide on the name for this stream. I think mediawiki.revision_revertrisk_language_agnostic_prediction_change.v1 would be more suitable? Since the model's input is revision_id, unlike the article country model and the outlink topic model where the input is page_title. The key distinction is that this model can predict risk for past revisions, while the others only work on the latest revision of a page. What do you think? @kevinbazira @Ottomata :)

This looks great thanks Kevin!

@achou great question.

Would these be the correct fuzzy definitions we'd use in different cases then?

  • article is for pages that are articles
  • page is for any page
  • revision is for any revision of any page

This makes a lot of sense to me, but I do wonder if we will confuse people who are looking for particular kinds of data. E.g. mediawiki.page_change.v1 stream is an event dataset that only contains changes to the current page state, but, when looking at the event.mediawiki_page_change_v1 table in Hive, it contains historical changes to current page, so it has past revisions in it.

Q: can the revertrisk prediction vary for a past revision? Or, should a given revision revertrisk's prediction always be the same, no matter when it is scored?

  • revision is for any revision of any page

For the revertrisk model, revision is for any revision of pages that are articles (in wikipedia domain)

Q: can the revertrisk prediction vary for a past revision? Or, should a given revision revertrisk's prediction always be the same, no matter when it is scored?

The revertrisk prediction for a given revision is always the same since it is based on the page state at that moment, no matter when it is scored.

This makes a lot of sense to me, but I do wonder if we will confuse people who are looking for particular kinds of data. E.g. mediawiki.page_change.v1 stream is an event dataset that only contains changes to the current page state, but, when looking at the event.mediawiki_page_change_v1 table in Hive, it contains historical changes to current page, so it has past revisions in it.

I see your point. In the stream case, it seems there's no difference between the revertrisk model and, say, the article country model, since the revertrisk model will always score the latest revision of the article from the page change stream. Over time, the stream generated table in Hive will contain historical revision scores. So using the prefix 'revision_' seems unnecessary and may cause confusion? I think the difference only becomes apparent when we are talking about users querying the model directly through Lift Wing, as they can get a score for a past revision (revertrisk) vs. they can only get a score for the latest revision of a page (article country).

vs. they can only get a score for the latest revision of a page (article country).

Just curious, why is this the case? Are there non deterministic inputs to the article country prediction? If we wanted to maintain a backfilled dataset of historical article country predictions, would that not be possible?

Another Q about revertrisk. Are visibilty settings relevant to possible revert risk? E.g. if the comment (or content!) of a revision is not visible, does its revert risk potentially change? Even if it isn't input to the current revertrisk model, could revision visibility settings be a potential signal for a new or different model?

If so, then that would mean that for any given revision, the score might not be totally deterministic just on revision content alone?

Re naming thoughts:

We currently have a mediawiki.page_change.v1 stream, in which the events represent changes to latest page state only. Changes to past revisions are not captured.

We have discussed the need to replace the (semi-deprecated) mediawiki.revision-visibility-change stream with a more standardized mediawiki.revision_change.v1 stream, so that we have a stream in which we can capture changes to past revisions. (We aren't sure if that stream should also have 'revision create' events in it (since page_change has these), or if it should strictly be 'updates' to past revision records.)

This naming convention would then be:

  • page_*_change datasets in realtime represent changes things about current page state. Current page has a head (latest) revision, so revision information may be included in page_*_change streams. A collection of (backfilled?) historical page_*_change events is still page change dataset, and should be named page change.
  • revision_*_change datasets in realtime represent changes things about any revision state. past revisions can change in some ways, you might receive an event now that is about a revision from years ago. A collection of (backfilled?) historical revision_*_change events is not necessarily about revision as an entity, not pages as an entity. (Also, a revision's page_id can change on merges and undeletes.)

If both mediawiki.page_change.v1 and mediawiki.revision_change.v1 existed, would you use them both to trigger emission of events into the stream we are creating in this ticket? If so, then we could name it after revision_* entity.

If only mediawiki.page_change.v1 is used, and the score for a given revision will never change, then I think we should name if after page_* entity, even though the model itself uses revision_id as input.

IIUC, the latter is true? If so, then how about either:

  • mediawiki.article_revertrisk_language_agnostic_prediction_change.v1 (If the model ONLY scores article pages), or
  • mediawiki.page_revertrisk_language_agnostic_prediction_change.v1 (If the model can also score non article pages)

cc also @gmodena for the (undefined) mediawiki entity stream naming convention discussion

Just curious, why is this the case? Are there non deterministic inputs to the article country prediction? If we wanted to maintain a backfilled dataset of historical article country predictions, would that not be possible?

It is possible, but it requires changing the preprocessing that fetches the input to the model. Currently the logic fetches the latest revision for a given page title.

Another Q about revertrisk. Are visibilty settings relevant to possible revert risk? E.g. if the comment (or content!) of a revision is not visible, does its revert risk potentially change? Even if it isn't input to the current revertrisk model, could revision visibility settings be a potential signal for a new or different model?

If so, then that would mean that for any given revision, the score might not be totally deterministic just on revision content alone?

AFAIK, visibility settings are not relevant to revert risk. @diego any thoughts on this? Can we say that the revert risk score is deterministic on revision content alone and is always the same, no matter when it is scored?

Thanks for all the information about mediawiki.revision_change.v1 and the naming convention for the event stream and generated datasets. A question about it (for @Ottomata or @gmodena) - what kinds of changes would the mediawiki.revision_change.v1 stream capture besides visibility settings?

what kinds of changes would the mediawiki.revision_change.v1 stream capture besides visibility settings?

A good question. It doesn't exist so we'd have to think about it. In theory, we'd want to represent changes to revision properties. I think the only revision properties that can change directly are visibility (rev_deleted), rev_parent_id, and...page_id. When a revision is moved, its page_id might change. When a page is undeleted, its revisions may be merged into another page, altering the history and changing rev_parent_ids. I don't think we'd want revision_change to capture big history changes like this in an event, as it would be a little impractical to use them.

Can we say that the revert risk score is deterministic on revision content alone and is always the same, no matter when it is scored?

BTW, I think we can safely say that it is not totally deterministic, because revision content can be hidden, which means LiftWing would not have access to it ;) But, I think that is different than the score 'changes'. When content is no longer visible: the score is just not available. More of an error (404) than a historical score change.

I think the only revision properties that can change directly are visibility (rev_deleted), rev_parent_id, and...page_id.

Revertrisk model does depend on rev_parent_id to fetch its parent revision and page_id to fetch page information. It then computes feature like quality differences between the current and parent revisions, the page age, and time elapsed since the parent revision. So when rev_parent_ids or page_ids change, the revertrisk score might change. But I don't know if we should capture this change and consider it as a historical score change.

Right, if this is being used for moderator tools, it is unlikely that moderators are looking at revert risk scores for undeleted + merged revisions.

I'd be inclined to name the stream after what will be in it, and I think LiftWing will only produce to it for current page state changes (edits). If there is no intention to e.g. produce a new score event to this stream when a past revision changes, then let's name it about page changes.

So, either:

  • mediawiki.article_revertrisk_language_agnostic_prediction_change.v1, If the model ONLY scores article pages

OR

  • mediawiki.page_revertrisk_language_agnostic_prediction_change.v1, If the model can also score non article pages

Does that sound right?

Another Q about revertrisk. Are visibilty settings relevant to possible revert risk? E.g. if the comment (or content!) of a revision is not visible, does its revert risk potentially change? Even if it isn't input to the current revertrisk model, could revision visibility settings be a potential signal for a new or different model?

I'm not sure if I'm understanding the question. With the same inputs the results would be always the same. Visibility is not a feature for this model (there is no "is_visible" column in the feature set). Now if lack of visibility blocks feature extraction, then we have a problem. In LiftWing the features are extracted through the MediaWiki API, so if this is blocked, the model won't be able to run. But if we feed the model with data coming from other sources (ie stream data), and then some visibility configuration is changed on the revision, that - by model design- shouldn't change the revert risk score.

If so, then that would mean that for any given revision, the score might not be totally deterministic just on revision content alone?

In theory yes, in practice could be some changes depending when you call the API.
Revert Risk models uses user's related features. In model design we assumed that those were the features of the users at the time of performing the revision that is being evaluated. In practice, when you call the LiftWing API, the users' features are collected with the current information, meaning that if user had changed their status (eg, had new user groups, or make more edits), the numbers final score can change.

Thanks @diego. A more specific question about this stream:

Do we ever intend to produce messages into this stream as a result of a change other than what is in the mediawiki.page_change.v1 stream? E.g. would we want for a change in a editor's features to result in a new revertrisk prediction event emitted into this stream?

Do we ever intend to produce messages into this stream as a result of a change other than what is in the mediawiki.page_change.v1 stream? E.g. would we want for a change in a editor's features to result in a new revertrisk prediction event emitted into this stream?

Imo, the revert risk score should be computed once, just after the revision is created.

Sounds great! Thanks for all the input. We agreed that for this new stream, only mediawiki.page_change.v1 will be used, and the score for a given revision will be computed once when a revision is created.

Between mediawiki.article_revertrisk_language_agnostic_prediction_change.v1 and mediawiki.page_revertrisk_language_agnostic_prediction_change.v1, I noticed the previous naming discussion in the article-country stream (T366273).

Although the revertrisk model is only used for Wikipedia Articles (namespace 0), the ML team would prefer more general and widely used terms to avoid confusion. Since "page" is the standard term in most places, using mediawiki.page_revertrisk_language_agnostic_prediction_change.v1 makes sense. Unlike the article-country model where "article" is part of the model name, we don't face this naming constraint with the revert risk model. However, using mediawiki.article_revertrisk_language_agnostic_prediction_change.v1 also makes sense for consistency. What do you think?

I personally prefer the general purpose page name as well. Article is a special case. Another point in favor of page: if we ever decided to unify LiftWing and MW REST APIs behind API gateway, I doubt 'article' would be in the URI endpoint.

See https://en.wiktionary.org/wiki/Special%3ARestSandbox, e.g I dunno /v1/page/{title}/prediction_revert_risk. (There are also /v1/revision/{id}/... examples there, and perhaps if we did unify revert risk API this would go under revision...buuuuut that is different than the content of this stream, which contains only revert risk scores for the head of the page at the time of the edit).

So!

Anyway, unless any folks really want to argue for 'article', let's go with mediawiki.page_revertrisk_language_agnostic_prediction_change.v1.

I personally prefer the general purpose page name as well. Article is a special case. Another point in favor of page: if we ever decided to unify LiftWing and MW REST APIs behind API gateway, I doubt 'article' would be in the URI endpoint.

See https://en.wiktionary.org/wiki/Special%3ARestSandbox, e.g I dunno /v1/page/{title}/prediction_revert_risk. (There are also /v1/revision/{id}/... examples there, and perhaps if we did unify revert risk API this would go under revision...buuuuut that is different than the content of this stream, which contains only revert risk scores for the head of the page at the time of the edit).

So!

Anyway, unless any folks really want to argue for 'article', let's go with mediawiki.page_revertrisk_language_agnostic_prediction_change.v1.

I would also suggest page over article. Does RevertRisk work for non main namespace revisions?

Does RevertRisk work for non main namespace revisions?

No, it only works for Wikipedia main/article namespace as stated in the model card.

Another point in favor of page: if we ever decided to unify LiftWing and MW REST APIs behind API gateway, I doubt 'article' would be in the URI endpoint.

That’s a good point!
Alright, so we'll use the name "mediawiki.page_revertrisk_language_agnostic_prediction_change.v1". Thanks all. :)

Change #1133603 had a related patch set uploaded (by Kevin Bazira; author: Kevin Bazira):

[operations/mediawiki-config@master] EventStreamConfig: Add RRLA prediction_change stream

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

Change #1133742 had a related patch set uploaded (by Kevin Bazira; author: Kevin Bazira):

[operations/deployment-charts@master] ml-services: update RRLA prod config

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

Change #1133742 merged by jenkins-bot:

[operations/deployment-charts@master] ml-services: update RRLA prod config

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

@Ottomata @kevinbazira I just realized we probably don't want language_agnostic in the stream name—we should simply use mediawiki.page_revert_risk_prediction_change.v1. Here's why:

  1. In addition to revert-risk language-agnostic model, we also have revert-risk multilingual model. These two models only differ in their supported languages and performance on IP edits. If we decide to use the multilingual version for certain languages in the future, we can produce events to the same 'mediawiki.page_revert_risk_prediction_change.v1' stream. We're not currently doing this because the multilingual version makes predictions more slowly.
  2. The revert-risk Wikidata version (which supports the Wikidata domain) is under development. When we add streaming for this model in the future, we can also produce events to the same 'mediawiki.page_revert_risk_prediction_change.v1' stream.

Okay, that sounds good to me! The model_name is a data field, so it should be easy enough to determine which model is used.

Once this stream is deployed and active, if we'd like to expose it publicly at https://stream.wikimedia.org,

https://gerrit.wikimedia.org/r/plugins/gitiles/operations/deployment-charts/+/refs/heads/master/helmfile.d/services/eventstreams/values.yaml#89

is where we'll need to change.

Should we consider exposing other streams too? outlink topic and/or article country?

100% up to ML team!

:)

Change #1133603 merged by jenkins-bot:

[operations/mediawiki-config@master] EventStreamConfig: Add RRLA prediction_change stream

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

Mentioned in SAL (#wikimedia-operations) [2025-04-08T08:05:52Z] <kartik@deploy1003> Started scap sync-world: Backport for [[gerrit:1133603|EventStreamConfig: Add RRLA prediction_change stream (T326179)]]

Mentioned in SAL (#wikimedia-operations) [2025-04-08T08:12:58Z] <kartik@deploy1003> kartik, kevinbazira: Backport for [[gerrit:1133603|EventStreamConfig: Add RRLA prediction_change stream (T326179)]] synced to the testservers (https://wikitech.wikimedia.org/wiki/Mwdebug)

Mentioned in SAL (#wikimedia-operations) [2025-04-08T08:29:14Z] <kartik@deploy1003> Finished scap sync-world: Backport for [[gerrit:1133603|EventStreamConfig: Add RRLA prediction_change stream (T326179)]] (duration: 23m 21s)

Change #1135054 had a related patch set uploaded (by Kevin Bazira; author: Kevin Bazira):

[operations/deployment-charts@master] ml-services: update RRLA output stream name

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

Change #1135153 had a related patch set uploaded (by Kevin Bazira; author: Kevin Bazira):

[operations/deployment-charts@master] changeprop: add liftwing RRLA source stream to prod

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

Change #1135153 merged by jenkins-bot:

[operations/deployment-charts@master] changeprop: add liftwing RRLA source stream to prod

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

Change #1135054 merged by jenkins-bot:

[operations/deployment-charts@master] ml-services: update RRLA output stream name

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

Nice!!!

https://wikitech.wikimedia.org/wiki/Event_Platform/Instrumentation_How_To#EventStreams

# Tunnel local traffic to port 4992 to eventstreams-internal.discovery.wmnet:4992 via bast1003.wikimedia.org
# Replace bast1003.wikimedia.org with your preferred bastion or other accessible production host.
ssh -N -L4992:eventstreams-internal.discovery.wmnet:4992 bast1003.wikimedia.org

https://localhost:4992/v2/ui/#/?streams=mediawiki.page_revert_risk_prediction_change.v1

Screenshot 2025-04-14 at 11.24.37.png (1,314×620 px, 115 KB)

https://superset.wikimedia.org/sqllab/?savedQueryId=1050

SELECT 
  page.page_title,
  revision.rev_id,
  predicted_classification
FROM
  event.mediawiki_page_revert_risk_prediction_change_v1 
LIMIT 1
;

Screenshot 2025-04-14 at 11.29.58.png (1,634×580 px, 94 KB)

Once this stream is deployed and active, if we'd like to expose it publicly at https://stream.wikimedia.org,

https://gerrit.wikimedia.org/r/plugins/gitiles/operations/deployment-charts/+/refs/heads/master/helmfile.d/services/eventstreams/values.yaml#89

is where we'll need to change.

Should we consider exposing other streams too? outlink topic and/or article country?

100% up to ML team!

:)

I suggest that we make all these streams public -- are there any considerations or limitations I might be overlooking?

I don't think so! The data in these streams is the same as in mediawiki.page_change.v1, + the model prediction data, which is already public via the LiftWing API.

Let's do it!

Change #1136933 had a related patch set uploaded (by Kevin Bazira; author: Kevin Bazira):

[operations/deployment-charts@master] eventstreams: expose RRLA event stream publicly

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

Change #1136933 merged by jenkins-bot:

[operations/deployment-charts@master] eventstreams: expose RRLA event stream publicly

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

Thanks everyone for your contributions! The RRLA model-server that produces revert-risk scores in the mediawiki.page_revert_risk_prediction_change.v1 event stream is now live in LiftWing production.

The model-server receives a mediawiki.page_change.v1 event, preprocesses it, produces a prediction, and publishes it into the stream.

If you have access to the internal WMF infrastructure, you can view the events as Andrew shows above (T326179#10739547) or consume them via Kafka as shown below:

$ kafkacat -C -b kafka-main1006.eqiad.wmnet:9093 -t eqiad.mediawiki.page_revert_risk_prediction_change.v1 -o -1 -e -X security.protocol=ssl -X ssl.ca.location=/etc/ssl/certs/wmf-ca-certificates.crt | jq 'select(. | tostring | test("mediawiki.page_revert_risk_prediction_change.v1"))'

{

  "changelog_kind": "update",
  "page_change_kind": "edit",
  "dt": "2025-04-17T05:33:47Z",
  "wiki_id": "enwiki",
  "page": {
    "page_id": 95364,
    "page_title": "Xhosa_language",
    "namespace_id": 0,
    "is_redirect": false
  },
  "performer": {
    "user_text": "Ymblanter",
    "groups": [
      "autoreviewer",
      "sysop",
      "*",
      "user",
      "autoconfirmed"
    ],
    "is_bot": false,
    "is_system": false,
    "is_temp": false,
    "user_id": 14596827,
    "registration_dt": "2011-05-17T10:59:34Z",
    "edit_count": 274693
  },
  "revision": {
    "rev_id": 1286016779,
    "rev_dt": "2025-04-17T05:33:47Z",
    "is_minor_edit": true,
    "rev_sha1": "poml5en58bdsn7ybar3xqeg03398n6z",
    "rev_size": 41571,
    "rev_parent_id": 1285903102,
    "comment": "/* Geographical distribution */",
    "editor": {
      "user_text": "Ymblanter",
      "groups": [
        "autoreviewer",
        "sysop",
        "*",
        "user",
        "autoconfirmed"
      ],
      "is_bot": false,
      "is_system": false,
      "is_temp": false,
      "user_id": 14596827,
      "registration_dt": "2011-05-17T10:59:34Z",
      "edit_count": 274693
    },
    "is_content_visible": true,
    "is_editor_visible": true,
    "is_comment_visible": true
  },
  "prior_state": {
    "revision": {
      "rev_id": 1285903102,
      "rev_dt": "2025-04-16T13:32:57Z",
      "is_minor_edit": false,
      "rev_sha1": "b85nlr1bi5lokekdgim0h1fetrdta31",
      "rev_size": 41585,
      "rev_parent_id": 1280997556,
      "comment": "Corrected spellings",
      "editor": {
        "user_text": "Roenashy",
        "groups": [
          "*",
          "user",
          "autoconfirmed"
        ],
        "is_bot": false,
        "is_system": false,
        "is_temp": false,
        "user_id": 47830236,
        "registration_dt": "2024-05-10T07:47:50Z",
        "edit_count": 35
      },
      "is_content_visible": true,
      "is_editor_visible": true,
      "is_comment_visible": true
    }
  },
  "$schema": "mediawiki/page/prediction_classification_change/1.1.0",
  "meta": {
    "stream": "mediawiki.page_revert_risk_prediction_change.v1",
    "id": "f3c5264d-b974-40e7-bc32-22f4d3fc4b69",
    "request_id": "0510ef7c-a463-4dfa-b57f-8a5bf0c31401",
    "domain": "en.wikipedia.org",
    "uri": "https://en.wikipedia.org/wiki/Xhosa_language",
    "dt": "2025-04-17T05:33:52.419Z"
  },
  "predicted_classification": {
    "model_name": "revertrisk-language-agnostic",
    "model_version": "3",
    "predictions": [
      "false"
    ],
    "probabilities": {
      "true": 0.376665860414505,
      "false": 0.623334139585495
    }
  }
}

Alternatively, you can access the stream externally without internal access by visiting the EventStreams UI:
https://stream.wikimedia.org/v2/ui/#/?streams=mediawiki.page_revert_risk_prediction_change.v1
then click the "Stream" button to start viewing RRLA events:

Screenshot from 2025-04-17 08-29-53.png (1,834×1,109 px, 549 KB)