Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Landan/text encoder refactor #124

Merged
merged 46 commits into from
Mar 12, 2024

Conversation

Landanjs
Copy link
Contributor

@Landanjs Landanjs commented Feb 29, 2024

This PR has a few new features:

  1. Changes SDXLTextEncoder and SDXLTokenizer to be MultiTextEncoder and MultiTokenizer, respectively. These two new classes enable using arbitrary combinations of OpenAI CLIP, OpenCLIP, E5 and possibly other models with minor tweaks.
    a. CONFIG CHANGE: Since there is no more SDXL specific tokenizer, a new argument sdxl_conditioning is added in image_caption.py to specify whether to generate SDXL-style conditioning in the dataset.
  2. Use the attention_mask in the text encoder.

Minor:

  1. Set qkv_clip = None

Copy link
Contributor

@jazcollins jazcollins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some comments!!

@Landanjs Landanjs marked this pull request as ready for review March 6, 2024 00:01
Copy link
Contributor

@jazcollins jazcollins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for refactoring!!

since we newly have the MultiTokenizer, we will want to change this line as well to access one of the tokenizers in the list:

text_captions = self.tokenizer.tokenizer.batch_decode(captions[:, 0, :], skip_special_tokens=True)

@Landanjs
Copy link
Contributor Author

Ooops, requested review before implementing .batch_decode...

Copy link
Collaborator

@coryMosaicML coryMosaicML left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for doing this!

Copy link
Contributor

@jazcollins jazcollins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, this is awesome landan!!!

doesn't necessarily have to be in the same PR, but it would be good to update the SDXL sample yamls (both mosaic and hydra) with the new relevant yaml params (tokenizer_names_or_paths and sdxl_conditioning in the dataloader, etc.)

@Landanjs Landanjs merged commit da716d7 into mosaicml:main Mar 12, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants