Skip to contents

Assemble a coding protocol

Usage

protocol(
  codebook,
  config,
  prompt = NULL,
  parser = parse_label(),
  replicates = 1L,
  label = NULL
)

Arguments

codebook

A codebook().

config

An LLMR::llm_config() for a generative model. For annotation work prefer temperature = 0.

prompt

Prompt template containing the placeholder {text} and, optionally, {codebook} (replaced by format_codebook()'s rendering). NULL uses a sensible default. Placeholders are substituted literally, so braces in the coded text itself are safe.

parser

A function (text, labels) -> label turning a model reply into one of the codebook's labels (or NA). Default parse_label().

replicates

How many times each unit is coded by code_corpus() (replicates make model self-disagreement measurable; see coder_agreement()).

label

Optional human-readable tag used in tournaments and reports (e.g. "v2-fewshot-qwen"); defaults to provider/model.

Value

A coding_protocol (unlocked).

Examples

cb  <- codebook("tone", "one sentence",
  list(cb_category("positive", "Approving."),
       cb_category("negative", "Critical.")))
cfg <- LLMR::llm_config("groq", "openai/gpt-oss-20b", temperature = 0)
p   <- protocol(cb, cfg)
protocol_lock(p)