File size: 4,227 Bytes
b26f487
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
---
pipeline_tag: image-text-to-text
license: other
license_name: deepseek
license_link: https://huggingface.co/deepseek-ai/deepseek-vl-7b-base/blob/main/LICENSE
base_model: deepseek-ai/deepseek-vl-7b-base
library_name: kerasformers
tags:
- keras
- kerasformers
- deepseek-vl
- vision-language
- image-text-to-text
- arxiv:2403.05525
- pytorch
- jax
- tf
---

## ***See [our collection](https://huggingface.co/collections/kerasformers/deepseek-vl-6a6ea961fe80d98b7c69b489) for all versions of DeepSeek-VL.***

# Run DeepSeek-VL with Keras 3: JAX, PyTorch, or TensorFlow

[![GitHub](https://img.shields.io/badge/GitHub-KerasFormers-black?logo=github)](https://github.com/IMvision12/KerasFormers) [![Docs](https://img.shields.io/badge/Docs-DeepSeek--VL--Hybrid-blue)](https://imvision12.github.io/KerasFormers/deepseek_vl_hybrid/) [![Collection](https://img.shields.io/badge/HF-DeepSeek--VL%20collection-yellow)](https://huggingface.co/collections/kerasformers/deepseek-vl-6a6ea961fe80d98b7c69b489)

# kerasformers/deepseek_vl_7b_base

Paper: [DeepSeek-VL: Towards Real-World Vision-Language Understanding (arXiv:2403.05525)](https://arxiv.org/abs/2403.05525) · [HF Papers](https://huggingface.co/papers/2403.05525)

DeepSeek-VL **7B hybrid** uses a dual vision tower (SigLIP @384 + SAM-style @1024) and a 3-way aligner for finer detail and small text. Import from `kerasformers.models.deepseek_vl_hybrid` (not `deepseek_vl`).

For more details on the model, please go to the upstream [model card](https://huggingface.co/deepseek-ai/deepseek-vl-7b-base).

Pure-**Keras 3** conversion of [`deepseek-ai/deepseek-vl-7b-base`](https://huggingface.co/deepseek-ai/deepseek-vl-7b-base) for [kerasformers](https://github.com/IMvision12/KerasFormers). One implementation runs unmodified on **TensorFlow / Torch / JAX**.

This is a **vision-language** (base) checkpoint (`DeepseekVLHybridConditionalGenerate`, 7B base (SigLIP + SAM hybrid)).

## ✨ Quick start

```python
import os
os.environ["KERAS_BACKEND"] = "torch"  # or "jax" / "tensorflow"

from PIL import Image
from kerasformers.models.deepseek_vl_hybrid import (
    DeepseekVLHybridConditionalGenerate,
    DeepseekVLHybridProcessor,
)

model = DeepseekVLHybridConditionalGenerate.from_weights("kerasformers/deepseek_vl_7b_base")
processor = DeepseekVLHybridProcessor.from_weights("kerasformers/deepseek_vl_7b_base")

image = Image.open("your_image.jpg")
inputs = processor(
    conversation=[
        {
            "role": "user",
            "content": [
                {"type": "image", "image": image},
                {"type": "text", "text": "Describe this image in one sentence."},
            ],
        }
    ]
)
outputs = model.generate(**inputs, max_new_tokens=64)
print(processor.decode(outputs[0]))
```

Load any DeepSeek-VL variant the same way with `from_weights("kerasformers/<variant>")`:

| Variant | Hub | Notes |
|---|---|---|
| `deepseek_vl_1.3b_base` | [`kerasformers/deepseek_vl_1.3b_base`](https://huggingface.co/kerasformers/deepseek_vl_1.3b_base) | 1.3B base |
| `deepseek_vl_1.3b_chat` | [`kerasformers/deepseek_vl_1.3b_chat`](https://huggingface.co/kerasformers/deepseek_vl_1.3b_chat) | 1.3B chat |
| `deepseek_vl_7b_base` | [`kerasformers/deepseek_vl_7b_base`](https://huggingface.co/kerasformers/deepseek_vl_7b_base) | 7B hybrid base |
| `deepseek_vl_7b_chat` | [`kerasformers/deepseek_vl_7b_chat`](https://huggingface.co/kerasformers/deepseek_vl_7b_chat) | 7B hybrid chat |

## Tips

- Set `KERAS_BACKEND` **before** importing Keras / kerasformers.
- Prefer `Processor.from_weights(...)` so vision + tokenizer match.
- 7B hybrid is a **different package** than 1.3B; do not mix imports.
- See [docs](https://imvision12.github.io/KerasFormers/deepseek_vl_hybrid/) and [Loading Weights](https://imvision12.github.io/KerasFormers/loading_weights/).
- Community / upstream safetensors still work via the `hf:` prefix, e.g. `DeepseekVLHybridConditionalGenerate.from_weights("hf:deepseek-ai/deepseek-vl-7b-base")`.

## Special Thanks

A huge thank you to the DeepSeek-VL authors for creating and releasing these models.

License: DeepSeek (`other` / deepseek). See [LICENSE](https://huggingface.co/deepseek-ai/deepseek-vl-7b-base/blob/main/LICENSE).