Nodes/ComfyUI-Pt-Wrapper/Ptv Hf Glove Dataset
ComfyUI Node

Ptv Hf Glove Dataset

Skip the transformer, embed text with static GloVe vectors

By HowToSD·Created about a year ago·Updated about a year ago· 7
Ptv Hf Glove Dataset
    • PTVDATASET
    name
    splittrain
    embed_dim100
    max_seq_len256
    sample_field_nametext
    label_field_namelabel

    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_dim isn'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.

    CategoryTraining

    Inputs (6)

    NameTypeDefaultDescription
    nameSTRING
    splitSTRINGtrain
    embed_dimINT10032–4096
    max_seq_lenINT2568–4096
    sample_field_nameSTRINGtext
    label_field_nameSTRINGlabel

    Outputs (1)

    NameTypeDescription
    PTVDATASETPTVDATASET