Image-to-Text
Transformers
Safetensors
qwen2_5_vl
image-text-to-text
OCR
vision-language
VLM
Reasoning
document-to-markdown
qwen2.5
markdown
extraction
RAG
text-generation-inference
Instructions to use numind/NuMarkdown-8B-Thinking with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use numind/NuMarkdown-8B-Thinking with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "image-to-text" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # 'pip install "transformers<5.0.0' from transformers import pipeline pipe = pipeline("image-to-text", model="numind/NuMarkdown-8B-Thinking")# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("numind/NuMarkdown-8B-Thinking") model = AutoModelForMultimodalLM.from_pretrained("numind/NuMarkdown-8B-Thinking", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -170,11 +170,10 @@ Pàgina 2 de 2
|
|
| 170 |
|
| 171 |
## vLLM:
|
| 172 |
```
|
| 173 |
-
vllm serve numind/NuMarkdown-8B-
|
| 174 |
```
|
| 175 |
|
| 176 |
```python
|
| 177 |
-
import json
|
| 178 |
from openai import OpenAI
|
| 179 |
import base64
|
| 180 |
|
|
@@ -193,28 +192,31 @@ def encode_image(image_path):
|
|
| 193 |
with open(image_path, "rb") as image_file:
|
| 194 |
return base64.b64encode(image_file.read()).decode('utf-8')
|
| 195 |
|
| 196 |
-
base64_image = encode_image("
|
|
|
|
| 197 |
|
| 198 |
chat_response = client.chat.completions.create(
|
| 199 |
-
model="numind/NuMarkdown-8B-
|
| 200 |
temperature=0.7,
|
| 201 |
messages=[
|
|
|
|
|
|
|
|
|
|
| 202 |
{
|
| 203 |
-
"
|
| 204 |
-
"
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
"min_pixels": 100 * 28 * 28,
|
| 208 |
-
"max_pixels": 5000 * 28 * 28,},
|
| 209 |
-
|
| 210 |
-
],
|
| 211 |
},
|
| 212 |
],
|
| 213 |
-
|
|
|
|
| 214 |
)
|
| 215 |
|
| 216 |
-
|
| 217 |
-
|
|
|
|
|
|
|
| 218 |
```
|
| 219 |
|
| 220 |
|
|
|
|
| 170 |
|
| 171 |
## vLLM:
|
| 172 |
```
|
| 173 |
+
vllm serve numind/NuMarkdown-8B-Thinking --trust_remote_code --limit-mm-per-prompt image=1
|
| 174 |
```
|
| 175 |
|
| 176 |
```python
|
|
|
|
| 177 |
from openai import OpenAI
|
| 178 |
import base64
|
| 179 |
|
|
|
|
| 192 |
with open(image_path, "rb") as image_file:
|
| 193 |
return base64.b64encode(image_file.read()).decode('utf-8')
|
| 194 |
|
| 195 |
+
base64_image = encode_image("image.png")
|
| 196 |
+
data_url = f"data:image/jpeg;base64,{base64_image}"
|
| 197 |
|
| 198 |
chat_response = client.chat.completions.create(
|
| 199 |
+
model="numind/NuMarkdown-8B-Thinking",
|
| 200 |
temperature=0.7,
|
| 201 |
messages=[
|
| 202 |
+
{
|
| 203 |
+
"role": "user",
|
| 204 |
+
"content": [
|
| 205 |
{
|
| 206 |
+
"type": "image_url",
|
| 207 |
+
"image_url": {"url": data_url},
|
| 208 |
+
"min_pixels": 100 * 28 * 28,
|
| 209 |
+
"max_pixels": 5000 * 28 * 28,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
},
|
| 211 |
],
|
| 212 |
+
},
|
| 213 |
+
]
|
| 214 |
)
|
| 215 |
|
| 216 |
+
result = chat_response.choices[0].message.content
|
| 217 |
+
reasoning = result.split("<think>")[1].split("</think>")[0]
|
| 218 |
+
answer = result.split("<answer>")[1].split("</answer>")[0]
|
| 219 |
+
print(answer)
|
| 220 |
```
|
| 221 |
|
| 222 |
|