Add alternative ways ('TE:' and 'EMB:') to load embeddings in prompt …#14745
Add alternative ways ('TE:' and 'EMB:') to load embeddings in prompt …#14745silveroxides wants to merge 3 commits into
Conversation
…since using 'embedding:' is kind of lengthy and cumbersome to use
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
Changes
Sequence Diagram(s)Not applicable. Estimated code review effort: 2 Related PRs: None identified. Suggested labels: tokenizer, enhancement Suggested reviewers: comfyanonymous 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@comfy/sd1_clip.py`:
- Line 538: The new embedding prefixes in sd1_clip.py are too generic and can be
misread from normal prompt text. Update the prefix handling in the logic around
embedding_identifiers and the parser that checks for preceding whitespace so
that "EMB:" and "TE:" only match with a stronger boundary or other
disambiguation, and do not turn ordinary prompt fragments into embedding
lookups. Keep the existing "embedding:" behavior intact while making the
abbreviated identifiers collision-safe in the embedding resolution path.
- Around line 537-538: The embedding prefix override hook is broken because
tokenize_with_weights now relies on embedding_identifiers instead of the single
source-of-truth embedding_identifier. Update sd1_clip.py so
tokenize_with_weights in the SD1 clip tokenizer derives its prefix checks from
self.embedding_identifier first, or builds the identifier list from that
singular attribute, preserving subclass/custom tokenizer overrides while keeping
the existing EMB:/TE: aliases.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 70e3fba5-8a98-44b6-8d29-d07774c713f9
📒 Files selected for processing (1)
comfy/sd1_clip.py
… self.embedding_identifier as the singular source of truth. Added dynamic embedding_identifiers property.
|
I am not super fan of this:
I would suggest to close it. |
…since using 'embedding:' is kind of lengthy and cumbersome to use.
This makes "embedding:", "EMB:" and "TE:" all valid identifiers when wanting to load embeddings in prompt.
Here is example if #14744 has not been merged
example_14744_notmerged.json
Here is example if #14744 has been merged (Which might still require me to make minor conflict resolution though)
example_14744_merged.json
Here is the embedding used in both workflows
qwen3vl_4b_duckonbear.safetensors