[NLP] Word Embedding - Skip Gram

2023. 3. 27. 15:35
๐Ÿง‘๐Ÿป‍๐Ÿ’ป ์ฃผ์š” ์ •๋ฆฌ
 
NLP
Word Embedding
Skip Gram

 

 

 

Skip Gram

 

skip gram์€ CBOW ๊ณผ์ •์—์„œ Input๊ณผ output์„ ๋ฐ˜๋Œ€๋กœ ํ•˜๋Š” ๊ฒƒ์œผ๋กœ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

๋‹ค์Œ ๊ทธ๋ฆผ์„ ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

 

์œ„์™€ ๊ฐ™์ด sat์„ input์œผ๋กœ ๋„ฃ๊ณ , ๋‚˜๋จธ์ง€ 4๊ฐœ์˜ ๋‹จ์–ด๋ฅผ ์ถœ๋ ฅ์œผ๋กœ ๋ฐ›๋Š” ํ˜•ํƒœ์ž…๋‹ˆ๋‹ค.

 

 

 

์œ„์™€ ๊ฐ™์ด W์™€ W'์˜ ํ˜•ํƒœ๋กœ ํ•™์Šต.

 

 

๊ทธ๋ฆฌ๊ณ , ์œ„์™€ ๊ฐ™์ด ๋‹จ์–ด์— ๋Œ€ํ•˜์—ฌ vector ๊ฐ’์„ embedding ์ž‘์—…์„ ๊ฑฐ์นฉ๋‹ˆ๋‹ค.

 

๊ทธ๋Ÿฌ๋‚˜, ์šฐ๋ฆฌ๋Š” ์—ฌ๊ธฐ์„œ ๋‹ค๋ฅธ ๊ฐ€์น˜๋ฅผ ๋‘ก๋‹ˆ๋‹ค.

 

์šฐ๋ฆฌ๋Š” ๋”ฅ๋Ÿฌ๋‹์—์„œ FeedForward๋ฅผ ํ†ตํ•ด ํ•™์Šต์„ ํ•˜๊ณ , ์›๋ž˜ ๊ฐ’๊ณผ ๋น„๊ตํ•˜์—ฌ ์ •ํ™•๋„๋ฅผ ๋ณผ ์ˆ˜ ์žˆ๊ณ ,

 

loss ๊ฐ’์„ ํ†ตํ•ด ์ •ํ™•๋„์˜ ํŒ๋‹จ ๊ธฐ์ค€๋ฅผ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

๊ทธ์— ๋Œ€ํ•œ ํ™•๋ฅ  ๊ฐ’์€ softmax function์„ ํ†ต๊ณผํ•˜๊ณ  ๋‚œ ๋’ค ๋‚˜์˜ต๋‹ˆ๋‹ค.

 

๊ทธ๋Ÿฌ๋‚˜ ์šฐ๋ฆฌ๋Š” ์ด ํ•™์Šต๋œ weight๊ฐ€ ํ•„์š”ํ•œ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

 

์ •ํ™•๋„๊ฐ€ ๋†’์€ ๊ฒƒ์ด ๋ชฉ์ ์ด ์•„๋‹™๋‹ˆ๋‹ค.

 

๊ฒฐ๊ตญ, input๊ณผ output์„ ํ†ตํ•ด ๋‚˜์˜ค๋Š” Weight๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ๋ชฉ์ ์ž…๋‹ˆ๋‹ค.

 

 

ํ•ด๋‹น Skip Gram ๊ณผ์ •์€ ์•„๋ž˜์™€ ๊ฐ™์ด ์ด๋ฃจ์–ด์ง‘๋‹ˆ๋‹ค.

 

 

 

 

 

๊ฒฐ๊ตญ Skip Gram์€ ์œ„์™€ ๊ฐ™์ด ํ•™์Šต์„ ํ†ตํ•ด์„œ Word Embedding vector๋ฅผ ์‚ฌ์šฉํ•ด์„œ ๋ชจ๋ธ์„ ๊ตฌ์ถ•ํ•˜๋Š” ๊ฒƒ์ด ๋ชฉ์ ์ž…๋‹ˆ๋‹ค.

 

๊ฒฐ๊ตญ ์ž์—ฐ์–ด ์ฒ˜๋ฆฌ๋ผ๋Š” ๊ฒƒ์€ ํŠน์ • ๋‹จ์–ด๋ฅผ one-hot vector๋กœ ํ‘œํ˜„ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๊ฐ€๋Šฅํ•ด์ง‘๋‹ˆ๋‹ค.

'Artificial Intelligence > Natural Language Processing' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[NLP] Word Embedding - CBOW and Skip-Gram  (2) 2023.03.27
[NLP] Word Embedding - Word2Vec  (0) 2023.03.27
[NLP] Word Embedding - CBOW  (1) 2023.03.27
[NLP] Introduction to Word Embedding  (0) 2023.03.26
[NLP] Overview NLP  (0) 2023.03.21

BELATED ARTICLES

more