Instructions to use Keyven/german-ocr-3.1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use Keyven/german-ocr-3.1 with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="Keyven/german-ocr-3.1", filename="german-ocr-3.1-F16.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 Keyven/german-ocr-3.1 with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf Keyven/german-ocr-3.1:Q4_K_M # Run inference directly in the terminal: llama cli -hf Keyven/german-ocr-3.1:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf Keyven/german-ocr-3.1:Q4_K_M # Run inference directly in the terminal: llama cli -hf Keyven/german-ocr-3.1:Q4_K_M
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 Keyven/german-ocr-3.1:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf Keyven/german-ocr-3.1:Q4_K_M
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 Keyven/german-ocr-3.1:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf Keyven/german-ocr-3.1:Q4_K_M
Use Docker
docker model run hf.co/Keyven/german-ocr-3.1:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use Keyven/german-ocr-3.1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Keyven/german-ocr-3.1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Keyven/german-ocr-3.1", "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/Keyven/german-ocr-3.1:Q4_K_M
- Ollama
How to use Keyven/german-ocr-3.1 with Ollama:
ollama run hf.co/Keyven/german-ocr-3.1:Q4_K_M
- Unsloth Studio
How to use Keyven/german-ocr-3.1 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 Keyven/german-ocr-3.1 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 Keyven/german-ocr-3.1 to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Keyven/german-ocr-3.1 to start chatting
- Atomic Chat new
- Docker Model Runner
How to use Keyven/german-ocr-3.1 with Docker Model Runner:
docker model run hf.co/Keyven/german-ocr-3.1:Q4_K_M
- Lemonade
How to use Keyven/german-ocr-3.1 with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Keyven/german-ocr-3.1:Q4_K_M
Run and chat with the model
lemonade run user.german-ocr-3.1-Q4_K_M
List all available models
lemonade list
JSON-Ausgabe unbrauchbar - was mache ich falsch?
Hallo Keyvan,
ich bin Neuling beim Thema lokale KI und habe jetzt mal dein Modell nach deiner Anleitung mit llama-server ausprobiert. Die Ergebnisse sind mangelhaft und inkonsistent. Ich vermute, ich mache irgendwo einen Fehler.
Mein Setup:
- Hardware: AMD Ryzen 7500F, 16GB RAM, GPU Intel Arc Pro B60 24GB VRAM
- Software: Windows 11, Intel AI Playground
Intel AI Playground verwendet (optional) als eine seiner Komponenten llama.cpp. Das habe ich zur Nutzung deines Modells verwendet.
Mein Vorgehen:
- Modell herunterladen (german-ocr-3.1-Q8_0.gguf)
- MMPROJ-Datei herunterladen (mmproj-german-ocr-3.1-F16.gguf)
- llama-server starten ( llama-server -m german-ocr-3.1-Q8_0.gguf --mmproj mmproj-german-ocr-3.1-F16.gguf --port 8080 -ngl 99)
- http://localhost:8080 aufrufen
- gut aufgelösten Screenshot einer einfachen einseitigen Rechnung hochgeladen + Prompt "Extrahiere als JSON"
Das Ergebnis ist JSON-artig. Allerdings kaputt (ein JSON-Validator zeigt Fehler) und gar nicht in der strukturierten Form , wie auf deiner Modellseite angegeben.
Die extrahierten Daten an sich sind fast alle korrekt, aber unvollständig.
Hier ein Beispiel einer Ausgabe:
{
"Rechnung": {
"Rechnungsnummer": "R12233455",
"Kundennummer": "D12345",
"Angebotsnummer": "445566",
"Leistungsdatum": "20.01.2025",
"Datum": "23.01.2025"
},
"Rechnung": {
"Bahnhof Schildburghausen - Reinigungsarbeiten",
"Position": "1",
"Art-Nr.": "CLE",
"Artikel": "Reinigung des Bahnsteiges",
"Anzahl": "1",
"Einheit": "Stck",
"Preis": "200,00",
"Gesamt": "200,00"
},
"Zahlungskonditionen": {
"Summe vor Steuern": "200,00",
"Umsatzsteuer": "19%",
"Gesamtbetrag": "238,00"
},
"Reinigung Cleantec": {
"Name": "Hans Saubermann",
"Adresse": "Wanderweg 13",
"Postleitzahl": "12345",
"Ort": "Wutzelwitz"
}
}
Was mache ich hier nicht richtig, hast du eine Idee?
Viele Grüße!
Raimo
Hallo Raimo,
Sorry für die späte Rückmeldung, ich schaue nur selten in die Hugging Face Discussions.
Kein Fehler bei dir, das ist ein Prompt-/Wrapper-Thema. German-OCR-3.1 liefert das saubere Schema-JSON nur, wenn sein System-Prompt aktiv ist. Der steckt im Chat-Template des Modells (sinngemäß: „…NUR ein einziges JSON-Objekt, null statt raten, festes Schema document_type / sender / recipient / line_items …"). Intel AI Playground nutzt aber seine eigene Prompt-Formatierung und lädt diesen System-Prompt nicht → das Modell free-styled → doppelte Keys, falsche Verschachtelung, unvollständig. Genau dein Output.
Drei Hebel, dann kommt das Schema von der Modellseite raus:
System-Prompt explizit setzen (geht auch im Playground): Trag ins System-/Instructions-Feld den German-OCR-System-Prompt ein (der vollständige Text steht in
chat_template.jinjaim Repo – beginnt mit „Du bist German-OCR-3.1 …").Temperatur = 0. Deine „Inkonsistenz" kommt von Sampling > 0 – für Extraktion immer greedy.
JSON per Schema erzwingen (garantiert valides JSON, keine doppelten Keys). Am saubersten über den stock
llama-server:
llama-server -m german-ocr-3.1-Q8_0.gguf --mmproj mmproj-german-ocr-3.1-F16.gguf \
-ngl 99 -c 32768 --temp 0 --jinja
--jinja lädt das Chat-Template inklusive System-Prompt automatisch. Danach per API response_format: {"type":"json_schema","json_schema": ...} mit dem Rechnungs-Schema verwenden – dann ist kaputtes JSON strukturell praktisch ausgeschlossen.
Wenn du magst, leg ich dir auch eine fertige schemas/invoice.json ins Repo (die habe ich bei German-OCR-3 bereits verwendet). Gib einfach Bescheid, ob es damit sauber funktioniert.
VG
Keyvan