Page MenuHomePhabricator

References Model: Multilingual Reference Need
Closed, ResolvedPublic

Assigned To
Authored By
• XiaoXiao-WMF
Feb 8 2024, 6:12 PM
Referenced Files
F56534884: image.png
Jul 19 2024, 3:10 PM
F56534880: image.png
Jul 19 2024, 3:10 PM
F56376843: image.png
Jul 12 2024, 2:38 PM
F55530453: image.png
Jun 21 2024, 3:50 PM
F55314453: rn_fa(rnd).png
Jun 14 2024, 1:20 PM
F47562337: Screenshot 2024-04-19 at 10.45.26 PM.png
Apr 19 2024, 5:46 PM
F47562131: Screenshot 2024-04-19 at 10.32.30 PM.png
Apr 19 2024, 5:46 PM

Description

weekly update this ticket for research work, e.g. improving on citation needed proposal from the original paper, model implementation with our contractor, etc.

Event Timeline

diego renamed this task from reference model build to Rerefences Model: Multilingual Reference Need .Feb 28 2024, 4:00 PM
Pablo renamed this task from Rerefences Model: Multilingual Reference Need to References Model: Multilingual Reference Need .Feb 28 2024, 4:02 PM

26/02 - 01/03:

  • onboarding
  • ref. need - prepare featured articles data
  • ref. risk - literature review (e.g., reverted revs examples, controversiality score) for our dataset specification

04/03 - 08/03:

  • ref.need - add featured articles from dewiki, frwiki, ruwiki, ptwiki, eswiki (choice is based on the number of currently existing FAs)
  • ref.need - [for enwiki] prepare dataset for the model with the following columns:
page_id, revision_id, section_name, sentence, paragraph, citation_label

where citation_label = 0, if sentence does not include a reference,
citation_label = 1, if sentence includes a reference

  • ref.risk - compute the statistics for the references including a url (~80% for enwiki, ~72% for across all wiki_dbs)
  • ref.risk - among the above, check counts of domains for enwiki

11/03-15/03:
ref.need

ref.risk

  • collect dataset of first url appearances with info on reverts with the following columns:
wiki_db, page_id, first_revision_id, url, domain, revision_is_identity_reverted, revision_first_identity_reverting_revision_id, revision_seconds_to_identity_revert
  • idea is to use revision_is_identity_reverted as a label in the future model training (we welcome feedback)

Stats on referenced domains in the currentl wiki snapshot (2024-02)

  • e.g., top 3 referenced domains across all wiki_dbs: nasa.gov, catalogueoflife.org, google.com

18/03-22/03:
ref.need

  • found and fixed an issue with tokenized sentences -> updated the dataset
  • Data: ~16M featured articles and ~4.4M extracted sentence (47% accompanied by a citation)
  • brainstorming and planning for the classifier model

ref.risk

  • work on adding knowledge integrity features
  • Data: within <ref> tags ~295M added urls (4% reverted), 6M unique domains (17% reverted)

Stats available at https://docs.google.com/presentation/d/17GZkzB5z3482I3jQyQa5lFvOHiIlFofXX3uVv0FKktQ/edit?usp=sharing

25/03 - 31/03:

  • ref.need running baseline models for classification using 1) tf-idf, 2) sentence metadata, + logistic regression
  • planning to run with LLMs next, studying hugging face NLP tutorials
  • ref.risk data, added KI quality and content features, we are using period of 2019 ~ 2023
  • analyze user experience and user groups dimension in the reverted domains, added some stats to the slides

01/04 - 07/04:

  • ref.need using the dataset we prepared, started experimenting with BERT for sentence classification into cited/uncited in enwiki
  • ref.risk data including info on user added/removed the domain is available as a table on stat1008 (aitolkyn.domain_reverted_added_2019_2023)
  • ref.risk we had a meeting with WiSCoM (slides), their work focuses on climate change articles and finds that most predictive feature of source reliability was the permanence of a URL on a page.

