Image-Text-to-Text
Transformers
Joblib
Safetensors
English
qwen3_5
ocr
pdf
markdown
document-parsing
tables
charts
parsebench
autoround
w4a16
gptq
llm-compressor
compressed-tensors
quantized
vllm
conversational
Run this model with HF Jobs
Run OpenTensorLab/OCRia-1-W4A16-LLM-Compressor on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/OpenTensorLab/OCRia-1-W4A16-LLM-Compressor. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/OpenTensorLab/OCRia-1-W4A16-LLM-Compressor on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/OpenTensorLab/OCRia-1-W4A16-LLM-Compressor. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Instructions to use OpenTensorLab/OCRia-1-W4A16-LLM-Compressor with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenTensorLab/OCRia-1-W4A16-LLM-Compressor with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="OpenTensorLab/OCRia-1-W4A16-LLM-Compressor") 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("OpenTensorLab/OCRia-1-W4A16-LLM-Compressor") model = AutoModelForMultimodalLM.from_pretrained("OpenTensorLab/OCRia-1-W4A16-LLM-Compressor", 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 OpenTensorLab/OCRia-1-W4A16-LLM-Compressor with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OpenTensorLab/OCRia-1-W4A16-LLM-Compressor" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OpenTensorLab/OCRia-1-W4A16-LLM-Compressor", "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/OpenTensorLab/OCRia-1-W4A16-LLM-Compressor
- SGLang
How to use OpenTensorLab/OCRia-1-W4A16-LLM-Compressor 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 "OpenTensorLab/OCRia-1-W4A16-LLM-Compressor" \ --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": "OpenTensorLab/OCRia-1-W4A16-LLM-Compressor", "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 "OpenTensorLab/OCRia-1-W4A16-LLM-Compressor" \ --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": "OpenTensorLab/OCRia-1-W4A16-LLM-Compressor", "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 OpenTensorLab/OCRia-1-W4A16-LLM-Compressor with Docker Model Runner:
docker model run hf.co/OpenTensorLab/OCRia-1-W4A16-LLM-Compressor
File size: 7,414 Bytes
d8db4d8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | // Copyright (c) 2026 LlamaIndex, Inc. All rights reserved.
// Licensed under the OCRia-1 Model and Code License (LICENSE at the root of this repository).
// This is not open-source software: see the license for permitted uses.
// Arrays are contiguous float64, int32, or byte booleans, owned by Python.
// Coordinates use attention-grid cells; valid indices retain transcript positions.
// Compile without fused arithmetic to preserve reference feature rounding.
#include <algorithm>
#include <cmath>
#include <vector>
static double median(std::vector<double>& v) {
std::sort(v.begin(),v.end()); const auto n=v.size();
return n%2 ? v[n/2] : (v[n/2-1]+v[n/2])/2.0;
}
extern "C" void neighborhood(int n, int m, const double* xy, const double* lengths,
const int* owner, const int* valid, double* out) {
for (int r=0;r<m;++r) {
const int u=valid[r];const double px=xy[2*u],py=xy[2*u+1];double* row=out+19*r;
const int offsets[4]={-2,-1,1,2};
for(int k=0;k<4;++k) {
const int v=u+offsets[k];
if(v>=0 && v<n && owner[v]==owner[u] && std::isfinite(xy[2*v])) {
row[k*4]=std::clamp(xy[2*v]-px,-20.0,20.0);
row[k*4+1]=std::clamp(xy[2*v+1]-py,-10.0,10.0);
row[k*4+2]=lengths[v];row[k*4+3]=1.0;
} else for(int j=0;j<4;++j)row[k*4+j]=0;
}
std::vector<int> nearby;std::vector<double> ys,adv;
for(int v=std::max(0,u-12);v<std::min(n,u+13);++v)
if(owner[v]==owner[u] && std::isfinite(xy[2*v]) && std::abs(xy[2*v+1]-py)<=1) {
nearby.push_back(v);ys.push_back(xy[2*v+1]);
}
for(size_t k=1;k<nearby.size();++k) {
const int a=nearby[k-1],b=nearby[k];
const double delta=xy[2*b]-xy[2*a];
const double chars=.75*lengths[a]+1+.25*lengths[b];
const double ratio=delta/std::max(chars,1.0);
if(ratio>=.1 && ratio<=1.5)adv.push_back(delta/chars);
}
row[16]=nearby.size();row[17]=adv.empty()?0:median(adv);row[18]=ys.empty()?0:median(ys)-py;
}
}
// Sum neighbors in transcript order to match the reference floating-point order.
extern "C" void pool_profiles(int n, int m, const double* xy, const int* owner,
const int* valid, const int* lookup,
const double* profiles, double* out) {
for(int r=0;r<m;++r) {
const int u=valid[r];double* row=out+8*r;
std::fill(row,row+8,0.0);int count=0;
for(int v=std::max(0,u-12);v<std::min(n,u+13);++v) {
if(v==u || owner[v]!=owner[u] || lookup[v]<0 || std::abs(xy[2*v+1]-xy[2*u+1])>1)continue;
const int offset=static_cast<int>(std::nearbyint(xy[2*v+1]-xy[2*u+1]));
for(int k=0;k<5;++k)row[1+offset+k]+=profiles[5*lookup[v]+k];
++count;
}
if(count)for(int k=0;k<7;++k)row[k]/=count;
row[7]=count;
}
}
// The caller supplies a true seed and a zeroed output mask. Visit only its
// eight-connected component; unrelated components do not need labels.
extern "C" void peak_component_bounds(int h, int w, const unsigned char* mask, int seed,
unsigned char* selected, int* bounds) {
bounds[0]=seed%w; bounds[1]=seed/w;
bounds[2]=bounds[0]+1; bounds[3]=bounds[1]+1;
std::vector<int> queue;queue.push_back(seed);selected[seed]=1;
for(size_t k=0;k<queue.size();++k) {
const int at=queue[k],y=at/w,x=at%w;
bounds[0]=std::min(bounds[0],x); bounds[1]=std::min(bounds[1],y);
bounds[2]=std::max(bounds[2],x+1); bounds[3]=std::max(bounds[3],y+1);
for(int yy=std::max(0,y-1);yy<std::min(h,y+2);++yy)
for(int xx=std::max(0,x-1);xx<std::min(w,x+2);++xx) {
const int j=yy*w+xx;
if(mask[j] && !selected[j]) { selected[j]=1;queue.push_back(j); }
}
}
}
extern "C" void peak_component(int h, int w, const unsigned char* mask, int seed,
unsigned char* selected) {
int bounds[4];
peak_component_bounds(h,w,mask,seed,selected,bounds);
}
#include <cmath>
#include <algorithm>
// Interleave eight independent rows to overlap dependent node loads. Each row
// still accumulates leaves in tree order; the tail handles incomplete groups.
// Compact nodes avoid converting integer links and fit two nodes per cache line.
struct TreeNode {
double value, threshold;
int feature, left, right, flags;
};
static_assert(sizeof(TreeNode)==32);
extern "C" void predict_compact_trees(int rows,int cols,const double* x,int trees,
const int* roots,const TreeNode* nodes,double baseline,double* out) {
std::fill(out,out+rows,baseline);
for(int t=0;t<trees;++t) {
int r=0;
for(;r+7<rows;r+=8) {
int j[8]={roots[t],roots[t],roots[t],roots[t],roots[t],roots[t],roots[t],roots[t]};
bool active=true;
while(active) {
active=false;
for(int k=0;k<8;++k) {
const auto& node=nodes[j[k]];
if(node.flags&2) continue;
active=true;
double v=x[(r+k)*cols+node.feature];
bool left=std::isnan(v)?(node.flags&1)!=0:v<=node.threshold;
j[k]=left?node.left:node.right;
}
}
for(int k=0;k<8;++k) out[r+k]+=nodes[j[k]].value;
}
for(;r<rows;++r) {
int j=roots[t];
while(!(nodes[j].flags&2)) {
const auto& node=nodes[j];
double v=x[r*cols+node.feature];
bool left=std::isnan(v)?(node.flags&1)!=0:v<=node.threshold;
j=left?node.left:node.right;
}
out[r]+=nodes[j].value;
}
}
}
// Eight-connected components in first-cell order, with exclusive right/bottom edges.
#include <vector>
#include <cstdint>
extern "C" int component_boxes(int h,int w,const uint8_t* mask,int* out) {
const int n=h*w;std::vector<uint8_t> seen(n);std::vector<int> q;q.reserve(n);int count=0;
for(int seed=0;seed<n;++seed){
if(!mask[seed]||seen[seed])continue;
q.clear();q.push_back(seed);seen[seed]=1;
int x0=seed%w,x1=x0+1,y0=seed/w,y1=y0+1;
for(size_t k=0;k<q.size();++k){int p=q[k],x=p%w,y=p/w;
if(x<x0)x0=x;if(x+1>x1)x1=x+1;if(y<y0)y0=y;if(y+1>y1)y1=y+1;
for(int dy=-1;dy<=1;++dy)for(int dx=-1;dx<=1;++dx){int nx=x+dx,ny=y+dy;
if(nx<0||nx>=w||ny<0||ny>=h)continue;int j=ny*w+nx;
if(mask[j]&&!seen[j]){seen[j]=1;q.push_back(j);}
}
}
out[count*4]=x0;out[count*4+1]=y0;out[count*4+2]=x1;out[count*4+3]=y1;++count;
}
return count;
}
// Bounds are clipped, nonempty cell-edge rectangles in x0,y0,x1,y1 order.
extern "C" void box_maxima(int width,const double* values,int count,
const int* bounds,double* out) {
for(int k=0;k<count;++k) {
const int* b=bounds+4*k;double maximum=values[b[1]*width+b[0]];
for(int y=b[1];y<b[3];++y) for(int x=b[0];x<b[2];++x) {
double v=values[y*width+x];
if(std::isnan(v)) {maximum=v;y=b[3];break;}
if(v>=maximum)maximum=v;
}
out[k]=maximum;
}
}
// Share marginal sums and cumulative mass across quantile rectangles.
#include <vector>
#include <algorithm>
extern "C" void mass_boxes(int h,int w,const double* v,int count,const double* q,double* out) {
std::vector<double> x(w,0),y(h,0);
for(int r=0;r<h;++r) for(int c=0;c<w;++c){double a=v[r*w+c];x[c]+=a;y[r]+=a;}
for(int c=1;c<w;++c)x[c]+=x[c-1];
for(int r=1;r<h;++r)y[r]+=y[r-1];
for(int k=0;k<count;++k){
out[k*4]=std::upper_bound(x.begin(),x.end(),q[k]*x.back())-x.begin();
out[k*4+1]=std::upper_bound(y.begin(),y.end(),q[k]*y.back())-y.begin();
out[k*4+2]=std::min(w,int(std::lower_bound(x.begin(),x.end(),(1-q[k])*x.back())-x.begin())+1);
out[k*4+3]=std::min(h,int(std::lower_bound(y.begin(),y.end(),(1-q[k])*y.back())-y.begin())+1);
}
}
|