# Different Schemes for Different Annotator Groups

Source: https://www.potatoannotator.com/docs/deployment/per-group-schemes

Potato can show each group of annotators a different set of annotation schemes inside one project, so an expert panel answers four questions about a post while crowd workers answer one. The groups are the `batch_assignment.groups` that [task assignment](/docs/deployment/task-assignment#custom-batch-assignment) uses to decide which items each annotator receives. A `schemes` key on a group names the schemes the group's annotators see. The optional top-level `scheme_sets` block holds named lists of schemes that several groups can share. Potato keeps the global `annotation_schemes` list as the default and shows the full list to an annotator who belongs to no group or to a group without a `schemes` key.

## When to use per-group schemes

Per-group schemes fit studies where annotators with different training answer different questions about the same items, or where the question itself is the variable under study. Two common designs are listed below:

- **Expert and crowd tiers.** Experts give the toxicity judgment and label the target group, the severity, and a rationale for each post. Crowd workers give only the toxic or not-toxic judgment on the same posts.
- **Wording tests.** Two randomly assigned groups label matching items under two wordings of one question. Comparing the label distributions of the two groups shows how much the wording moved the answers.

When the groups differ by one question, [`display_logic` on a condition](/docs/experiments/experiment-flow#testing-a-condition-in-rules) shows or hides the question inside one scheme list. When only the wording of a question changes, a [`{condition.<factor>}` placeholder](/docs/experiments/experiment-flow#wording-per-condition) in the question text varies the wording per condition. Per-group schemes fit designs where the groups answer different sets of questions or choose from different label sets.

## Configuration

The `schemes` key goes on a group in `batch_assignment.groups`, and the optional `scheme_sets` block sits at the top level of the config. The config below gives two experts all four schemes and three crowd workers a one-scheme set, on the same posts:

```yaml
annotation_task_name: Toxicity with expert and crowd schemes
task_dir: .
output_annotation_dir: annotation_output/
data_files:
  - data/posts.jsonl
item_properties:
  id_key: id
  text_key: text
user_config:
  allow_all_users: true
  users: []

annotation_schemes:
  - annotation_type: radio
    name: toxicity
    description: Is this post toxic?
    labels: [toxic, not_toxic]
  - annotation_type: multiselect
    name: target_group
    description: Which groups does the post target?
    labels: [gender, race_ethnicity, religion, sexual_orientation, disability, none]
  - annotation_type: likert
    name: severity
    description: How severe is the toxicity?
    size: 5
    min_label: Mild
    max_label: Severe
  - annotation_type: text
    name: rationale
    description: Quote the words that decided your label.

scheme_sets:
  crowd_short: [toxicity]

assignment_strategy: batch
num_annotators_per_item: 5
batch_assignment:
  groups:
    - name: experts
      annotators: [expert_1, expert_2]
      instances_file: batches/round1.csv
      schemes: [toxicity, target_group, severity, rationale]
    - name: crowd
      annotators: [worker_01, worker_02, worker_03]
      instances_file: batches/round1.csv
      schemes: crowd_short
```

Both groups read the same `instances_file`, so experts and crowd workers label the same posts. Potato retires an item once the item reaches `num_annotators_per_item`, and the value of 5 covers all five annotators across the two groups. A lower cap would let the first annotators to finish an item close the item to everyone else. The expert group could also leave out `schemes`, because an annotator in a group without a binding sees the full global list.

### Keys and validation

Each key, the values Potato accepts, and the checks Potato runs when the config loads are listed below:

| Key | Accepts | Checked at load |
|---|---|---|
| `scheme_sets` | A mapping from a set name to a list of scheme names, inline scheme definitions, or both. A single scheme name in place of the list also works. | The block must be a mapping. Every name in a set must be a scheme in `annotation_schemes`. A set cannot name another set. |
| `batch_assignment.groups[].schemes` | A set name from `scheme_sets`, a single scheme name from `annotation_schemes`, or a list of scheme names and inline scheme definitions | Every name must resolve. An empty list and `schemes: null` are refused. A list entry must be a name or a mapping. |
| `batch_assignment.groups[].name` | Any string | Not checked by the binding, but the name is the key Potato uses to find the group's schemes |

An inline scheme definition is validated like any entry in `annotation_schemes`, so a definition without a `description` is refused. A misspelled name stops `potato start` and `python -m potato.validate_cli` with an error that names the group and the bad value:

```text
batch_assignment.groups[0].schemes references unknown scheme name 'sentimnet' (not found in annotation_schemes)
batch_assignment.groups[0].schemes references unknown scheme set / scheme name 'mininal'
scheme_sets['b'] references unknown scheme name 'a' (not found in annotation_schemes)
batch_assignment.groups[0].schemes must be a non-empty scheme-set name or list of schemes
```

Every group still needs the fields the batch strategy requires. A group lists `annotators` (or the alias `users`) unless `auto_assign_annotators` is on, and every group names the group's items through `instances`, `instances_file`, or `data_file`. Even a group that exists only to bind schemes needs an item list.

## Assigning annotators to groups

Potato finds an annotator's group in one of three ways. First, an annotator listed in a group's `annotators` belongs to the group from the first login. Second, with `auto_assign_annotators: true`, a group with no `annotators` list takes annotators in order of arrival. Third, `group_by_condition` sends each participant to the auto-assigned group named after the participant's level of a [condition](/docs/experiments/experiment-flow#different-items-for-each-cell).

Auto-assigned groups need a few precautions. Potato pins each new annotator to the open group with the fewest annotators and breaks ties toward the group listed first. Setting `max_annotators` (or `annotator_count` or `slots`) on a group closes the group once full. A group with none of the three keys takes at most `num_annotators_per_item` annotators when that key is set. After a restart, Potato rebuilds each pin from the items the annotator was assigned and chooses the group holding most of the annotator's items. Keep the item sets of auto-assigned groups disjoint. During the rebuild, an item listed in two auto-assigned groups counts toward the first group, and an annotator rebuilt into the wrong group sees the wrong schemes.

Group membership comes only from `batch_assignment.groups`. Items that list permitted annotators through `batch_assignment.annotator_key` put no annotator in a group, and the annotators named on items see the global list. A group's item list is read only under `assignment_strategy: batch`, and under another strategy every annotator draws from the whole dataset. The `schemes` binding of a group that lists its annotators by name applies under any strategy. An auto-assigned group gets its schemes only under `assignment_strategy: batch`, because Potato pins annotators to auto-assigned groups only while the batch strategy assigns items. After a restart, the pin rebuild runs under any strategy and can pin a returning annotator to an auto-assigned group by item overlap. Under a strategy other than batch, the validator warns only when a group lists items inline under `instances`, and `--strict` counts the warning as an error. Groups that name their items through `items`, `instance_ids`, `instances_file`, `items_file`, or `data_file` get no warning.

## A wording test with random assignment

A wording test needs random assignment and the same items under each wording. The config below assigns each participant a level of `wording` on first arrival, sends the participant to the group of the same name, and shows only the matching version of the question:

```yaml
annotation_task_name: Sentiment wording test
task_dir: .
output_annotation_dir: annotation_output/
data_files: []
item_properties:
  id_key: id
  text_key: text
user_config:
  allow_all_users: true
  users: []

annotation_schemes:
  - annotation_type: radio
    name: sentiment_plain
    description: Is this review positive or negative?
    labels: [positive, negative]
  - annotation_type: radio
    name: sentiment_feeling
    description: How did the writer feel about the product?
    labels: [liked_it, disliked_it]

scheme_sets:
  plain: [sentiment_plain]
  feeling: [sentiment_feeling]

conditions:
  factors:
    wording: [plain, feeling]

assignment_strategy: batch
batch_assignment:
  auto_assign_annotators: true
  group_by_condition: wording
  groups:
    - name: plain
      data_file: data/arm_a.jsonl
      schemes: plain
    - name: feeling
      data_file: data/arm_b.jsonl
      schemes: feeling
```

The validator requires one auto-assigned group per level of the factor, each named exactly after a level. The two data files hold copies of the same reviews under distinct IDs (`r1_a` in one file, `r1_b` in the other), because item IDs must be unique across all data files. Each wording also gets a separate scheme name. Export columns are named after schemes, so distinct names keep the two wordings apart in the data, and the adjudication page keeps only the first definition of a repeated name.

## Annotation pages per group

At startup, Potato builds the default annotation page from the global list and one extra page for each group with a `schemes` key. Each annotator is served the page for the annotator's group, and the AI assistant looks up schemes in the same group's list. A custom [`task_layout`](/docs/features/layout-customization) file is the exception. Potato logs a warning and serves the same custom layout to every group, so per-group schemes need the auto-generated layout.

The [adjudication](/docs/features/adjudication) page shows the union of every group's schemes, with the global schemes first and one copy of each scheme name. An adjudicator can therefore resolve items from any group on one form.

## Exports and agreement

Potato saves each annotation under the annotator and the scheme name, and the export records no group. A CSV, TSV, or JSONL export has one row per annotator and item, with columns for each scheme the annotator answered. In the toxicity config above, a crowd worker's row fills the `toxicity` columns and leaves the expert-only columns empty. To split the data by group, join the export's `user_id` column against the groups' `annotators` lists, or against the participant's condition in the [flow record](/docs/experiments/experiment-flow#the-flow-record) for a condition-routed study.

The admin dashboard's [agreement metrics](/docs/features/quality-control#agreement-metrics) and the `/admin/iaa` report both compute agreement per scheme over the global `annotation_schemes` list. For a scheme that several groups see, the coefficient pools every annotator who answered the scheme, whatever the annotator's group. A scheme defined inline in a group's `schemes` list and absent from the global list gets no agreement figure. Defining every scheme in `annotation_schemes` and binding groups by name keeps every scheme in the agreement reports. For agreement within one group, compute the coefficient from the export after the join.

## Interactions with training and quality checks

The [training phase](/docs/features/training-phase) does not read groups. Every annotator trains on the global list or on the subset named in `training.annotation_schemes`, and the same training applies to every group. Survey and consent pages in `phases` take questions from the phase definitions and look the same to every group.

[Attention checks and gold-standard items](/docs/features/quality-control) are scored against every scheme named in the expected answer. An annotator whose group does not see one of the named schemes cannot answer the scheme and fails the item. Write expected answers against schemes that every group sees, such as `toxicity` in the toxicity config above.

## Known limitations in 2.14.0

Potato 2.14.0 has five known limits on per-group schemes, each with a workaround:

- **Required schemes are checked against the global list.** Potato's server-side check for [required schemes](/docs/core-concepts/annotation-schemes) reads only the global `annotation_schemes` list, and the status badge on the annotation page uses the same check. A global scheme marked `required: true` or `label_requirement: {required: true}` therefore stops annotators whose group does not show the scheme from moving to the next item, and the badge on those items stays at in progress. A required scheme defined only inline in a group is never checked. Mark as required only the schemes that every group sees.
- **Unnamed auto-assigned groups get the global list.** Potato calls an unnamed auto-assigned group `batch_1`, `batch_2`, and so on when assigning items, while the scheme lookup calls the same group `group_0`, `group_1` by position in the list. The two names never match, and the annotators of an unnamed auto-assigned group see the global list. An unnamed group with an explicit `annotators` list gets the group's schemes, because both lookups use the position name for that group. Give every auto-assigned group a `name`.
- **An annotator in two groups gets the first group's schemes.** When one username appears in two groups, the annotator receives the items of both groups and sees the schemes of the group listed first. List each username in one group only.
- **Submissions are not filtered by group.** The `/updateinstance` endpoint does not check a submitted scheme against the annotator's group, and a client that posts to the endpoint directly can store answers to schemes outside the group. Join the export against the groups' `annotators` lists and drop answers to schemes outside each annotator's group before analysis.
- **Annotators in no group get no items under the batch strategy.** Under `assignment_strategy: batch`, an annotator who is in no group, is not auto-assigned to one, and is named on no item through `annotator_key` receives no items. List every annotator in a group, or leave an auto-assigned group open for newcomers.

## Example project

Potato ships a runnable example in [`examples/advanced/per-cohort-schemas`](https://github.com/davidjurgens/potato/tree/master/examples/advanced/per-cohort-schemas). The example defines `sentiment`, `topic`, and `notes` in the global list, puts `alice` in a group bound to a one-scheme set, and puts `bob` in a group bound to `sentiment` and `topic`. Separately, the example's `rbac` block gives `carol` the admin role. From the root of a Potato checkout, start the server:

```bash
potato start examples/advanced/per-cohort-schemas/config.yaml -p 8000
```

Log in at `http://localhost:8000` as `alice`, then as `bob`, and compare the two annotation pages. Any other username gets no items, because the example uses the batch strategy and lists no group for other users.

## Further reading

- [Task assignment](/docs/deployment/task-assignment), for the batch strategy, item files, and per-item annotator lists
- [Experiment flow](/docs/experiments/experiment-flow), for conditions, `group_by_condition`, and `display_logic` on a condition
- [Adjudication](/docs/features/adjudication), for resolving disagreements from every group
- [Quality control](/docs/features/quality-control), for attention checks, gold-standard items, and agreement metrics

For implementation details, see the [source documentation](https://github.com/davidjurgens/potato/blob/master/docs/advanced/per_cohort_schemas.md).
