inif.converters.inspect_ai
Requires the inspect extra (pip install "inif[inspect]"). See the Inspect AI converter guide for what gets preserved (per-token logprobs, generated annotations, scores, generation config, eval / run ids) and how the tokenizer is resolved.
Entry points
from_eval_log
Convert an Inspect AI EvalLog to an InifDocument.
def from_eval_log(
eval_log: Any,
tokenizer: Any = "auto",
include_messages: bool = True,
deduplicate: bool = True,
min_sequence_length: int = 5,
tag_chat_roles: bool = True,
tag_generated: bool = True,
tag_reasoning: bool = True,
extract_logprobs: bool = True,
) -> InifDocumenteval_logAny-
An inspect_ai.log.EvalLog object.
tokenizerAny-
One of:
"auto"(default) orNone— auto-loadAutoTokenizer.from_pretrainedbased oneval_log.eval.model, after stripping any routing prefix (together/,hf/, …). RaisesValueErrorif the model id is missing or the tokenizer cannot be loaded (closed-source ids likeopenai/gpt-4will hit this).- a model id string — loaded via
AutoTokenizer.from_pretrained; warns if the resolved id disagrees with the source eval’s model id. - a tokenizer instance — used as-is; warns if its
name_or_pathdisagrees with the source eval’s model id.
Tokens are a load-bearing invariant of every INIF sample, so there is no way to opt out of tokenization — every option here yields a usable tokenizer or raises.
include_messagesbool-
Whether to include message-level text segments.
deduplicatebool-
Whether to run sequence deduplication.
min_sequence_lengthint-
Minimum length for common sequence detection.
tag_chat_rolesbool-
Whether to record per-message chat-template roles (
system/user/assistant/template) onSample.annotationswithmetadata={"source": "message_role"}. tag_generatedbool-
Whether to tag the model’s response tokens with
"generated". The response is the last assistant message. tag_reasoningbool-
Whether to annotate
ContentReasoningblocks pulled from each assistant message. Tokens overlapping any reasoning span getreasoning+assistant; tokens within the span whose id appears intokenizer.all_special_idsadditionally gettemplate. Best-effort: silently skipped on lossy tokenizers or when the reasoning text can’t be located in the rendered chat template. extract_logprobsbool-
Whether to attach per-token logprobs from the eval output to the response tokens (best-effort: requires the tokenizer and the eval-source tokenization to agree on token count).
from_eval_file
Load an Inspect AI eval log file and convert to InifDocument.
def from_eval_file(path: str, **kwargs: Any) -> InifDocumentpathstr**kwargsAny