Articles → NLP → Word2vec (CBOW Version) In NLP
Word2vec (CBOW Version) In NLP
Purpose
- Input → Context words
- Output → Target word (centre word).
Steps
- Tokenization
- Choose window size
- Create CBOW training pairs
- Convert words to vectors (one-hot encoding)
- Passing data to a neural network
Tokenization
[I, love, working, with, AI]
Choose Window Size
Create CBOW Training Pairs
| Context (Input) | Target (Output) |
|---|
| [love] | I |
| [I, working] | love |
| [love, with] | working |
| [working, AI] | with |
| [with] | AI |
Convert Words To Vectors (One-Hot Encoding)
I → [1,0,0,0,0]love → [0,1,0,0,0]working → [0,0,1,0,0]with → [0,0,0,1,0]AI → [0,0,0,0,1]
Passing Data To A Neural Network
Target = "working"Context = ["love", "with"]
love → [0,1,0,0,0]with → [0,0,0,1,0]
([0,1,0,0,0] + [0,0,0,1,0]) / 2 = [0, 0.5, 0, 0.5, 0]
| Posted By - | Karan Gupta |
| |
| Posted On - | Friday, February 20, 2026 |