-
Notifications
You must be signed in to change notification settings - Fork 34
Gemma3 initial commit #102
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
base: main
Are you sure you want to change the base?
Conversation
Updated configs Moved embed_tokens to more natural place Updated run_model to use sampler and stop at end_of_turn token Added test_sharding_gemma3 Added batched forward test. Need more complex behavior and testing
|
Also, please make sure your selective tests are passing |
| def make_input(processor, dtype=torch.float32, msg1=True): | ||
| if msg1: | ||
| messages = [ | ||
| {"role": "system", "content": [{"type": "text", "text": "You are a helpful assistant."}]}, | ||
| { | ||
| "role": "user", | ||
| "content": [ | ||
| { | ||
| "type": "image", | ||
| "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg", | ||
| }, | ||
| {"type": "text", "text": "What is shown in this image?"}, | ||
| ], | ||
| }, | ||
| ] | ||
| else: | ||
| messages = [ | ||
| {"role": "system", "content": [{"type": "text", "text": "You are a helpful assistant."}]}, | ||
| { | ||
| "role": "user", | ||
| "content": [ | ||
| { | ||
| "type": "image", | ||
| "image": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/bee.jpg", | ||
| }, | ||
| {"type": "text", "text": "Describe this image in detail."}, | ||
| ], | ||
| }, | ||
| ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very lengthy and difficult to read. How about having something like this?
def make_input(processor, dtype=torch.float32, msg1=True):
url = "pipeline-cat-chonk.jpeg" if msg1 else "bee.jpg"
prompt = "What is shown in this image?" if msg1 else "Describe this image in detail."
img_key = "url" if msg1 else "image"
messages = [
{"role": "system", "content": [{"type": "text", "text": "You are a helpful assistant."}]},
{"role": "user", "content": [
{"type": "image", img_key: f"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/{url}"},
{"type": "text", "text": prompt}
]}
]
# Add your return statement or processor logic here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I implemented your suggested change. The final output ends up longer because of the ruff formatting, but it is shorter than before.
Resolves #100
Adds the Gemma3 model to the Bonsai Repo. This first commit is just a working version, but I am still working on optimizing it.
Reference
Refer to Issue #100
Checklist
run_model.pyfor model usage,test_outputs.pyand/ormodel_validation_colab.ipynbfor quality).