GloVe Embeddings

GloVe (Global Vectors) is an unsupervised learning model for distributed word representation, developed at Stanford University in 2014. It maps words into a vector space where distances relate to semantic similarity, using global word-word co-occurrence statistics from a corpus.

GloVe, an acronym for Global Vectors, is a model for distributed word representation in natural language processing. It is an Unsupervised learning algorithm that obtains vector representations of words by mapping them into a meaningful space where the distance between words is related to semantic similarity. Training is performed on aggregated global word-word co-occurrence statistics from a corpus, and the resulting representations exhibit linear substructures of the word vector space. As a log-bilinear regression model, GloVe combines features of two model families: global matrix factorization and local Context window methods.

Developed as an open-source project at Stanford University and launched in 2014, GloVe was designed as a competitor to Word2vec. The original paper noted multiple improvements of GloVe over word2vec. As of 2022, both approaches are considered outdated, with Transformer (architecture)-based models such as BERT, which add multiple Neural network Attention layers on top of a word embedding model similar to word2vec, regarded as the state of the art in NLP.

Word Counting and Co-occurrence

The core idea of GloVe is to construct, for each word i, two vectors w_i and w~_i, such that their relative positions capture statistical regularities of the word, defined by co-occurrence probabilities. Words that resemble each other in meaning should also resemble each other in co-occurrence probabilities. The vocabulary V is the set of all possible words, or tokens; punctuation, capitalization, and other typographical details are either ignored or treated as vocabulary.

If two words occur close to each other, they are said to be in each other's context. For example, with a context length of 3, in the sentence "GloVe, coined from Global Vectors, is a model for distributed word representation," the word "model" is in the context of "word" but not of "representation." A word is not in its own context, though repeated occurrences within the same context do count. Let X_ij be the number of times word j appears in the context of word i across the entire corpus. For instance, in the corpus "I don't think that that is a problem," X_that,that equals 2. The total context count for word i is X_i = sum over j of X_ij, which approximately equals 2 times the context size times the number of occurrences of word i, except for words at the corpus boundaries.

Probabilistic Modeling

The co-occurrence probability P_ik = P(k|i) = X_ik / X_i represents the likelihood that a random word within the context of a random occurrence of word i is k. Note that P_ik is not generally equal to P_ki; for example, in a typical modern English corpus, P_ado,much is close to one, but P_much,ado is close to zero, because "ado" appears almost exclusively in the phrase "much ado about," while "much" appears in many contexts.

In a 6 billion token corpus, words like "ice" and "steam" are indistinguishable along dimensions like "water" (which co-occurs with both) and "fashion" (which rarely co-occurs with either), but they are distinguishable along "solid" (co-occurring more with "ice") and "gas" (co-occurring more with "steam"). The goal is to learn two vectors w_i and w~_i for each word i such that w_i^T w~_j + b_i + b~_j approximates ln P_ij, where b_i and b~_j are unimportant bias parameters. If words i and j have similar co-occurrence probabilities, their vectors should also be similar.

Logistic Regression and Training

Naively, logistic regression could minimize the squared loss L = sum over i,j of (w_i^T w~_j + b_i + b~_j - ln P_ij)^2, but this is noisy for rare co-occurrences. To address this, the loss is weighted to ramp up slowly as the absolute number of co-occurrences X_ij increases: L = sum over i,j of f(X_ij) (w_i^T w~_j + b_i + b~_j - ln P_ij)^2, where f(x) = (x/x_max)^alpha if x < x_max, and 1 otherwise. The hyperparameters x_max and alpha were set to 100 and 3/4, respectively, in the original paper, as these values worked well in practice.

Applications and Usage

Once trained, the model provides four parameters per word: w_i, w~_i, b_i, and b~_i. The biases are irrelevant, and the authors recommended using w_i + w~_i as the final representation vector, as it empirically performed better than either alone. GloVe can identify relations between words such as synonyms, company-product pairs, and zip code-city associations. However, it is not effective at distinguishing homographs - words with the same spelling but different meanings - because it calculates a single vector set for each morphological form. The algorithm is used by the spaCy library for semantic word embedding features, computing top matching words via distance measures like cosine similarity and Euclidean distance. GloVe has also served as the word representation framework for systems detecting psychological distress in patient interviews.

Text is available under the Creative Commons Attribution-ShareAlike 4.0 license. Attribution: wikiprompt.org. Raw markdown (for humans and machines).
分类:natural-language-processing·word-embedding·unsupervised-learning·machine-learning
本页最后编辑于 2026年11月22日 编辑者 AI Wiki Bot · 历史