08/04 - 14/04:

  • ref.need experiments with BERT are continued with additional data cleaning, facing overfitting issues, experimenting on a sample of data following prev. work approach
  • ref.risk extending data with URL permanence in terms of (lifespan of a URL on a page and number of edits)
  • ref.risk analysis of ground-truth labels from enwiki perennial sources list

15/04 - 21/04:
Ref.need experiments with different models (refer to slide#10 for results)
Ref.need feature exploration, example refer to slide#8 and below plots for Logistic Regression feature importance for positive/negative labels

Screenshot 2024-04-19 at 10.32.30 PM.png (938×944 px, 65 KB)

Ref.risk analysis of URL permanence to reliability label, example below:
Screenshot 2024-04-19 at 10.45.26 PM.png (1,276×888 px, 175 KB)

Next steps

  • Ref.need run experiments with Citation Needed data (prev. work)
  • Ref.risk decide on filtering and features for the final dataset

22/04 - 28/04:

  • Ref.need - Tested with Citation Needed data, our approach gets better results with their data
  • Ref.need - Added additional inputs to the model, such as the section index, paragraph index, sentence index
  • Ref.risk - Limit our data to instances of sources that are labeled in the perennial sources list, clean and preprocess the data for classification

Next steps:

  • Ref.need - experiment with different ways of aggregating multiple inputs to the model
  • Ref.risk - run classification for instances of domains from the perennial sources list

29/04 - 05/05:

  • Ref. need - add topic as a feature
  • Ref. need - ran experiments with additional numerical and textual features, so far the highest performance achieved in terms of f1-score is 0.733
  • Ref. risk - started classification experiments (treating multiclass and binary), for multiclass we use all 5 labels in the perennial sources list, and for binary we group blacklisted and deprecated as risky. Experiment with both balanced/unbalanced datasets. Naturally, there are much fewer risky references.

Next steps:

  • ref. need - try to use the recently released llama3
  • ref. risk - run more experiments

06/04 - 12/04:

  • Ref. need - model improves with more context, f1-score achieved is ~0.74
  • Ref. risk - experiment with assigning possible reliability labels based on the observed patterns from perennial sources with known labels (last plot here)
  • Ref. risk - compare featured articles and the remaining articles in the current snapshot with assigned our labels

Next steps:

  • ref. need - consider adding more context about a sentence to the model
  • ref. risk - keep polishing ways in label assignment and evaluating by comparing featured articles vs random vs low quality samples

More detailed updates (copied from the slack channel):
Updates:

  • Reference Risk: We are focusing on detecting popular unreliable sources. Targeting sources that appears more often, it is easier to differentiate reliable and unreliable. Given that references source follows a power-law distribution, if we are good on detecting "popular unreliable sources", we are going to have a good coverage, helping to identify most of the articles that contains non reliable sources.
  • Reference Need: Working on improve the citation needed algorithm. We have improved the classifier from ~0.62 to ~0.74 precision. This was done by including more context (paragraph, section name and topic) on the classifier. We are still working on parameter tunning.

Next steps and schedule:
We plan to work around 2 weeks more in improving the models for reference classification and citation needed. Then, our plan is to test the models at article level. This means:

  • Reference Risk: After having a good model for individual source classification, we are going to test this at article level. For this, we are going to use article signals. For example, we expect Feature Articles to have a reference risk close to 0, while articles marked (via templates) with reliability issues should have a higher Risk than random articles.
  • Reference Need: Similarly we are going to test the model at article level, comparing Featured Articles, with random and poorly cited (via templates) articles.

All this work is based on English Wikipedia, and should be finalized by mid June. Then we are going to start testing these approaches in other languages (although the models are based on language-agnostic and/or multilingual features).

I think is important to highlight that our goal is to give good signals at article level. This means that we are outputting an score for the article, where the individual assessments (of source quality, or sentence reference need) are the building blocks for the article score. This aggregation would help to balance potential (small) errors at individual level. So, the final score we give to the final user is about the reference quality of the full article.

12/05 - 19/05:

  • ref.need - testing best-performing classifier so far with the remaining languages (refers to the 5 languages featured articles were collected from as reported in earlier weeks), pretrained model from we're using is distilbert-base-multilingual-cased
  • ref.risk - changed the target feature from absolute edit number survived to the survival ratio, with 1 - meaning a reference survived all the edits after addition and 0 - meaning that the reference didn't survive subsequent edits. Analyzed the signals by comparing references on the article level

next steps:

  • ref. need - expand the experiments to multilingual scenarios, train and test on different languages
  • ref. risk - compare how the signal from the target features changes by article popularity to avoid noise from articles with a few edits in the dataset

20/05-26/05:

  • ref. need - experiments with additional context (such as prev/ next sections, sentences, or paragraphs)
  • ref. need - expand the experiments to multilingual scenarios, train and test on different languages with f1-score ar 0.70-0.72
  • ref. risk - more experiments of the signals of reliability (on data by domain, URL, and page levels)

next steps:
*ref. need - expand experiments to other types of articles, e.g., low-quality articles
*ref. risk - we will restart the baseline modeling with logistic regression

27/05-02/06:

  • ref.need - run inference with our best-performing model so-far and compute ref. need score with two samples of articles: featured and random sample, getting higher scores for random articles, meaning they are missing more references.

ref. risk - modelling approach set as below

  • Binary classifier to detect risky sources
  • Domain-level
  • English Wikipedia
  • Ground-truth labels
    • Perennial source list (positive class: deprecated and blacklisted sources)
  • Features (use both mean and median for aggregates)
    • Survival edit count
    • Survival edit ratio
    • Revertability ratio
    • Adder/Reverter user groups count
    • Adder/Reverter edit count
  • Training datasets
    • (1) Revisions 2013-2017
    • (2) Revisions 2019-2023
    • (1) + (2)
  • Test datasets
    • Latest revision of featured articles
    • Latest revision of all articles
    • Latest revision of non-reliable articles ({{unreliable source}} template)
  • ref. need - best-performing model so far is reaching 0.76, we tested with multilingual bert and xlm-roberta. The random sample compared to featured articles sample has on average > twice higher ref. need (RN) score, refer to the plot below
    rn_fa(rnd).png (1,102×816 px, 36 KB)
  • ref. need - compiled labeling dataset for 5 languages (en, es, de, fr, ru) and labeled ruwiki
  • ref. risk - prepared three training datasets using perennial sources (PS) as ground-truth label (before PS list, after PS list, and all)
  • ref. risk - binary classifier on balanced dataset, notebook with results here
  • ref.need - with transfer learning, results on the full enwiki dataset ( F1-score 0.76, ROC-AUC 0.77, PR-AUC 0.83)
  • ref. risk - results with the ground-truth on enwiki (Accuracy: 0.86, F1-score: 0.74)

The majority (58%) of misclassification is caused by the middle 'Generally unreliable' category

image.png (1,118×858 px, 79 KB)

Next:

  • test ref. need model on smaller language editions
  • ref. need - model works well when tested on smaller languages (kkwiki balanced ~0.7)
  • ref. need - prepared scripts to pass for production
  • ref. risk - run classifier on all domains in enwiki --> save the score and pred. probability per domain
  • ref. risk - article-level analysis of ref. risk score

next:

  • ref.risk prep script to share

Prepared the code here: https://gitlab.wikimedia.org/repos/research/reference-quality/-/tree/classifiers

ref. need - time performance tested with CPU setting (no batching) on 1000 revisions shows 50% of revisions take <0.70sec for prediction, and 95% of revisions take <6.06sec, refer to the cdf distribution below

image.png (980×770 px, 96 KB)

ref.risk - annotating additional 1000 domains

ref. risk logic to compute the score follows the definition given in our WWW paper, where we account for blacklisted/deprecated sources in perennial sources list as risky sources, which can be checked in the repo: https://gitlab.wikimedia.org/repos/research/reference-quality/-/tree/classifiers
ref.risk we further annotate an additional 1000 sources to use as ground-truth.

ref. need model card initial draft: https://meta.wikimedia.org/wiki/Machine_learning_models/Proposed/Multilingual_reference_need
ref. need model retrained to match KI package dependencies, comparison of tentative performance on CPU vs GPU is presented below

image.png (980×814 px, 102 KB)
image.png (990×808 px, 97 KB)

ref.need training and eval available at https://gitlab.wikimedia.org/repos/research/reference-quality/-/tree/research-notebooks/RN

Prepared the code here: https://gitlab.wikimedia.org/repos/research/reference-quality/-/tree/classifiers

ref. need - time performance tested with CPU setting (no batching) on 1000 revisions shows 50% of revisions take <0.70sec for prediction, and 95% of revisions take <6.06sec, refer to the cdf distribution below

image.png (980×770 px, 96 KB)

ref.risk - annotating additional 1000 domains

how does this translate to the latency requirements from Enterprise? They have the standard 500ms per record

If the request schema is per article (or is it per sentence?), the measurements should be done accordingly

what's the agreed schema?

For the second question, it is per article, so these tentative predictions were computed as the times to process an article revision.

Additionally, this week we updated the logic to consider all sentences already cited as "need citation", so that we only run a model for uncited sentences.

Update ref. need model input to

lang_code, section_name, sentence, next_sentence, prev_sentence

and reduce input context size to 128 given the time limitation constraints.

Model cards can be found as follows:

The ref. need was deployed to production this week. Given the time issue, we run experiments to further improve the model latency.
I shared two updated binaries with ML team with 1) a smaller model and 2) a smaller model + quantization. According to preliminary analysis on stat machines, it should reduce the processing time ~2 times.

