Influence
Privacy-first local LLM inference - Download models from HuggingFace and run them entirely on your machine.
Why Influence?
The Problem: Most LLM tools require cloud APIs, expensive subscriptions, or complex Python setups. Your data leaves your machine, you pay per token, and you're locked into someone else's infrastructure.
The Solution: Influence gives you:
- Complete privacy - All inference happens locally on your machine
- No API costs - Pay once (in compute) and use forever
- No vendor lock-in - Models are downloaded to your disk
- Simplicity - Single binary, no Python, no virtual environments
- GPU acceleration - Metal (macOS) and CUDA (Linux/Windows) support with auto-detection
What Makes It Different?
| Feature | Influence | Ollama | vLLM | Cloud APIs (OpenAI, etc.) | Python Tools |
|---|---|---|---|---|---|
| Privacy | 100% local | 100% local | 100% local | Data sent to servers | Local but complex |
| Cost | Free (after download) | Free | Free | Pay per token | Free but complex setup |
| Setup | Single binary | Binary install | Python, pip, venv | API key required | Python, pip, venv |
| GPU Support | Metal (macOS), CUDA (Linux/Windows) | Metal/CUDA | CUDA only | Server-side | Hard to configure |
| Offline Use | Yes | Yes | Yes | No | Yes |
| Model Management | Built-in list & deploy commands | CLI | Manual | N/A | Manual setup |
| API Server | Built-in REST/SSE | Built-in REST | OpenAI-compatible API | N/A | Manual setup |
Quick Start
# Build from source
# Search for a model
# Download a model (~1GB for TinyLlama)
# Generate text locally (auto-detects GPU: Metal/CUDA or falls back to CPU)
Usage Examples
Example 1: Model Management
# List all downloaded models
# Search and download a model
# List again to see your downloaded model
Benefit: Easy model management with clear visibility of what's installed.
Example 2: Deploy and Serve
# Deploy a model as an API server
# In another terminal, test the API
Benefit: Quick deployment of local models as REST APIs for your applications.
Example 3: Quick Question Answering
# Ask a factual question
Benefit: Get instant answers without:
- Opening a browser
- Waiting for cloud API responses
- Paying per token
- Sending your queries to third parties
Example 2: Code Generation
# Generate code with higher temperature for creativity
Benefit: Generate code locally with:
- No rate limits
- No API keys to manage
- Full context control
- Works offline
Example 3: Content Creation
# Generate blog post or documentation
Benefit: Create content without:
- Using cloud services
- Exposing your ideas to third parties
- Worrying about content policies
Current Status
Working:
- Model search and download from Hugging Face
- Model management with
listanddeploycommands - Local inference with Llama-architecture models (including TinyLlama, Llama 2/3)
- GPU acceleration (Metal on macOS, CUDA on Linux/Windows)
- Streaming generation with fresh KV cache per request
- Enhanced interactive chat mode with slash commands and session persistence
/help,/clear,/save,/load,/history,/set,/quit- Session save/load (JSON format)
- Runtime parameter adjustment
- CLI UX improvements with streaming markdown rendering and syntax highlighting
- Configuration management with
configcommand - Web API server (REST + SSE streaming)
- Top-k, top-p sampling and temperature control
- Repetition penalty
- System prompt support
- Metal GPU warmup for reduced first-token latency
- Ollama-compatible API endpoints (
/api/generate,/api/embeddings,/api/tags) - GGUF model detection and metadata parsing (full inference coming soon)
Tested Models:
TinyLlama/TinyLlama-1.1B-Chat-v1.0- Working perfectly- Other Llama-architecture models - Supported
Installation
Build from Source
# Clone the repository
# Build release binary with Metal support (macOS)
# The binary will be at target/release/influence
Features:
metal(default) - Metal GPU acceleration for macOSaccelerate- CPU acceleration for macOScuda- CUDA support for NVIDIA GPUs on Linux/Windowsgguf- GGUF quantized model support (experimental)
Build with GGUF support:
Build without GPU:
GGUF (Quantized) Model Support
Influence now supports GGUF format models for reduced memory usage. GGUF models offer significant memory savings through quantization, making it possible to run larger models on hardware with limited RAM.
Current Implementation Status
β Working Now:
- GGUF file auto-detection (
.ggufextension) - Quantization format detection from filenames
- Metadata parsing (quantization type, file path)
- Architecture detection (prioritizes GGUF over safetensors)
- Comprehensive test coverage (7 GGUF-specific tests)
π§ In Development:
- Full GGUF inference engine integration
- Text generation with GGUF models
- Streaming support for GGUF models
Enabling GGUF Support
# Build with GGUF support
# With Metal GPU (macOS)
# With CUDA GPU (Linux/Windows)
# Run GGUF-specific tests
Supported Quantization Formats
GGUF models come in various quantization formats that trade off quality for memory efficiency:
| Format | Bit Width | Memory (7B model) | Quality | Use Case |
|---|---|---|---|---|
| Q2_K | 2-bit | ~2.5 GB | Lower | Maximum compression |
| Q4_K | 4-bit | ~4 GB | Good | Balanced option |
| Q4_K_M | 4-bit | ~4 GB | Good | Recommended - Best balance |
| Q5_K | 5-bit | ~5 GB | Better | High quality |
| Q5_K_M | 5-bit | ~5 GB | Better | High quality mixed |
| Q6_K | 6-bit | ~6 GB | Near-original | Excellent quality |
| Q8_0 | 8-bit | ~8 GB | Minimal loss | Maximum quality |
| F16 | 16-bit | ~14 GB | Original | No compression |
Where to Get GGUF Models
Popular sources for GGUF models:
-
TheBloke (HuggingFace) - Largest collection:
- https://huggingface.co/TheBloke
- Search:
TheBloke/Llama-2-7B-GGUF,TheBloke/Mistral-7B-Instruct-v0.2-GGUF
-
MaziyarPanahi (Quantized models):
- https://huggingface.co/maziyarpanahi
- Search:
maziyarpanahi/Llama-3-8B-GGUF
-
Bartowski (High-quality conversions):
- https://huggingface.co/bartowski
- Search:
bartowski/Meta-Llama-3.1-8B-Instruct-GGUF
Example download:
# Using wget
# Using huggingface-cli
Using GGUF Models
# Place a .gguf file in your models directory
# GGUF files are auto-detected by their .gguf extension
# The quantization format is automatically detected from the filename
# and logged: "Detected quantization: Q4_K_M"
Memory Comparison
For a 7B parameter model:
| Format | VRAM/RAM Required | File Size | Compression Ratio |
|---|---|---|---|
| FP16 (safetensors) | ~14 GB | ~14 GB | 1x (baseline) |
| Q8_0 | ~8 GB | ~8 GB | ~1.75x |
| Q6_K | ~6 GB | ~6 GB | ~2.3x |
| Q4_K_M | ~4 GB | ~4 GB | 3.5x |
| Q2_K | ~2.5 GB | ~2.5 GB | ~5.6x |
Key Benefit: Q4_K_M uses only 29% of the memory required for FP16 while maintaining good quality!
Technical Details
Detection Priority
When loading a model directory with both GGUF and safetensors files:
- GGUF files (
.gguf) are checked first - If found,
ModelArchitecture::LlamaQuantizedis detected - Falls back to
config.jsonfor safetensors models
This allows easy switching between formats by simply adding/removing GGUF files.
Quantization Format Detection
The quantization format is detected from the filename using these patterns:
q2_kβ Q2_Kq4_k_mβ Q4_K_M (checked beforeq4_k)q4_kβ Q4_Kq5_k_mβ Q5_K_M (checked beforeq5_k)q5_kβ Q5_Kq6_kβ Q6_Kq8_0β Q8_0f16β F16- Case-insensitive matching
Testing
GGUF functionality is thoroughly tested:
# Run all GGUF tests
# Run specific test
# Test GGUF file detection
# Run all tests (including GGUF)
Current test coverage:
- β Quantization format detection (11 formats)
- β GGUF file detection
- β Architecture detection with GGUF files
- β Multiple GGUF files handling
- β GGUF priority over safetensors
- β Feature flag validation
- β Backend metadata methods
Note: Full GGUF inference support is under active development. Currently, GGUF files are detected and their metadata is parsed. Complete generation support will be added in an upcoming release.
Configuration
Influence supports configuration via environment variables for convenience. Create a .env file in the project root:
# Edit .env with your preferred defaults
Available environment variables:
# Model Configuration
INFLUENCE_MODEL_PATH=./models/TinyLlama_TinyLlama-1.1B-Chat-v1.0
# Generation Parameters
INFLUENCE_TEMPERATURE=0.7
INFLUENCE_TOP_P=0.9
INFLUENCE_TOP_K=
INFLUENCE_REPEAT_PENALTY=1.1
INFLUENCE_MAX_TOKENS=512
# Device Configuration
INFLUENCE_DEVICE=auto
INFLUENCE_DEVICE_INDEX=0
# Server Configuration
INFLUENCE_PORT=8080
# Performance Tuning
INFLUENCE_WARMUP_TOKENS=6
# Download Configuration
INFLUENCE_MIRROR=https://hf-mirror.com
INFLUENCE_OUTPUT_DIR=./models
Priority: CLI arguments > Environment variables > Built-in defaults
Command Reference
search - Find Models on HuggingFace
Examples:
# Search for llama models
# Search with filters
# Search for small models
Options:
-l, --limit <N>- Max results (default: 20)-a, --author <ORG>- Filter by author
download - Download Model from HuggingFace
Examples:
# Download TinyLlama (recommended for testing)
# Download to custom location
# Use custom mirror
Options:
-m, --model <MODEL>- Model name (required)-r, --mirror <URL>- Mirror URL (default: hf-mirror.com)-o, --output <PATH>- Output directory (default: ./models/)
list - List Downloaded Models
Examples:
# List all models in the default models directory
# List models from a custom location
# See model details: format, architecture, size
Output shows:
- Model name
- File path
- Format (SafeTensors, GGUF with quantization)
- Architecture (llama, mistral, etc.)
- Size on disk
- File count
Options:
-m, --models-dir <PATH>- Custom models directory
deploy - Deploy Model Server
Examples:
# Deploy model with default settings (port 8080)
# Deploy on custom port with Metal GPU
# Deploy in background (detached mode)
Deploy starts:
- REST API server on the specified port
- SSE streaming endpoint
- Health check endpoint
- Ollama-compatible API endpoints
Options:
-m, --model-path <PATH>- Path to model directory (or use INFLUENCE_MODEL_PATH from .env)-p, --port <PORT>- Port to serve on (default: 8080)-d, --device <DEVICE>- Compute device: auto|cpu|metal|cuda (default: auto)--device-index <N>- GPU device index (default: 0)--detached- Run in background (detached from terminal)
After deployment, test with:
# Health check
# Generate text
# Chat completion (streaming)
generate - Generate Text Locally
Examples:
# Basic generation (with explicit model path)
# Or use .env configuration (set INFLUENCE_MODEL_PATH)
# With custom parameters
# Lower temperature for more focused output
Options:
-m, --model-path <PATH>- Path to model directory (required)--max-tokens <N>- Max tokens to generate (default: 512)--temperature <0.0-2.0>- Sampling temperature (default: 0.7)- Lower (0.1-0.3): More focused, deterministic
- Higher (0.7-1.0): More creative, diverse
chat - Interactive Chat Mode
Examples:
# Start interactive chat
# Chat with a system prompt
# Chat with custom parameters
# Load a previous chat session
# Auto-save session on exit
Chat Features:
Interactive chat mode includes powerful slash commands for session management:
| Command | Description |
|---|---|
/help |
Show all available commands |
/clear |
Clear conversation history (keeps system prompt) |
/history |
Display all messages in current session |
/save <filename> |
Save conversation to a JSON file |
/load <filename> |
Load conversation from a JSON file |
/set <param> <value> |
Change parameters during chat |
/quit or /exit |
Exit chat mode |
Runtime Parameter Adjustment:
Change parameters mid-conversation using /set:
Available parameters:
temperature- Sampling creativity (0.0-2.0)top_p- Nucleus sampling threshold (0.0-1.0)top_k- Top-k sampling limitrepeat_penalty- Repetition penalty (0.0-2.0)max_tokens- Maximum tokens per response
Session Management:
Save and resume conversations:
# During chat, save your session
# Later, resume the session
Session File Format:
Sessions are saved as JSON with complete conversation history:
Conversation History:
- Maintains full conversation context across turns
- Automatically keeps last 10 turns (20 messages) to manage memory
- System prompt is preserved when clearing or truncating
- View full history with
/historycommand
Options:
-m, --model-path <PATH>- Path to model directory (required)--system <PROMPT>- System prompt to set conversation context--max-tokens <N>- Max tokens per response (default: 512)--temperature <0.0-2.0>- Sampling temperature (default: 0.7)--top-p <0.0-1.0>- Top-p sampling threshold (default: 0.9)--top-k <N>- Top-k sampling limit (default: disabled)--repeat-penalty <0.0-2.0>- Repetition penalty (default: 1.1)-d, --device <DEVICE>- Compute device: auto|cpu|metal|cuda (default: auto)--device-index <N>- GPU device index (default: 0)--session <FILE>- Load chat session from file on startup--save-on-exit <FILE>- Auto-save session to file on exit
config - Show Configuration Settings
Examples:
# Show all current configuration settings
What it displays:
The config command shows all current configuration settings from environment variables and .env file:
-
Model Settings
- Model path
- Output directory
- Mirror URL
-
Generation Parameters
- Temperature
- Top-p (nucleus sampling)
- Top-k sampling
- Repeat penalty
- Max tokens
-
Device Settings
- Compute device (auto/cpu/metal/cuda)
- Device index
-
Server Settings
- Port
It also displays a helpful reference of all available environment variables that can be set in your .env file.
Options: None (takes no arguments)
Recommended Models
For Testing & Development
| Model | Size | Speed | Use Case |
|---|---|---|---|
TinyLlama/TinyLlama-1.1B-Chat-v1.0 |
~1GB | Fast | Testing, quick experiments |
microsoft/phi-2 |
~2GB | Medium | Quality vs speed balance |
mistralai/Mistral-7B-v0.1 |
~14GB | Slower | Production-quality output |
Why TinyLlama?
# Download and try TinyLlama first
Benefits:
- Fast downloads (~1GB)
- Quick inference (even on CPU)
- Good quality for many tasks
- Great for learning and experimentation
Benefits Over Alternatives
vs Cloud APIs (OpenAI, Anthropic, etc.)
You Save:
- Money - No per-token costs
- Privacy - Data never leaves your machine
- Latency - No network round-trips
- Reliability - Works offline
- Control - No rate limits or content policies
vs Python Tools (llama.cpp, transformers, etc.)
You Get:
- Simplicity - Single binary, no dependencies
- Performance - Rust speed with GPU acceleration
- Stability - No version conflicts or dependency hell
- Integration - Easy to script and automate
How It Works
βββββββββββββββ
β Your Promptβ
ββββββββ¬βββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββ
β Tokenization (HuggingFace) β
ββββββββ¬ββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββ
β Model Loading (.safetensors) β
β - Memory-mapped for efficiency β
β - GPU acceleration (Metal/CUDA) β
ββββββββ¬ββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββ
β Inference (Candle) β
β - Forward pass with KV cache β
β - Temperature-based sampling β
β - Token-by-token generation β
ββββββββ¬ββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββ
β Output Textβ
βββββββββββββββ
Technical Details
Ollama-Compatible API (partial)
When running influence serve, Influence also exposes a small subset of Ollama-compatible endpoints. This is intended to make it easier to integrate with tools that already speak Ollama, while keeping Influenceβs internal callflow minimal.
Supported:
POST /api/generate- Non-stream: returns JSON
- Stream: returns
application/x-ndjson(one JSON object per line)
POST /api/embeddings(BERT embeddings only)POST /api/tags(returns the currently served model name)
Notes / limitations:
- The
modelfield is currently accepted but not used to dynamically switch models (Influence serves one loaded model). - Some Ollama fields are ignored for now; only a small set of
optionsis mapped.
Model Requirements
Each model directory must contain:
config.json- Model architecture and parameterstokenizer.jsonortokenizer_config.json- Tokenizer*.safetensors- Model weights (memory-mapped)
Supported Architectures
- OK Llama (meta-llama/Llama-2-7b-hf, TinyLlama)
- OK Mamba (mamba family configs)
- OK GraniteMoeHybrid (attention-only configs)
- OK Encoder-only embeddings: BERT (
influence embed ...) - X Mixture of Experts (MoE) models (not yet supported)
- X GraniteMoeHybrid configs containing Mamba layers (not supported by candle-transformers yet)
Performance
Optimizations:
- KV Caching - Reuse computed tensors for faster generation
- Memory Mapping - Zero-copy model loading
- Streaming Output - Display tokens as they're generated
- GPU Acceleration - Metal support on macOS (enabled by default)
- Proper Token Spacing - Handles SentencePiece space markers correctly
Metal Warmup (macOS)
On macOS with Metal GPU, the first few decode steps can be significantly slower due to Metal kernel compilation overhead. To mitigate this, Influence automatically runs a small warmup (default: 6 decode steps) during model load to pre-compile kernels and reduce visible latency for the first generated tokens.
- Control warmup: Set
INFLUENCE_WARMUP_TOKENS=0to disable, or adjust the count (e.g.,INFLUENCE_WARMUP_TOKENS=10). - When it helps: Most noticeable with TinyLlama and similar models on Metal.
- Trade-off: Slightly longer model load time in exchange for faster first-token generation.
KV Cache Behavior
Influence creates a fresh KV cache for each generation request:
- Stateless generation: Each
generateor API call starts with a clean cache, ensuring predictable behavior. - No cross-request cache reuse: Currently, KV cache is not persisted across requests or chat turns.
- Memory efficient: Cache is automatically freed after each generation completes.
- Future enhancement: Session-based cache reuse for multi-turn conversations is planned to reduce redundant prefill computation.
Troubleshooting
Model Not Found Error
# Error: Model directory not found
# Solution: Check the model path exists
Missing Tokenizer Error
# Error: Tokenizer file not found
# Solution: Ensure these files exist in model directory:
# - tokenizer.json (or tokenizer_config.json)
# - config.json
# - *.safetensors files
Unsupported Architecture Error
# Error: Unsupported model architecture (Mamba/MoE)
# Solution: Use a supported model like TinyLlama
Slow Generation on CPU
# CPU inference is slower. Options:
# 1. Use a smaller model (TinyLlama instead of Mistral-7B)
# 2. Reduce max-tokens
# 3. Build with Metal support (macOS):
Development
Build with Debug Logging
RUST_LOG=influence=debug
Run Tests
Roadmap
Completed
- Streaming markdown renderer with syntax highlighting for code blocks
- CLI UX improvements with formatted output
- Configuration management with
configcommand - Security hardening and retry logic
- Comprehensive API documentation
- Model management with
listanddeploycommands - Interactive chat mode with slash commands and session persistence
- GGUF model detection and metadata parsing
- Embeddings support (BERT encoder-only models)
- Ollama-compatible API endpoints
- Metal GPU warmup for reduced first-token latency
In Progress
- Full GGUF inference engine integration (detection working, inference in development)
Planned
- Batch generation
- More quantization formats support
- Session-based KV cache reuse for multi-turn conversations
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Acknowledgments
Built with:
- Candle - ML framework by HuggingFace
- Tokenizers - Fast tokenization
- Clap - CLI parsing