Page MenuHomePhabricator

Predicting edit intent from diffs
Open, Needs TriagePublic

Description

We have 10.9M English Wikipedia article edits (2024-01-01 to 2026-01-01) with an intent label derived from the edit summary (15 categories, regex lexicon, first-match). We want a model that predicts the same intent label from the revision diff (or edit-type output)

Why: only 27 percent of edits have an interpretable summary. A diff-based classifier lets us estimate intent for the other 73 percent (empty or unlabeled summaries).

Task

Given a revision diff predict the edit intent (intent field in the dataset explained below). Notice that the edit_summary field is used to create the label, so it can't be used as input

Possible approaches:

  • Use an LLM to summarize the diff (probably too expensive)
  • Create a diff embedding (vector that represents the edit)

others ?

Input data

Base path: hdfs:///user/dsaez/intent_sessions/ (analytics cluster)
All datasets cover enwiki, namespace 0, non-redirect, 2024-01-01 to 2026-01-01.
Dataset summary:

editor_classusersedits
uwer331312232506
registered18772030379729

edits_interpretable/

One row = one edit whose summary matched the lexicon. ~10.9M rows expected.

columntypemeaning
user_idlongperformer id (NULL for IP edits)
user_namestringperformer name or IP string
revision_idlongTHE KEY. Unique id of the revision. Use it to fetch the diff
page_idlongpage edited
event_timestampstringedit time, 'yyyy-MM-dd HH:mm:ss'
user_revision_countlongperformer's cumulative enwiki edit count at edit time
comment_lowerstringlowercased edit summary. FORBIDDEN as a model feature (see 5.1)
editor_classstringbot / ip / registered / uwer
is_revertbooleanedit is an identity revert
intentstringTHE LABEL. One of 15 categories (section 4)
interpretablebooleanalways true in this dataset

users_interpretable/ - qualifying users (context only)

One row = one user (no bots, no IPs) with at least 5 edits in the window and at least 5 percent interpretable. Not needed for training; useful analyses.

columntypemeaning
user_id, user_namelong, stringuser identity
editor_classstringregistered / uwer
n_edits_windowlongedits in the 2-year window
n_interpretablelongof which interpretable
revcount_at_first_editlongcumulative edit count entering the window
revcount_at_last_editlongcumulative edit count at last observed edit (lifetime enwiki total)
pct_interpretabledouble100 * n_interpretable / n_edits_window

Related code:

The dataset was generated with this script.
The repo for the project is: https://gitlab.wikimedia.org/dsaez/edit-sessions-intent

Related Work

Yang, D., Halfaker, A., Kraut, R., & Hovy, E. (2017, September). Identifying semantic edit intentions from revisions in wikipedia. In Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing (pp. 2000-2010).

Details

Related Changes in GitLab:
TitleReferenceAuthorSource BranchDest Branch
edit_intent: add notebooks for predicting edit intent from diffsrepos/research/research-datasets!113fabedit_intentmain
Customize query in GitLab

Event Timeline

Thanks for creating this task! Might be useful to try to think through all of the potential ways of representing a diff and potential models upfront so we can split up the work a little? My gut feeling is that we should first see how we can do from content alone as it should hopefully be enough alone to determine the larger category of edit that's being made. I'm sure the user features will boost offline model performance a bit as there are definitely user patterns, but they will also will build in some long-term fragility to the model I suspect because those are things that could easily change.

Models:

As far as input data, I suspect almost all of this will have to be wikitext unfortunately because otherwise we won't be able to collect enough data for training the models. That said, I'll add a few more small-scale experiments we can do at least with the LLMs (only smaller-scale evaluation data needed) to test if they have any impact on quality. How to represent the diff:

  • Side-by-side revisions (full thing, no diff)?
  • Reduced diff -- i.e. remove sections that are common between the two revisions to reduce size?
  • A list of changed tokens (no attempt to say whether added or removed, just split on whitespace and provide as list)?
  • Same as above but split between "Inserted" and "Removed"?
  • List of all changes from the more Structured Edit Types output? [the above ideas we can do cheaply outside of mwedittypes library but this would require mwedittypes]

Smaller-scale experiments:

  • The above but based on HTML (we've been gathering HTML diffs for several months now for moderator metrics so have a pretty large sample actually available).
  • Use the diff representation that comes via API:Compare. This is based on wikitext and unfortunately I'm not sure if there's a nice compact representation based on the HTML available.
Isaac renamed this task from Prediciting edit intent from diffs to Predicting edit intent from diffs.Jul 27 2026, 2:18 PM

A first set of notebooks can be found here.

  • The raw features notebook generates research_dev.edit_intent_raw: The ~10.9M interpretable enwiki edits enriched with revision wikitext, the parent wikitext, the parent diff, and the structured edit-types JSON. This is the shared input for every use case below, and it uses a broadcast revision_id key-set to prune the large content tables rather than shuffle them.
  • A shared library module holds the config and helpers, and an exploratory analysis notebook compute general statistics about the labelled dataset

Derived use cases (starting points on top of the raw features, aka no iteration on quality):

  • The logistic regression notebook writes research_dev.edit_intent_features_logreg: simple top-level features (diff sizes, edit-type counts, user features) for a classifier of intent, with a stratified/grouped/temporal split cell and a baseline fit. The first run shows reasonable for well-solved structural intents (category, date, and link maintenance, page creation and move, stubs with a F1 ~0.85 to 0.93) and harder semantic ones (content add/remove/update, copyedit, unsourced, vandalism much worse at 0.1 to 0.5).
  • The edit-type clustering notebook runs SVD then HDBSCAN on edit-type feature vectors (same as used for the logistic regression), coloured by intent, the plot of the first two PC shows clusters for some edit intents (matching the regression results).
  • One notebook embeds the words each revision added (using intfloat/multilingual-e5-large-instruct) and writes research_dev.edit_intent_added_embeddings; a second notebook clusters those embeddings (SVD, HDBSCAN, t-SNE) to test whether added content alone recovers the intent categories unsupervised.

Note that the _export.ipynb linked above were just exported for the gitlab sharing, to work with these notebooks use the interactive versions with the same name.