Image-Text-to-Text
Transformers
Safetensors
German
ocr
vision-language
lightonocr
document-understanding
german
shorthand
manuscript
medieval
conversational
Instructions to use wjbmattingly/LightOnOCR-2-1B-german-shorthand-line with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use wjbmattingly/LightOnOCR-2-1B-german-shorthand-line with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="wjbmattingly/LightOnOCR-2-1B-german-shorthand-line") 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)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("wjbmattingly/LightOnOCR-2-1B-german-shorthand-line", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use wjbmattingly/LightOnOCR-2-1B-german-shorthand-line with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "wjbmattingly/LightOnOCR-2-1B-german-shorthand-line" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "wjbmattingly/LightOnOCR-2-1B-german-shorthand-line", "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/wjbmattingly/LightOnOCR-2-1B-german-shorthand-line
- SGLang
How to use wjbmattingly/LightOnOCR-2-1B-german-shorthand-line 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 "wjbmattingly/LightOnOCR-2-1B-german-shorthand-line" \ --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": "wjbmattingly/LightOnOCR-2-1B-german-shorthand-line", "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 "wjbmattingly/LightOnOCR-2-1B-german-shorthand-line" \ --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": "wjbmattingly/LightOnOCR-2-1B-german-shorthand-line", "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 wjbmattingly/LightOnOCR-2-1B-german-shorthand-line with Docker Model Runner:
docker model run hf.co/wjbmattingly/LightOnOCR-2-1B-german-shorthand-line
| {% set image_count = namespace(value=0) %} | |
| {% for message in messages %} | |
| {% if loop.first and message['role'] != 'system' %} | |
| <|im_start|>system<|im_end|> | |
| {% endif %} | |
| <|im_start|>{{ message['role'] }} | |
| {% if message['content'] is string %} | |
| {{ message['content'] }}<|im_end|> | |
| {% else %} | |
| {% for content in message['content'] %} | |
| {% if content['type'] == 'image' or 'image' in content or 'image_url' in content %} | |
| {% set image_count.value = image_count.value + 1 %} | |
| {% if add_vision_id %} | |
| Picture {{ image_count.value }}: | |
| {% endif -%} | |
| <|image_pad|> | |
| {%- elif 'text' in content %} | |
| {{ content['text'] }} | |
| {% endif %} | |
| {% endfor %} | |
| <|im_end|> | |
| {% endif %} | |
| {% endfor %} | |
| {% if add_generation_prompt %} | |
| <|im_start|>assistant | |
| {% endif %} |