Principle:AUTOMATIC1111 Stable diffusion webui Network prompt activation
| Knowledge Sources | |
|---|---|
| Domains | Stable Diffusion, LoRA, Prompt Engineering, Text Parsing |
| Last Updated | 2026-02-08 00:00 GMT |
Overview
Network prompt activation is the mechanism by which network adapter parameters are embedded inline within generation prompts using a tag syntax, parsed at generation time, and separated from the textual prompt before being dispatched to the appropriate network handlers.
Description
Stable Diffusion WebUI uses an inline tag syntax to allow users to activate network adapters (LoRA, Hypernetwork, etc.) directly from within their text prompts. This design eliminates the need for separate UI controls for each network type and enables per-prompt, per-batch network configuration.
The tag syntax follows the pattern:
<network_type:name:arg1:arg2:...>
For LoRA networks specifically, the syntax supports multiple forms:
- Basic:
<lora:network_name:weight>-- applies the same multiplier to both text encoder and UNet - Split weights:
<lora:network_name:te_weight:unet_weight>-- separate multipliers for text encoder and UNet - Dynamic dimension:
<lora:network_name:te_weight:unet_weight:dyn_dim>-- with dynamic rank truncation - Named parameters:
<lora:network_name:1.0:te=0.5:unet=0.8:dyn=128>-- explicit named overrides
The activation process consists of two phases:
Phase 1 -- Parsing: A regex-based parser scans the prompt text, extracts all <type:args> tags, strips them from the prompt, and groups the extracted parameters by network type. The cleaned prompt (without tags) is passed to the text encoder, while the extracted parameters are dispatched to network handlers.
Phase 2 -- Activation: Each registered extra network handler receives the list of parsed parameters. The LoRA handler extracts network names and multipliers, then calls the network loading system. Networks not mentioned in the current prompt are deactivated (called with an empty parameter list) to ensure clean state.
Usage
This mechanism is used on every image generation run. Users write prompts like:
1girl, masterpiece, best quality <lora:character_lora:0.8> <lora:style_lora:0.6:0.4>
The system parses this into a clean prompt ("1girl, masterpiece, best quality ") and a parameter structure that activates two LoRA networks with their respective weights. This approach enables:
- Multiple simultaneous network activations
- Per-prompt weight tuning without UI interaction
- Batch processing with different networks per prompt
- Easy sharing of generation parameters (the full prompt with tags serves as a complete recipe)
Theoretical Basis
The parsing is built on a regular expression that matches the tag pattern:
re_extra_net = re.compile(r"<(\w+):([^>]+)>")
This captures two groups: the network type name and the colon-separated argument string. The parsing algorithm operates as a substitution: each match is replaced with an empty string (removing the tag from the prompt) while the callback accumulates the extracted parameters:
PARSE(prompt):
extra_data = defaultdict(list)
for each match of <type:args> in prompt:
items = args.split(":")
extra_data[type].append(ExtraNetworkParams(items))
remove match from prompt
return cleaned_prompt, extra_data
For batch prompts, parse_prompts processes multiple prompts but only uses the extra network data from the first prompt (all prompts in a batch share the same network configuration):
PARSE_PROMPTS(prompts):
cleaned = []
extra_data = None
for prompt in prompts:
cleaned_prompt, parsed_data = PARSE(prompt)
if extra_data is None:
extra_data = parsed_data
cleaned.append(cleaned_prompt)
return cleaned, extra_data
The ExtraNetworkParams class separates positional and named arguments:
ExtraNetworkParams(items=["name", "0.8", "te=0.5"]):
positional = ["name", "0.8"]
named = {"te": "0.5"}
The activation handler then interprets positional arguments by position:
| Position | Meaning | Default |
|---|---|---|
| 0 | Network name | (required) |
| 1 | Text encoder multiplier | 1.0 |
| 2 | UNet multiplier | same as TE multiplier |
| 3 | Dynamic dimension | None |
Named parameters (te=, unet=, dyn=) override positional values when present.