Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,45 @@
|
|
1 |
-
---
|
2 |
-
license: gemma
|
3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: gemma
|
3 |
+
---
|
4 |
+
|
5 |
+
GGUFs of Google's Paligemma 3b 224 mix model. Currently in development so you'll need to use it with https://github.com/ggerganov/llama.cpp/pull/7553 or https://github.com/abetlen/llama-cpp-python/pull/1777
|
6 |
+
|
7 |
+
# Installation
|
8 |
+
|
9 |
+
```bash
|
10 |
+
pip install git+https://github.com/abetlen/llama-cpp-python.git@add-paligemma-support
|
11 |
+
```
|
12 |
+
|
13 |
+
# Usage
|
14 |
+
|
15 |
+
```python
|
16 |
+
from llama_cpp import Llama
|
17 |
+
from llama_cpp.llama_chat_format import PaligemmaChatHandler
|
18 |
+
|
19 |
+
chat_handler = PaligemmaChatHandler.from_pretrained(
|
20 |
+
repo_id="abetlen/paligemma-3b-mix-224-gguf",
|
21 |
+
filename="*mmproj*",
|
22 |
+
)
|
23 |
+
|
24 |
+
llm = Llama.from_pretrained(
|
25 |
+
repo_id="abetlen/paligemma-3b-mix-224-gguf",
|
26 |
+
filename="*text-model*",
|
27 |
+
chat_handler=chat_handler,
|
28 |
+
n_ctx=2048, # n_ctx should be increased to accommodate the image embedding
|
29 |
+
n_ubatch=512, # must be large enough to fit image embeddings and text input in a single batch
|
30 |
+
n_batch=512
|
31 |
+
)
|
32 |
+
|
33 |
+
response = llm.create_chat_completion(
|
34 |
+
messages = [
|
35 |
+
{
|
36 |
+
"role": "user",
|
37 |
+
"content": [
|
38 |
+
{"type" : "text", "text": "What's in this image?"},
|
39 |
+
{"type": "image_url", "image_url": {"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg" } }
|
40 |
+
|
41 |
+
]
|
42 |
+
}
|
43 |
+
]
|
44 |
+
)
|
45 |
+
```
|