Ptv Hf Glove Dataset
Skip the transformer, embed text with static GloVe vectors
- PTVDATASET
Most text-classification paths in ComfyUI go through a transformer tokenizer. This node takes the older, cheaper road: it loads a Hugging Face dataset and converts every text sample into a stack of static GloVe word vectors - no neural tokenizer, no attention masks, just numbers a simple RNN or LSTM can train on. If you're doing the pack's RNN/GRU/LSTM text-classification tutorials, this is the dataset node they expect.
How it works
For each sample it tokenizes the text (lowercase, strips punctuation and HTML), then looks up every word in a pretrained GloVe embedding via gensim. Unknown words become a zero vector. Sequences are padded (also with zeros) to max_seq_len, so each sample comes out as a tensor of shape [max_seq_len, embed_dim] alongside its label. The embeddings are loaded by dimension from gensim.downloader - glove-wiki-gigaword-100 for the default embed_dim of 100.
The inputs that matter
- name - HF dataset id, e.g.
stanfordnlp/imdb. - split - default
train. - embed_dim - GloVe dimension, default 100.
- max_seq_len - default 256. Truncates and pads to this length.
- sample_field_name / label_field_name - defaults
text/label; rename to match your dataset's columns.
The traps
The big one: embed_dim only really supports 50, 100, 200, or 300. The node lets you type anything from 32 to 4096, but gensim only ships those four pretrained files. The moment you pick 128, the code builds the key glove-wiki-gigaword-128, can't find it, and errors. Treat the UI range as a lie; stick to the four real values.
Second: the first run downloads the GloVe vectors through gensim - that's a few hundred megabytes depending on dimension, and gensim's downloader can be flaky behind proxies. It caches after that.
Third, and worth knowing even if it never bites you: this pack pins gensim==4.3.2 in requirements.txt because newer gensim broke against scipy's deprecated triu, and the code even monkey-patches scipy.linalg.triu = np.triu at import. Don't "help" by upgrading gensim; you'll just reintroduce the bug the pin exists to avoid.
Wiring it in
Output is a PTVDATASET - same type as the other dataset nodes, so it feeds the Pt Data Loader and then a training node. Because each sample is already [max_seq_len, embed_dim], it pairs naturally with the pack's RNN/GRU/LSTM model nodes rather than a transformer.
Install
One install for the whole pack:
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper
Restart ComfyUI, or grab it from ComfyUI Manager by searching "ComfyUI-Pt-Wrapper". Gensim is part of the pack's requirements, so it installs automatically - just don't let it float off the pinned version later.
Common issues
- "dataset 'glove-wiki-gigaword-128' not found" -
embed_dimisn't 50/100/200/300. - Slow first load - that's the GloVe download, not a hang.
- Everything embedding to zeros - if your text is in a language gensim's English GloVe barely covers, most tokens will be unknown vectors and the model will learn nothing useful. This node is an English-GloVe tool; that's a real limit, not a bug.
For the same datasets with a real tokenizer (and usually better results), reach for Ptv Hf Dataset With Token Encode instead. This one shines when you want small, fast, CPU-friendly training runs.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| name | STRING | — | |
| split | STRING | train | — |
| embed_dim | INT | 10032–4096 | — |
| max_seq_len | INT | 2568–4096 | — |
| sample_field_name | STRING | text | — |
| label_field_name | STRING | label | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| PTVDATASET | PTVDATASET | — |