llm-checker

repository·main·Indexed 25 days ago

https://github.com/signerless/llm-checker

An AI-powered CLI tool (v3.7.6) that analyzes system hardware (VRAM, memory bandwidth, etc.) to recommend optimal local LLM models from Hugging Face, Ollama, and GPT4All. It features an AI model selector, hardware detection, calibration workflows for routing policies, and a built-in Model Context Protocol (MCP) server for integration with assistants like Claude Code.

Tokens
26.5K
Snippets
59
Records
176
Agent score
83%

What's inside llm-checker

  1. Understand the LLM Checker Architecture

    main

    LLM Checker is composed of a CLI interface (enhanced_cli.js) that interacts with a main engine (src/index.js). The engine coordinates three primary subsystems:

    1. Hardware Detection: Analyzes CPU, RAM, and GPU to determine hardware tiers and performance capabilities.
    2. AI Model Selector: Uses a mathematical 5-factor scoring algorithm to rank models based on hardware and user preferences.
    3. Model Database: A collection of 15+ models containing technical characteristics and scoring data.

    The system also includes an Ollama Integration for client-side interaction and scraping.

  2. Use Calibrated Routing in `recommend` and `ai-run`

    main

    You can use calibration routing policies generated by calibrate --policy-out to steer model selection.

    • Use the --calibrated [file] flag to specify a policy file. If the file is omitted, it defaults to ~/.llm-checker/calibration-policy.{yaml,yml,json}.
    • The --policy <file> flag takes precedence over --calibrated.

    Resolution Precedence:

    1. --policy (explicit)
    2. --calibrated (explicit file or default discovery)
    3. deterministic selector fallback
    llm-checker recommend --calibrated --category coding
    llm-checker recommend --calibrated ./calibration-policy.yaml --category reasoning
    llm-checker ai-run --calibrated --category coding --prompt "Refactor this function"
    llm-checker ai-run --policy ./calibration-policy.yaml --prompt "Summarize this report"
  3. Initialize and update the local model database

    main

    On the first run, llm-checker automatically copies a packaged snapshot (models.db) to ~/.llm-checker/models.db. To maintain this database after the initial setup, use the following commands:

    • Use llm-checker sync to update your local Ollama copy.
    • Use llm-checker registry-sync to refresh the multi-source registry in your local copy (which includes artifacts from Hugging Face, Ollama, and GPT4All).
    llm-checker sync
    llm-checker registry-sync
  4. Use the Interactive CLI Panel

    main

    Running llm-checker with no arguments opens an interactive TTY terminal panel. This is useful for manual exploration without remembering specific flags.

    Navigation:

    • Use up/down arrows to select a command.
    • Type / to open the full command list.
    • Press Enter to execute the selected command.
    • You can add optional extra flags before running a command (e.g., --json --limit 5).
    llm-checker
  5. How the Intelligent Selector Algorithm works

    main

    The selection process follows a five-step flow to determine the best model for a user's specific hardware and needs:

    1. Hardware Analysis: Analyzes the system's CPU, RAM, and GPU.
    2. Model Scoring: Calculates a score for every available model using a 5-factor system.
    3. Ranking & Selection: Sorts models by score.
    4. Confidence Calculation: Determines how certain the selection is based on hardware analysis.
    5. Reasoning Generation: Produces a human-readable explanation for the recommendation.

    The scoring is weighted as follows:

    • Memory Efficiency (35%): Penalizes models that exceed available RAM.
    • Performance Match (25%): Matches CPU/GPU capabilities against model requirements.
    • Task Optimization (20%): Matches model specialization (e.g., 'coding') to user preference.
    • Quality/Popularity (15%): Combines community quality and adoption scores.
    • Resource Efficiency (5%): Considers inference speed and thermal constraints.
  6. Optimize performance for specific GPU architectures

    main

    Use architecture-specific flags and environment variables to ensure LLM Checker utilizes the correct backend (Metal for Apple Silicon, CUDA for NVIDIA, or OpenCL for AMD).

    # Apple Silicon (M1/M2/M3)
    export LLAMA_METAL=1
    
    # NVIDIA GPUs
    llm-checker check --gpu-acceleration cuda
    
    # AMD GPUs
    export LLAMA_OPENCL=1
  7. Set up LLM Checker as a Claude Code MCP server

    main

    LLM Checker includes a built-in Model Context Protocol (MCP) server that allows Claude Code and other MCP-compatible assistants to analyze your hardware and manage local models.

    To set it up, you can use one of the following methods:

    Method 1: Global Install (Recommended)

    1. Install the package globally: npm install -g llm-checker
    2. Add it to Claude Code: claude mcp add llm-checker -- llm-checker-mcp

    Method 2: Using npx (No global install required) claude mcp add llm-checker -- npx llm-checker-mcp

    Method 3: Automatic Setup Command You can generate the exact command for your environment by running: llm-checker mcp-setup

    After running the command, restart Claude Code to complete the integration.

    # Install globally first
    npm install -g llm-checker
    
    # Add to Claude Code
    claude mcp add llm-checker -- llm-checker-mcp
  8. Collect Benchmark Data and Train AI Model

    main

    To improve the model's accuracy or generate a new model, you can collect performance benchmarks and then run the training pipeline. If your environment uses python3 instead of python, execute the scripts directly from the ml-model directory.

    # Using npm scripts
    npm run benchmark
    npm run train-ai
    
    # Using python3 directly if 'python' is not found
    cd ml-model
    python3 python/benchmark_collector.py
    python3 python/train_model.py
  9. Install LLM Checker

    main

    You can install LLM Checker globally via npm or run it directly using npx.

    Requirements:

    • Node.js 16 or higher
    • Ollama installed for running models

    Note on optional dependencies: If database commands report sql.js is missing, reinstall with the --include=optional flag to ensure the SQLite-powered catalog is available.

    Termux (Android) Installation:

    pkg update
    pkg install ollama
    npm install -g llm-checker
    # Install globally
    npm install -g llm-checker
    
    # Or run directly with npx
    npx llm-checker hw-detect
    
    # If database commands fail due to missing sql.js:
    npm install -g llm-checker --include=optional
  10. Implement Enterprise Policy Enforcement

    main

    Manage model governance using policy files:

    • policy init: Generates a policy.yaml template.
    • policy validate: Validates a policy file against the schema.
    • audit export: Evaluates policy outcomes and exports compliance reports in json, csv, or sarif formats.

    Policy Enforcement in check and recommend

    Both check and recommend support the --policy <file> flag:

    • Audit mode: Policy violations are reported, but the command exits with 0.
    • Enforce mode: Blocking violations return a non-zero exit code (default 1). You can override this using enforcement.exit_code in your policy.yaml.

    Policy Audit Export

    Use audit export to generate machine-readable compliance evidence for CI/CD or security tooling.

    • --command check|recommend: Chooses the candidate source.
    • --format all: Exports all configured formats (defaults to json,csv,sarif).
    • --out-dir <dir>: Specifies the output directory.
    # Single report format
    llm-checker audit export --policy ./policy.yaml --command check --format json --out ./reports/check-policy.json
    
    # Export all configured formats (json, csv, sarif)
    llm-checker audit export --policy ./policy.yaml --command check --format all --out-dir ./reports
  11. Execute the Calibration Workflow

    main

    To implement deterministic routing based on your own calibration artifacts, follow this workflow:

    1. Prepare a calibration suite (e.g., a .jsonl file).
    2. Run calibrate to generate a calibration contract and a routing policy.
    3. Use the generated policy with recommend or ai-run using the --calibrated flag.

    Flag Precedence:

    • --policy <file> overrides --calibrated [file].
    • --calibrated (without a path) automatically loads ~/.llm-checker/calibration-policy.{yaml,yml,json}.
    # Generate calibration contract + routing policy
    llm-checker calibrate \
      --suite ./sample-suite.jsonl \
      --models qwen2.5-coder:7b llama3.2:3b \
      --runtime ollama \
      --objective balanced \
      --dry-run \
      --output ./artifacts/calibration-result.json \
      --policy-out ./artifacts/calibration-policy.yaml
    
    # Route recommend/ai-run through calibrated policy
    llm-checker recommend --calibrated ./artifacts/calibration-policy.yaml --category coding
    llm-checker ai-run --calibrated ./artifacts/calibration-policy.yaml --category coding --prompt "Refactor this function"
  12. Find and run coding assistant models

    main

    For developers needing coding assistance, you can compare specific models, browse models in the coding category, or run a quick coding session.

    Use the --calibrated flag with ai-run to enable a calibrated routing policy (auto-discovery) which considers model specialization, context length, and performance benchmarks.

    # Compare coding-specific models
    llm-checker ai-check --models codellama:7b deepseek-coder:6.7b starcoder:7b
    
    # Browse all coding models
    llm-checker list-models --category coding
    
    # Quick coding session
    llm-checker ai-run --prompt "Help me write a Python function to parse JSON"
    
    # Quick coding session with calibrated routing policy (auto-discovery)
    llm-checker ai-run --calibrated --category coding --prompt "Help me write a Python function to parse JSON"