| explore | R Documentation |
'explore()' orchestrates running several models over the same prompts, captures their predictions, and returns both long and wide annotation tables that can be fed into confusion-matrix and reliability helpers.
explore(
models,
instruction = NULL,
prompts = NULL,
engine = c("auto", "parallel", "single"),
batch_size = 8L,
reuse_models = FALSE,
sink = NULL,
progress = interactive(),
clean = TRUE,
keep_prompts = FALSE,
hash = TRUE,
chat_template = TRUE,
system_prompt = NULL
)
models |
Model definitions. Accepts one of the following formats:
Each model specification list supports the following keys:
|
instruction |
Default task instruction inserted into 'spec' whenever a model entry does not override it. |
prompts |
One of: (1) a function (for example 'function(spec)') that returns prompts (character vector or a data frame with a 'prompt' column); (2) a character vector of ready-made prompts; or (3) a template list where each named element becomes a section in the rendered prompt. Field names are used as-is for headers. Vector fields matching 'sample_id' length are treated as per-item values. Use 'sample_id' to specify item IDs (meta, not rendered). When 'NULL', each model must provide its own 'prompts' entry. |
engine |
One of '"auto"', '"parallel"', or '"single"'. Selects whether the parallel or single-prompt backend is used. |
batch_size |
Number of prompts to send per backend call when the parallel engine is active. Must be >= 1. |
reuse_models |
If 'TRUE', model/context handles stay alive for the duration of the function (useful when exploring lots of prompts). When 'FALSE' (default) handles are released after each model to minimise peak memory usage. |
sink |
Optional function that accepts '(chunk, model_id)' and is invoked after each model finishes. This makes it easy to stream intermediate results to disk via helpers such as [annotation_sink_csv()]. |
progress |
Whether to print progress messages for each model/batch. |
clean |
Forwarded to 'generate()'/'generate_parallel()' to remove control tokens from the outputs. |
keep_prompts |
If 'TRUE', the generated prompts are preserved in the long-format output (useful for audits). Defaults to 'FALSE'. |
hash |
When ‘TRUE' (default), computes SHA-256 hashes for each model’s prompts and resulting labels so replication collaborators can verify inputs and outputs. Hashes are attached to the returned list via the '"hashes"' attribute. |
chat_template |
When ‘TRUE', wraps prompts using the model’s built-in chat template before generation. This uses [apply_chat_template()] to format prompts with appropriate special tokens for instruction-tuned models. Individual models can override this via their spec. Default: 'TRUE'. |
system_prompt |
Optional system message to include when 'chat_template = TRUE'. This is prepended as a system role message before the user prompt. Individual models can override this via their spec. Default: 'NULL'. |
A list with elements 'annotations' (long table) and 'matrix' (wide annotation matrix). When 'sink' is supplied the 'annotations' and 'matrix' entries are set to 'NULL' to avoid duplicating the streamed output.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.