readWordEmbedding — Read a word embedding model from a UTF-8 text file or zip archive.

readWordEmbedding(filename) reads UTF-8 word2vec or GloVe text embedding data. Zip archives are supported when they contain an embedding text file.

Syntax

emb = readWordEmbedding(filename)

Inputs

NameTypeRequiredDefaultDescription
filenameAnyYesUTF-8 word2vec/GloVe text file or zip file containing one.

Returns

NameTypeDescription
embAnyWord embedding compatibility object.

Errors

IdentifierWhenMessage
RunMat:readWordEmbedding:InvalidInputInputs do not match a supported readWordEmbedding form.readWordEmbedding received invalid input
RunMat:readWordEmbedding:IOErrorThe requested word embedding file cannot be read.Unable to read word embedding file

How readWordEmbedding works

  • filename may be a string scalar, character vector, or a 1-by-1 cell array containing a character vector.
  • Plain text files may use GloVe-style rows (word value value ...) or word2vec text rows with a leading numWords dimension header.
  • Zip archives are scanned for a text-like embedding entry (.txt, .vec, .glove, or .emb); otherwise the first file entry is parsed as UTF-8 text.
  • Duplicate words are collapsed so the last duplicate row supplies the vector, matching MATLAB's documented duplicate-word behavior.
  • The returned RunMat wordEmbedding compatibility object exposes Dimension and Vocabulary. Vector storage is kept in an implementation-detail property used by word2vec and vec2word.
  • Binary word2vec files, compressed formats other than zip, full pretrained model download helpers, the full fastText support-package corpus, and exact fastText optimizer parity for trainWordEmbedding remain tracked in the broader Text Analytics compatibility issue.

GPU memory and residency

readWordEmbedding performs host file IO and has no provider kernel.

Examples

Read An Embedding File

emb = readWordEmbedding('vectors.vec')

Expected output:

`emb` is a RunMat `wordEmbedding` compatibility object.

Inspect Metadata

emb.Dimension
emb.Vocabulary

Expected output:

`Dimension` is the vector length, and `Vocabulary` is a string row vector of words.

Using readWordEmbedding with coding agents

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

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

FAQ

Does readWordEmbedding support zip files?

Yes. RunMat reads a UTF-8 embedding text file from a zip archive.

Does readWordEmbedding download pretrained embeddings?

No. This helper reads local UTF-8 text or zip files. Pretrained download helpers remain separate Text Analytics work.

Does readWordEmbedding execute on the GPU?

No. It is host file parsing and object construction.

Open-source implementation

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

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.