compel
A prompting enhancement library for transformers-type text embedding systems.
What it is and what it does
Compel is a prompt weighting library for diffusion models that lets you control how much influence different parts of a text prompt have on the final image generation. Instead of treating a prompt as a flat string, you can use syntax like `word++` to upweight a concept or `word--` to downweight it, and these weights are applied to the embedding tensor before being passed to the diffusion pipeline. It works with Hugging Face's diffusers library and supports Stable Diffusion, SDXL, and Flux models, as well as negative prompts, style prompts, and batched generation.
The library handles the tokenization and embedding transformation internally, so you just pass your weighted prompt string and get back conditioning tensors ready for the pipeline. It also supports textual inversion embeddings and provides tokenization info for debugging. The main dependencies are torch, transformers, and diffusers—all standard for generative AI work—and it has no compiled dependencies, making installation straightforward.
Use it for:
- Emphasize specific objects or attributes in Stable Diffusion prompts by using ++ or -- syntax to control their visual weight in the generated image
- Generate batches of images with different prompt weights applied consistently across multiple prompts and negative prompts
- Combine style prompts with content prompts in SDXL or Flux, with independent weighting for each component
- Integrate textual inversion embeddings into weighted prompts for fine-grained control over custom concepts
- Debug tokenization and embedding behavior by accessing tokenization_info from the conditioning output
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Compel lets you re-weight different parts of text prompts to control how much influence each part has on the embedding tensor produced by diffusion models, using an intuitive syntax like `word++` or `word--`.
Yes. Compel is actively maintained, has no security vulnerabilities, uses a permissive license, and requires only standard dependencies. It solves a real problem—fine-grained prompt control—for anyone using diffusers-based image generation. Install it if you need to adjust the relative importance of different parts of your prompts; skip it if you're happy with flat prompt strings.
Install
compel on PyPI
pip
pip install compeluv
uv add compelpoetry
poetry add compelInstalling compel
Before you install
Low install friction: pure Python wheel with no compiled dependencies. Active maintenance as of 2026-05-30 with 606 repository stars. Requires Python >=3.10 and transformers >=5,<6, both standard in modern environments.
License in practice
Permissive license (MIT) means you can use, modify, and distribute Compel with minimal restrictions in commercial or open-source projects.
Quickstart
pip install compel
from diffusers import StableDiffusionPipeline
from compel import CompelForSD
pipeline = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")
compel = CompelForSD(pipeline)
prompt = "a cat playing with a ball++ in the forest"
conditioning = compel(prompt)
images = pipeline(prompt_embeds=conditioning.embeds, num_inference_steps=20).images
Requires Python >=3.10 and transformers >=5,<6. Needs a compatible diffusers-based pipeline (StableDiffusionPipeline, SDXL, or Flux) already instantiated.
Verify before relying
- Whether memory/VRAM leak workarounds (torch.no_grad blocks, explicit tensor dereferencing) are still necessary in current versions
- Performance overhead of Compel's prompt parsing and reweighting relative to raw embeddings
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 5 — diffusers, notebook, pyparsing, torch, transformers |
| Maintenance | actively maintained — 76 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 131,251/month — #11,596 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: compel-2.4.0-py3-none-any.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
diffusersDiffusers provides pretrained diffusion models…
permissive · top 5,000 on PyPI
tomesdSpeeds up Stable Diffusion image generation by…
permissive · top 15,000 on PyPI
clip-interrogatorGenerates natural-language prompts from images…
permissive · top 15,000 on PyPI
cache-ditCache-DiT accelerates inference for Diffusion…
unclear · top 15,000 on PyPI
axial-positional-embeddingProvides axial positional embeddings for…
permissive · top 15,000 on PyPI
CoLT5-attentionImplements conditionally routed efficient…
permissive · top 15,000 on PyPI
setfitSetFit fine-tunes Sentence Transformers for…
permissive · top 15,000 on PyPI
segtokSplits Indo-European text into sentences and…
permissive · top 15,000 on PyPI
tensorflow-textTensorFlow Text provides text preprocessing…
permissive · top 5,000 on PyPI
sentence-transformersComputes embeddings and reranking scores for…
permissive · top 1,000 on PyPI