[WIP] Add moondream3 model#42310
Draft
nyxkrage wants to merge 1 commit into
Draft
Conversation
Member
|
cc @zucchini-nlp for VLMs! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Taken from my first attempt at NyxKrage/moondream3-preview-hf, however it needed some changes to work properly with the latest transformers from git, and so the model with the proper config json files can be found at NyxKrage/moondream3-preview-hf-git, though the weights stay the same.
Moondream3 modeling code ported over to follow more proper HuggingFace conventions, code is mostly functional, though there are currently some pretty glaring issues.
Opening this as a draft PR to get some initial feedback on the proper way to handle a most of these as I'm generally unfamiliar with the specifics in terms of how image models should be implemented.
Also the code has the full modeling code rather than using the modular setup for now, because I felt that it would be easier to "fix" the issues, and then identify which parts can be modularized afterwards.
For point 1, from what I couldn't tell if the proper way would be to override the generate method and handle it there, or just have the model handle generation and let the end user worry about the point/bounding box functionality?
For point 2, I think the main pain point, comes from the fact that I ended up handling the image embeddings and shifting around stuff in the modeling code, rather than adding padding for the space the image embeddings should take up in full input embeddings in the processor, but I ended up going for this way just because I was unsure what the correct approach was with the lack of an image token, and so if point 4 gets solved by moving that to the processor, this should come for free I believe.
For point 3, the batching of differently sized images, should just require a bit of tweaking in the reconstruction path for the image projection to handle padding the number of crops, and for the query/point problem, that should hopefully be fixed by the way of solving point 1.