RunMat
  • Pricing
RunMat
GitHub
GitHub
DownloadSign InTry in Browser
DesktopRuntimeServer
RunMat

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact

Explore

  • RunMat for academia
  • RunMat vs MATLAB Online
  • Benchmarks

Get product updates and release notes from the RunMat team.

© 2026 Dystr · Made withfor the scientific community.

RunMat™ is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

LicensePrivacy
/
See all docs
Builtin Reference
    • addDependencyDetails
    • addEntityDetails
    • addLemmaDetails
    • addPartOfSpeechDetails
    • addSentenceDetails
    • addTypeDetails
    • bagOfNgrams
    • bagOfWords
    • cosineSimilarity
    • doc2sequence
    • encode
    • extractFileText
    • extractHTMLText
    • fastTextWordEmbedding
    • findElement
    • getAttribute
    • htmlTree
    • ind2word
    • isVocabularyWord
    • normalizeWords
    • readWordEmbedding
    • removeLongWords
    • removeShortWords
    • removeStopWords
    • removeWords
    • stopWords
    • tokenDetails
    • tokenizedDocument
    • trainWordEmbedding
    • vaderSentimentScores
    • vec2word
    • word2ind
    • word2vec
    • wordEncoding
    • writeWordEmbedding

trainWordEmbedding — Train a word embedding from a text file or tokenized documents.

trainWordEmbedding(filename) and trainWordEmbedding(documents) return a wordEmbedding trained from local text. File input is UTF-8 text with one document per line and whitespace-separated words; tokenizedDocument input uses its stored tokens.

Syntax

emb = trainWordEmbedding(filename)
emb = trainWordEmbedding(documents)
emb = trainWordEmbedding(___, Name, Value)

Inputs

NameTypeRequiredDefaultDescription
sourceAnyYes—UTF-8 text filename or tokenizedDocument object.
NameValueAnyVariadic—Name-value options controlling local deterministic embedding training.

Returns

NameTypeDescription
embAnyWord embedding compatibility object.

Errors

IdentifierWhenMessage
RunMat:trainWordEmbedding:InvalidInputInputs do not match a supported trainWordEmbedding form.trainWordEmbedding received invalid input

How trainWordEmbedding works

  • filename may be a string scalar, character vector, scalar string array, or 1-by-1 cell containing a text filename.
  • documents must be a tokenizedDocument object.
  • Dimension, Window, Model, DiscardFactor, LossFunction, NumNegativeSamples, NumEpochs, MinCount, NGramRange, InitialLearnRate, UpdateRate, and Verbose are parsed and validated using the documented MATLAB option names.
  • MinCount filters vocabulary words before model construction. Vocabulary order is descending frequency with first-seen order as the tie-breaker.
  • The returned object exposes Dimension and Vocabulary and stores dense vectors in the same implementation-detail property used by word2vec and vec2word.
  • The current trainer is deterministic and uses lexical/subword hashing with windowed co-occurrence features. It supports repeatable embedding lookup workflows but does not implement the fastText optimizer.
  • RunMat mode accepts native integer option values. Counts, sizes, ranges, and Verbose are decoded exactly; integer-valued learning-rate controls must be exactly representable as double.
  • Very large dense embedding outputs are rejected before allocation when they exceed the configured model-size limit.

GPU memory and residency

trainWordEmbedding performs host text processing and model construction and has no provider kernel.

Examples

Train From File

emb = trainWordEmbedding("training.txt", "Dimension", 50, "MinCount", 1)

Expected output:

`emb` is a `wordEmbedding` object.

Train From Tokenized Documents

documents = tokenizedDocument(["alpha beta"; "beta gamma"]);
emb = trainWordEmbedding(documents, "Window", 2)

Expected output:

`emb.Vocabulary` contains the retained document tokens.

Using trainWordEmbedding with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how trainWordEmbedding changes the result.

Run a small trainWordEmbedding example, explain the result, then change one input and compare the output.

FAQ

Does RunMat implement MATLAB's exact fastText training algorithm?⌄

No. The current deterministic lexical/subword and co-occurrence trainer produces a usable wordEmbedding, but its vectors are not fastText optimizer results.

Can the trained model be used with word2vec and vec2word?⌄

Yes. The output is the wordEmbedding object consumed by the existing embedding lookup builtins.

Does trainWordEmbedding execute on the GPU?⌄

No. It reads host text/model data and builds host vectors.

Related Strings functions

Text Analytics

addDependencyDetails · addEntityDetails · addLemmaDetails · addPartOfSpeechDetails · addSentenceDetails · addTypeDetails · bagOfNgrams · bagOfWords · cosineSimilarity · doc2sequence · encode · extractFileText · extractHTMLText · fastTextWordEmbedding · findElement · getAttribute · htmlTree · ind2word · isVocabularyWord · normalizeWords · readWordEmbedding · removeLongWords · removeShortWords · removeStopWords · removeWords · stopWords · tokenDetails · tokenizedDocument · vaderSentimentScores · vec2word · word2ind · word2vec · wordEncoding · writeWordEmbedding

Transform

append · deblank · erase · eraseBetween · erasePunctuation · eraseURLs · extractAfter · extractBefore · extractBetween · insertAfter · insertBefore · join · lower · pad · replace · replaceBetween · reverse · split · splitlines · strcat · strip · strjoin · strjust · strrep · strsplit · strtrim · upper

Core

blanks · char · compose · convertCharsToStrings · convertContainedStringsToChars · convertStringsToChars · genvarname · int2str · isletter · isspace · isStringScalar · isstrprop · mat2str · native2unicode · newline · num2str · sprintf · sscanf · str2double · str2num · strcmp · strcmpi · string · string.empty · strings · strlength · strncmp · strncmpi · strtok · unicode2native

Search

contains · endsWith · matches · startsWith · strfind

Pattern

digitsPattern · lettersPattern · pattern · regexpPattern · textBoundary · wildcardPattern

Regex

regexp · regexpi · regexprep

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how trainWordEmbedding is executed, line by line, in Rust.

  • View the source for trainWordEmbedding in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • How trainWordEmbedding works
  • GPU memory and residency
  • Examples
  • Train From File
  • Train From Tokenized Documents
  • Using trainWordEmbedding with coding agents
  • FAQ
  • Related Strings functions
  • Text Analytics
  • Transform
  • Core
  • Search
  • Pattern
  • Regex
  • Open-source implementation
  • About RunMat