Doc2VecVectorizer<T>
Models & Types ยท AiDotNet.Preprocessing.TextVectorizers
Converts text documents to dense vectors using Doc2Vec (Paragraph Vector).
Inheritance: TextVectorizerBase<T> โ Doc2VecVectorizer<T>
For Beginners
Doc2Vec is Word2Vec for whole documents:
- Each document gets its own unique learned vector
- Captures document meaning, not just word averages
- Great for document similarity, classification, and clustering
- Better than averaging word vectors for longer documents
How It Works
Doc2Vec extends Word2Vec to learn fixed-length representations for documents. Two architectures are supported:
- PV-DM (Distributed Memory): Uses document vector with context words to predict target
- PV-DBOW (Distributed Bag of Words): Uses document vector alone to predict words
Unlike Word2Vec averaging, Doc2Vec learns document-specific vectors that capture document-level semantics beyond just word averages.
Constructors
| Constructor | Summary |
|---|---|
Doc2VecVectorizer(int vectorSize, int windowSize, int minCount, int epochs, double learningRate, int negativeSamples, Doc2VecArchitecture architecture, bool lowercase, int? randomState, Func<string, IEnumerable<string>> tokenizer, HashSet<string> stopWords, ITokenizer advancedTokenizer) |
Creates a new instance of Doc2VecVectorizer. |
Properties
| Property | Summary |
|---|---|
Dictionary<int, double[]> DocVectors { get; } |
Gets the learned document vectors (indexed by training order). |
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 |
|---|---|
Matrix<T> Transform(IEnumerable<string> documents) |
Transforms documents to dense vectors by inferring document vectors. |
void Fit(IEnumerable<string> documents) |
Trains Doc2Vec embeddings on the corpus. |