Accelerate local model execution by reducing VRAM prefill workload.
Compress input prompts for local models (Llama 3, DeepSeek-R1, Qwen 2.5) running on Ollama.
Install LLMSlim and the official Ollama SDK using your package manager:
pip install llmslim ollama1. User sends prompt to local backend application.
2. LLMSlim executes 100% offline CPU compression (< 20ms).
3. Forward compressed text to local Ollama daemon.
Complete, runnable implementation wrapper for Ollama:
import ollama
from llmslim import compress
prompt = "Long system instructions... " + "Context detail... " * 50
# Compress prompt locally without external API calls
slim_prompt = compress(prompt, target_ratio=0.4).compressed_text
response = ollama.chat(
model="llama3.2",
messages=[{"role": "user", "content": slim_prompt}]
)
print(response['message']['content'])| Metric Dimension | Uncompressed Payload | LLMSlim Compressed | Recorded Impact |
|---|---|---|---|
| Local Context Payload | 5,000 tokens | 2,000 tokens | 60% VRAM Prefill Reduction |
No. Core LLMSlim runs entirely offline using local Python algorithms.