Usman391's picture
Publish saved WildChat VEA taxonomy, judging protocol, and reproducible summaries
565cb9e verified
Raw History Blame Contribute Delete
1.39 kB
"""Original reasoning extraction and taxonomy input-window functions."""
def split_reasoning(response: str) -> str:
inkling_start = "<|message_model|><|content_thinking|>"
inkling_end = "<|end_message|><|message_model|><|content_text|>"
if response.startswith(inkling_start) and inkling_end in response:
return response[len(inkling_start) :].split(inkling_end, 1)[0]
text = response.removeprefix("<think>\n")
if "</think>" in text:
return text.split("</think>", 1)[0]
return response
def clip_text(text: str, limit: int) -> str:
if len(text) <= limit:
return text
side = (limit - 100) // 2
return text[:side] + f"\n\n[... {len(text)-2*side:,} characters omitted ...]\n\n" + text[-side:]
def evidence_context(reasoning: str, evidence: list[str], limit: int = 8000) -> str:
if len(reasoning) <= limit:
return reasoning
positions = [reasoning.find(item) for item in evidence if item and reasoning.find(item) >= 0]
if not positions:
return clip_text(reasoning, limit)
start = max(0, min(positions) - limit // 2)
end = min(len(reasoning), start + limit)
start = max(0, end - limit)
prefix = "[... earlier reasoning omitted ...]\n\n" if start else ""
suffix = "\n\n[... later reasoning omitted ...]" if end < len(reasoning) else ""
return prefix + reasoning[start:end] + suffix