Skip to content

Add LiftWing model visualization feature #70

@zache-fi

Description

@zache-fi

Add a new web page to PendingChangesBot that allows users to visualize how LiftWing machine learning models evaluate Wikipedia articles over their revision history.

User Story

As a user, I want to select a Wikipedia article and visualize how different LiftWing model scores have changed across its revision history, so that I can better understand how these models work and how article quality evolves over time.

Links

Example code

import json
from pywikibot.comms import http

url = 'https://api.wikimedia.org/service/lw/inference/v1/models/revertrisk-multilingual:predict'
headers = {
    'Content-Type': 'application/json',
    'User-Agent': 'PendingChangesBot/1.0 (https://fi.wikipedia.org/wiki/User:SeulojaBot)'
}
payload = json.dumps({'rev_id': 23599483, 'lang':'fi'})  # your rev ID
resp = http.fetch(url, method='POST', headers=headers, data=payload)
print(resp.text)

Feature Requirements

1. Wiki and Article Selection

  • Add new web page to PendingChangesBot interface
  • Implement wiki selection using existing main wiki selection interface
  • Add text search field for article selection within the selected wiki (see https://pageviews.wmcloud.org as example)
  • Validate article exists before proceeding

2. Revision History Fetching

  • Fetch complete revision history for selected article starting from first revision
  • Store revision data in local database using existing PendingChangesBot database model
  • Handle pagination for articles with large revision histories
  • Implement error handling for API failures

3. LiftWing Model Selection

  • Create configuration file defining available models per Wikipedia language version
  • Implement model selection interface (dropdown or checkboxes for multiple selection)
  • Filter available models based on selected wiki's language
  • Start with a subset of commonly used models (specify which in implementation)

4. Model Data Fetching and Caching

  • Fetch LiftWing model predictions for each revision of the selected article
  • Cache model values in local database to avoid redundant API calls
  • Implement background/async loading for large revision sets
  • Add loading indicators during data fetching
  • Handle cases where model data is unavailable for certain revisions

5. Visualization - Line Graph

  • Implement interactive line graph with:
    • X-axis: Revision number/sequence
    • Y-axis: Model prediction values
  • Support multiple lines when:
    • Multiple models are selected
    • Single model returns multiple values per revision
  • Use different colors for each data series
  • Add legend identifying each line/model/value
  • Make graph responsive and interactive (zoom, hover for values, etc.)
  • If it easy to implement make graph clickable so

6. Revision List Table

  • Display revision list below the graph with columns:
    • Timestamp
    • Username
    • Edit comment
    • Model value(s)
  • Make timestamp clickable, linking to diff view on the specific Wikipedia
  • Synchronize table with graph (e.g., highlight row when hovering over corresponding point)
  • If user clicks the graph then show diff below of the graph. See the Show human readable reviews when you run autoreview #42 for as example.

Technical Considerations

  • Extend existing PendingChangesBot database model to store:
    • Complete revision history (not just pending changes)
    • Cached LiftWing model predictions per revision
    • Model metadata and timestamps

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions