P or Prompt Arguments
Prompt tuning args — where 'RANDOM vs TEXT' decides your whole run
- peft_args
P_or_Prompt_Arguments builds the PEFT PromptTuningConfig for the LLM School trainer. Prompt tuning is the minimalist end of the parameter-efficient spectrum: you add a small set of trainable soft tokens in front of your input, freeze everything else, and train only those tokens. In this pack it backs two of the trainer's fine_tuning_method options - p-tuning and prompt_tuning both map to PromptTuningConfig in the training core - so this one node serves both. If you want to adapt a model to a task with the absolute minimum of trainable parameters, this is the method.
The one genuinely interesting decision here is how the prompt starts. prompt_tuning_init gives you RANDOM (the soft tokens begin as random vectors and learn everything from scratch) or TEXT (they're initialized from the embeddings of an actual sentence you provide in prompt_tuning_init_text). The TEXT option is the practical one for a real task - starting from a sensible sentence ("Answer the question based on the context:") puts the tokens in the neighborhood of the right semantic space and trains faster and more stably than random noise. For most people, that's the difference between a run that works and a run that wanders.
The inputs that matter
prompt_tuning_init-RANDOMorTEXT. The fork in the road; see above.prompt_tuning_init_text- the sentence used when init isTEXT. Make it task-relevant and it pays off.tokenizer_name_or_path- defaultbert-base-uncased. This is the tokenizer used to encode your init text, and it must be compatible with your model's vocabulary - feeding a BERT tokenizer's IDs to a GPT-2 model is a recipe for nonsense. Set it to your model's tokenizer, not the default, if you're usingTEXTinit.num_virtual_tokens- default 20. How many soft tokens to prepend. 20 is a sane default; shorter for easier tasks.token_dim,num_transformer_submodules,num_attention_heads,num_layers- the GPT-2-shaped PEFT defaults again. Settoken_dimto your model's hidden size if you're not on GPT-2.
A bug you'll hit on first use
The node's Argument method signature requires a task_type parameter, but that field isn't in the node's inputs - so when ComfyUI calls the node it raises TypeError: Argument() missing 1 required positional argument: 'task_type' and the node fails on execution. There's no workaround in the UI; you have to patch the source. The cleanest fix: edit the method signature in train.py to give it a default, e.g. task_type="CAUSAL_LM", or delete the task_type parameter from the signature and from the args dict it builds. It's a small edit, but it's the difference between this node working and being a brick - and it's a good reminder that this pack is early-stage and unpolished.
Install
ComfyUI Manager, search "comfyui_LLM_schools", or:
cd ComfyUI/custom_nodes
git clone https://github.com/heshengtao/comfyui_LLM_schools
then restart. Deps: huggingface_hub, datasets, transformers, peft.
Other things that'll trip you up
- The trainer's
full_fine_tuningdefault raisesValueErrorin the current code - you'll be pickingp-tuning/prompt_tuningexplicitly anyway. - Missing
config.iniin the pack folder (copy fromconfig.ini.example) breaks node loading entirely. - If a run starts but quality is bad, suspect the
tokenizer_name_or_pathmismatch before anything else.
It's the most promising method in the pack and the least finished. If you're willing to patch one line, prompt tuning from TEXT init is a great way to adapt a causal LM cheaply - just don't expect it to work untouched.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| num_virtual_tokens | INT | 201–100 | — |
| token_dim | INT | 7681–4096 | — |
| num_transformer_submodules | INT | 11–12 | — |
| num_attention_heads | INT | 121–16 | — |
| num_layers | INT | 121–24 | — |
| prompt_tuning_init | COMBO | RANDOM | 2 options: RANDOM, TEXT |
| prompt_tuning_init_text | STRING | — | |
| tokenizer_name_or_path | STRING | bert-base-uncased | — |
| is_enable | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| peft_args | ARGS | — |