transformers torch accelerate safetensors
A custom node for ComfyUI to load and use my custom tuned LFM2-350M model trained on 60k base pairs to work as a prompt enhancer for z-image turbo or any other long token model.
torch.compile() (automatically fixes _orig_mod. weight prefix)custom_nodes folder:“`bash
cd ComfyUI/custom_nodes
git clone https://github.com/marduk191/ComfyUI_LFM2-350M.git
“`
“`bash
cd ComfyUI_LFM2-350M
pip install -r requirements.txt
“`
Loads the model and tokenizer.
| Input | Description |
|——-|————-|
| repo_id | HuggingFace repository ID (default: marduk191/lfm2-350m-dp-marduk191) |
| local_path | Optional local path to a pre-downloaded/fine-tuned model |
| precision | Model precision: bf16, fp16, fp32, or auto |
| device | cuda or cpu |
Generates text based on prompts.
| Input | Description |
|——-|————-|
| model_context | Connect to Loader’s model output |
| tokenizer | Connect to Loader’s tokenizer output |
| system_prompt | System instructions for the model |
| prompt | User input text |
| max_new_tokens | Maximum tokens to generate (1-4096) |
| temperature | Randomness control (default: 0.3) |
| top_p | Nucleus sampling parameter |
| top_k | K sampling parameter |
| min_p | Minimum probability (default: 0.15) |
| repetition_penalty | Penalty for repeating tokens (default: 1.05) |
For best results with LFM2-350M:
temperature: 0.3min_p: 0.15repetition_penalty: 1.05MIT License