SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2407.06576 · EMNLP · 2024

Virtual Personas for Language Models via an Anthology of Backstories

Marwa Abdulhai, Suhong Moon, Widyadewi Soedarmadji, Minwoo Kang, Joseph Suh, Eran Kohen Behar, David M. Chan

arXiv · PDF · Open in the Atlas

Code that ran

10 of 15 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 9 failures of our instrument; 5 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2407.06576.json · badge: /api/ran/2407.06576.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
cannylab/anthology canonical (classifier label)
classifier basis: census
9 ran · 5 no recorded run
CannyLab/anthology community
Papers with Code archive
1 ran · 0 no recorded run
FunctionStatusWhere it lives
generate_mcq Ran
ran; our contract draft was wrong, not the code
cannylab/anthology/anthology/lm_inference/question_utils.py
code served (permissive licence) · get_code("2216c17ba1c6e4b5")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

from omegaconf import DictConfig, ListConfig

# Create a small ListConfig for choices
choices = ListConfig([
    "Option A: First choice",
    "Option B: Second choice", 
    "Option C: Third choice"
])

# Create a DictConfig for choice_format with left and right symbols
choice_format = DictConfig({
    "left_symbol": "[",
    "right_symbol": "]"
})

# Create a DictConfig for surveyor_respondent with surveyor, respondent, and connector
surveyor_respondent = DictConfig({
    "surveyor": "Surveyor",
    "respondent": "Respondent",
    "connector": ":"
})

