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 prefertemperature = 0.- prompt
Prompt template containing the placeholder
{text}and, optionally,{codebook}(replaced byformat_codebook()'s rendering).NULLuses a sensible default. Placeholders are substituted literally, so braces in the coded text itself are safe.- parser
A function
(text, labels) -> labelturning a model reply into one of the codebook's labels (orNA). Defaultparse_label().- replicates
How many times each unit is coded by
code_corpus()(replicates make model self-disagreement measurable; seecoder_agreement()).- label
Optional human-readable tag used in tournaments and reports (e.g.
"v2-fewshot-qwen"); defaults to provider/model.
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)