Skip to content

Drag-and-Drop Ranking

Configure Potato's ranking scheme, where annotators drag a fixed set of options into a full order, and read the stored order and Kendall's tau agreement.

The ranking annotation type shows the annotator a fixed list of options and asks for the whole list in order, best at the top. Annotators reorder the rows by dragging them, by pressing each row's Move up and Move down buttons, or with the arrow keys. Potato stores the finished order as one comma-separated string per scheme, and the agreement report at /admin/iaa compares annotators' orders with Kendall's tau and a normalized Spearman footrule.

When to use ranking

Ranking fits a judgment over a small set of options that all fit on one screen, usually three to eight. The annotator compares every option with every other one at once, and the effort per item grows quickly past about eight options. The other comparison types cover the cases ranking handles poorly:

TypeWhat the annotator doesOptions per judgmentEqual answers
rankingPuts every option in a full orderThe whole labels listNo
pairwisePicks the better of two, or sets how much better on a sliderTwoallow_tie: true adds a tie button
bwsPicks only the best and the worstA tuple sampled from a pool, usually fourNo
likertRates one item on a fixed scaleOneTwo items can get the same rating

Two-way comparisons belong in pairwise, because a ranking of two options is a pairwise judgment without the tie button or the strength of preference. A pool of hundreds of items is too large for one screen, and best-worst scaling builds overlapping tuples from the pool and scores the items after collection. A ranking also says nothing about absolute quality, since four poor responses still come out first to fourth. A study that needs to know whether any response is acceptable adds a Likert or radio question beside the ranking.

Configuration

A ranking scheme needs a name, a description, and a non-empty labels list. Add this block to a config:

yaml
annotation_schemes:
  - annotation_type: ranking
    name: response_quality
    description: "Drag the responses into order, best at the top."
    labels:
      - Response A
      - Response B
      - Response C
      - Response D
    label_requirement:
      required: true

The type takes one option of its own beyond the shared scheme keys:

OptionDefaultDescription
labelsrequiredThe options to rank, as strings or as mappings with a name
allow_tiesfalseAccepted, but the 2.14.0 widget shows no tie control (see Ties)
label_requirement.requiredfalseBlocks the Next button until the ranking has a stored order (see Required answers)

A label written as a mapping can carry a tooltip. The tooltip appears when the annotator points at the row:

yaml
annotation_schemes:
  - annotation_type: ranking
    name: response_quality
    description: "Drag the responses into order, best at the top."
    labels:
      - name: Response A
        tooltip: "The first model's answer"
      - name: Response B
        tooltip: "The second model's answer"
      - name: Response C
        tooltip: "The third model's answer"

Data format

The labels list is the same on every item, so each row of the data file carries the content behind the labels. Potato's example project puts the question and the four responses in one text field:

json
{"id": "rk001", "text": "Question: How do I reverse a list in Python?\n\nResponse A: Use the .reverse() method which modifies the list in place, or use slicing list[::-1] to create a reversed copy.\nResponse B: You can reverse it by looping backwards through the indices and appending to a new list.\nResponse C: Python doesn't have a built-in way to reverse lists. You need to write a custom sorting function.\nResponse D: Try using the sorted() function with a key parameter set to the negative index value."}

Separate fields read more easily once responses run longer than a sentence or two. An instance_display block with one text field per response shows each response under a heading that matches the response's label:

yaml
instance_display:
  fields:
    - key: question
      type: text
      label: "Question"
    - key: response_a
      type: text
      label: "Response A"
    - key: response_b
      type: text
      label: "Response B"
    - key: response_c
      type: text
      label: "Response C"

Add this block to the config above, with one field for every label in the scheme.

Moving rows

Every row has a drag handle, the row's current rank, the label, and a Move up and a Move down button. The buttons carry aria-label text for screen readers, and Tab reaches the buttons like any other button. With one of a row's buttons focused, the Down arrow key moves that row one place down, and the Up arrow key moves the row one place up. In the 2.14.0 code, a move up redraws the row and appears to drop the focus, so a keyboard user may need to focus the row's button again before the next key press. That reading comes from the code and has not been tested in a browser. Ranking schemes have no number-key shortcuts. On a phone, tapping the buttons reorders the list, and Potato's touch tests check that the Move down button is at least 44 pixels on each side.

Dragging has a known issue in 2.14.0. A drag released outside the list reorders the rows on screen, but the new order is never saved, so the visible order and the stored answer disagree. Tell annotators to drop every row inside the list.

Every annotator starts from the order labels lists, on every item. Potato 2.14.0 does not shuffle a ranking's starting order, and the ranking scheme has no randomize_order option. An annotator who tends to leave the first row near the top passes that position bias to whichever response sits behind "Response A". When you build the data file, rotate which response appears as A, B, C, and D, and record each item's rotation. The position bias then spreads across responses instead of landing on one.

Ties

