Get reference need prediction

POST /service/lw/inference/v1/models/reference-need:predict

This model uses revision content to predict the reference need score of that revision. Check the model card for more info.

Examples

curl

Anonymous access

# Get the reference need score for the edit on English Wikipedia identified by the revision id 123456.
$ curl https://api.wikimedia.org/service/lw/inference/v1/models/reference-need:predict -X POST -d '{"rev_id": 123456, "lang": "en"}'

Logged in access

# Get the reference need score for the edit on English Wikipedia identified by the revision id 123456.
$ curl https://api.wikimedia.org/service/lw/inference/v1/models/reference-need:predict -X POST -d '{"rev_id": 123456, "lang": "en"}' -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Python

# Python 3
# Get the reference need score for the edit on English Wikipedia identified by the revision id 123456.

import json
import requests

use_auth = False
inference_url = 'https://api.wikimedia.org/service/lw/inference/v1/models/reference-need:predict'

if use_auth:
  headers = {
      'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
      'User-Agent': 'YOUR_APP_NAME (YOUR_EMAIL_OR_CONTACT_PAGE)',
      'Content-type': 'application/json'
  }
else:
  headers = {}
data = {"rev_id": 123456, "lang": "en"}
response = requests.post(inference_url, headers=headers, data=json.dumps(data))
print(response.json())

JavaScript

/*
Get the reference need score for the edit on English Wikipedia identified by the revision id 123456.
*/

const inferenceUrl = "https://api.wikimedia.org/service/lw/inference/v1/models/reference-need:predict";
const accessToken = "YOUR_ACCESS_TOKEN";
const appName = "YOUR_APP_NAME";
const email = "YOUR_EMAIL_OR_CONTACT_PAGE";
let headers = new Headers({
    "Content-Type": "application/json",
    "Authorization": "Bearer " + accessToken,
    "Api-User-Agent": appName + " ( " + email + " )"
});
let data = {"rev_id": 123456, "lang": "en"};

fetch(inferenceUrl, {
    method: "POST",
    headers: headers,
    body: JSON.stringify(data)
})
.then(response => response.json())
.then(inferenceData => console.log(inferenceData));

POST Parameters

lang

required

A string representing the language code related to the target wiki. Example: "en" for English Wikipedia.
rev_id

required

The revision id for the wiki identified by the lang parameter.

Responses

200 Success: Returns a Reference need score object.
Example
{
   "model_name":"reference-need",
   "model_version":0,
   "wiki_db":"enwiki",
   "revision_id":1242378206,
   "reference_need_score":0.16666666666666666
}