Natural Language Processing · TEE · papers

Q2b · Text vectorization alternatives

2023-01-30 · re-exam · recovered AI paper

Previous examination · complete worked answers

Question. Define word embeddings and explain one-hot, Bag of Words, bag of n-grams and TF–IDF with advantages and disadvantages. [10 marks]

Answer

A sparse representation has many zero entries and often one coordinate per vocabulary item. BoW and TF–IDF are common sparse document representations. A dense embedding has comparatively few learned real-valued coordinates; one word's properties are spread across many coordinates.

RepresentationWhat coordinates meanStrengthLimitation
One-hotOne identity position per vocabulary wordUnambiguous IDDifferent words are orthogonal; no learned similarity
Count-based context vectorContext-word co-occurrence countsTransparent corpus evidenceLarge, sparse; frequent words may dominate
TF–IDF document vectorWeighted vocabulary termsUseful retrieval weightingWord order and contextual meaning are limited
Dense word embeddingLearned latent featuresCompact semantic/syntactic relationshipsCoordinates are not generally human-labelled features

Distributional describes learning from patterns of linguistic context. Distributed describes representing an item across multiple coordinates rather than a single active identity bit. These are related but different ideas. A one-hot ID alone does not learn distributional similarity.

Model design choices

Choose contexts (document, sentence, fixed window), weighting (raw counts, normalization, TF–IDF-like weighting or association scores), dimensionality reduction or learned embeddings, and a similarity measure. Cosine compares direction and is less affected by length than a raw dot product; Euclidean distance also reflects magnitude.

Sparse = bahut zero. Dense = chhoti learned number-list. Similar context se useful similarity seekhte hain.

MethodConstruction and exampleStrengthLimitation
One-hotOne1in vocabulary coordinate: cat=(1,0,0)Simple unique identitySparse; all distinct words equally distant
BoWCounts per vocabulary coordinateSimple interpretable frequencyLoses order and context
Bag of n-gramsCounts contiguous word groups, e.g. not goodRetains local order/phrasesVocabulary grows; sparse unseen phrases
TF–IDFTerm frequency weighted by inverse document frequencyDownweights ubiquitous terms for retrievalNo contextual meaning; depends on corpus statistics

Dense learned embeddings differ from these sparse count encodings: similarity may reflect learned context. Explain the representation before computing any metric.