Image-Text-to-Text
Transformers
Safetensors
cohere_compass
vision
multimodal
conversational
multilingual
native-resolution
Instructions to use CohereLabs/North-Micro-Vision-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use CohereLabs/North-Micro-Vision-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="CohereLabs/North-Micro-Vision-Instruct") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("CohereLabs/North-Micro-Vision-Instruct") model = AutoModelForMultimodalLM.from_pretrained("CohereLabs/North-Micro-Vision-Instruct", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use CohereLabs/North-Micro-Vision-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "CohereLabs/North-Micro-Vision-Instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "CohereLabs/North-Micro-Vision-Instruct", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/CohereLabs/North-Micro-Vision-Instruct
- SGLang
How to use CohereLabs/North-Micro-Vision-Instruct with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "CohereLabs/North-Micro-Vision-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "CohereLabs/North-Micro-Vision-Instruct", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "CohereLabs/North-Micro-Vision-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "CohereLabs/North-Micro-Vision-Instruct", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use CohereLabs/North-Micro-Vision-Instruct with Docker Model Runner:
docker model run hf.co/CohereLabs/North-Micro-Vision-Instruct
Update README.md
Browse files
README.md
CHANGED
|
@@ -46,33 +46,42 @@ Developed by [Cohere](https://cohere.com/).
|
|
| 46 |
| Total parameters | 2.4B |
|
| 47 |
| Language model | 2B parameters |
|
| 48 |
| Vision encoder | 400M parameters; custom-trained starting from [SigLIP 2 SO400M](https://huggingface.co/google/siglip2-so400m-patch16-384) |
|
| 49 |
-
| Inputs |
|
| 50 |
| Output | Text |
|
| 51 |
-
| Languages | English, German, French, Spanish, Italian, Portuguese, Hindi, Japanese, Korean, Chinese, and
|
| 52 |
| Tokenizer vocabulary size | 262,144 |
|
| 53 |
| LM Backbone context window | 128K tokens |
|
| 54 |
| Multimodal training context | 8K tokens |
|
| 55 |
| Checkpoint precision | bfloat16 |
|
| 56 |
| License | Apache 2.0 |
|
| 57 |
|
| 58 |
-
The language backbone supports a 128K-token context window, but
|
| 59 |
|
| 60 |
## Quickstart
|
| 61 |
|
| 62 |
### Installation
|
| 63 |
|
| 64 |
-
North Micro Vision requires Transformers 5.15.0. Until
|
| 65 |
|
| 66 |
```bash
|
|
|
|
| 67 |
uv pip install "git+https://github.com/huggingface/transformers.git"
|
| 68 |
```
|
| 69 |
|
| 70 |
Once Transformers 5.15.0 is available on PyPI, install the released package with:
|
| 71 |
|
| 72 |
```bash
|
| 73 |
-
uv pip install "transformers==5.15.0"
|
| 74 |
```
|
| 75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
### Transformers
|
| 77 |
|
| 78 |
The following example loads an image from a URL and asks the model to describe it. Prompts can interleave text with one or more images; for text-only prompts, omit the image entries.
|
|
@@ -85,22 +94,19 @@ model_id = "CohereLabs/North-Micro-Vision-Instruct"
|
|
| 85 |
|
| 86 |
processor = AutoProcessor.from_pretrained(
|
| 87 |
model_id,
|
| 88 |
-
trust_remote_code=True,
|
| 89 |
)
|
| 90 |
model = AutoModelForImageTextToText.from_pretrained(
|
| 91 |
model_id,
|
| 92 |
dtype="auto",
|
| 93 |
device_map="auto",
|
| 94 |
-
trust_remote_code=True,
|
| 95 |
)
|
| 96 |
|
| 97 |
# To enable Flash Attention 2, load the model with the following settings:
|
| 98 |
-
# model =
|
| 99 |
# model_id,
|
| 100 |
# dtype=torch.bfloat16,
|
| 101 |
# attn_implementation="flash_attention_2",
|
| 102 |
# device_map="auto",
|
| 103 |
-
# trust_remote_code=True,
|
| 104 |
# )
|
| 105 |
|
| 106 |
image_url = "https://cdn-uploads.huggingface.co/production/uploads/66d732effe6684fc16b12c28/Io_5OCmftsmH-n158ZtPs.png"
|
|
@@ -109,7 +115,7 @@ messages = [
|
|
| 109 |
"role": "user",
|
| 110 |
"content": [
|
| 111 |
{"type": "image", "url": image_url},
|
| 112 |
-
{"type": "text", "text": "
|
| 113 |
],
|
| 114 |
}
|
| 115 |
]
|
|
@@ -124,20 +130,50 @@ inputs = processor.apply_chat_template(
|
|
| 124 |
|
| 125 |
outputs = model.generate(
|
| 126 |
**inputs,
|
| 127 |
-
max_new_tokens=
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
)
|
| 129 |
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
|
|
|
|
|
|
|
|
|
| 133 |
skip_special_tokens=True,
|
| 134 |
-
|
|
|
|
| 135 |
print(response)
|
| 136 |
```
|
| 137 |
|
| 138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
|
| 140 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
|
| 142 |
## Intended Use
|
| 143 |
|
|
@@ -154,7 +190,7 @@ North Micro Vision Instruct is intended for research and development use cases s
|
|
| 154 |
- The model is intended as a compact foundation for customization rather than a replacement for larger general-purpose chat assistants.
|
| 155 |
- It is not a reasoning model and has limited math and code-generation capabilities.
|
| 156 |
- Tool calling and agentic workflows are not supported.
|
| 157 |
-
-
|
| 158 |
- Multimodal training used an 8K-token context; longer contexts have not been validated.
|
| 159 |
- Native-resolution inputs can increase memory use and latency as image dimensions grow.
|
| 160 |
|
|
@@ -472,19 +508,6 @@ The complete comparison is provided below. We ran vision-language and text-only
|
|
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
-
### vLLM
|
| 476 |
-
|
| 477 |
-
Public vLLM support is coming soon. For both text-only and vision-language inference, use:
|
| 478 |
-
|
| 479 |
-
```python
|
| 480 |
-
temperature = 0.7
|
| 481 |
-
top_p = 0.8
|
| 482 |
-
top_k = 20
|
| 483 |
-
min_p = 0.0
|
| 484 |
-
presence_penalty = 1.5
|
| 485 |
-
repetition_penalty = 1.0
|
| 486 |
-
```
|
| 487 |
-
|
| 488 |
## Citation
|
| 489 |
|
| 490 |
```bibtex
|
|
|
|
| 46 |
| Total parameters | 2.4B |
|
| 47 |
| Language model | 2B parameters |
|
| 48 |
| Vision encoder | 400M parameters; custom-trained starting from [SigLIP 2 SO400M](https://huggingface.co/google/siglip2-so400m-patch16-384) |
|
| 49 |
+
| Inputs | Interleaved text and images |
|
| 50 |
| Output | Text |
|
| 51 |
+
| Languages | English, German, French, Spanish, Italian, Portuguese, Hindi, Japanese, Korean, Chinese, Arabic, and more |
|
| 52 |
| Tokenizer vocabulary size | 262,144 |
|
| 53 |
| LM Backbone context window | 128K tokens |
|
| 54 |
| Multimodal training context | 8K tokens |
|
| 55 |
| Checkpoint precision | bfloat16 |
|
| 56 |
| License | Apache 2.0 |
|
| 57 |
|
| 58 |
+
The language backbone supports a 128K-token context window, but the validated operating range for multimodal prompts is up to 8K tokens. Longer multimodal contexts may rely on extrapolation and have not been benchmarked.
|
| 59 |
|
| 60 |
## Quickstart
|
| 61 |
|
| 62 |
### Installation
|
| 63 |
|
| 64 |
+
Install [PyTorch](https://pytorch.org/get-started/locally/) for your platform first. North Micro Vision requires Transformers 5.15.0, together with `accelerate` for automatic device placement and Pillow for image loading. Until Transformers 5.15.0 is released, install the runtime dependencies and Transformers from source:
|
| 65 |
|
| 66 |
```bash
|
| 67 |
+
uv pip install accelerate pillow
|
| 68 |
uv pip install "git+https://github.com/huggingface/transformers.git"
|
| 69 |
```
|
| 70 |
|
| 71 |
Once Transformers 5.15.0 is available on PyPI, install the released package with:
|
| 72 |
|
| 73 |
```bash
|
| 74 |
+
uv pip install accelerate pillow "transformers==5.15.0"
|
| 75 |
```
|
| 76 |
|
| 77 |
+
Flash Attention 2 is optional. On supported CUDA systems, install it with:
|
| 78 |
+
|
| 79 |
+
```bash
|
| 80 |
+
uv pip install flash-attn --no-build-isolation
|
| 81 |
+
```
|
| 82 |
+
|
| 83 |
+
If you do not use `uv`, replace `uv pip` with `pip` in the commands above.
|
| 84 |
+
|
| 85 |
### Transformers
|
| 86 |
|
| 87 |
The following example loads an image from a URL and asks the model to describe it. Prompts can interleave text with one or more images; for text-only prompts, omit the image entries.
|
|
|
|
| 94 |
|
| 95 |
processor = AutoProcessor.from_pretrained(
|
| 96 |
model_id,
|
|
|
|
| 97 |
)
|
| 98 |
model = AutoModelForImageTextToText.from_pretrained(
|
| 99 |
model_id,
|
| 100 |
dtype="auto",
|
| 101 |
device_map="auto",
|
|
|
|
| 102 |
)
|
| 103 |
|
| 104 |
# To enable Flash Attention 2, load the model with the following settings:
|
| 105 |
+
# model = AutoModelForImageTextToText.from_pretrained(
|
| 106 |
# model_id,
|
| 107 |
# dtype=torch.bfloat16,
|
| 108 |
# attn_implementation="flash_attention_2",
|
| 109 |
# device_map="auto",
|
|
|
|
| 110 |
# )
|
| 111 |
|
| 112 |
image_url = "https://cdn-uploads.huggingface.co/production/uploads/66d732effe6684fc16b12c28/Io_5OCmftsmH-n158ZtPs.png"
|
|
|
|
| 115 |
"role": "user",
|
| 116 |
"content": [
|
| 117 |
{"type": "image", "url": image_url},
|
| 118 |
+
{"type": "text", "text": "What do you see?"},
|
| 119 |
],
|
| 120 |
}
|
| 121 |
]
|
|
|
|
| 130 |
|
| 131 |
outputs = model.generate(
|
| 132 |
**inputs,
|
| 133 |
+
max_new_tokens=128,
|
| 134 |
+
do_sample=True,
|
| 135 |
+
temperature=0.7,
|
| 136 |
+
top_p=0.8,
|
| 137 |
+
top_k=20,
|
| 138 |
)
|
| 139 |
|
| 140 |
+
generated_ids = [
|
| 141 |
+
output_ids[len(input_ids) :]
|
| 142 |
+
for input_ids, output_ids in zip(inputs.input_ids, outputs)
|
| 143 |
+
]
|
| 144 |
+
response = processor.batch_decode(
|
| 145 |
+
generated_ids,
|
| 146 |
skip_special_tokens=True,
|
| 147 |
+
clean_up_tokenization_spaces=False,
|
| 148 |
+
)[0]
|
| 149 |
print(response)
|
| 150 |
```
|
| 151 |
|
| 152 |
+
The example uses the recommended Transformers sampling settings. For deterministic output, set `do_sample=False` and omit `temperature`, `top_p`, and `top_k`.
|
| 153 |
+
|
| 154 |
+
### Grounding Coordinates
|
| 155 |
+
|
| 156 |
+
Bounding boxes are returned as `[x1, y1, x2, y2]` on a normalized 0–1000 scale. Map them back to the original image by scaling each axis:
|
| 157 |
+
|
| 158 |
+
```python
|
| 159 |
+
x1_px = x1 / 1000 * image_width
|
| 160 |
+
y1_px = y1 / 1000 * image_height
|
| 161 |
+
x2_px = x2 / 1000 * image_width
|
| 162 |
+
y2_px = y2 / 1000 * image_height
|
| 163 |
+
```
|
| 164 |
+
|
| 165 |
+
### vLLM
|
| 166 |
|
| 167 |
+
Public vLLM support is coming soon. Until it is available, use Transformers as shown above. The recommended vLLM settings will be:
|
| 168 |
+
|
| 169 |
+
```python
|
| 170 |
+
temperature = 0.7
|
| 171 |
+
top_p = 0.8
|
| 172 |
+
top_k = 20
|
| 173 |
+
min_p = 0.0
|
| 174 |
+
presence_penalty = 1.5
|
| 175 |
+
repetition_penalty = 1.0
|
| 176 |
+
```
|
| 177 |
|
| 178 |
## Intended Use
|
| 179 |
|
|
|
|
| 190 |
- The model is intended as a compact foundation for customization rather than a replacement for larger general-purpose chat assistants.
|
| 191 |
- It is not a reasoning model and has limited math and code-generation capabilities.
|
| 192 |
- Tool calling and agentic workflows are not supported.
|
| 193 |
+
- System prompts are not recommended because the model was not trained with them, although the chat template accepts the `system` role.
|
| 194 |
- Multimodal training used an 8K-token context; longer contexts have not been validated.
|
| 195 |
- Native-resolution inputs can increase memory use and latency as image dimensions grow.
|
| 196 |
|
|
|
|
| 508 |
|
| 509 |
|
| 510 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 511 |
## Citation
|
| 512 |
|
| 513 |
```bibtex
|