Instructions to use PatSnap/Hiro-OCSR with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use PatSnap/Hiro-OCSR with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="PatSnap/Hiro-OCSR") 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 AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("PatSnap/Hiro-OCSR") model = AutoModelForMultimodalLM.from_pretrained("PatSnap/Hiro-OCSR", 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=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use PatSnap/Hiro-OCSR with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "PatSnap/Hiro-OCSR" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "PatSnap/Hiro-OCSR", "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/PatSnap/Hiro-OCSR
- SGLang
How to use PatSnap/Hiro-OCSR 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 "PatSnap/Hiro-OCSR" \ --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": "PatSnap/Hiro-OCSR", "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 "PatSnap/Hiro-OCSR" \ --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": "PatSnap/Hiro-OCSR", "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 PatSnap/Hiro-OCSR with Docker Model Runner:
docker model run hf.co/PatSnap/Hiro-OCSR
Hiro-OCSR
Hiro-OCSR is an optical chemical structure recognition model that converts chemical structure images into machine-readable SMILES.
This checkpoint is a full-parameter fine-tune of Qwen3-VL-8B-Instruct for image-to-SMILES generation. It is an early-training release intended for evaluation and continued improvement, not a final or fully validated OCSR model.
Quickstart
Install the inference dependencies:
pip install "transformers>=4.57.1" accelerate torch torchvision pillow
The inference interface follows Qwen3-VL. Use the OCSR prompt exactly as shown below:
from transformers import AutoProcessor, Qwen3VLForConditionalGeneration
model_id = "PatSnap/Hiro-OCSR"
model = Qwen3VLForConditionalGeneration.from_pretrained(
model_id,
dtype="auto",
device_map="auto",
)
processor = AutoProcessor.from_pretrained(model_id)
messages = [
{
"role": "user",
"content": [
{
"type": "image",
"image": "path/to/chemical-structure.png",
},
{
"type": "text",
"text": "Convert chemical structure in this image to SMILES.",
},
],
}
]
inputs = processor.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
return_dict=True,
return_tensors="pt",
)
inputs = inputs.to(model.device)
generated_ids = model.generate(
**inputs,
max_new_tokens=1024,
do_sample=False,
)
generated_ids_trimmed = [
output_ids[len(input_ids) :]
for input_ids, output_ids in zip(inputs.input_ids, generated_ids)
]
output_text = processor.batch_decode(
generated_ids_trimmed,
skip_special_tokens=True,
clean_up_tokenization_spaces=False,
)
print(output_text)
For the local SDK, chemical post-processing, structure validation, depiction, and batch inference utilities, see the Hiro-OCSR source repository.
Model details
- Base model: Qwen/Qwen3-VL-8B-Instruct
- Fine-tuning method: full-parameter fine-tuning
- Task: optical chemical structure recognition and image-to-SMILES generation
- Architecture: Qwen3VLForConditionalGeneration
- Recommended prompt:
Convert chemical structure in this image to SMILES. - Release stage: early training
Limitations
This model may produce inaccurate, incomplete, misrecognized, improperly canonicalized, or chemically invalid SMILES. Errors may include missing atoms or bonds, incorrect stereochemistry, charges, isotopes, salts, abbreviations, R-groups, variable attachments, repeat units, or reaction components.
Model outputs must be reviewed and validated before use in chemical analysis, patent work, regulatory submissions, laboratory workflows, safety-critical applications, database curation, or other professional contexts. Users are responsible for ensuring they have the necessary rights to process input images and documents.
See the full Disclaimer before using the model.
License and attribution
This model repository is made available under the Apache License 2.0. The model is based on Qwen3-VL-8B-Instruct; review the base model card and its applicable terms as well.
See NOTICE for copyright, trademark, and attribution information.
Related resources
- Downloads last month
- 4
Model tree for PatSnap/Hiro-OCSR
Base model
Qwen/Qwen3-VL-8B-Instruct