Datasets:
Download protocol/input_windows.py from Usman391/WildChat-Evaluation-Awareness-Taxonomy: direct link, hf CLI and curl.
- Browser
- Download file 1.39 kB
-
https://huggingface.co/datasets/Usman391/WildChat-Evaluation-Awareness-Taxonomy/resolve/main/protocol/input_windows.py
- Command line
-
hf download hf://datasets/Usman391/WildChat-Evaluation-Awareness-Taxonomy/protocol/input_windows.py
-
curl -L -o input_windows.py https://huggingface.co/datasets/Usman391/WildChat-Evaluation-Awareness-Taxonomy/resolve/main/protocol/input_windows.py
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 | |