-
Notifications
You must be signed in to change notification settings - Fork 12k
[Important] Added README to the Qwen2VL implementation #11642
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
Open
samkoesnadi
wants to merge
3
commits into
ggml-org:master
Choose a base branch
from
samkoesnadi:feat/qwen2vl-readme
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# QWEN2-VL | ||
|
||
This implementation supports all versions of Qwen2VL, e.g. [Qwen2-VL-2B-Instruct](https://huggingface.co/Qwen/Qwen2-VL-2B-Instruct). | ||
|
||
## Usage | ||
|
||
After building, run `./llama-qwen2vl-cli` to use it. Or you can also get the ready one on Huggingface, e.g. [Qwen2-VL-2B-Instruct-GGUF](https://huggingface.co/bartowski/Qwen2-VL-2B-Instruct-GGUF) : | ||
|
||
### The basic one for running with an image and a prompt | ||
|
||
```sh | ||
./bin/llama-qwen2vl-cli -m /models/Qwen2-VL-2B-Instruct-Q4_0.gguf --mmproj /models/mmproj-Qwen2-VL-2B-Instruct-f32.gguf -p 'Describe this image.' --image '/models/test_image.jpg' | ||
``` | ||
|
||
The image argument is optional in case you just want to use the model for text. However, the mmproj still has to be there as it will be loaded. | ||
|
||
Without defining the system prompt in the prompt, it will default to `You are a helpful assistant.`. | ||
|
||
### Or if you want the image to be directly in the prompt as a base64 | ||
|
||
```sh | ||
./llama-qwen2vl-cli -m /models/Qwen2-VL-2B-Instruct-Q4_0.gguf --mmproj /models/mmproj-Qwen2-VL-2B-Instruct-f32.gguf -p '<img src="{base64}">Describe this image.' | ||
``` | ||
|
||
### Or a complete prompt with the system message | ||
|
||
```sh | ||
./llama-qwen2vl-cli -m /models/Qwen2-VL-2B-Instruct-Q4_0.gguf --mmproj /models/mmproj-Qwen2-VL-2B-Instruct-f32.gguf -p '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>user\n<|vision_start|><|vision_pad|><|vision_end|>Describe this image.' --image '/models/test_image.jpg' | ||
``` | ||
|
||
**Note**: A lower temperature like 0.1 is recommended for better quality. Add `--temp 0.1` to the command to do so. | ||
**Note**: For GPU offloading, ensure to use the `-ngl` flag as usual. | ||
|
||
## GGUF Conversion | ||
|
||
1. Clone the Qwen2-VL model: | ||
|
||
```sh | ||
git clone https://huggingface.co/Qwen/Qwen2-VL-2B-Instruct | ||
``` | ||
|
||
2. Use `qwen2_vl_surgery.py` to prepare the model for conversion: | ||
|
||
```sh | ||
python ./examples/llava/qwen2_vl_surgery.py ./model_path --data_type fp32 | ||
``` | ||
|
||
It will generate the vision model, and output the filename in the log. | ||
|
||
3. Use `examples/convert_hf_to_gguf.py` to convert the Qwen2-VL model to GGUF: | ||
|
||
```sh | ||
python convert_hf_to_gguf.py ./model_path -outtype f32 | ||
``` | ||
|
||
Now the model is ready to use in the `model_path` directory. You can quantize them as you normally would with other GGUF files. | ||
|
||
*Have fun with the models ! :)* | ||
|
||
## Limitations | ||
|
||
* Currently, only support the image to be in the very beginning of the input prompt to the LLM. |
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
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.
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.
We should probably mention the fact that the vision model(clip.cpp) currently had its GPU backend support disabled #10896
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 have just added this in the limitations section...