[DL] Constrained Decoding

2024. 12. 3. 13:38ใ†๐Ÿงช Data Science/ML, DL

 

์—ฐ๊ตฌ์‹ค์˜ ์„์‚ฌ๋ถ„์ด Constrained Decoding์— ๋Œ€ํ•˜์—ฌ ๋ฐœํ‘œ๋ฅผ ์ง„ํ–‰ํ•˜์…จ๋‹ค.
๋‚ด์šฉ์„ ๊ธฐ์–ตํ•˜๊ธฐ ์œ„ํ•ด ๋ณธ ํฌ์ŠคํŒ…์œผ๋กœ ์ •๋ฆฌํ•˜๊ณ ์ž ํ•œ๋‹ค.

 

 

Constrained Decoding

: ์ž์—ฐ์—‰ ์ƒ์„ฑ ์ž‘์—…์—์„œ ์ƒ์„ฑ๋œ ํ…์ŠคํŠธ๊ฐ€ ์ œ์•ฝ ์กฐ๊ฑด์„ ๋งŒ์กฑํ•˜๋„๋ก ๋ณด์žฅํ•˜๋Š” ๋””์ฝ”๋”ฉ ๋ฐฉ๋ฒ•

 

 

์ ์šฉ ์‚ฌ๋ก€
- ํฌ๋งท ๊ฐ•์ œ (์˜ˆ, ๋‚ ์งœ ํ˜•์‹)
- ๋‹จ์–ด ์„ ํƒ ์ œํ•œ
- ๊ตฌ์กฐ์  ์ œ์•ฝ
- ๋…ผ๋ฆฌ์  ์ œ์•ฝ

 

 

Constrained Decoding Flow
Step 1. ์ž…๋ ฅ ์ฒ˜๋ฆฌ: ์ž…๋ ฅ ๋ฌธ์žฅ๊ณผ ์กฐ๊ฑด์„ ๋…ผ๋ฆฌ์ ์œผ๋กœ ํ‘œํ˜„


Step 2. Decoder Initialization: ๋””์ฝ”๋” ์ดˆ๊ธฐํ™”


Step 3. Constraint Tracker ์ƒ์„ฑ(์กฐ๊ฑด ์ถ”์ ํ•˜๋Š” Tracker ์„ค์ •)


Step 4. ํ† ํฐ ์ƒ์„ฑ ๋ฐ˜๋ณต(ํ›„๋ณด ํ† ํฐ ์ •ํ•˜๊ณ  Constraint Filtering > ์Šค์ฝ”์–ด ์žฌ์กฐ์ • > ํ† ํฐ ์ƒ์„ฑ)

** ๋…ผ๋ฌธ ' Fast Lexically Constrained Decoding with Dynamic Beam Allocation for Neural Machine Translation' ์—์„  ์กฐ๊ฑด์ด ๋งŒ์กฑํ•˜์ง€ ์•Š์•„๋„ ํŠน์ • ์ ์ˆ˜(๋…ผ๋ฌธ์—์„œ ์ •์˜๋จ)๊ฐ€ ๋†’์œผ๋ฉด ํ›„๋ณด๊ตฐ์— ์ €์žฅํ•ด๋‘”๋‹ค.

t์—์„œ ๋„ํ˜•์˜ ๋ฐ˜๋งŒ ์ƒ‰์น ๋˜์–ด ์žˆ๋Š” ๊ฒฝ์šฐ, 

Step 5. Constraint Validation: ์—ฌ์ „ํžˆ ์กฐ๊ฑด ๋งŒ์กฑํ•˜๋Š”์ง€ ํ™•์ธ

 

Constrained Decoding ํ† ํฐ from GPT

Constrained Decoding๊ณผ ํ† ํฐ
๋””์ฝ”๋”ฉ ๊ณผ์ •์—์„œ๋Š” ๋ชจ๋ธ์ด ํ…์ŠคํŠธ๋ฅผ ํ•˜๋‚˜์˜ ํ† ํฐ์”ฉ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, "2024๋…„ 12์›”"์ด๋ผ๋Š” ํ…์ŠคํŠธ๋ฅผ ์ƒ์„ฑํ•œ๋‹ค๊ณ  ํ•  ๋•Œ:
์ฒซ ๋ฒˆ์งธ ํ† ํฐ: 2024๋‘ ๋ฒˆ์งธ ํ† ํฐ: ๋…„์„ธ ๋ฒˆ์งธ ํ† ํฐ: 12๋„ค ๋ฒˆ์งธ ํ† ํฐ: ์›”
์ด๋ ‡๊ฒŒ ์ˆœ์ฐจ์ ์œผ๋กœ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. Constrained Decoding์—์„œ๋Š” ๊ฐ ๋‹จ๊ณ„์—์„œ ์ƒ์„ฑ๋œ ํ† ํฐ์ด ์กฐ๊ฑด์— ๋งž๋Š”์ง€ ๊ฒ€์ฆํ•˜๊ณ , ์กฐ๊ฑด์— ๋ถ€ํ•ฉํ•˜์ง€ ์•Š์œผ๋ฉด ํ•ด๋‹น ํ† ํฐ์„ ์ œ๊ฑฐํ•˜๊ฑฐ๋‚˜ ๋‹ค๋ฅธ ํ›„๋ณด๋ฅผ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.
ํŠนํžˆ ๋„ˆ๊ฐ€ ์—ฐ๊ตฌํ•˜๊ณ  ์žˆ๋Š” ๊ฐ•ํ™”ํ•™์Šต์ฒ˜๋Ÿผ ๊ตฌ์กฐ์  ํ…์ŠคํŠธ๊ฐ€ ํ•„์š”ํ•œ ์ž‘์—…์—์„œ ํ† ํฐ ์ œ์•ฝ์ด ์ค‘์š”ํ•  ์ˆ˜ ์žˆ์–ด. ์˜ˆ๋ฅผ ๋“ค์–ด, ์ˆ˜์‹์ด๋‚˜ ์ฝ”๋“œ๋ฅผ ์ƒ์„ฑํ•  ๋•Œ ์ ์ ˆํ•œ ํ† ํฐ๋งŒ ์„ ํƒ๋˜๋„๋ก ๋ณด์žฅํ•˜๋Š” ๋ฐฉ์‹์ด์ฃ .

 

 

 

๊ด€๋ จ ๋…ผ๋ฌธ

 

- A General-Purpose Algorithm for Constrained Sequential InferenceLexically Constrained Decoding for Sequence Generation Using Grid Beam Search
- Fast Lexically Constrained Decoding with Dynamic Beam Allocation for Neural Machine Translation
- Improved Lexically Constrained Decoding for Translation and Monolingual RewritingGuided Open Vocabulary Image - Captioning with Constrained Beam Search

- Incorporating Discriminator in Sentence Generation: a Gibbs Sampling Method
- CGMH: Constrained Sentence Generation by Metropolis-Hastings Sampling