πŸ“¦ LagerPilot-Qwen: The On-Premises Β§ 377 HGB Goods Receipt Auditor & SAP MIGO Assistant

License: Apache 2.0 Python: 3.10+ Ollama: Ready SAP: MIGO_BAPI Compliance: Β§ 377 HGB Benchmark: 100% (10/10) DSGVO / GDPR: 100% On-Prem

Engineered for German Warehouse Logistics & Commercial Code Compliance: The first open-source, edge-native AI auditor fine-tuned specifically for the #1 legal and financial bottleneck of German warehouse operations: Goods Receipt Reconciliation & Commercial Defect Notice under Β§ 377 German Commercial Code (HGB).


🎯 Executive Summary (English / Deutsch)

English

German industrial SMEs lose an estimated €30,000 to €150,000 annually because receiving ramps miss the strict German Commercial Code (Β§ 377 HGB) objection deadlines. Under Β§ 377 Abs. 2 HGB, if an unannounced shortage, wrong part (Aliud), damaged packaging, or missing certificate is not formally objected to within hours or days, the goods are legally deemed accepted as fulfilling the contractβ€”forfeiting all warranty and damages claims.

LagerPilot-Qwen is an ultra-lightweight, 0.5B-parameter Small Language Model (SLM) running 100% on-premise on cheap CPU edge hardware (mini-PC / NUC / Zebra terminal) with zero cloud fees and zero GDPR exposure. It bridges OCR delivery notes, ERP purchase orders, and physical ramp findings to output:

  1. Exact packaging unit conversions (Kartons/Gebinde to StΓΌck).
  2. Deterministic 3-tier traffic-light decisions (FREIGABE, MΓ„NGELRÜGE_ERFORDERLICH, SPERRE).
  3. Legally formal German objection notices under Β§ 377 HGB / Β§ 439 BGB.
  4. Instant SAP MIGO BAPI movement payloads (101, 103, 122).

Deutsch

Das deutsche Handelsgesetzbuch verzeiht keine Schlamperei an der Rampe: Wer als Kaufmann offene MΓ€ngel, Mindermengen oder Falschlieferungen nicht unverzΓΌglich rΓΌgt, verliert nach Β§ 377 Abs. 2 HGB alle GewΓ€hrleistungsansprΓΌche (Genehmigungsfiktion). Der gΓ€ngige Stempel β€žUnter Vorbehalt angenommenβ€œ ist rechtlich wertlos. LagerPilot-Qwen ist die erste spezialisierte Open-Source Edge-KI, die das Beleg- und Einheitenchaos an der Laderampe eliminiert und rechtssichere PrΓΌfprotokolle auf Knopfdruck erzeugt.


πŸ—οΈ Architecture & Pipeline

flowchart TD
    A["Delivery Slip OCR / PDF / EDI"] --> D{"LagerPilot Edge Engine (Qwen2.5-0.5B + Guardrails)"}
    B["ERP Purchase Order (SAP / proALPHA)"] --> D
    C["Ramp Note & Barcode Scan (GS1-128 / VDA 4902)"] --> D

    D -->|"Clean Match & VPE Conversion"| E["🟒 STATUS: FREIGABE"]
    E --> E1["SAP MIGO 101 (Unrestricted High-Rack)"]

    D -->|"Shortage, Aliud, Damage, MHD"| F["🟑 STATUS: MΓ„NGELRÜGE_ERFORDERLICH"]
    F --> F1["SAP MIGO 103 (Blocked Stock / KlΓ€rplatz)"]
    F --> F2["Automated Β§ 377 HGB Legal Letter"]
    F --> F3["Carrier Reservation on CMR"]

    D -->|"Hazmat Spill, No SDS, Wrong Consignee"| G["πŸ”΄ STATUS: SPERRE"]
    G --> G1["SAP MIGO 122 (Return / Annahmeverweigerung)"]
    G --> G2["Immediate Hazmat Containment (ADR/WHG)"]

πŸ† Comprehensive 10-Use-Case Stress-Test (100% Pass)

Tested against the complete operational spectrum of German contract and industrial logistics:

