Instructions to use unsloth/Nanonets-OCR-s-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use unsloth/Nanonets-OCR-s-GGUF with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="unsloth/Nanonets-OCR-s-GGUF") 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("unsloth/Nanonets-OCR-s-GGUF", dtype="auto") - llama-cpp-python
How to use unsloth/Nanonets-OCR-s-GGUF with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="unsloth/Nanonets-OCR-s-GGUF", filename="Nanonets-OCR-s-BF16.gguf", )
llm.create_chat_completion( 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" } } ] } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use unsloth/Nanonets-OCR-s-GGUF with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf unsloth/Nanonets-OCR-s-GGUF:UD-Q4_K_XL # Run inference directly in the terminal: llama-cli -hf unsloth/Nanonets-OCR-s-GGUF:UD-Q4_K_XL
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf unsloth/Nanonets-OCR-s-GGUF:UD-Q4_K_XL # Run inference directly in the terminal: llama-cli -hf unsloth/Nanonets-OCR-s-GGUF:UD-Q4_K_XL
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf unsloth/Nanonets-OCR-s-GGUF:UD-Q4_K_XL # Run inference directly in the terminal: ./llama-cli -hf unsloth/Nanonets-OCR-s-GGUF:UD-Q4_K_XL
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf unsloth/Nanonets-OCR-s-GGUF:UD-Q4_K_XL # Run inference directly in the terminal: ./build/bin/llama-cli -hf unsloth/Nanonets-OCR-s-GGUF:UD-Q4_K_XL
Use Docker
docker model run hf.co/unsloth/Nanonets-OCR-s-GGUF:UD-Q4_K_XL
- LM Studio
- Jan
- vLLM
How to use unsloth/Nanonets-OCR-s-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "unsloth/Nanonets-OCR-s-GGUF" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "unsloth/Nanonets-OCR-s-GGUF", "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/unsloth/Nanonets-OCR-s-GGUF:UD-Q4_K_XL
- SGLang
How to use unsloth/Nanonets-OCR-s-GGUF 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 "unsloth/Nanonets-OCR-s-GGUF" \ --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": "unsloth/Nanonets-OCR-s-GGUF", "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 "unsloth/Nanonets-OCR-s-GGUF" \ --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": "unsloth/Nanonets-OCR-s-GGUF", "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" } } ] } ] }' - Ollama
How to use unsloth/Nanonets-OCR-s-GGUF with Ollama:
ollama run hf.co/unsloth/Nanonets-OCR-s-GGUF:UD-Q4_K_XL
- Unsloth Studio
How to use unsloth/Nanonets-OCR-s-GGUF with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for unsloth/Nanonets-OCR-s-GGUF to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for unsloth/Nanonets-OCR-s-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for unsloth/Nanonets-OCR-s-GGUF to start chatting
- Atomic Chat new
- Docker Model Runner
How to use unsloth/Nanonets-OCR-s-GGUF with Docker Model Runner:
docker model run hf.co/unsloth/Nanonets-OCR-s-GGUF:UD-Q4_K_XL
- Lemonade
How to use unsloth/Nanonets-OCR-s-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull unsloth/Nanonets-OCR-s-GGUF:UD-Q4_K_XL
Run and chat with the model
lemonade run user.Nanonets-OCR-s-GGUF-UD-Q4_K_XL
List all available models
lemonade list
Fixed Nanonets GGUFs!
Hey guys we reuploaded the GGUFs with some llama.cpp and chat template fixes which should drastically improve performance.
Example:
Extract the text from the above document as if you were reading it naturally. Return the tables in html format. Return the equations in LaTeX representation. If there is an image in the document and image caption is not present, add a small description of the image inside the <img></img> tag; otherwise, add the image caption inside <img></img>. Watermarks should be wrapped in brackets. Ex: <watermark>OFFICIAL COPY</watermark>. Page numbers should be wrapped in brackets. Ex: <page_number>14</page_number> or <page_number>9/22</page_number>. Prefer using β and β for check boxes.
For llama.cpp do you recommend the following parameters or they are recommend for ollama only
{
"temperature": 0.0,
"min_p" : 0.01,
"repeat_penalty" : 1.0
}
For llama.cpp do you recommend the following parameters or they are recommend for ollama only
{
"temperature": 0.0,
"min_p" : 0.01,
"repeat_penalty" : 1.0
}
I'm not sure what nanonets officially recommends
For old version output was okay but never as their announcement. I was using Q6 XL.
For me new version is far worse that old one. For new release I tried Q6 XL and Q8 XL. New version started looping it self when it tries to create HTML table. Also in new version system prompt is not passed even if using --jinja. So I have been putting the prompt as agent.
following are my settings. I also tried sampling parameters mentioned in my above post.
llama.cpp b5757 vulkan backend
${llama-cpp}
-m /home/tipu/.lmstudio/models/unsloth/Nanonets-OCR/Nanonets-OCR-s-UD-Q6_K_XL.gguf
--mmproj /home/tipu/.lmstudio/models/unsloth/Nanonets-OCR/nanonets-mmproj-F16.gguf
--jinja
-n -1
-ngl 99
--repeat-penalty 1.05
--temp 0.0
--top-p 1.0
--min-p 0.0
--top-k -1
-t 4
--no-webui
-a Nanonets-OCR
-c 10240
--no-context-shift
--mlock
--seed 3502
--swa-full
I tried the model via llama.cpp. While it gives nice results for text-only, image encoding and decoding takes a lot of time per request (300s)
Any idea how to accelerate text + Image instructions?
I tried the model via llama.cpp. While it gives nice results for text-only, image encoding and decoding takes a lot of time per request (300s)
Any idea how to accelerate text + Image instructions?
Can you give me your llama.cpp version and settings. For me it is not working okay on llama.cpp server but on lmstudio it works fine.