local llm image understanding using GLM OCR
GLM OCR is pretty lightweight and fit for purpose when i tried it out on invoice images. Here is the code for setting up and running it locally. """ Extract line items from an invoice image using a local model served at http://localhost:8888/v1, called through LiteLLM. Setup: pip install litellm pydantic export LOCAL_API_KEY="your-local-server-key" Usage: python extract_invoice_local.py invoice.jpg """ import base64 import json import mimetypes import os import re import sys from typing import Optional import litellm from pydantic import BaseModel # Same settings as your LiteLlm config --------------------------------------- MODEL = "openai/ggml-org/GLM-OCR-GGUF" API_BASE = "http://localhost:8888/v1" API_KEY = "sk-unsloth-4d0a1b198bd177a2a72ee1954585342a" # keep the key out of source code TEMPERATURE = 0.0 # Ask the server to constrain output to the schema (llama.cpp-based server...