Views
No views yet
reducto/RolmOCR.1export VLLM_USE_V1=1
2vllm serve reducto/RolmOCR 1# HOST YOUR OPENAI COMPATIBLE API WITH THE FOLLOWING COMMAND in VLLM:
2# export VLLM_USE_V1=1
3# vllm serve reducto/RolmOCR
4
5from openai import OpenAI
6import base64
7
8client = OpenAI(api_key="123", base_url="http://localhost:8000/v1")
9
10model = "reducto/RolmOCR-7b"
11
12def encode_image(image_path):
13 with open(image_path, "rb") as image_file:
14 return base64.b64encode(image_file.read()).decode("utf-8")
15
16def ocr_page_with_rolm(img_base64):
17 response = client.chat.completions.create(
18 model=model,
19 messages=[
20 {
21 "role": "user",
22 "content": [
23 {
24 "type": "image_url",
25 "image_url": {"url": f"data:image/png;base64,{img_base64}"},
26 },
27 {
28 "type": "text",
29 "text": "Return the plain text representation of this document as if you were reading it naturally.\n",
30 },
31 ],
32 }
33 ],
34 temperature=0.2,
35 max_tokens=4096
36 )
37 return response.choices[0].message.content
38
39test_img_path = "path/to/image.png"
40img_base64 = encode_image(test_img_path)
41print(ocr_page_with_rolm(img_base64))@misc{RolmOCR,
author = {Reducto AI},
title = {RolmOCR: A Faster, Lighter Open Source OCR Model},
year = {2025},
}