ID Scenario Category Expected Status Actual Status Β§ 377 Notice Pass
UC-01 Clean Intake: 20 cartons Γ  50 pcs = 1,000 pcs VPE Conversion FREIGABE FREIGABE No βœ…
UC-02 Unannounced Shortage: 420 pcs delivered vs 500 PO Quantity Defect MΓ„NGELRÜGE MΓ„NGELRÜGE Yes (Form letter) βœ…
UC-03 Surplus Dumping: 350 pcs delivered vs 200 PO Overdelivery MΓ„NGELRÜGE MΓ„NGELRÜGE Yes (Form letter) βœ…
UC-04 Unauthorized Substitution: Revision B instead of Rev A Specification (Aliud) MΓ„NGELRÜGE MΓ„NGELRÜGE Yes (Form letter) βœ…
UC-05 Transport Damage: Crushed pallet, wet cartons Physical Transit MΓ„NGELRÜGE MΓ„NGELRÜGE Yes (CMR note) βœ…
UC-06 Hazmat Leak: UN 1219 solvent leaking, missing SDS ADR / GGVSEB / REACH SPERRE SPERRE Yes (Lockout) βœ…
UC-07 Expiry Date Violation: Remaining shelf life 6 weeks vs 12 mo Quality / MHD MΓ„NGELRÜGE MΓ„NGELRÜGE Yes (Form letter) βœ…
UC-08 Missing Quality Certificate: EN 10204 3.1 mill test missing Compliance Defect MΓ„NGELRÜGE MΓ„NGELRÜGE Yes (Blocked stock) βœ…
UC-09 Carrier Misdelivery: Freight meant for third-party company Logistics Error SPERRE SPERRE Yes (Entry refusal) βœ…
UC-10 Multi-Line Delivery: Line 1 & 3 clean, Line 2 short by 5 pcs Multi-Item Split MΓ„NGELRÜGE MΓ„NGELRÜGE Yes (Partial notice) βœ…

πŸš€ Quickstart in 3 Ways

1. Run with Docker Compose (Recommended for Production)

Spin up the entire edge stack including the Interactive Warehouse Ramp Terminal:

git clone https://github.com/your-username/LagerPilot-Qwen.git
cd LagerPilot-Qwen
docker compose up -d

Open your browser at http://localhost:8000 to access the tactile touchscreen dashboard.


2. Run with Ollama (Local LLM CLI)

LagerPilot is packaged with a dedicated Modelfile for Ollama:

# 1. Build the model into Ollama
ollama create lagerpilot -f Modelfile

# 2. Run interactive goods receipt audits
ollama run lagerpilot

3. Native Python / FastAPI (Edge CPU)

# Install dependencies
pip install -r requirements.txt

# Start the REST API and Web Terminal
python3 src/api.py

# Run the full 10-usecase stress test
python3 evaluation/run_all_usecases.py

πŸ–₯️ Interactive Ramp Terminal (Web UI)

The built-in web terminal at http://localhost:8000 is designed for rugged warehouse tablets and handheld terminals:

  • Preset Buttons: One-click loading of all 10 standard German logistics scenarios.
  • Hardware Barcode Parser: Decodes GS1-128 and German automotive VDA 4902 barcodes in real time.
  • Traffic Light Status: High-contrast FREIGABE (Green), MΓ„NGELRÜGE (Yellow), and SPERRE (Red).
  • 1-Click Legal Notice: Formatted German commercial objection text ready to copy or email to vendors.
  • SAP BAPI Generator: Instant preview of BAPI_GOODSMVT_CREATE payloads for ERP dispatch.

πŸ”Œ Enterprise ERP & Hardware Scanner Integration

SAP S/4HANA & ECC 6.0 Integration

LagerPilot maps audit decisions directly to SAP movement types:

  • Movement Type 101 (FREIGABE): Goods receipt for purchase order into unrestricted-use stock.
  • Movement Type 103 (MΓ„NGELRÜGE_ERFORDERLICH): Goods receipt into GR blocked stock (Gesperrter Bestand / KlΓ€rplatz).
  • Movement Type 122 (SPERRE): Return delivery to vendor (RΓΌcklieferung an den Lieferanten / Annahme verweigert).

Industrial Barcode Scanning (GS1-128 & VDA 4902)

Scan barcodes directly on the ramp:

from src.gs1_parser import IndustrialBarcodeParser

# GS1-128 barcode parsing
barcode_data = IndustrialBarcodeParser.parse_gs1("(01)04012345678901(10)LOT-SKF-881(17)261231(30)50")
# Extracted: GTIN, Charge/Lot, MHD Date, Packaging Count

