Module 9 Glossary

Bag-of-Words (BoW)
Bag-of-words is a text representation that converts documents into fixed-length vectors by counting word occurrences, ignoring word order and grammar. Each position in the vector corresponds to a vocabulary word, and the value is the word's count or binary presence. While simple and fast, BoW produces sparse high-dimensional vectors and cannot capture semantic similarity (synonyms are completely different features).
TF-IDF (Term Frequency-Inverse Document Frequency)
TF-IDF is a numerical statistic that reflects how important a word is to a document in a collection. It combines term frequency (how often a word appears in the document) with inverse document frequency (logarithmic measure of how rare the word is across all documents). Words that are frequent in a specific document but rare overall receive high scores, making TF-IDF effective for identifying distinctive terms.
N-gram
An n-gram is a contiguous sequence of n items (typically words or characters) from a text. Unigrams are single words, bigrams are pairs, trigrams are triplets, and so on. N-grams capture some word order information that bag-of-words loses, making them useful for distinguishing phrases like "not good" from "good." The tradeoff is exponentially larger vocabulary and increased sparsity.
Word Embedding
A word embedding is a dense, low-dimensional vector representation of a word (typically 100-300 dimensions) learned from large text corpora. Unlike one-hot or bag-of-words representations, embeddings place semantically similar words close together in vector space. This enables arithmetic-like operations: vector("king") - vector("man") + vector("woman") ≈ vector("queen"). Pre-trained embeddings can be transferred to new tasks.
Word2Vec
Word2Vec is a family of neural network models that learn word embeddings from text. The Skip-gram variant predicts context words given a center word, while CBOW predicts the center word from context. Training on large corpora, Word2Vec learns that words appearing in similar contexts should have similar vectors. It was a breakthrough that demonstrated embeddings could capture semantic relationships like analogies.
GloVe (Global Vectors)
GloVe is a word embedding method that combines global co-occurrence statistics with local context learning. It constructs a word-word co-occurrence matrix from the corpus, then learns embeddings that predict these co-occurrence counts. GloVe embeddings often perform comparably to Word2Vec and are widely available pre-trained on various corpora including Wikipedia and Common Crawl.
Cosine Similarity
Cosine similarity measures the cosine of the angle between two vectors, computed as their dot product divided by the product of their magnitudes. Values range from -1 (opposite directions) to 1 (same direction), with 0 indicating orthogonality. Cosine similarity is preferred for comparing embeddings because it focuses on direction rather than magnitude, making it robust to vector length differences.
Document Embedding
A document embedding is a fixed-length vector representation of an entire document (sentence, paragraph, or longer). Simple approaches average the word embeddings of constituent words, optionally weighted by TF-IDF. Advanced methods like Doc2Vec and Sentence-BERT learn document representations directly. Document embeddings enable semantic similarity comparison between documents of different lengths.
Tokenization
Tokenization is the process of splitting text into individual units (tokens), typically words or subwords. Simple tokenization splits on whitespace and punctuation. Subword tokenization (BPE, WordPiece) breaks rare words into common pieces, handling out-of-vocabulary issues. Tokenization is the first step in most NLP pipelines and significantly affects downstream model performance.
Vocabulary
The vocabulary is the set of unique tokens known to the model, mapping each token to an integer index. In bag-of-words, vocabulary size determines vector dimensionality. For embeddings, each vocabulary word has a corresponding vector. Words not in the vocabulary (out-of-vocabulary or OOV) must be handled specially—either ignored, mapped to an unknown token, or processed with subword methods.
Transfer Learning (for NLP)
Transfer learning in NLP uses representations learned from a large corpus on a new task with limited data. Pre-trained word embeddings (Word2Vec, GloVe) provide general language understanding. Modern transformers (BERT, GPT) are pre-trained on massive text and fine-tuned for specific tasks. Transfer learning dramatically reduces the data needed for many NLP tasks while achieving state-of-the-art performance.
Sentence Transformers
Sentence transformers are neural models that produce dense embeddings for sentences or short paragraphs. Unlike word-level embeddings that require averaging, sentence transformers consider the entire context at once. Models like Sentence-BERT are trained specifically to produce embeddings where semantically similar sentences are close in vector space, making them excellent for semantic search and clustering.