feat(meeting): ground AI transcript correction in learned vocabulary
AI polishing of a recorded or pasted transcript was a generic rewrite: it cleaned fillers but left names and in-house terms mangled even when the app already knew them. Polishing now corrects dictionary pronunciations and typed identifiers deterministically before and after the model, and hands the model the learned term list plus the user's own expressions with explicit rules: rewrite a misheard name, product or in-house term to the learned spelling, and never swap an ordinary noun or ending on similarity alone. Dictation output is re-checked the same way after the model runs.
This commit is contained in:
parent
1f5372bfcc
commit
e2d17601a4
8 changed files with 120 additions and 23 deletions
|
|
@ -152,6 +152,19 @@ describe('LLM 교열 참고 블록', () => {
|
|||
expect(section).toContain('오늘 회의는 세 시에 시작합니다')
|
||||
})
|
||||
|
||||
it('자주 쓰는 용어와 교정 지시를 함께 넣는다', () => {
|
||||
const glossary = buildTranscriptGlossary({
|
||||
dictionary: [{ word: 'D3RO', pronunciation: '디에로' }],
|
||||
phrases: phrases(['하람로그에 정리해줘', 6], ['안녕하세요', 4], ['dkssudgktpdy', 3]),
|
||||
})
|
||||
|
||||
const section = buildGlossaryPromptSection(glossary)
|
||||
|
||||
expect(section).toContain('반드시 아래 표기로 고치세요')
|
||||
expect(section).toContain('[사용자가 자주 쓰는 용어')
|
||||
expect(section).toContain('하람로그')
|
||||
expect(section).not.toContain('dkssudgktpdy')
|
||||
})
|
||||
it('STT 힌트는 기존 문맥 뒤에 붙는다', () => {
|
||||
const glossary = buildTranscriptGlossary({ dictionary: [{ word: 'Whisper' }] })
|
||||
|
||||
|
|
|
|||
|
|
@ -156,32 +156,34 @@ export function buildTranscriptGlossary(input: {
|
|||
}
|
||||
|
||||
const examples: string[] = []
|
||||
const exampleCandidates: Array<{ text: string; tokens: readonly string[] }> = []
|
||||
const phraseTokens = new Map<string, number>()
|
||||
/** 같은 뜻의 한글 표기가 코퍼스에 있는 영문 토큰(한영 자판 오타 산물) — 힌트·교정에서 뺀다. */
|
||||
/** 같은 뜻의 한글 표기가 코퍼스에 있는 영문 토큰(한영 자판 오타 산물) — 힌트·교정·예시에서 뺀다. */
|
||||
const hangulObserved = new Set<string>()
|
||||
for (const phrase of (input.phrases ?? []).slice(0, limits.phrases)) {
|
||||
const text = phrase.text?.replace(/\s+/gu, ' ').trim()
|
||||
if (!text) continue
|
||||
if (
|
||||
examples.length < limits.refineExamples &&
|
||||
text.length >= 4 &&
|
||||
text.length <= 80 &&
|
||||
!examples.includes(text)
|
||||
) {
|
||||
examples.push(text)
|
||||
}
|
||||
const tokens: string[] = []
|
||||
const weight = Math.max(1, phrase.count)
|
||||
for (const token of tokenizeWords(text)) {
|
||||
const word = token.text
|
||||
if (!isLearnableToken(word)) continue
|
||||
if (/^[가-힣]+$/u.test(word)) hangulObserved.add(word)
|
||||
const key = word.toLowerCase()
|
||||
tokens.push(key)
|
||||
bump(phraseTokens, key, weight)
|
||||
if (!canonical.has(key)) canonical.set(key, word)
|
||||
}
|
||||
if (
|
||||
exampleCandidates.length < limits.refineExamples * 2 &&
|
||||
text.length >= 4 &&
|
||||
text.length <= 80
|
||||
) {
|
||||
exampleCandidates.push({ text, tokens })
|
||||
}
|
||||
}
|
||||
|
||||
// 한영 자판 오타 산물( 같은)은 같은 뜻의 한글 표기가 코퍼스에 있으므로 뺀다.
|
||||
// 한영 자판 오타 산물(dkssudgktpdy 같은)은 같은 뜻의 한글 표기가 코퍼스에 있으므로 뺀다.
|
||||
// 그대로 두면 STT 힌트가 의미 없는 라틴 문자열로 편향되고, 식별자 교정 후보로도 쓰인다.
|
||||
for (const word of [...phraseTokens.keys()]) {
|
||||
if (!/^[a-z]+$/u.test(word)) continue
|
||||
|
|
@ -192,6 +194,14 @@ export function buildTranscriptGlossary(input: {
|
|||
}
|
||||
}
|
||||
|
||||
// 교정 산물이 섞인 문장은 예시로도 쓰지 않는다 — 모델이 그 표기를 따라 쓰게 된다.
|
||||
for (const candidate of exampleCandidates) {
|
||||
if (examples.length >= limits.refineExamples) break
|
||||
if (examples.includes(candidate.text)) continue
|
||||
if (candidate.tokens.some((token) => /^[a-z]+$/u.test(token) && !phraseTokens.has(token))) continue
|
||||
examples.push(candidate.text)
|
||||
}
|
||||
|
||||
for (const [word, count] of topEntries(phraseTokens, limits.vocabularyTerms)) {
|
||||
if (count < limits.minLearnedCount) break
|
||||
if (vocabulary.has(word)) continue
|
||||
|
|
@ -425,6 +435,7 @@ export function buildGlossaryPromptSection(glossary: TranscriptGlossary): string
|
|||
const parts: string[] = []
|
||||
if (glossary.dictionary.length > 0) {
|
||||
parts.push('[사용자 용어 — 이 표기를 그대로 쓰세요]')
|
||||
parts.push('전사에 이 용어가 비슷하게 다르게 적혀 있으면 반드시 아래 표기로 고치세요. 이미 맞게 적힌 것은 건드리지 마세요.')
|
||||
for (const entry of glossary.dictionary.slice(0, 30)) {
|
||||
parts.push(
|
||||
entry.variants.length > 0
|
||||
|
|
@ -433,6 +444,18 @@ export function buildGlossaryPromptSection(glossary: TranscriptGlossary): string
|
|||
)
|
||||
}
|
||||
}
|
||||
const frequentTerms = [...glossary.vocabulary.entries()]
|
||||
.filter(([word, count]) => count >= TRANSCRIPT_GLOSSARY_LIMITS.minLearnedCount && word.length >= 2)
|
||||
.sort((a, b) => (b[1] - a[1] !== 0 ? b[1] - a[1] : a[0].localeCompare(b[0])))
|
||||
.slice(0, 20)
|
||||
.map(([word]) => glossary.canonical.get(word) ?? word)
|
||||
if (frequentTerms.length > 0) {
|
||||
parts.push(
|
||||
'',
|
||||
'[사용자가 자주 쓰는 용어 — 문맥상 이 단어를 말한 것이 확실하면 이 표기로 쓰세요]',
|
||||
frequentTerms.join(', '),
|
||||
)
|
||||
}
|
||||
if (glossary.examples.length > 0) {
|
||||
parts.push('', '[사용자가 실제로 쓰는 표현 — 말투·용어만 참고하고 문장을 그대로 베끼지 마세요]')
|
||||
for (const example of glossary.examples.slice(0, TRANSCRIPT_GLOSSARY_LIMITS.refineExamples)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue