AI in pendrive
A lightweight, secure AI environment that runs from a pendrive without installation
Building JARVIS-on-a-Stick requires a "Swiss Army Knife" approach to software: every component must be portable, relative-pathed, and optimized for the slower I/O speeds of USB flash storage.
Here is a detailed breakdown of the architecture and the logic that makes it work.
Phase 1: The "Ghost" Environment (WinPython)
Traditional Python installs itself into the Windows Registry. For a USB project, we use WinPython or the Python Embedded Package.
The Logic: These distributions are "zero-footprint." They live entirely in one folder.
Path Isolation: You must use a
launch.batfile to tell the computer, "Forget your system settings; use the Python inside this folder."Key Command: ```batch
SET PATH=%~dp0Python-Embedded;%~dp0Python-Embedded\Scripts;%PATH%
*(The `%~dp0` variable is magic: it automatically finds the drive letter (D:, E:, etc.) of the USB drive on any computer.)*
Phase 2: The Brain (Quantized LLMs)
You cannot run a 40GB model from a USB drive; the "Read" speed would take 20 minutes just to start.
GGUF Format: We use Llama.cpp (the engine) and GGUF (the model format). These are optimized to run on standard CPUs without needing an expensive NVIDIA graphics card.
Quantization: We use "4-bit" versions. This compresses a massive model into a 2GB–4GB file.
The Best Fits: * Llama-3.2-3B: The current gold standard for speed vs. intelligence.
Phi-3 Mini: Extremely logical, great for following automation commands.
Phase 3: The Senses (Offline Voice)
Most AI assistants (Siri, Alexa) send your voice to a server. JARVIS-on-a-Stick does not.
Hearing (STT): We use Vosk. It’s a 50MB library that converts speech to text in real-time on your CPU. It doesn't need an internet connection.
Speaking (TTS): We use pyttsx3. This hooks into the "SAPI5" voices already built into every Windows computer. It's instant and requires zero extra storage.
Phase 4: The Hands (Function Calling)
This is what makes it "JARVIS." Instead of just chatting, the AI can execute code.
The Prompt: We tell the AI: "You are a system controller. If the user asks to open a file, output exactly
{"action": "open", "target": "notepad"}."The Parser: A small Python script sits between you and the AI. If it sees that JSON bracket, it stops the text and triggers a Python command:
Python
if action == "open":
os.startfile(target)The Loop: JARVIS performs the action, then says, "Done. I've opened Notepad for you."
The Final Folder Structure
This is the "blueprint" you should follow on your USB drive:
FolderContent/env/The portable Python binaries (WinPython)./models/Your .gguf files (Llama-3, Phi-3)./core/Your main jarvis.py logic and automation scripts./tools/Small .exe helpers like ffmpeg (for audio).launch.batThe double-click file that starts the whole system.
USB Bottleneck: The biggest enemy is the "Read" speed.
Cheap USB 2.0: Will take 60+ seconds to "load" the brain.
USB 3.1/3.2: Loads the brain in 5–10 seconds.
Recommendation: Use a SanDisk Extreme Pro or a Portable NVMe SSD.