GloVeVectorizer<T>

Models & Types ยท AiDotNet.Preprocessing.TextVectorizers

Converts text documents to dense vectors using GloVe-style word embeddings.

Inheritance: TextVectorizerBase<T> โ†’ GloVeVectorizer<T>

For Beginners

GloVe combines the best of both worlds:

  • Uses global word co-occurrence statistics (like LSA)
  • Produces dense vectors (like Word2Vec)
  • Often produces high-quality embeddings with less training time
  • The resulting word relationships are mathematically meaningful

How It Works

GloVe (Global Vectors for Word Representation) learns word vectors by factorizing the word-word co-occurrence matrix. Unlike Word2Vec which uses local context windows, GloVe leverages global corpus statistics for potentially better embeddings.

The objective function is:

Where Xij is the co-occurrence count and f is a weighting function.

Constructors

Constructor Summary
GloVeVectorizer(int vectorSize, int windowSize, int minCount, int epochs, double learningRate, double xMax, double alpha, Word2VecAggregation aggregation, bool lowercase, int? randomState, Func<string, IEnumerable<string>> tokenizer, HashSet<string> stopWords, ITokenizer advancedTokenizer) Creates a new instance of GloVeVectorizer.

Properties

Property Summary
Dictionary<string, double[]> WordVectors { get; } Gets the learned word vectors.
bool IsFitted { get; }
int FeatureCount { get; }
int VectorSize { get; } Gets the vector dimensionality.

Methods

Method Summary
List<ValueTuple<string, double>> MostSimilar(string word, int topN) Finds the most similar words to a given word.
Matrix<T> Transform(IEnumerable<string> documents) Transforms documents to dense vectors by aggregating word vectors.
double[] GetWordVector(string word) Gets the vector for a specific word.
void Fit(IEnumerable<string> documents) Trains GloVe embeddings on the corpus.