Download code/rerank_ins/train_cot/cot_eval_utils.py from WaitXian/liqi: direct link, hf CLI and curl.
- Browser
- Download file 495 Bytes
-
https://huggingface.co/WaitXian/liqi/resolve/main/code/rerank_ins/train_cot/cot_eval_utils.py
- Command line
-
hf download hf://WaitXian/liqi/code/rerank_ins/train_cot/cot_eval_utils.py
-
curl -L -o cot_eval_utils.py https://huggingface.co/WaitXian/liqi/resolve/main/code/rerank_ins/train_cot/cot_eval_utils.py
495 Bytes
| import re | |
| def parse_final_answer(text, num_docs): | |
| patterns = [ | |
| rf"【最终答案】\s*([0-3]{{{num_docs}}})", | |
| rf"最终答案\s*[::]?\s*([0-3]{{{num_docs}}})", | |
| rf"答案\s*[::]?\s*([0-3]{{{num_docs}}})", | |
| ] | |
| for pattern in patterns: | |
| matches = re.findall(pattern, text, re.DOTALL) | |
| if matches: | |
| return matches[-1] | |
| matches = re.findall(rf"[0-3]{{{num_docs}}}", text) | |
| if matches: | |
| return matches[-1] | |
| return None | |