सामग्री पर जाएं
यह पृष्ठ अभी आपकी भाषा में उपलब्ध नहीं है। अंग्रेज़ी संस्करण दिखाया जा रहा है।

Drag-and-Drop Ranking

Configure Potato's ranking scheme, where annotators drag options into a full order or a top N, with optional ties, and read 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, or with top_k for the annotator's top N only. Annotators reorder the rows by dragging the rows, 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, or the top N, in orderThe whole labels listallow_ties: true adds an = button
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 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. Rankings also say 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

Beyond the shared scheme keys, the ranking type takes two options:

OptionDefaultDescription
labelsrequiredThe options to rank, as strings or as mappings with a name
allow_tiesfalseAdds an = button that ties an option with the option above (see Ties). New in v2.15.0
top_knoneRanks only the annotator's top N, from 1 to the number of labels (see Ranking only the top N). New in v2.15.0
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 have aria-label text for screen readers. Tab reaches each row and the row's buttons, and with a row or one of the row's buttons focused, the Up and Down arrow keys move the row one place. Focus stays on the row that moved, so a keyboard user can keep pressing. 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. A drag released outside the list leaves the order unchanged.

Every annotator starts from the order labels lists, on every item. Potato 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

New in v2.15.0

With allow_ties: true, every ranked row after the first has an = button that ties the row with the row above. Tied rows share a rank number, so four options with the middle two tied are numbered 1, 2, 2, 4. Pressing = again unties the row, and moving a tied row up or down takes the row out of the tie. With a row focused, the = key does the same as the button.

yaml
annotation_schemes:
  - annotation_type: ranking
    name: summary_quality
    description: "Rank the summaries. Use the = button to tie equally good ones."
    allow_ties: true
    labels:
      - Summary A
      - Summary B
      - Summary C

The stored order joins tied labels with =, so B,D=A,C puts B first, D and A level in second place, and C last. Both the agreement report and the reward-model trainer read ties in the same form. Potato stops at startup with an error when a scheme with allow_ties has a label containing =.

Ranking only the top N

New in v2.15.0

top_k asks the annotator to order only the N options that matter most and to leave the rest unranked. Add the scheme below to a config:

yaml
annotation_schemes:
  - annotation_type: ranking
    name: top_features
    description: "Pick your three most important features and put them in order."
    top_k: 3
    labels: [Price, Battery, Camera, Screen, Size, Weight, Brand]
    label_requirement:
      required: true

The widget shows two boxes, "Your top 3" and "Not ranked", and every option starts in "Not ranked" in the order labels lists. Annotators drag an option into the top box or press the option's Add button, and the × button takes the option back out. With a row focused, Enter adds or removes the row, and Delete removes the row. Once the top box has N options, adding another option shows a message and leaves the top box unchanged. A required scheme blocks Next until exactly N options are ranked. top_k takes a whole number from 1 to the number of labels and combines with allow_ties, where two tied options still take two of the N places.

The stored order names only the ranked options, such as Camera,Price,Battery. Potato's agreement report and reward-model trainer read the unranked options as one tie below the ranked options. Each ranked option then counts as above each unranked option, and the unranked options have no order. A pre-label must rank exactly N options, and a longer prediction is cut to the first N unless the cut would split a tie. Orders saved before a study added top_k contain every label, and the page asks the annotator to take the extra options out before the page can be saved.

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.

Potato checks every order saved to /updateinstance, whether the page, the API, or a script sent the order (New in v2.15.0). The server answers with a 400 and stores nothing from the save when an order names a label the scheme does not have, names a label twice, has an empty place (C,,A), ties labels without allow_ties, or ranks more than top_k options. Potato stores an order with fewer than top_k options, because the page saves the order while the annotator builds the order.

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.