Potato 2.14.0 accepts allow_ties, but the option has no effect. The ranking widget renders no control for placing two options at one rank. Every stored order is therefore strict, whatever the setting. Potato's readers of ranking data do accept ties. The agreement report and the reward-model trainer read an order such as B,D=A,C as B first, D and A tied second, and C last. An order with ties reaches those readers only from annotation data written outside the annotation page. For an equal judgment collected from annotators, use pairwise with allow_tie: true, or rate each option on a Likert scale.

Required answers

The ranking's stored value is empty when an item opens, unless the server has already filled the value. The server fills the value from the annotator's saved answer on a return visit, or from a model pre-label that orders every option. On the page, the annotator's first move of a row fills the value, although pressing Move up on the top row stores nothing. With label_requirement.required: true, the Next button stays blocked until the stored value is non-empty. A restored answer or a full-order pre-label therefore meets the requirement with no move, and the configured starting order alone never does. An annotator who agrees with the configured starting order moves one row and moves the row back. Without required, an untouched item with no pre-label saves no ranking. A returning annotator sees the saved order, and an item with no saved ranking or pre-label opens in the configured order.

Stored output and exports

Each annotator's answers persist to <output_annotation_dir>/<user>/user_state.json. In that file, a ranking sits under instance_id_to_label_to_value as a pair. The pair's first element names the scheme and the label rank_order, and the second element is the order as one string, best first. The jsonl export writes one line per annotator and item, with the order nested under labels by scheme name and rank_order. The line below is abridged to the fields a ranking fills:

json
{"instance_id": "rk001", "user_id": "annotator1", "labels": {"response_quality": {"rank_order": "Response B,Response D,Response A,Response C"}}}

The csv and tsv exports put the order in one column named response_quality.rank_order, and a script recovers the ranks by splitting the cell on commas. Keep commas and = out of label names, because Potato's own readers split on both characters. See export formats for the other formats.

Kendall's tau and footrule agreement

The agreement report at /admin/iaa classifies a ranking scheme as a ranking and reports two numbers for the scheme:

  • kendall_tau is Kendall's tau-b between two annotators' orders of the same item, averaged over every pair of annotators and every item both ranked. A value of 1 means identical orders, and -1 means one order is the reverse of the other.
  • spearman_footrule is the summed distance each option moved between the two orders, divided by the largest possible sum. A value of 0 means identical orders, 1 means the largest possible disagreement, and lower is better.

The report scores items whose per-item annotator cap is at least two and that have reached the cap. Two annotators per item is the minimum:

yaml
num_annotators_per_item: 2

The report is admin-only and returns JSON by default:

bash
curl -H "X-API-Key: $POTATO_ADMIN_KEY" "http://localhost:8000/admin/iaa"

Add ?format=html to the URL for a table. The inter-annotator agreement guide covers the coefficients Potato reports for every other scheme type, and agreement drift tracks the same numbers window by window.

Reward models trained on rankings

The reward-model trainer learns from ranking schemes along with pairwise and best-worst ones. By default the trainer fits a Plackett-Luce model over each full order, and an order with ties trains on the order's untied pairs instead. The trainer option ranking_loss: pairs switches to a Bradley-Terry model over each order's pairs. Each option's text is the label string itself, scored given the item's text. The trainer therefore suits rankings whose labels are the options themselves (e.g., a list of policy priorities) more than labels like "Response A" that point at content elsewhere in the item. The trainer's predictions are scored with Kendall's tau. A prediction that orders every option can appear on the annotation page as a pre-label in place of the configured order. Such a pre-label fills the stored value and meets required without a move (see Required answers). A prediction that leaves an option out is not shown.

Importing ranking questions

The survey importers turn a Qualtrics rank-order question, a SurveyJS ranking element, an XLSForm rank question, and a LimeSurvey ranking question into a ranking scheme. A REDCap matrix ranking is imported as a rating grid without the ranking constraint, and the import report lists the question. The Argilla project importer reports ranking questions and leaves them out.

Full example

The config below is the examples/classification/ranking project from the Potato repository, with the answer made required. Four model responses to one question are ranked for helpfulness and accuracy:

yaml
annotation_task_name: "Response Quality Ranking"
task_dir: "."
 
data_files:
  - data/ranking-example.json
 
item_properties:
  id_key: id
  text_key: text
 
annotation_schemes:
  - annotation_type: ranking
    name: response_quality
    description: "Rank the responses from best (1st) to worst (last) based on helpfulness and accuracy"
    labels:
      - Response A
      - Response B
      - Response C
      - Response D
    allow_ties: false
    label_requirement:
      required: true
 
output_annotation_dir: "annotation_output/ranking/"
export_annotation_format: jsonl
 
user_config:
  allow_all_users: true

Start the server from the project folder:

bash
potato start config.yaml -p 8000

The exports land in annotation_output/ranking/exports/jsonl/, one line per annotator and item.


Further reading

For implementation details, see the source documentation.