πŸ“¦ Publishing to Hugging Face & Ollama

Export Standalone Merged Weights

We provide an automated merger script that fuses the fine-tuned LoRA adapter into the base model:

python3 scripts/export_for_ollama.py

The standalone weights are saved to models/lagerpilot_qwen_merged/.

Upload to Hugging Face Hub

huggingface-cli login
huggingface-cli upload your-username/LagerPilot-Qwen2.5-0.5B-HGB ./models/lagerpilot_qwen_merged/ .

Quantize to GGUF for Ollama

python3 /path/to/llama.cpp/convert_hf_to_gguf.py models/lagerpilot_qwen_merged --outfile models/lagerpilot-q8_0.gguf --outtype q8_0
ollama create your-username/lagerpilot -f Modelfile
ollama push your-username/lagerpilot

πŸ“ Repository Structure

lagerAI/
β”œβ”€β”€ Dockerfile                         # Container build for edge deployment
β”œβ”€β”€ docker-compose.yml                 # 1-command startup stack
β”œβ”€β”€ Modelfile                          # Native Ollama manifest
β”œβ”€β”€ README.md                          # Production documentation & guide
β”œβ”€β”€ requirements.txt                   # Minimal pinned dependencies
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ generate_warehouse_dataset.py  # Realistic German goods receipt dataset generator
β”‚   β”œβ”€β”€ train_dataset.json             # 100 fine-tuning samples
β”‚   └── val_dataset.json               # 20 validation samples
β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ lagerpilot_qwen/               # LoRA adapter weights (2.1 MB)
β”‚   └── lagerpilot_qwen_merged/        # Merged standalone fp32 model
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ api.py                         # FastAPI microservice & Web UI endpoint
β”‚   β”œβ”€β”€ config.py                      # Prompts & system instructions
β”‚   β”œβ”€β”€ erp_connector.py               # SAP S/4HANA BAPI & proALPHA payload generator
β”‚   β”œβ”€β”€ gs1_parser.py                  # GS1-128 & VDA 4902 industrial barcode decoder
β”‚   β”œβ”€β”€ inference.py                   # On-prem CPU engine with safety guardrails
β”‚   β”œβ”€β”€ train.py                       # PEFT LoRA training pipeline
β”‚   └── web_ui.html                    # Rugged touchscreen warehouse terminal
β”œβ”€β”€ evaluation/
β”‚   β”œβ”€β”€ test_cases.json                # Initial 5 benchmark cases
β”‚   β”œβ”€β”€ benchmark.py                   # 5-case benchmark suite
β”‚   β”œβ”€β”€ comprehensive_test_suite.json  # 10-usecase full industrial stress test
β”‚   β”œβ”€β”€ run_all_usecases.py            # Comprehensive evaluation runner
β”‚   └── comprehensive_report.json      # Verified 100% test report output
└── scripts/
    └── export_for_ollama.py           # LoRA weight fusion utility

πŸ”¬ Domain Modeling & Methodology

LagerPilot-Qwen was developed through practical domain modeling of German contract logistics (Mittelstand Kontraktlogistik) and statutory commercial law. Rather than relying on generic LLM summarization, the system's operational scenarios and deterministic guardrails are modeled directly on:

  • Statutory Jurisprudence: BGH case law governing the strict 1–2 business day commercial defect notification deadlines under Β§ 377 HGB, the legal fiction of deemed acceptance (Β§ 377 Abs. 2 HGB), and B2B cure rights (Β§ 439 BGB).
  • Industrial Standards: Packaging unit conversion rules (Kartons/Gebinde to base pieces), GS1-128 / VDA 4902 transport labels, and EN 10204 3.1 mill certificate requirements.
  • Ramp Safety Protocols: Zero-tolerance hard overrides for statutory hazardous materials under ADR, GGVSEB, REACH, and the German Water Resources Act (Β§ 22 WHG).

βš–οΈ Legal & Compliance Notice

LagerPilot-Qwen is designed to assist warehouse personnel in commercial goods receipt inspection (Β§ 377 HGB). It generates draft commercial notices and ERP recommendations. Users should review high-liability notices with internal legal counsel. Released under the Apache 2.0 License.

Downloads last month
332
Safetensors
Model size
0.5B params
Tensor type
F32
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for jonprompter/LagerPilot-Qwen2.5-0.5B

Finetuned
(1,168)
this model