pei39 commited on
Commit
273aa38
·
verified ·
1 Parent(s): da97b5f

Fix bounded DeepSeek reasoning and answer generation

Browse files
README.md CHANGED
@@ -43,17 +43,19 @@ python script.py --input path/to/test.csv --output submission.csv
43
  python script.py --self-test
44
  ```
45
 
46
- The output file is initialized before model loading and atomically rewritten
47
- after every completed row. If evaluation reaches its time limit, predictions
48
- already completed remain in a valid submission file.
49
 
50
  ## DeepSeek reasoning and generation
51
 
52
  DeepSeek's solver instructions, retrieved context, and current problem are
53
  placed in one user message rather than a separate system message. The assistant
54
  prompt is prefixed with `<think>` to engage the distilled reasoning behavior.
55
- Completed reasoning content is kept separately from the visible response; only
56
- the strict `FINAL ANSWERS:` block is serialized into `pred`.
 
 
57
 
58
  Defaults follow DeepSeek's recommended sampling values while retaining a bounded
59
  challenge-time output:
@@ -61,8 +63,9 @@ challenge-time output:
61
  - `temperature=0.6`
62
  - `top_p=0.95`
63
  - sampling enabled
64
- - `max_new_tokens=2048`
65
- - at most two attempts, with the second used only after a parser failure
 
66
 
67
  The model context is capped at 32,768 tokens. The script loads AWQ directly in
68
  FP16, enables the KV cache, and applies an inference-only last-token `lm_head`
@@ -78,8 +81,9 @@ indexed.
78
 
79
  Settings are in `rag_resources/config.json`. Environment overrides are available
80
  for `IOL_TOP_METHODS`, `IOL_TOP_EXAMPLES`, `IOL_CHAR_TFIDF_WEIGHT`,
81
- `IOL_RAG_MAX_CHARS`, `IOL_MAX_NEW_TOKENS`,
82
- `IOL_EXPLANATION_MAX_NEW_TOKENS`, `IOL_MAX_ATTEMPTS`,
 
83
  `IOL_ENABLE_EXPLANATIONS`, and `IOL_SEED`.
84
 
85
  ## Sources and licenses
 
43
  python script.py --self-test
44
  ```
45
 
46
+ After the model loads successfully, the output file is initialized and then
47
+ atomically rewritten after every completed row. If evaluation reaches its time
48
+ limit, predictions already completed remain in a valid submission file.
49
 
50
  ## DeepSeek reasoning and generation
51
 
52
  DeepSeek's solver instructions, retrieved context, and current problem are
53
  placed in one user message rather than a separate system message. The assistant
54
  prompt is prefixed with `<think>` to engage the distilled reasoning behavior.
55
+ Reasoning stops when `</think>` appears or at its configured cap. The runtime
56
+ then starts a separate `FINAL ANSWERS:` stage, guaranteeing that reasoning
57
+ cannot consume the answer budget. Only that answer block is serialized into
58
+ `pred`.
59
 
60
  Defaults follow DeepSeek's recommended sampling values while retaining a bounded
61
  challenge-time output:
 
63
  - `temperature=0.6`
64
  - `top_p=0.95`
65
  - sampling enabled
66
+ - `max_reasoning_tokens=4096`
67
+ - `max_answer_tokens=1024`
68
+ - one answer-only retry with `answer_retry_tokens=512`
69
 
70
  The model context is capped at 32,768 tokens. The script loads AWQ directly in
71
  FP16, enables the KV cache, and applies an inference-only last-token `lm_head`
 
81
 
82
  Settings are in `rag_resources/config.json`. Environment overrides are available
83
  for `IOL_TOP_METHODS`, `IOL_TOP_EXAMPLES`, `IOL_CHAR_TFIDF_WEIGHT`,
84
+ `IOL_RAG_MAX_CHARS`, `IOL_MAX_REASONING_TOKENS`,
85
+ `IOL_MAX_ANSWER_TOKENS`, `IOL_ANSWER_RETRY_TOKENS`,
86
+ `IOL_EXPLANATION_MAX_NEW_TOKENS`,
87
  `IOL_ENABLE_EXPLANATIONS`, and `IOL_SEED`.
88
 
89
  ## Sources and licenses
rag_resources/config.json CHANGED
@@ -4,9 +4,10 @@
4
  "char_tfidf_weight": 3.0,
5
  "rag_max_chars": 12000,
6
  "model_context_tokens": 32768,
7
- "max_new_tokens": 2048,
 
 
8
  "explanation_max_new_tokens": 400,
9
- "max_attempts": 2,
10
  "enable_explanations": false,
11
  "temperature": 0.6,
12
  "top_p": 0.95,
 
4
  "char_tfidf_weight": 3.0,
5
  "rag_max_chars": 12000,
6
  "model_context_tokens": 32768,
7
+ "max_reasoning_tokens": 4096,
8
+ "max_answer_tokens": 1024,
9
+ "answer_retry_tokens": 512,
10
  "explanation_max_new_tokens": 400,
 
11
  "enable_explanations": false,
12
  "temperature": 0.6,
13
  "top_p": 0.95,
rag_resources/system_prompt.txt CHANGED
@@ -17,6 +17,6 @@ Common task types and what to return:
17
  - number to text: the number written in words in the requested language;
18
  - any other type: exactly what the instruction requests, with no extra material in the answer.
19
 
20
- Reason step by step, but keep the analysis focused and always reserve enough of the 2048-token output budget for the final answer. Finish with a line that says exactly:
21
  FINAL ANSWERS:
22
  Below it, put one bare answer per requested item or blank, in order. Do not number the lines. Do not add quotes, labels, explanations, or commentary inside that final block.
 
17
  - number to text: the number written in words in the requested language;
18
  - any other type: exactly what the instruction requests, with no extra material in the answer.
19
 
20
+ Reason step by step, but keep the analysis focused. The runtime reserves a separate answer stage, so complete the analysis as soon as you have a consistent solution. Finish with a line that says exactly:
21
  FINAL ANSWERS:
22
  Below it, put one bare answer per requested item or blank, in order. Do not number the lines. Do not add quotes, labels, explanations, or commentary inside that final block.