|
21 | 21 | TopPLogitsWarper, |
22 | 22 | ) |
23 | 23 |
|
24 | | -# The S3 codec's silence token, as an offset within the audio range. Runs of it are |
25 | | -# the model's most common stuck state, and it is the one token the repetition |
26 | | -# penalty must leave alone (see RepetitionPenaltyExempt). |
27 | | -SILENCE_TOKEN = 4299 |
28 | | - |
29 | | - |
30 | 24 | class RepetitionPenaltyExempt(LogitsProcessor): |
31 | 25 | """Repetition penalty that never penalises the sequence-terminating tokens. |
32 | 26 |
|
33 | | - `<speech_end>`, `[STOP]` and the silence codec token are exempt: penalising |
34 | | - them suppresses the trailing silence the model needs before it can close a |
35 | | - segment, which turns a clean ending into an over-generation. |
| 27 | + `<speech_end>` and `[STOP]` are exempt: penalising them would push the model |
| 28 | + away from closing the segment it has just finished. |
| 29 | +
|
| 30 | + The silence codec token is deliberately *not* exempt. Runs of it are the |
| 31 | + model's most common stuck state, and the windowed penalty is what pulls it out: |
| 32 | + with silence exempt, the main checkpoint drifts into seconds of silence (or |
| 33 | + silence until the token cap) and drops sentences from long chunks. |
36 | 34 |
|
37 | 35 | window=None scans the whole sequence. window=N restricts the scan to the last |
38 | 36 | N *generated* positions, so codec tokens from a long in-context reference |
@@ -99,13 +97,12 @@ def build_logits_processors(token_map, temperature, top_k, top_p, min_p, |
99 | 97 | scores; that ordering is part of what the decode presets were tuned against. |
100 | 98 | """ |
101 | 99 | lo, hi = token_map.audio_id_base, token_map.audio_id_end |
102 | | - silence_id = lo + SILENCE_TOKEN |
103 | 100 | processors = LogitsProcessorList() |
104 | 101 |
|
105 | 102 | if token_run_penalty: |
106 | 103 | processors.append(TokenRunPenalty(lo, hi, token_run_grace, token_run_penalty)) |
107 | 104 | if repetition_penalty != 1.0: |
108 | | - exempt = {token_map.speech_end_id, token_map.stop_id, silence_id} |
| 105 | + exempt = {token_map.speech_end_id, token_map.stop_id} |
109 | 106 | processors.append(RepetitionPenaltyExempt( |
110 | 107 | repetition_penalty, exempt, window=repetition_window, prompt_length=prompt_length)) |
111 | 108 | if temperature != 1.0: |
|
0 commit comments