Byte is an open-source, context-aware 3D desktop pet companion built natively for macOS using Swift and SceneKit. Operating as a transparent, interactive overlay above the macOS desktop, Byte interacts with your active windows, responds to physical gestures, listens to your voice offline, and exhibits dynamic emotional behaviors fine-tuned using local machine learning.
Unlike static desktop widgets, Byte runs a hybrid machine learning architecture:
- Q-Learning Action Brain (
ReinforcementLearningModel): Autonomous wandering, sleeping, perching, and idle state selections calculated via Bellman equation state-reward policies. - Local Empathy LLM (
byte-llm): Fine-tuned on 45,000+ open-source empathetic dialogue pairs (Meta AI's EmpatheticDialogues) using Apple Silicon MLX GPU acceleration. - On-Device Voice Subsystem: Offline speech recognition via Whisper STT and hyper-realistic speech synthesis via Kokoro TTS.
- Open-Source Fine-Tuning: Trained on 45,328 conversation pairs using Apple MLX Metal GPU LoRA fine-tuning.
- Dual Tag Output: Generates structured action-emotion predictions (
[ACTION: sitOnCorner] [EMOTION: cozy]) to seamlessly animate the 3D pet sprite alongside text dialogue. - Workplace Pacing: Detects deep coding sessions, long IDE typing, compiler errors, or evening hours to gently suggest hydration, stretch breaks, or posture checks.
- Speech-to-Text (STT): Local low-latency audio transcription using
faster-whisper(Port 9000). - Text-to-Speech (TTS): Natural speech output powered by Kokoro TTS (Port 8880).
- Privacy First: Zero cloud API dependencies; your voice audio and workspace state never leave your Mac.
- Custom Surface & Window Gravity: Byte walks along window frames, perches on the menu bar, and walks across the macOS Dock floor.
- Interactive Drag & Throw Physics: Click and toss Byte across your desktop with velocity, drag, friction, and bounce trajectory calculations.
- Camera Orbiting & Touch Controls: Rotate Byte 360ยฐ on the Y-axis using mouse trackpad scrolling or drag interactions.
- Accessibility API Integration (
AXUIElement): Reads active application names and window frame coordinates. - Screen Vision (
ByteVisionEngine+ Florence-2): Microsoft's Florence-2-Base model (Port 9005) reads on-screen text and UI regions on demand, so Byte can notice a compiler error or the file you're editing, not just which app is frontmost. - Media & Headphone Detection: Subscribes to
CoreAudioto detect output device changes and media playback (Apple Music, Spotify). - Real-Time Environment Adaptability: Synchronizes behavior with local weather and time of day (e.g. cozy night rest mode, rainy day umbrella state).
- PersonaPlex-7B (Port 9006): A dedicated FastAPI server for NVIDIA's PersonaPlex-7B full-duplex speech model is wired into the app's TTS pipeline.
- Status: the API surface (
/health,/prompt,/synthesize_speech,/ws/duplex) is live, but real model inference isn't implemented yet โ it currently serves placeholder audio and reportsis_mock: trueat/health. Byte transparently falls back to Kokoro or the system voice, so this never blocks normal use. Contributions welcome โ see backend/personaplex_server.py.
Byte is designed to feel like it's actually there with you, not a chatbot in a window. A few ways to build that up:
- Hold โ (Command) and talk. Byte listens, transcribes offline, and replies in character โ no typing required.
- Click, drag, and throw it. Byte reacts physically (and emotionally) to how you handle it.
- Just leave it running. The Q-learning brain wanders, perches, and
sleeps on its own between interactions, and the
ReflectionEnginequietly reviews your conversations while Byte "sleeps" to update what it remembers about you inmemory_graph.json. - Tell it about yourself. Mention your name, what you like, or where
you're from in conversation โ
MemoryGraphpicks facts like these up automatically and Byte will bring them back up later. - Open Settings (right-click the pet) to switch its personality profile and visual theme, or to see exactly which engine (LLM, vision, STT, TTS) is active and what it currently believes about you and your workspace.
- Byte notices your workspace, not just your clicks. Long coding sessions, compiler errors on screen, and time of day all nudge its mood and the breaks it suggests.
BehaviorDirector combines what's playing, how focused you are, and whether you're on a call:
| What you're doing | What Byte does |
|---|---|
| Playing music in Apple Music or Spotify | Dances, headbangs, and spins along. Artists you play a lot become "favorites" (hearts and extra excitement), and he remembers them in conversation |
| Focused work in an IDE or terminal | Walks to a free bottom corner away from your window, sits, and quietly watches your screen with small curious glances. No chatter |
| Focused work with music on | Stays in his corner and bobs along every so often, still quiet |
| On a video call (Zoom, Teams, Meet, FaceTime) | Moves out of the way and stays completely silent |
| Finishing a 25+ minute focus session | Stretches, looks proud, and cheers you on |
Music detection uses the players' own system notifications: no microphone, no permission prompt, and it works with headphones. A quick alt-tab to a browser won't make him get up. He only leaves his work spot after about 45 seconds away from your editor, and if you drag him off, he walks back.
sequenceDiagram
autonumber
actor User
participant App as macOS DesktopPet App (Swift)
participant Vision as Florence-2 Vision (Port 9005)
participant STT as Whisper Server (Port 9000)
participant LLM as Ollama byte-llm (Port 11434)
participant TTS as Kokoro / PersonaPlex TTS (Port 8880 / 9006)
App->>Vision: On-demand screen read (active window)
Vision-->>App: Extracted text / caption / UI regions
User->>App: Voice command or text interaction
alt Voice Input
App->>STT: Stream Audio Bytes
STT-->>App: Return Transcribed Text
end
App->>LLM: Send CONTEXT + VISION CONTEXT + USER SAID
LLM-->>App: Return "[ACTION: sitOnCorner] [EMOTION: love] I'm right here with you."
App->>App: Trigger 3D Sprite Animation & State Transition
App->>TTS: Synthesize Text to Audio (PersonaPlex first, Kokoro fallback)
TTS-->>App: Return Audio Buffer
App->>User: Play Voice Output & Perform 3D Animation
For full technical specifications, read our Empathy AI & ML Architecture Guide.
- Dataset Size: 45,328 total items (
train.jsonl: 38,528 |valid.jsonl: 6,800). - Hardware Acceleration: Apple Silicon Metal GPU via
mlx-lm. - Validation Loss Improvement: Drop from
4.487โ2.151(>50% optimization). - Quantized Deployment: Exported to
./training/byte_fused_modeland served through Ollamabyte-llm.
- Offline Self-Reflection Engine (
ReflectionEngine): Background reflection pass during sleep mode analyzes user interactions and updates permanent rules inmemory_graph.json. - On-Device Q-Learning Reinforcement (
ReinforcementLearningModel): Physical movement and state transitions continuously update a local Q-table via Bellman reward signals. - Incremental LoRA Checkpoints: User interaction feedback is periodically merged back into
train.jsonlto re-tune model weights incrementally.
For a deep mathematical break-down, read our Empathy AI Architecture & Continuous Learning Guide.
- macOS 14.0 (Sonoma) or newer on Apple Silicon (M1/M2/M3/M4) or Intel Mac.
- Xcode 15+ installed.
- Python 3.9+ installed.
- Ollama installed.
git clone https://github.com/Pratikdate/Byte.git
cd ByteOption A: Build & Run in Xcode (Recommended)
open DesktopPet.xcodeproj
# Cmd+B to build, Cmd+R to runOn launch, BackgroundServerManager automatically detects (or starts) Ollama, pulls/registers the main trained model (byte-llm), and launches the Whisper, Kokoro, Florence-2, and PersonaPlex background microservices for you โ no manual setup required.
Option B: Background Launcher Script Useful if you want the backend services running independently of the app (e.g. while developing):
chmod +x start.sh
./start.shA five-minute walkthrough with troubleshooting lives in QUICKSTART.md.
python3 training/download_and_build_master_dataset.pychmod +x training/train_mlx.sh
./training/train_mlx.shtraining/ByteModelfile is FROM llama3.2:1b: the base model with Byte's prompt. Byte's personality fine-tune is a LoRA adapter that Ollama applies on top of that same base, so deploying it needs only ~50 MB, not a multi-GB fused copy.
cd training
python3 -m mlx_lm lora -c lora_config_1b.yaml # train on train.jsonl / valid.jsonl (~35 min on an M-series Mac)
./deploy_finetune.sh # convert to GGUF, create byte-llm:v2-lora, run the head-to-headdeploy_finetune.sh never changes the model the app uses. It prints a scored comparison against the current byte-llm on real app prompts (tag format, Mac commands, memory use, reply time). Promote the fine-tune only if it wins:
ollama cp byte-llm byte-llm:pre-lora-backup && ollama cp byte-llm:v2-lora byte-llmDetails worth knowing:
- The adapter is trained on the Llama 3.2 chat format, so
ByteModelfile.lorauses that template. PlainCONTEXT: โฆ RESPONSE:prompts don't match what it learned. build_lora_gguf.pyhandles the MLX to llama.cpp conversion, including the Q/K row permutation llama.cpp uses. Without it, the adapter silently corrupts attention.- The older
adapters/checkpoint (Aug 1, 200 steps) predates the current dataset. It scores worse than the base model, so don't deploy it.
When DesktopPet.app starts, it makes sure byte-llm exists: it aliases byte-llm:v1-fused if you've built one, or otherwise creates byte-llm:v1-base from llama3.2:1b + ByteModelfile.
- Memory that persists: facts, chat history, and learned Q-tables live in
~/Library/Application Support/Byte/. Delete that folder to give Byte a fresh start. - Facts stay clean: a new name, city, or job replaces the old one; liking something you previously disliked flips the fact; repeated mentions make a fact rank higher.
- Relevant memories, not all memories: each turn picks up to 8 facts about you, ranked by how related they are to what you just said, then by how often and how recently they came up, plus your name. This keeps the prompt within the 1B model's 2048-token window.
- Prompt layout built for speed: unchanging instructions come first so Ollama reuses its cached prefix. On an M-series Mac this cut prompt processing from about 460 ms to about 40 ms per turn. The model is warmed up at launch and kept loaded for 30 minutes between chats.
- Safe Mac control:
[CMD: ...]actions are parsed against a short allowlist (open an app or web URL, volume, mute, dark mode, screenshot, sleep, Spotlight search) and run directly, never through a shell. Commands the model emits are honored only on turns where you asked for something, so on-screen text can't trigger them.
Byte/
โโโ DesktopPet/ # Native macOS Swift overlay app
โ โโโ AIEngine.swift # LLM prompt synthesis & response parsing
โ โโโ AppDelegate.swift # App lifecycle + BackgroundServerManager (auto-starts local services)
โ โโโ PetScene.swift # 3D SceneKit rendering & custom physics loop
โ โโโ PetBrain.swift # State machine & priority queue
โ โโโ ByteVisionEngine.swift # Screen-reading context (Accessibility API + Florence-2)
โ โโโ MemoryGraph.swift # Long-term facts & behavioral rules about the user
โ โโโ ReinforcementLearningModel.swift # Swift Q-Learning engine
โโโ DesktopPet.xcodeproj # Xcode project configuration
โโโ docs/ # In-depth architectural & ML documentation
โ โโโ EMPATHY_TRAINING_AND_ML_ARCHITECTURE.md
โ โโโ CODE_FLOW_DIAGRAM.md
โโโ training/ # Machine learning fine-tuning suite
โ โโโ ByteModelfile # Ollama model definition
โ โโโ download_and_build_master_dataset.py # Open-source dataset converter
โ โโโ generate_1000_connective_dataset.py # Domain generator
โ โโโ train_mlx.sh # Apple Silicon LoRA fine-tuning script
โ โโโ train.jsonl # Master training dataset (38k+ pairs)
โ โโโ valid.jsonl # Validation dataset (6.8k pairs)
โโโ backend/ # Python microservices
โ โโโ whisper_server.py # Offline speech-to-text API (Port 9000)
โ โโโ tts_server.py # Kokoro text-to-speech API (Port 8880)
โ โโโ florence_vision_server.py # Microsoft Florence-2 screen-reading API (Port 9005)
โ โโโ personaplex_server.py # NVIDIA PersonaPlex-7B full-duplex speech API (Port 9006, experimental)
โโโ assets/ # Sprites, motion renders, and logos
โโโ QUICKSTART.md # 5-minute setup + troubleshooting
โโโ start.sh # Universal background launcher script
Contributions are warmly welcomed! Please read our guidelines before submitting pull requests:
- Fork the project.
- Create a feature branch (
git checkout -b feature/amazing-feature). - Commit your changes (
git commit -m 'feat: add amazing feature'). - Push to the branch (
git push origin feature/amazing-feature). - Open a Pull Request.
Distributed under the MIT License. See LICENSE for more information.






