
Replicate a coding task
qlm_replicate.RdRe-executes a coding task from a qlm_coded object, optionally with
modified settings. If no overrides are provided, uses identical settings
to the original coding: both the execution arguments and the arguments the
original run passed to ellmer::chat(), such as params and api_args.
Credentials and endpoint settings are an exception, and are carried over
only while the endpoint itself is unchanged.
Usage
qlm_replicate(
x,
...,
codebook = NULL,
model = NULL,
batch = NULL,
backfill = NULL,
name = NULL,
notes = NULL
)Arguments
- x
A
qlm_codedobject.- ...
Optional overrides passed to
qlm_code(), such asparams,api_args, ormax_active. Any setting not overridden is restored from the original run when the endpoint is unchanged, including the arguments it passed toellmer::chat(). An endpoint is identified by both the provider prefix andbase_url(an explicitbase_url = NULL, meaning the provider's default host, counts as a change of endpoint), since every provider ellmer has nochat_*()for is reached asopenai_compatible/<model>— so Qwen through Alibaba Model Studio and Kimi through Moonshot share a prefix while being different services with different credentials. When either changes, only portable chat settings (paramsandecho) are carried over; supply credentials, endpoint settings and other endpoint-specific arguments explicitly. An informational message names inherited arguments that were omitted and not explicitly replaced. Registeredtoolsare carried like the rest: kept on the same endpoint, since a hosted tool belongs to its provider, and dropped with the message when it changes; passtoolsto replace them. An object read back from a trail records its tools by description and configuration only, and those are not sent either.- codebook
Optional replacement codebook. If
NULL(default), uses the codebook fromx.- model
Optional replacement model (e.g.,
"openai/gpt-4o"). IfNULL(default), uses the model fromx.- batch
Optional logical to override batch processing setting. If
NULL(default), uses the batch setting fromx. Set toTRUEto use batch processing orFALSEto use parallel processing, regardless of the original setting.- backfill
Logical, integer, or
NULL; controls backfilling after the replication.NULL(default) replays the passes recorded onx, using the same models and overrides in the same order.FALSEor0performs no backfill.TRUEruns a fresh backfill with the replication's model and the default number of passes, currently two; a positive integer runs at most that many fresh passes. A fresh backfill does not reproduce a different model used by the parent's recorded passes. If a replayed pass fails outright, the replication and any earlier recoveries are retained, the failure is recorded, and no later passes are replayed.- name
Optional name for this run. If
NULL, defaults to the model name (if changed) or"replication_N"where N is the replication count.- notes
Optional character string with descriptive notes about this replication. Useful for documenting why this replication was run or what differs from the original. Default is
NULL.
Details
The coding path is reproduced from the path the original run actually took,
not the structured mode it requested: a run that asked for "auto" and
fell back to JSON mode replicates as "json", so that an intermittently
conforming endpoint cannot quietly skip the local validation the original
relied on. Pass structured explicitly to override. When the endpoint
changes, provider or base_url, the path is chosen afresh for it. By the
same rule,
a parent that was completed with qlm_backfill() has its passes replayed
on the replication, so the two are complete on the same terms; see
backfill.
See also
qlm_code() for initial coding, qlm_compare() for comparing
replicated results, qlm_backfill() to re-code only the units a run
failed on.
Examples
if (FALSE) { # \dontrun{
# First create a coded object
texts <- c("I love this!", "Terrible.", "It's okay.")
coded <- qlm_code(texts, data_codebook_sentiment, model = "openai/gpt-4o-mini", name = "run1")
# Replicate with same model
coded2 <- qlm_replicate(coded, name = "run2")
# Compare results
qlm_compare(coded, coded2, by = "sentiment", level = "nominal")
} # }