Uses a scoring specification to evaluate open-ended survey responses with a language model. Supports multiple scoring runs with shuffling to assess consistency and reliability of scores. Uses parallel API calls for improved performance.
Usage
aisc_score(
x,
spec,
batch_size = 8,
n_runs = 1,
model = "gpt-4.1-mini",
max_active = 20,
rpm = 500
)Arguments
- x
A character vector of responses to score.
- spec
A scoring specification object created by
aisc_spec_generate()or loaded withaisc_spec_read().- batch_size
Number of responses to process in each API call. Default is 8. Recommended values are between 5-20.
- n_runs
Number of times to score each response. Default is 1. When > 1, responses are shuffled before each run to reduce order effects.
- model
OpenAI model to use for scoring.
- max_active
The maximum number of simultaneous requests to send.
For
chat_anthropic(), note that the number of active connections is limited primarily by the output tokens per minute limit (OTPM) which is estimated from themax_tokensparameter, which defaults to 4096. That means if your usage tier limits you to 16,000 OTPM, you should either setmax_active = 4(16,000 / 4096) to decrease the number of active connections or useparams()inchat_anthropic()to decreasemax_tokens.- rpm
Maximum number of requests per minute.
Value
A tibble with the following columns:
x: The original response textscore: The mean score across all runsmin: Minimum score across runsmax: Maximum score across runssd: Standard deviation of scores across runs (NA if n_runs = 1)score_runs: A matrix with one column per run, containing individual scores
Examples
if (FALSE) { # \dontrun{
# Create a scoring specification
spec <- aisc_spec_generate(
question = "What do you think are the main benefits of remote work?",
score_levels = 0:4
)
# Or load from file: spec <- aisc_spec_read("path/to/spec.yml")
# Use synthetic responses from package data
responses <-
oe_responses_remote_work |>
# Sample 1 per quality level for quick testing (comment out for full run)
dplyr::slice_sample(n = 1, by = gen_quality) |>
dplyr::pull(response)
# Score responses
results <- aisc_score(responses, spec)
# Score with multiple runs for reliability assessment
results <- aisc_score(responses, spec, n_runs = 3)
} # }