transformers accelerate optimum optimum[onnxruntime-gpu] transformers[sentencepiece] peft triton; platform_system == "Linux" bitsandbytes; platform_system == "Linux" optimum-quanto; platform_system != "Linux"





Custom AI prompt generator node for
ComfyUI. With this node, you can
use text generation models to generate prompts. Before using, text generation
model has to be trained with prompt dataset or you can use the
git clone https://github.com/alpertunga-bile/prompt-generator-comfyui.git
command under custom_nodes folder
ComfyUI_windows_portable folder and install the required packageswith
.\python_embeded\Scripts\python.exe -s -m pip install -r .\ComfyUI\custom_nodes\prompt-generator-comfyui\requirements.txt
command
models/prompt_generators folder. You have toput generator as folder. Do not just put pytorch_model.bin file for
example.
ComfyUI_windows_portable folder and run therun_nvidia_gpu.bat file
hires.fixWithPromptGenerator.json orbasicWorkflowWithPromptGenerator.json workflow
git clone https://github.com/alpertunga-bile/prompt-generator-comfyui.git
command under custom_nodes folder.
packages with pip install -r requirements.txt command
models/prompt_generators folder. You have toput generator as folder. Do not just put pytorch_model.bin file for
example.
hires.fixWithPromptGenerator.json orbasicWorkflowWithPromptGenerator.json workflow
node.
models/prompt_generators folder. You have toput generator as folder. Do not just put pytorch_model.bin file for
example.
hires.fixWithPromptGenerator.json orbasicWorkflowWithPromptGenerator.json workflow
index value. You can check the generated prompts from the log file and
terminal. The prompts are logged and printed in order.
Quanto and
packages. See this section.
Peft package. (The feature is not
full tested in this repository because of my low VRAM but I am using the same
implementation in Google Colab for training and inference and it is working
there)
package.
generated_prompts folder with current date as filename.
in ComfyUI is not going to change
models/prompt_generators folder.model_name variable (If youcan’t see the generator, restart the ComfyUI).
one is better.
experimental models.
model
model as the base model
| Variable Names | Definitions |
| :———————–: | :————————————————————————————————————————————————————————————————————————————————————————————————————— |
| model_name | Folder name that contains the model |
| accelerate | Open optimizations. Some of the models are not supported by BetterTransformer (Check your model). If it is not supported switch this option to disable or convert your model to ONNX |
| quantize | Quantize the model. The quantize type is changed based on your OS and torch version. none value disables the quantization. Check this section for more information |
| token_healing | Enable token healing algorithm which is used for fixing unintended bias. Read more from this blog post. To use it, the transformers package version has to be newer from or equal to 4.6 version |
| prompt | Input prompt for the generator |
| seed | Seed value for the model |
| lock | Lock the generation and select from the last generated prompts with index value |
| random_index | Random index value in [1, 5]. If the value is enable, the index value is not used |
| index | User specified index value for selecting prompt from the generated prompts. random_index variable must be disable |
| cfg | CFG is enabled by setting guidance_scale > 1. Higher guidance scale encourages the model to generate samples that are more closely linked to the input prompt, usually at the expense of poorer quality |
| min_new_tokens | The minimum numbers of tokens to generate, ignoring the number of tokens in the prompt. |
| max_new_tokens | The maximum numbers of tokens to generate, ignoring the number of tokens in the prompt. |
| do_sample | Whether or not to use sampling; use greedy decoding otherwise |
| early_stopping | Controls the stopping condition for beam-based methods, like beam-search |
| num_beams | Number of steps for each search path |
| num_beam_groups | Number of groups to divide num_beams into in order to ensure diversity among different groups of beams |
| diversity_penalty | This value is subtracted from a beam’s score if it generates a token same as any beam from other group at a particular time. Note that diversity_penalty is only effective if group beam search is enabled. |
| temperature | How sensitive the algorithm is to selecting low probability options |
| top_k | The number of highest probability vocabulary tokens to keep for top-k-filtering |
| top_p | If set to float < 1, only the smallest set of most probable tokens with probabilities that add up to top_p or higher are kept for generation |
| repetition_penalty | The parameter for repetition penalty. 1.0 means no penalty |
| no_repeat_ngram_size | The size of an n-gram that cannot occur more than once. (0=infinity) |
| remove_invalid_values | Whether to remove possible nan and inf outputs of the model to prevent the generation method to crash. Note that using remove_invalid_values can slow down generation. |
| self_recursive | See this section |
| recursive_level | See this section |
| preprocess_mode | See this section |
for text generation strategies.
Quanto and
packages.
torch >= 2.4 and Bitsandbytes package worksout-of-box with Linux OS. So the node is checking which package to use:
quantize variable and it has only none value.
none, int8, float8, int4 values.
none, int8, int4 values.
selects the Bitsandbytes package.
The strategy is called Multinomial sampling.
generation.
last generated prompts.
a, as seed and recursive level is 1. I am going to use thesame outputs for this example to explain the functionality more
understandable.
b. So next seed isgoing to be b and generator’s output is c. Final output is a, c. It can
be used for generating random outputs.
b. So next seed isgoing to be a, b and generator’s output is c. Final output is a, b, c.
It can be used for more accurate prompts.
(masterpiece), ((masterpiece)) is not allowed. Checkingthe pure keyword without parantheses and weights. The algorithm is adding the
prompts from the beginning of the generated text, so add important prompts to
prompt variable.
(masterpiece), ((masterpiece)) is allowed but(masterpiece), (masterpiece) is not. Checking the exact match of the prompt.
# ---------------------------------------------------------------------- Original ---------------------------------------------------------------------- #
((masterpiece)), ((masterpiece:1.2)), (masterpiece), blahblah, blah, blah, ((blahblah)), (((((blah))))), ((same prompt)), same prompt, (masterpiece)
# ------------------------------------------------------------- Preprocess (Exact Keyword) ------------------------------------------------------------- #
((masterpiece)), blahblah, blah, ((same prompt))
# ------------------------------------------------------------- Preprocess (Exact Prompt) -------------------------------------------------------------- #
((masterpiece)), ((masterpiece:1.2)), (masterpiece), blahblah, blah, ((blahblah)), (((((blah))))), ((same prompt)), same prompt
bug label
transformers and
optimum packages. So most of the
problems may be caused from these packages. For overcome these problems you
can try to update these packages:
pip install --upgrade -r requirements.txt command.ComfyUI_windows_portable folder..\python_embeded\Scripts\python.exe -s -m pip install --upgrade -r .\ComfyUI\custom_nodes\prompt-generator-comfyui\requirements.txt
command.
workflow. But don’t worry, you have to just delete the node in the workflow
and add it again.
quantize values for your environment, delete the node and addit again in your workflow.
yourself please follow these steps:
with enhancement label.
or to README file.