# Define the ARGS dictionary with all parameters
ARGS = {
    "question": "What is your favorite color?",
    "choices": choices,
    "choice_format": choice_format,
    "mcq_symbol": "number",
    "surveyor_respondent": surveyor_respondent
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
omegaconf — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
label_to_index_mapper Ran
ran, honoured the contract we drafted
cannylab/anthology/anthology/demographic_survey/response_parse_utils.py
code served (permissive licence) · get_code("9832a0e52b22286b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned int, ndim 0, dtype family int, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# Analyze the function:
# - letter: str - a single character
# - num_choices: int - number of valid choices
# The function converts a letter to an ordinal index, returning -1 if out of range

ARGS = {
    "letter": "C",
    "num_choices": 5
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type int, ndim 0, dtype family int, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_backstory Ran
ran; our contract draft was wrong, not the code
CannyLab/anthology/anthology/backstory/backstory.py
code served (permissive licence) · get_code("1169149be5b9f40b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned DataFrame. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import pandas as pd
import pathlib
import tempfile
import os

# Create a temporary CSV file with valid backstory data
temp_dir = tempfile.mkdtemp()
backstory_path = os.path.join(temp_dir, "backstory.csv")

# Create a sample backstory dataframe
backstory_data = {
    'uid': [1, 2, 3, 4, 5],
    'full_passage': [
        'This is a backstory passage one.',
        'This is a backstory passage two.',
        'This is a backstory passage three.',
        'This is a backstory passage four.',
        'This is a backstory passage five.'
    ],
    'backstory_generated_token_length': [50, 60, 45, 55, 70]
}

df = pd.DataFrame(backstory_data)
df.to_csv(backstory_path, index=False)

ARGS = {
    'backstory_path': backstory_path,
    'backstory_type': 'default',
    'num_backstory': 3,
    'shuffle_backstory': True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_data Ran
ran; our contract draft was wrong, not the code
cannylab/anthology/anthology/analysis/atp.py
code served (permissive licence) · get_code("6a7644fed88642f7")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned DataFrame. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import pandas as pd
import tempfile
import os

# Create a temporary CSV file with sample data
temp_dir = tempfile.mkdtemp()
csv_path = os.path.join(temp_dir, "survey_data.csv")

# Create sample survey data
sample_data = pd.DataFrame({
    'model_name': ['GPT-4', 'Claude', 'Llama'],
    'score': [9.2, 8.8, 7.5],
    'category': ['reasoning', 'helpfulness', 'speed']
})
sample_data.to_csv(csv_path, index=False)

ARGS = {
    'path': csv_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
nonzero_index_finder Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
cannylab/anthology/anthology/demographic_survey/response_parse_utils.py
code served (permissive licence) · get_code("515607e16f43d17c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

# Construct a simple list with mixed positive and non-positive values
# The function iterates through the list and finds indices where arr[i] > 0
arr = [0, 5, -3, 2, 0, 7, -1, 4]

ARGS = {
    "arr": arr
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family int — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
prepare_llm Ran
ran; our contract draft was wrong, not the code
cannylab/anthology/anthology/lm_inference/llm.py
code served (permissive licence) · get_code("09aa43be3289a19d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import openai

# Mock the openai.Model.list() to avoid network calls
class MockModel:
    @staticmethod
    def list():
        return {'data': [{'id': 'mock-model'}]}

openai.Model = MockModel()

# Set up environment variables
os.environ['TOGETHER_API_KEY'] = 'test-together-key'
os.environ['OPENAI_API_KEY'] = 'test-openai-key'

ARGS = {
    'api_provider': 'together',
    'model_name': 'llama-3-70b'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
openai — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
regex_leaning_letter_classifier Ran
ran; our contract draft was wrong, not the code
cannylab/anthology/anthology/demographic_survey/political_affiliation.py
code served (permissive licence) · get_code("393f36298ef6a632")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import re

def regex_leaning_letter_classifier(response):
    pattern = '^\\s*[\\(\\[]?([A-C])[\\)\\]]?\\.?\\s*(?:$|\\s+|\\))'
    match = re.match(pattern, response, re.IGNORECASE)
    if match:
        return match.group(1)
    else:
        return None

ARGS = {
    'response': '(A) This is a test'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
regex_strength_letter_classifier Ran
ran; our contract draft was wrong, not the code
cannylab/anthology/anthology/demographic_survey/political_affiliation.py
code served (permissive licence) · get_code("a536ee7b78d018e3")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import re

def regex_strength_letter_classifier(response):
    pattern = '^\\s*[\\(\\[]?([A-B])[\\)\\]]?\\.?\\s*(?:$|\\s+|\\))'
    match = re.match(pattern, response, re.IGNORECASE)
    if match:
        return match.group(1)
    else:
        return None

# Test cases to understand what the function expects
test_responses = [
    "A",
    "B",
    "(A)",
    "[B]",
    "  A. ",
    "  B) ",
    "a",
    "b",
    "(a)",
    "[b].",
    "A some text",
    "B)",
    "C",  # Should return None
    "invalid",  # Should return None
]

# Build ARGS dict with a valid response string
ARGS = {
    "response": "A"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
regex_strength_response_classifier Ran
ran; our contract draft was wrong, not the code
cannylab/anthology/anthology/demographic_survey/political_affiliation.py
code served (permissive licence) · get_code("0d42cc0269a379e6")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import re

def regex_strength_response_classifier(response):
    pattern = '.*?(strong|not very strong|neither one or equally close to both).*?'
    match = re.match(pattern, response, re.IGNORECASE)
    if match:
        text = match.group(1)
        text = text.lower().replace(' ', '_')
    else:
        text = None
    return text

ARGS = {
    "response": "The evidence is strong and compelling."
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
retry_with_exponential_backoff Ran
ran; our contract draft was wrong, not the code
cannylab/anthology/anthology/lm_inference/backoff.py
code served (permissive licence) · get_code("052a7adf33f0375f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned function. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import random
import time
from typing import Any, Callable, Collection, Generic, List, Optional, Type, TypeVar

Q = TypeVar('Q', bound=Callable[..., Any])

def retry_with_exponential_backoff(initial_delay: float=1, exponential_base: float=2, jitter: bool=True, max_retries: int=10, no_retry_on: Optional[Collection[Type[Exception]]]=None) -> Callable[[Q], Q]:
    """Retry a function with exponential backoff."""

    def decorator(func: Q) -> Q:

        def wrapper(*args, **kwargs):
            num_retries = 0
            delay = initial_delay
            error = None
            while num_retries <= max_retries:
                try:
                    return func(*args, **kwargs)
                except Exception as e:
                    if no_retry_on is not None and type(e) in no_retry_on:
                        raise e
                    time.sleep(delay)
                    delay *= exponential_base * (1 + jitter * random.random())
                    error = e
                    num_retries += 1
                    print(f'Retrying {func.__name__} after error: {e} (retry {num_retries} of {max_retries})')
            if error is not None:
                raise error
        return wrapper
    return decorator


# Setup code to construct valid arguments
ARGS = {
    'initial_delay': 0.1,
    'exponential_base': 2.0,
    'jitter': True,
    'max_retries': 3,
    'no_retry_on': (ValueError, TypeError)
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_tokenizer Not yet run
unverified (harvested, no recorded run)
cannylab/anthology/anthology/lm_inference/llm.py
code served (permissive licence) · get_code("c3a7b5e25aa5107e")
How it ran

no invocation recorded.

number_to_index_mapper Not yet run
unverified (harvested, no recorded run)
cannylab/anthology/anthology/demographic_survey/response_parse_utils.py
code served (permissive licence) · get_code("305afac82adc9356")
How it ran

no invocation recorded.

numerical_response_parser Not yet run
unverified (harvested, no recorded run)
cannylab/anthology/anthology/demographic_survey/response_parser.py
code served (permissive licence) · get_code("2282f20fccb0175c")
How it ran

no invocation recorded.

preprocess_numerical_response Not yet run
unverified (harvested, no recorded run)
cannylab/anthology/anthology/demographic_survey/response_parser.py
code served (permissive licence) · get_code("41533974dab8e04c")
How it ran

no invocation recorded.

string_response_parser Not yet run
unverified (harvested, no recorded run)
cannylab/anthology/anthology/demographic_survey/response_parser.py
code served (permissive licence) · get_code("320efa985e8b290b")
How it ran

no invocation recorded.

Also present in other papers' code

Of 15 samples lifted from this paper's linked repositories, 15 carry a function identity and 0 do not. Of the 15 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 15 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Large language models (LLMs) are trained from vast repositories of text authored by millions of distinct authors, reflecting an enormous diversity of human traits. While these models bear the potential to be used as approximations of human subjects in behavioral studies, prior efforts have been limited in steering model responses to match individual human users. In this work, we introduce "Anthology", a method for conditioning LLMs to particular virtual personas by harnessing open-ended life narratives, which we refer to as "backstories." We show that our methodology enhances the consistency and reliability of experimental outcomes while ensuring better representation of diverse subpopulations. Across three nationally representative human surveys conducted as part of Pew Research Center's American Trends Panel (ATP), we demonstrate that Anthology achieves up to 18% improvement in matching the response distributions of human respondents and 27% improvement in consistency metrics. Our code is available at https://github.com/CannyLab/anthology. A: I'm 37. I grew up in a small town, in a small house … A: Certainly! I am a new college grad from New Jersey … A: Born and raised in Tennessee, I had a blissful childhood … Step 1. LLM-Generation of Backstories Step 3. Match Virtual Personas to Target Human User Distribution Match to Human User Distribution (Demographic Variables) Step 2. Demographic Survey on Virtual Personas Q: What is your age? (a) 18-29 (d) 65 or above (b) 30-49 (d) Prefer not to answer (c) 50-64 A: (b) 37 years old. Backstory Conditioned Virtual Persona Q: What is the highest level of education you have completed ? (a) Less than high school … … A: (e) Bachelor's degree LLM Q: Tell me about yourself.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2407.06576")
get_code_for_paper("2407.06576")
have("2407.06576")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2407.06576.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2407.06576.svg)](https://syntology.ai/paper/2407.06576)

Connect an agent — have() is free.