Skip to content

Commit cc6cac0

Browse files
authored
llava : add --skip-unknown to 1.6 convert.py (ggml-org#5632)
This commit adds the `--skip-unknown` option to the convert.py script and removes the saving of the updated checkpoints to avoid updating possibly checked out files. The motivation for this change is that this was done for 1.5 in Commit fc0c8d2 ("llava : update surgery script to not remove tensors") and makes the examples more consistent. Signed-off-by: Daniel Bevenius <[email protected]>
1 parent 580111d commit cc6cac0

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

examples/llava/README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,32 +63,31 @@ Now both the LLaMA part and the image encoder is in the `llava-v1.5-7b` director
6363
```console
6464
git clone https://huggingface.co/liuhaotian/llava-v1.6-vicuna-7b
6565
```
66-
2) Backup your pth/safetensor model files as llava-surgery modifies them
67-
3) Use `llava-surgery-v2.py` which also supports llava-1.5 variants pytorch as well as safetensor models:
66+
2) Use `llava-surgery-v2.py` which also supports llava-1.5 variants pytorch as well as safetensor models:
6867
```console
6968
python examples/llava/llava-surgery-v2.py -C -m ../llava-v1.6-vicuna-7b/
7069
```
7170
- you will find a llava.projector and a llava.clip file in your model directory
72-
4) Copy the llava.clip file into a subdirectory (like vit), rename it to pytorch_model.bin and add a fitting vit configuration to the directory:
71+
3) Copy the llava.clip file into a subdirectory (like vit), rename it to pytorch_model.bin and add a fitting vit configuration to the directory:
7372
```console
7473
mkdir vit
7574
cp ../llava-v1.6-vicuna-7b/llava.clip vit/pytorch_model.bin
7675
cp ../llava-v1.6-vicuna-7b/llava.projector vit/
7776
curl -s -q https://huggingface.co/cmp-nct/llava-1.6-gguf/raw/main/config_vit.json -o vit/config.json
7877
```
7978

80-
5) Create the visual gguf model:
79+
4) Create the visual gguf model:
8180
```console
8281
python ./examples/llava/convert-image-encoder-to-gguf.py -m vit --llava-projector vit/llava.projector --output-dir vit --clip-model-is-vision
8382
```
8483
- This is similar to llava-1.5, the difference is that we tell the encoder that we are working with the pure vision model part of CLIP
8584

86-
6) Then convert the model to gguf format:
85+
5) Then convert the model to gguf format:
8786
```console
88-
python ./convert.py ../llava-v1.6-vicuna-7b/
87+
python ./convert.py ../llava-v1.6-vicuna-7b/ --skip-unknown
8988
```
9089

91-
7) And finally we can run the llava-cli using the 1.6 model version:
90+
6) And finally we can run the llava-cli using the 1.6 model version:
9291
```console
9392
./llava-cli -m ../llava-v1.6-vicuna-7b/ggml-model-f16.gguf --mmproj vit/mmproj-model-f16.gguf --image some-image.jpg -c 4096
9493
```

examples/llava/llava-surgery-v2.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ def clean_vision_tower_from_checkpoint(checkpoint_path):
6565
for name in clip_tensors:
6666
del checkpoint[name]
6767

68-
# Save the updated checkpoint
6968
checkpoint_path = checkpoint_path
70-
save_model(checkpoint, checkpoint_path, file_type)
7169
return True
7270
return False
7371

@@ -152,16 +150,6 @@ def proj_criteria(checkpoint):
152150
if len(projector) > 0:
153151
save_model(projector, f"{args.model}/llava.projector", 'pytorch')
154152

155-
for name in mm_tensors:
156-
del last_checkpoint[name]
157-
for name in first_mm_tensors:
158-
del first_checkpoint[name]
159-
160-
if len(mm_tensors) > 0:
161-
save_model(last_checkpoint, projector_checkpoint_path, file_type)
162-
if len(first_mm_tensors) > 0:
163-
save_model(first_checkpoint, newline_checkpoint_path, file_type)
164-
165153
print("Done!")
166154
print(f"Now you can convert {args.model} to a a regular LLaMA GGUF file.")
167155
print(f"Also, use {args.model}/llava.projector to prepare a llava-encoder.gguf file.")

0 commit comments

Comments
 (0)