End the hint prompt in a full stop: an unterminated list made Whisper drop punctuation and loop
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1c5952f212
commit
8236ea3504
4 files changed
+39
-17
No files matched your search
+17
-8
@@ -72,14 +72,22 @@ describe("fitHintToBudget (D-WS2a truncation rule)", () => {
|
||||
expect(fitHintToBudget(" \n", charEncode)).toEqual([]);
|
||||
});
|
||||
|
||||
test("a hint within budget is encoded with Whisper's leading space", () => {
|
||||
test("a hint within budget is encoded as a space-led sentence ending in a full stop", () => {
|
||||
// Measured (D-WS2a): an unterminated list prompt suppresses punctuation
|
||||
// and triggers repetition loops on smaller models; a full stop does not.
|
||||
expect(fitHintToBudget("Maxwell\nVoices of the Void", charEncode)).toEqual(
|
||||
charEncode(" Maxwell, Voices of the Void"),
|
||||
charEncode(" Maxwell, Voices of the Void."),
|
||||
);
|
||||
});
|
||||
|
||||
test("over budget: keeps whole leading words and drops a dangling comma", () => {
|
||||
expect(charDecode(fitHintToBudget("alpha, beta gamma", charEncode, 10))).toBe(" alpha");
|
||||
test("a hint already ending in . ? or ! gets no extra full stop", () => {
|
||||
expect(charDecode(fitHintToBudget("Is it Maxwell?", charEncode))).toBe(" Is it Maxwell?");
|
||||
expect(charDecode(fitHintToBudget("Dr. Bao.", charEncode))).toBe(" Dr. Bao.");
|
||||
});
|
||||
|
||||
test("over budget: keeps whole leading words, drops a dangling comma, ends in a full stop", () => {
|
||||
expect(charDecode(fitHintToBudget("alpha, beta gamma", charEncode, 10))).toBe(" alpha.");
|
||||
expect(charDecode(fitHintToBudget("alpha, beta gamma", charEncode, 13))).toBe(" alpha, beta.");
|
||||
});
|
||||
|
||||
test("a single word longer than the budget is cut at the budget", () => {
|
||||
@@ -96,10 +104,11 @@ describe("fitHintToBudget (D-WS2a truncation rule)", () => {
|
||||
expect(ids.length).toBeLessThanOrEqual(223);
|
||||
expect(ids.length).toBeGreaterThan(200);
|
||||
const kept = charDecode(ids);
|
||||
expect(` ${hint}`.startsWith(kept)).toBe(true);
|
||||
// Ends on a whole term: the next character of the hint is a separator.
|
||||
expect(kept.endsWith(",")).toBe(false);
|
||||
expect([",", " "]).toContain(` ${hint}`.charAt(kept.length));
|
||||
// Ends on a whole term plus the full stop: the hint continues with a separator there.
|
||||
expect(kept.endsWith(".")).toBe(true);
|
||||
const body = kept.slice(0, -1);
|
||||
expect(` ${hint}`.startsWith(body)).toBe(true);
|
||||
expect([",", " "]).toContain(` ${hint}`.charAt(body.length));
|
||||
});
|
||||
|
||||
test("is deterministic", () => {
|
||||
|
||||
@@ -110,10 +110,10 @@ describe("buildPromptPrefix", () => {
|
||||
expect(buildPromptPrefix(tokenizer, " \n ")).toEqual([]);
|
||||
});
|
||||
|
||||
test("a hint → <|startofprev|> then the space-led hint tokens", () => {
|
||||
test("a hint → <|startofprev|> then the space-led, full-stopped hint tokens", () => {
|
||||
expect(buildPromptPrefix(tokenizer, "Max\nVoid")).toEqual([
|
||||
PREV,
|
||||
...[..." Max, Void"].map((c) => c.charCodeAt(0)),
|
||||
...[..." Max, Void."].map((c) => c.charCodeAt(0)),
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user