prompts
genlm.eval.domains.livecodebench.prompts
Prompt formatting + code extraction kept identical to the official lcb_runner
so numbers are leaderboard-comparable (base models: style="genericbase" = the official
few-shot protocol, paired with whole-output extraction). NB lcb_runner uses the
Meta-Llama-3-8B-Instruct chat template for all Llama-3.x instruct models.
format_lcb_prompt(row, tokenizer=None, chat_template=False, style='generic', enable_thinking=None)
Prompt for an lcb_runner LMStyle: "generic" (LLaMa3, via chat template when chat_template=True), "codeqwen" (CodeQwenInstruct, raw <|im_*|> string), or "deepseek" (DeepSeekCodeInstruct, raw ### Instruction/Response string).
enable_thinking forwards to apply_chat_template (Qwen3-style reasoning toggle); left out of the call when None so non-reasoning templates are unaffected.
Source code in genlm/eval/domains/livecodebench/prompts.py
extract_code(model_output, style='generic')
Code between the last two ``` fences (last block if 3+); "" if fewer than two. style="genericbase" = whole stripped output. Matches lcb_runner extract_code.
Source code in genlm/eval/domains/livecodebench/prompts.py
extract_code_prefix(model_output, style='generic')
Code being written, for prefix scoring: text after the last open fence, or
"" when no block is open. Deferring on a closed block (a later block could
supersede it) keeps prefix consistent with extract_code at complete.
style="genericbase" = whole stripped output.
Source code in genlm/eval/domains/livecodebench/prompts.py
decode_context(context)
Decode a genlm.control context (str/bytes/list of byte tokens or int byte ids) into text.