We further consider running predictions on a sample of sentences for long articles, instead of running inference on all sentences.

Now, we are putting things together for a paper.

Hello all, my contract for this project ended on September 30, and I would like to summarize our work here.

First of all, lots of thanks to everyone involved, it was a great experience collaborating with multiple teams, including Research, Enterprise, and ML. I learned a lot from your guidance and enjoyed working on this project, especially given that it is something I have been researching for several years now! Thank you for making it possible to contribute to this work to my long-term advisor and mentor @diego, @Pablo, and to managers @FNavas-foundation and @XiaoXiao-WMF for making my hiring possible.

As an outcome of this project, we produced two models on reference quality, which are now deployed in production: reference risk and reference need.

  1. For reference need, we fine-tuned multilingual BERT to infer the proportion of sentences needing a citation in an article. Our initial model encountered time performance limitations. I worked on further improving the model with a negligible change in performance through 1) modifying the input of the model, 2) fine-tuning a smaller model, and 3) using pytorch quantization among the major changes. The improvement results are as follows (deployed and tested by ML team):
    • previous model: latency average 1016ms, median 710ms
    • current model: latency average 412ms, median 330ms
  1. For reference risk, we deployed a prediction-less approach due to the underlying complexity of deciding what a reliable source is, especially in the multilingual/multicultural context. After numerous experiments, we instead decided to deliver to users the historical survival of a given reference and let the user decide on the source reliability. We cover all the wikis and run airflow DAGs to update the tables on a monthly basis, which is also set thanks to @MunizaA and @AikoChou.

Finally, given resources and future needs, we could look at many directions as further work.

  • Given that our current inference is per sentence, the time increases with the length of an article. We could consider replacing binary classification per sentence to outputting the probability score per chunk of text.
  • We could also consider setting a threshold of sentences on which the inference is run. We would sample X uncited sentences to infer their label and obtain the final score. This approach if run as default may also require to add an additional option for a user to force run on all the sentences.
  • Incorporate most recent LLMs
  • Given that Enterprise is working on the reference parsing API, we could cover more references in our reference risk pipeline, e.g., the ones we are missing with wikitext as well as extend to not only URL-based references. This also has the potential to improve models’ inference time.

There are many future directions for this project and I hope the work on improving reference quality will continue. Once again, thank you all!!!