damian0815/compel
A prompting enhancement library for transformers-type text embedding systems
What it solves
Compel provides a way to precisely control the influence of specific words or phrases in a text prompt for image generation models. Standard text encoders often treat all words with equal weight, making it difficult to emphasize or de-emphasize certain elements of an image without rewriting the entire prompt.
How it works
The library implements a flexible syntax for weighting and blending embeddings. By using markers like ++ to upweight a term, it modifies the embedding tensor produced by the text encoder. It supports advanced operations such as:
- Weighting: Increasing or decreasing the importance of specific tokens.
- Blending: Concatenating different prompt segments using a
.and()syntax to improve image quality for complex prompts. - Style Prompts: Separate handling of style and content prompts for models like SDXL and Flux.
- Long Prompt Handling: Chunking and padding prompts that exceed the model's maximum token length.
Who it’s for
It is designed for developers and researchers using diffusers-based systems (such as Stable Diffusion, SDXL, and Flux) who need fine-grained control over how their text prompts are interpreted by the model.
Highlights
- Broad Model Support: Compatible with Stable Diffusion v1.5, SDXL, and Flux.
- Intuitive Syntax: Uses a simple string-based weighting system (e.g.,
ball++). - Advanced Embedding Control: Supports negative prompts, style prompts, and textual inversion managers.
- Flexible Tokenization: Offers multiple modes for splitting long text to avoid truncation.
- Integration: Seamlessly integrates with Hugging Face's
StableDiffusionPipelineand otherdiffuserspipelines.
Related
- Dispatch
- Dispatch
- Project
- Project
- Project