Refactor Aya Vision with modular - #36688
Conversation
|
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. When it is ready for review, please click the |
|
Hey @Cyrilvallez ! transformers/utils/modular_model_converter.py Lines 861 to 865 in 0ba8784 This new behavior is also extended to all constants in |
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
|
Hey @yonigozlan! I agree that we should allow something like that. It is a bit magic, and it's not ideal, but for now it will make our lives easier with the docstrings (while we wait on better docstring support). What you did is quite close to what is proposed in https://github.com/huggingface/transformers/pull/35902/files#diff-dcfd09afc0f209bd5e8403add12d0cc6707dca021dcb639bc0b9a95c41843c7e. Actually, I'd like a mix of both approaches: yours checks for all other patterns None value, and the one proposed by @nikosanto13 is a bit opaque, being directly hard-coded in the Let me know what you think. It's a bit annoying to have the |
|
@Cyrilvallez sounds good to me! Maybe it's best that I open a separate PR to make those changes then :) |
|
Ready for final review @ArthurZucker ;) |
ArthurZucker
left a comment
There was a problem hiding this comment.
I don't know about the image patch changes in the processor but the rest LGTM.
Just make sure we don't have issue with some of the code that is replaced!
|
|
||
| class AyaVisionMultiModalProjector(LlavaMultiModalProjector): | ||
| def __init__(self, config: AyaVisionConfig): | ||
| LlavaMultiModalProjector().__init__() |
There was a problem hiding this comment.
super should just work here as well
There was a problem hiding this comment.
Yes they are not needed anymore :)
| def tie_weights(self): | ||
| return self.language_model.tie_weights() | ||
|
|
||
| def resize_token_embeddings(self, new_num_tokens: Optional[int] = None, pad_to_multiple_of=None) -> nn.Embedding: | ||
| model_embeds = self.language_model.resize_token_embeddings(new_num_tokens, pad_to_multiple_of) | ||
| # update vocab size | ||
| self.config.text_config.vocab_size = model_embeds.num_embeddings | ||
| self.vocab_size = model_embeds.num_embeddings | ||
| return model_embeds |
* refactor aya_vision with modular (incorrect docstring) * Fix docstrings * Fix other modulars * fix docstring * revert changes * add tie_weights and resize_token_embeddings
What does this PR do?
Inherit from Llava with modular to remove most of the custom code.
I ran the integration tests with both 8B and 32B version and everything seems to work as expected.