GGUF quantized version of lightonai/LightOnOCR-2-1B.
llama-server -hf staghado/LightOnOCR-2-1B-Q4_K_S-GGUF -c 8192 --temp 0.2 --top-k 0 --top-p 0.9
Note: The flags --temp 0.2 --top-k 0 --top-p 0.9 set the default generation parameters to match the original model.
import requests
import base64
with open('document.png', 'rb') as f:
image_base64 = base64.b64encode(f.read()).decode()
response = requests.post('http://localhost:8000/v1/chat/completions', json={
"model": "LightOnOCR-2-1B",
"messages": [{
"role": "user",
"content": [
{"type": "image_url", "image_url": {"url": f"data:image/png;base64,{image_base64}"}}
]
}],
"max_tokens": 1024,
"temperature": 0.2,
"top_k": 0,
"top_p": 0.9
})
print(response.json()['choices'][0]['message']['content'])
Note: This model only accepts images, no text prompts.
If you want to create your own quantized GGUF files:
git clone https://github.com/ggml-org/llama.cpp.git
cd llama.cpp
python -m venv venv
source venv/bin/activate
pip install git+https://github.com/huggingface/transformers.git torch sentencepiece
Note: transformers must be installed from source until the next release includes LightOnOCR support.
hf download lightonai/LightOnOCR-2-1B --repo-type model --local-dir ./models/LightOnOCR-2-1B
python convert_hf_to_gguf.py ./models/LightOnOCR-2-1B --outtype bf16 --outfile LightOnOCR-2-1B-bf16.gguf
llama-quantize LightOnOCR-2-1B-bf16.gguf LightOnOCR-2-1B-Q4_K_S.gguf Q4_K_S
python convert_hf_to_gguf.py ./models/LightOnOCR-2-1B --mmproj --outtype q8_0 --outfile mmproj-LightOnOCR-2-1B-Q8_0.gguf