Merge feat/vocabulary-hint: names-and-terms decoder prompt (spec 001 workstream 2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	docs/Architecture.md
#	docs/Decisions.md
#	docs/WorkBreakdown.md
#	server-py/sidecar.py
#	src/App.tsx
#	src/server/live.ts
#	src/server/transcribe.ts
#	tests/fixtures/fake_sidecar.py
#	tests/transcribe.test.ts
This commit is contained in:
Lucas Winther
2026-10-30 01:35:28 +01:00
26 changed files with 1177 additions and 21 deletions
+18
View File
@@ -17,6 +17,13 @@ import {
type ProgressInfo,
} from "@huggingface/transformers";
import { resolveDefaultDtype } from "../lib/models";
import {
buildPromptPrefix,
installPromptSupport,
PROMPT_PREFIX_KWARG,
type PromptableModel,
type PromptTokenizer,
} from "./prompt";
import {
deviceAttempts,
dtypeRequiresF16,
@@ -409,6 +416,17 @@ async function transcribe(message: TranscribeMessage): Promise<void> {
if (message.task !== undefined) {
options.task = message.task;
}
// "Names and terms" hint (D-WS2a): one prefix per pass, applied by the
// generate() wrapper to every 30 s window (Transformers.js ignores
// `prompt_ids`, see src/worker/prompt.ts). The wrapper is idempotent.
const promptPrefix = buildPromptPrefix(
asr.tokenizer as unknown as PromptTokenizer,
message.prompt ?? "",
);
if (promptPrefix.length > 0) {
installPromptSupport(asr.model as unknown as PromptableModel);
options[PROMPT_PREFIX_KWARG] = promptPrefix;
}
const output = await asr(message.audio, options);