Skip to contents

Functions for creating, saving, and loading specifications for AI-based scoring of open-ended survey responses. The specification includes a scoring prompt and the score levels to be used for evaluation. Use the resulting specification with aisc_score() to score responses.

Usage

aisc_spec_generate(question, score_levels, context = "", model = "gpt-5.4")

aisc_spec_write(spec, file)

aisc_spec_read(file)

Arguments

question

A character string containing the survey question to be scored.

score_levels

A numeric vector of allowed score values (e.g., 0:1 or 0:4). Higher values should indicate better responses.

context

Optional character string providing additional scoring requirements or constraints (e.g., "evaluate only how well written the text is" or "focus on whether responses mention specific examples"). If NULL (default), the scoring criteria will be inferred solely from the question.

model

OpenAI model to use for generating the scoring prompt.

spec

A scoring specification object created by aisc_spec_generate().

file

Path to the YAML file where the specification should be saved or loaded from.

Value

  • aisc_spec_generate(): A list with two components:

    • score_levels: The numeric vector of score levels

    • prompt: The generated scoring prompt as a character string

  • aisc_spec_write(): Invisibly returns the file path.

  • aisc_spec_read(): A list with the same structure as returned by aisc_spec_generate().

Functions

  • aisc_spec_write(): Write a scoring specification to a YAML file

  • aisc_spec_read(): Read a scoring specification from a YAML file

See also

Examples

if (FALSE) { # \dontrun{
# Generate a scoring specification
spec <- aisc_spec_generate(
  question = "What do you think are the main benefits of remote work?",
  score_levels = c(0, 1, 2, 3)
)

# Generate with additional context to narrow scoring focus
spec_focused <- aisc_spec_generate(
  question = "What do you think are the main benefits of remote work?",
  score_levels = 0:4,
  context = "Evaluate only how specific and well-articulated the response is, not correctness"
)

# Save the specification to a file
aisc_spec_write(spec, file = "scoring_specs/remote_work.yml")

# Later, load the specification
loaded_spec <- aisc_spec_read("scoring_specs/remote_work.yml")
} # }