2023-10-12 15:23:18 +00:00
|
|
|
# LLaVA
|
|
|
|
|
|
|
|
Currently this implementation supports [llava-v1.5](https://huggingface.co/liuhaotian/llava-v1.5-7b) variants.
|
|
|
|
|
|
|
|
The pre-converted [7b](https://huggingface.co/mys/ggml_llava-v1.5-7b)
|
|
|
|
and [13b](https://huggingface.co/mys/ggml_llava-v1.5-13b)
|
|
|
|
models are available.
|
|
|
|
|
|
|
|
After API is confirmed, more models will be supported / uploaded.
|
|
|
|
|
|
|
|
## Usage
|
2023-11-06 21:36:23 +00:00
|
|
|
Build with cmake or run `make llava-cli` to build it.
|
2023-10-12 15:23:18 +00:00
|
|
|
|
2023-11-06 21:36:23 +00:00
|
|
|
After building, run: `./llava-cli` to see the usage. For example:
|
2023-10-12 15:23:18 +00:00
|
|
|
|
|
|
|
```sh
|
2024-02-08 14:20:03 +00:00
|
|
|
./llava-cli -m ../llava-v1.5-7b/ggml-model-f16.gguf --mmproj ../llava-v1.5-7b/mmproj-model-f16.gguf --image path/to/an/image.jpg
|
2023-10-12 15:23:18 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
**note**: A lower temperature like 0.1 is recommended for better quality. add `--temp 0.1` to the command to do so.
|
|
|
|
|
|
|
|
## Model conversion
|
|
|
|
|
2024-02-08 08:58:19 +00:00
|
|
|
- Clone `llava-v15-7b` and `clip-vit-large-patch14-336` locally:
|
2023-10-12 15:23:18 +00:00
|
|
|
|
|
|
|
```sh
|
|
|
|
git clone https://huggingface.co/liuhaotian/llava-v1.5-7b
|
|
|
|
|
|
|
|
git clone https://huggingface.co/openai/clip-vit-large-patch14-336
|
|
|
|
```
|
|
|
|
|
2024-02-09 13:00:59 +00:00
|
|
|
2. Install the required Python packages:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
pip install -r examples/llava/requirements.txt
|
|
|
|
```
|
|
|
|
|
|
|
|
3. Use `llava-surgery.py` to split the LLaVA model to LLaMA and multimodel projector constituents:
|
2023-10-12 15:23:18 +00:00
|
|
|
|
|
|
|
```sh
|
|
|
|
python ./examples/llava/llava-surgery.py -m ../llava-v1.5-7b
|
|
|
|
```
|
|
|
|
|
2024-02-09 13:00:59 +00:00
|
|
|
4. Use `convert-image-encoder-to-gguf.py` to convert the LLaVA image encoder to GGUF:
|
2023-10-12 15:23:18 +00:00
|
|
|
|
|
|
|
```sh
|
2024-02-08 14:20:03 +00:00
|
|
|
python ./examples/llava/convert-image-encoder-to-gguf.py -m ../clip-vit-large-patch14-336 --llava-projector ../llava-v1.5-7b/llava.projector --output-dir ../llava-v1.5-7b
|
2023-10-12 15:23:18 +00:00
|
|
|
```
|
|
|
|
|
2024-02-09 13:00:59 +00:00
|
|
|
5. Use `convert.py` to convert the LLaMA part of LLaVA to GGUF:
|
2023-10-12 15:23:18 +00:00
|
|
|
|
|
|
|
```sh
|
|
|
|
python ./convert.py ../llava-v1.5-7b
|
|
|
|
```
|
|
|
|
|
|
|
|
Now both the LLaMA part and the image encoder is in the `llava-v1.5-7b` directory.
|
|
|
|
|
|
|
|
## TODO
|
|
|
|
|
|
|
|
- [ ] Support non-CPU backend for the image encoding part.
|
|
|
|
- [ ] Support different sampling methods.
|
|
|
|
- [ ] Support more model variants.
|