Turn one persona_frame() into a designed set of personas. Two modes:
Usage
persona_variants(p, vary, n = NULL, .config = NULL)
# S3 method for class 'persona_set'
print(x, ...)Arguments
- p
A
persona_frame()(the base).- vary
A named list of the dimensions to vary. Enumerated mode reads the level vectors (e.g.
list(age = c("28", "52"), risk = c("cautious", "tolerant"))); generative mode reads only the names.- n
Number of briefs to generate (generative mode only). Ignored when enumerating.
- .config
Optional generative
LLMR::llm_config(). WhenNULL(default), the set is enumerated offline.- x
A
persona_set.- ...
Ignored.
Value
An object of class persona_set: a tibble with a persona list
column of persona_frame() objects, an id column (each frame's hash), a
variant_of column (the base hash), and one column per varied attribute.
Details
Enumerated (default,
.config = NULL):varyis a named list of level vectors and the result is their full Cartesian product. Each combination is rendered by appending the varied attributes to the base brief in plain, factual language (no stereotyping copula), so the design is legible and the base text is never rewritten.Generative (
.configis a generativeLLMR::llm_config()andnis given): one structured call asks the model fornindividuated briefs that varynames(vary), under a hard-coded anti-essentialism instruction. Use this when you want fluent, non-templated briefs; audit the result withpersona_audit().
Varying a demographic attribute does not license writing a stereotype. The enumerated renderer states attributes flatly; the generative prompt forbids caricature. Neither mode certifies the output: it produces briefs to be inspected, not a population to be trusted.
Examples
base <- persona_frame("A first-time voter in a swing district.",
source = "synthetic")
set <- persona_variants(base, vary = list(age = c("19", "24"),
leaning = c("undecided", "left")))
set
set$persona[[1]]$attributes
if (FALSE) { # \dontrun{
cfg <- LLMR::llm_config("openai", "gpt-4o-mini")
gen <- persona_variants(base, vary = list(age = NA, occupation = NA),
n = 5, .config = cfg)
persona_audit(gen)
} # }