SPICA: Retrieving Scenarios for Pluralistic In-Context Alignment
Quan Ze Chen et al., Nov 2024arXiv:2411.10912MethodBuiltAuthority: Affected public (open)
Retrieves few-shot examples for a model from a bank of past scenarios, using metrics that weigh how groups differ rather than similarity alone. On an alignment task with inputs from four demographic groups (n = 544), the retrieved examples matched observed preferences more closely. In an end-to-end evaluation (n = 120), SPICA was rated above similarity-based retrieval. Groups gained up to 0.16 points on a five-point scale, and every group benefited rather than only some.
CodeSPICA
from aiag import LM
from aiag.cases import SPICA, CaseBank
lm = LM("Qwen/Qwen2.5-1.5B-Instruct")
bank = CaseBank(lm) # each group's rating, 1-5, of how acceptable a scenario is
for scenario, group, rating in [("Eating meat", "vegans", 1), ("Eating meat", "farmers", 5), ("Wearing wool", "vegans", 2),
("Wearing wool", "farmers", 5), ("Recycling", "vegans", 5), ("Recycling", "farmers", 5)]:
bank.add(scenario, f"rated {rating}/5", group=group, rating=rating)
# Retrieve by similarity plus how far the group's rating departs from other groups', so examples carry what sets it apart
spica = SPICA(lm, bank, "vegans", k=2)
print(spica.examples("Wearing leather")) # the group's scenarios to show the model
print(spica.chat("Wearing leather"))- SPICAWrapperaiag/cases/legal_pluralism.py:336 SPICA: a group's few-shot scenarios are retrieved by similarity plus a group-contrast score, how far the group's rating of a scenario departs from other groups' ratings of it, so the examples carry what sets the group apart rather than what merely looks alike (Chen et al., 2024).
pip install aiagEvery method in aiag Library on GitHub