<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Garry N. Osborne on Medium]]></title>
        <description><![CDATA[Stories by Garry N. Osborne on Medium]]></description>
        <link>https://medium.com/@garryosborne?source=rss-80e13c426d76------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*WHXj0wuBpTsZ6nRfjn301Q.jpeg</url>
            <title>Stories by Garry N. Osborne on Medium</title>
            <link>https://medium.com/@garryosborne?source=rss-80e13c426d76------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 16:50:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@garryosborne/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Running an AI Chatbot on Apple Watch Ultra 2: Edge Computing at Your Wrist]]></title>
            <link>https://medium.com/@garryosborne/running-an-ai-chatbot-on-apple-watch-ultra-2-edge-computing-at-your-wrist-d711d46f0e5e?source=rss-80e13c426d76------2</link>
            <guid isPermaLink="false">https://medium.com/p/d711d46f0e5e</guid>
            <category><![CDATA[small-language-model]]></category>
            <category><![CDATA[edge-computing]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[edge-ai]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Garry N. Osborne]]></dc:creator>
            <pubDate>Tue, 02 Dec 2025 02:22:46 GMT</pubDate>
            <atom:updated>2025-12-02T02:22:46.719Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Imagine asking your watch a question and getting an immediate answer without needing internet connectivity — that’s the power of running a AI Small Language Model (SLM) on the device itself. In this three-part series, we will explore building a simple chatbot that runs entirely on an Apple Watch Ultra 2, using a small open-source language model.</p><p>By running the AI model locally on the watch (instead of a cloud server), we achieve on-device intelligence with compelling benefits:</p><ul><li><strong>Privacy</strong>: Your data stays on your wrist — no server processing required</li><li><strong>Offline Access</strong>: Works anywhere, even without cellular or WiFi</li><li><strong>Reduced Latency</strong>: No network round-trip means faster responses</li><li><strong>Independence</strong>: No subscription services or API costs</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lXj4CD6I3uuHfi9M" /></figure><p>Click to view full-size infographic</p><h3>What is Edge Computing?</h3><p>Edge computing is a paradigm where computation or in our case an AI model, happens locally on the “edge” device rather than in the cloud. Instead of sending your data to a remote server for processing, the device itself handles the workload.</p><p>For AI applications, this means running machine learning models directly on consumer hardware. Apple has been quietly building toward this future. Their latest watches process Siri voice requests on-device when possible, thanks to the S9 chip’s Neural Engine.</p><h3>The Apple Watch Ultra 2: A Tiny Powerhouse</h3><p>The Apple Watch Ultra 2’s hardware makes on-device AI feasible:</p><p>The Neural Engine is the secret weapon here. Apple designed it specifically for machine learning tasks, and it can perform tensor operations far more efficiently than the CPU alone. When we deploy our chatbot, we’ll target this hardware accelerator using CoreML.</p><h3>The Challenge: Miniaturizing AI</h3><p>Here’s the catch — Large Language Models (LLMs) are typically resource-intensive. Models like GPT-5.1 have hundreds of billions of parameters and require enterprise-grade hardware. Even “small” language models (SLMs) like Llama 2–7B need 14GB of memory in half-precision.</p><p>On a tiny wearable with ~1GB of RAM, we need to be clever:</p><ul><li>Use a <strong>small, optimized model</strong> (under 100M parameters)</li><li>Leverage <strong>efficient code</strong> and Apple’s ML frameworks</li><li>Accept <strong>trade-offs</strong> in capability for portability</li></ul><p>And when it comes to performance, well, think of this project as a proof of concept. I am not going into this with the expectation of reasonable tokens per second response times.</p><p>The good news? Enthusiasts have already demonstrated that a distilled GPT-2 model can run locally on Apple Watch Ultra 2 using CoreML. This proves feasibility — with careful optimization, you really can have a miniature chatbot on your wrist. Previous attempts at running a GPT-2 model on an Ultra 2 had challenges with token count. We will be diving deep into every layer of the model to understand exactly how tokens flow through the SLM of choice.</p><h3>Defining Our Chatbot Function</h3><p>Before diving into SLM model selection and implementation, let’s outline the basic structure of our chatbot. At its core, the chatbot takes user input and generates a text response. Here’s the conceptual flow in Swift pseudocode:</p><pre>func chatbotReply(to userMessage: String) -&gt; String {<br>    // 1. Tokenize: Convert input string to model-readable token IDs <br>    let inputTokens: [Int] = tokenize(userMessage) <br><br>    // 2. Inference: Run the language model to generate response tokens <br>    var responseTokens: [Int] = model.generateResponse(to: inputTokens) <br><br>    // 3. Detokenize: Convert output tokens back to human-readable text <br>    let responseText: String = detokenize(responseTokens) <br><br>    return responseText <br>} <br><br>// Example usage <br>let userQuestion = &quot;Hello, how are you?&quot; <br>let botAnswer = chatbotReply(to: userQuestion) <br>// Output: &quot;Hello! I&#39;m doing well. How can I help you today?&quot;</pre><p>This three-step pipeline is universal to all AI SLMs:</p><ol><li><strong>Tokenization</strong>: Breaking text into numerical tokens the model understands</li><li><strong>Inference</strong>: Running the neural network forward pass</li><li><strong>Detokenization</strong>: Converting the output numbers back to words</li></ol><h3>Input Methods on the Watch</h3><p>You might wonder how users will input text on such a small screen. Several options exist:</p><ul><li><strong>Voice Dictation</strong>: Speak your question, let the watch transcribe it</li><li><strong>Scribble</strong>: Draw letters on the screen</li><li><strong>Paired iPhone</strong>: Type on your phone, send to watch</li><li><strong>Pre-set Prompts</strong>: Quick-reply style buttons for common queries</li></ul><p>For our implementation, we’ll support all of these through the standard watchOS text input APIs. We will start with pre-set prompts for quick and easy testing.</p><h3>Series Roadmap</h3><p>Here’s what we’ll cover in this three-part series:</p><p><strong>Part 1 (This Article)</strong>: Introduction to edge computing and the project concept</p><p><strong>Part 2</strong>: Choosing the right small language model — we’ll compare candidates like GPT-2 Small, DistilGPT-2, and others, explaining why model selection is critical for success on constrained hardware.</p><p><strong>Part 3</strong>: Step-by-step implementation — converting the model to CoreML, building the Swift app, and deploying to the Apple Watch Ultra 2.</p><h3>Development Environment</h3><p>For this project, we’re using:</p><ul><li><strong>Development Machine</strong>: Mac Studio M3 Ultra (512GB unified memory)</li><li><strong>IDE</strong>: VSCode with Cline extension for AI-assisted coding</li><li><strong>Apple Tools</strong>: Xcode 15+ with watchOS 10 SDK</li><li><strong>Version Control</strong>: The code will be made available through a GitHub repository</li><li><strong>Target Device</strong>: Apple Watch Ultra 2</li></ul><p>The Mac Studio’s generous memory makes model conversion, fine tuning and testing smooth, even when working with multiple model variants.</p><h3>What’s Next</h3><p>In Part 2, we’ll dive deep into the world of small language models. We’ll explore why DistilGPT-2 (82 million parameters) emerges as our top choice, and walk through the model conversion pipeline that transforms a PyTorch model into a watchOS-ready CoreML package.</p><p>Stay tuned — we’re about to put AI on your wrist!</p><p>This is Part 1 of a three-part series on building an on-device AI chatbot for Apple Watch Ultra 2. Follow Tomorrow’s Innovations for Parts 2 and 3.</p><h3>Resources</h3><p>Published on Tomorrow’s Innovations | <a href="https://tomorrowsinnovations.co/">tomorrowsinnovations.co</a></p><p>This is Part 1 of a three-part series</p><p><em>Originally published at </em><a href="https://www.tomorrowsinnovations.co/blog/edge-computing-apple-watch-part-1"><em>https://www.tomorrowsinnovations.co</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d711d46f0e5e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Words Made Visible — Part 3 | A Vestaboard ChatBot.]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@garryosborne/words-made-visible-part-3-a-vestaboard-chatbot-fef0c35e07de?source=rss-80e13c426d76------2"><img src="https://cdn-images-1.medium.com/max/1893/1*wDuSyT6F-tY8hX5ebYi6aA.png" width="1893"></a></p><p class="medium-feed-snippet">Part 3&#x200A;&#x2014;&#x200A;Words Made Visible: Simulating Vestaboard Output and Sharing the Project</p><p class="medium-feed-link"><a href="https://medium.com/@garryosborne/words-made-visible-part-3-a-vestaboard-chatbot-fef0c35e07de?source=rss-80e13c426d76------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@garryosborne/words-made-visible-part-3-a-vestaboard-chatbot-fef0c35e07de?source=rss-80e13c426d76------2</link>
            <guid isPermaLink="false">https://medium.com/p/fef0c35e07de</guid>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[localai]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[vestaboard]]></category>
            <dc:creator><![CDATA[Garry N. Osborne]]></dc:creator>
            <pubDate>Mon, 24 Nov 2025 16:39:19 GMT</pubDate>
            <atom:updated>2025-11-24T16:39:19.299Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Part 2 — From Code to Conversation: Designing the Gradio Interface for a Tangible AI Experience]]></title>
            <link>https://medium.com/@garryosborne/part-2-from-code-to-conversation-designing-the-gradio-interface-for-a-tangible-ai-experience-2d2094f71b8d?source=rss-80e13c426d76------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d2094f71b8d</guid>
            <category><![CDATA[vestaboard]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ai-edge-computing]]></category>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Garry N. Osborne]]></dc:creator>
            <pubDate>Sun, 19 Oct 2025 11:10:19 GMT</pubDate>
            <atom:updated>2025-10-19T11:10:19.839Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Part 2 — From Code to Conversation: Designing the Gradio Interface for a Tangible AI Experience</strong></h3><p><em>Where a local AI learns to speak — and soon, to move.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wDuSyT6F-tY8hX5ebYi6aA.png" /><figcaption>AI LLM Speaking through a Vestaboard</figcaption></figure><h3><strong>Introduction — Turning Concept into Conversation</strong></h3><p>In <a href="https://tomorrowsinnovations.co/blog/when-ai-speaks-in-color-part1">Part 1 → <em>The Spark of Color: Giving AI a Voice Beyond the Screen</em></a>,<br>we explored the idea of giving a <strong>digital AI</strong> a <strong>mechanical voice</strong> through the <strong>Vestaboard</strong>.</p><p>Now, in Part 2, the vision begins to move.</p><p>This stage builds the <strong>conversation layer</strong> — the bridge between human and machine that allows thought to flow both ways, eventually manifesting as sound and color.<br>Here, <strong>LangChain</strong>, <strong>Gradio</strong>, and <strong>local inference</strong> converge to make AI expression both private and tangible.</p><p>The complete source code for this project is publicly available on GitHub at<br><a href="https://github.com/Garry-TI/vestaboard-vc">GitHub — Garry-TI/vestaboard-vc: Python application with Gradio interface for controlling Vestaboard display</a>.</p><p>There you can explore all referenced files — including app.py, llm_client.py, and vestaboard_client.py — to follow along or replicate the project in your own environment.</p><p>You will also need to request an API key from Vestaboard by sending an email to <a href="/service/mailto:support@vestaboard.com">support@vestaboard.com</a></p><h3>1 · Establishing the Local Mind</h3><p>The project’s foundation begins in config.py, where every supported LLM is described with its Hugging Face path, token limits, and temperature:</p><pre># Local Vestaboard Configuration<br># Use the API key you received after enabling the Local API (not the enablement token)<br>VESTABOARD_CONFIG = {<br>    &#39;ip&#39;: &#39;#.#.#.#&#39;, # Replace with the IP address assisgned to your Vestaboard<br>    &#39;api_key&#39;: &#39;Your API Key Here&#39;  # Replace with your actual API key<br>}<br><br># LLM Model Configuration<br># Configure local LLM models for AI chat feature<br><br>LLM_MODELS = {<br>    &#39;Llama-3.2-1B-Instruct&#39;: {<br>        &#39;model_id&#39;: &#39;meta-llama/Llama-3.2-1B-Instruct&#39;,<br>        &#39;max_tokens&#39;: 132, # Vestaboard Character limit (6 rows x 22 chars)<br>        &#39;temperature&#39;: 0.7,<br>        &#39;description&#39;: &#39;Llama 3.2 1B Instruct – Fast and efficient&#39;<br>    },<br>    # Ad more LLM models here as needed<br>}<br><br># Default Model for AI chat<br>DEFAULT_LLM_MODEL = &#39;Llama-3.2-1B-Instruct&#39;</pre><p>The <strong>LLMClient</strong> in <a href="https://github.com/Garry-TI/vestaboard-vc/blob/main/llm_client.py">llm_client.py</a> manages model initialization and text generation using <strong>LangChain’s</strong> HuggingFacePipeline:</p><pre>from typing import Dict, Optional<br>from langchain_community.llms import HuggingFacePipeline<br>from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline<br>import torch<br>from config import LLM_MODELS, DEFAULT_LLM_MODEL<br><br>class LLMClient:<br>    &quot;&quot;&quot;Client for managing local LLM inference.&quot;&quot;&quot;<br>        <br>    def __init__(self, model_name: Optional[str] = None):<br>    def initialize(self) -&gt; Dict[str, str]:<br>    def generate_response(self, prompt: str, max_length: int = 132) -&gt; Dict[str, str]:<br>    def _format_prompt(self, user_prompt: str) -&gt; str:<br>    def _clean_response(self, response: str, original_prompt: str) -&gt; str:<br>    def _truncate_response(self, response: str, max_length: int) -&gt; str:<br>    def get_model_info(self) -&gt; Dict[str, any]:<br>    def change_model(self, model_name: str) -&gt; Dict[str, str]:</pre><p>All inference happens <strong>locally</strong> — no cloud calls, no external APIs.<br>Your data, your hardware, your conversation.</p><h3>2 · Giving the AI a Voice — LangChain Response Flow</h3><p>To ensure responses fit the <strong>Vestaboard’s 6×22 grid (132 characters)</strong>, the prompt is formatted and bounded:</p><pre>system_msg = &quot;You are a helpful assistant. Provide concise answers in 132 characters or less.&quot;<br>formatted = (<br>    f&quot;&lt;|im_start|&gt;system\n{system_msg}&lt;|im_end|&gt;\n&quot;<br>    f&quot;&lt;|im_start|&gt;user\n{user_prompt}&lt;|im_end|&gt;\n&quot;<br>    f&quot;&lt;|im_start|&gt;assistant\n&quot;<br>)</pre><p>Each output is <strong>cleaned and truncated</strong> to stay within physical display limits — turning token streams into concise, intentional statements ready for mechanical delivery.</p><h3>3 · Building the Interface — Gradio as the Human Touch</h3><p>In <a href="https://github.com/Garry-TI/vestaboard-vc/blob/main/app.py">app.py</a>, the <strong>VestaboardApp</strong> class defines a full Gradio UI that acts as the conversational front-end:</p><pre>import gradio as gr<br>from llm_client import LLMClient<br>from vestaboard_client import VestaboardClient<br>from config import LLM_MODELS<br><br>    def __init__(self):<br>        &quot;&quot;&quot;Initialize the Vestaboard application.&quot;&quot;&quot;<br>        try:<br>            self.client = VestaboardClient()<br>            self.connection_status = &quot;Initializing...&quot;<br>        except Exception as e:<br>            self.client = None<br>            self.connection_status = f&quot;Error initializing: {str(e)}&quot;<br><br>        # Initialize LLM client (lazy loading - will initialize on first use)<br>        self.llm_client = None<br>        self.current_llm_model = None</pre><p>The interface includes:</p><ul><li><strong>Test Connection</strong> — verify the board’s reachability</li><li><strong>AI Chat to Vestaboard</strong> — ask questions, receive AI answers, and send them straight to the board</li><li><strong>Color Test &amp; Price Feed</strong> — diagnostic and live-data modes for gold/silver pricing</li></ul><p>A single Gradio callback powers the magic:</p><pre>    def chat_with_ai(self, user_question: str, model_name: str) -&gt; Tuple[str, str]:<br>        &quot;&quot;&quot;<br>        Send question to AI and display response on Vestaboard.<br><br>        Args:<br>            user_question: User&#39;s question for the AI<br>            model_name: Selected model name<br><br>        Returns:<br>            Tuple of (AI response, Vestaboard status)<br>        &quot;&quot;&quot;<br>        if not user_question or user_question.strip() == &quot;&quot;:<br>            return &quot;Please enter a question&quot;, &quot;No message to send&quot;<br><br>        # Initialize model if needed<br>        if not self.llm_client or self.current_llm_model != model_name:<br>            init_status = self.initialize_llm(model_name)<br>            if &quot;Error&quot; in init_status or &quot;✗&quot; in init_status:<br>                return f&quot;Model initialization failed: {init_status}&quot;, &quot;Model not ready&quot;<br><br>        # Generate AI response<br>        try:<br>            result = self.llm_client.generate_response(user_question, max_length=132)<br><br>            if result[&#39;status&#39;] != &#39;success&#39;:<br>                return f&quot;Error: {result[&#39;message&#39;]}&quot;, &quot;AI generation failed&quot;<br><br>            ai_response = result[&#39;response&#39;]<br><br>            # Send to Vestaboard<br>            if self.client:<br>                vb_result = self.client.send_message(ai_response)<br>                vb_status = vb_result[&#39;message&#39;]<br>            else:<br>                vb_status = &quot;Vestaboard client not initialized&quot;<br><br>            return ai_response, vb_status<br><br>        except Exception as e:<br>            return f&quot;Error: {str(e)}&quot;, &quot;Failed to process request&quot;</pre><p>When you press <strong>“Ask AI &amp; Send to Vestaboard,” </strong>you trigger a real-time pipeline:</p><pre>Gradio UI → LangChain LLMClient → VestaboardClient → Analog Display</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*3RwtyulDch27jwRzAcWsgw.png" /><figcaption>Gradio interface into the Vestaboard AI ChatBot</figcaption></figure><h3>4 · Orchestrating Dialogue and Display</h3><p>Every control in the UI serves a purpose:</p><ul><li><strong>Load Model</strong> — swap models (Llama or Qwen) instantly</li><li><strong>Test Connection</strong> — Vestaboard must be on the same local network as client</li><li><strong>Test Color Bits</strong> — Displays a color pattern on the Vestaboard for a quick test</li><li><strong>Display Precious Metals Prices</strong> — Will display the current gold and silver prices</li><li><strong>Your Question</strong> — type your question here</li><li><strong>Ask AI &amp; Send to Vestaboard</strong> — type your question here</li><li><strong>AI Response Pane</strong> — see the generated reply</li><li><strong>Vestaboard Status</strong> — confirm physical delivery</li></ul><p>Underneath, VestaboardClient in <a href="https://github.com/Garry-TI/vestaboard-vc/blob/main/vestaboard_client.py">vestaboard_client.py</a><br>handles sanitization (uppercase only, valid character map) and posts messages to the board’s <strong>local API</strong>.</p><p>The result: a <strong>closed-loop system</strong> where the AI’s thought becomes a physical movement you can see and hear.</p><h3>5 · The Experience in Motion</h3><p>LangChain memory + Gradio interaction + Vestaboard mechanics =<br>an AI that doesn’t just respond — it <strong>performs</strong>.</p><p>Each flip of a tile is a syllable of machine expression, each line of text a verse in a mechanical poem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wDuSyT6F-tY8hX5ebYi6aA.png" /><figcaption>Now you have a fully functional Vestaboard AI Chatbot.</figcaption></figure><h3>Conclusion — A Conversation You Can Hear</h3><p>By the end of this stage, the AI has found its voice: a <strong>local</strong>, <strong>secure</strong>, and <strong>tactile</strong> one.</p><p>It can think with LangChain, speak through Gradio, and be heard via Vestaboard.</p><p>Next: <a href="https://tomorrowsinnovations.co/blog"><strong>Part 3 → Words Made Visible: Displaying AI Thoughts on a Vestaboard</strong></a>)<br>where these responses transform into <strong>synchronized color and motion</strong> — the final stage of digital thought becoming analog art.</p><blockquote>When the AI’s response flutters across the board, it’s not just an answer — it’s proof that thought itself can make a sound.</blockquote><p><strong>Read the Series</strong></p><p>1️⃣ <a href="https://tomorrowsinnovations.co/blog/when-ai-speaks-in-color-part-1">Part 1 → <em>The Spark of Color</em></a>)<br>2️⃣ <strong>Part 2 → <em>From Code to Conversation</em></strong> (you are here)<br>3️⃣ Part 3 → Coming Soon…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d2094f71b8d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Converting Dots.OCR to MLX -Part 2: The Vision Tower Awakens]]></title>
            <link>https://medium.com/@garryosborne/converting-dots-ocr-to-mlx-part-2-the-vision-tower-awakens-59b8a5599d68?source=rss-80e13c426d76------2</link>
            <guid isPermaLink="false">https://medium.com/p/59b8a5599d68</guid>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[vlm]]></category>
            <category><![CDATA[ai-tools]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Garry N. Osborne]]></dc:creator>
            <pubDate>Sat, 11 Oct 2025 17:07:58 GMT</pubDate>
            <atom:updated>2025-10-11T17:07:58.255Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Continues from </em><a href="https://www.tomorrowsinnovations.co/blog/converting-dots-ocr-to-mlx-part-1"><em>Part 1</em></a></p><p>In <a href="https://www.tomorrowsinnovations.co/blog/converting-dots-ocr-to-mlx-part-1"><strong>Part 1</strong></a>, we walked through converting the Qwen2 text backbone of dots.ocr to MLX, enabling Apple Silicon to run the text model natively. That milestone gave us the ability to handle prompts and generate text. But OCR isn&#39;t just about text — it&#39;s about understanding images and turning them into structured words. That&#39;s where the vision tower comes in.</p><p>In this second installment, we dive into the vision side of the model: building the tower in MLX, wiring in its layers, and preparing it to splice seamlessly with the text backbone.</p><h3>Revisiting the Architecture</h3><p>DotsOCR is a vision-language model. The vision tower processes image patches and transforms them into embeddings. A projector then maps those vision embeddings into the same dimensional space as the text backbone. Finally, the model stitches the two modalities together by splicing vision embeddings into the token stream, bracketed by special tokens like &lt;|vision_start|&gt; and &lt;|vision_end|&gt;.</p><p>Our job was to replicate this process in MLX, ensuring that patch embedding, transformer layers, and the projector all load and align with the text dimension of Qwen2.</p><h3>Extracting and Preparing Weights</h3><p>The Hugging Face repository contains both text and vision weights, but MLX needs a clean set for the vision tower. We exported only the relevant tensors — patch embedding, transformer blocks, norms, and the projector — into a dedicated .npz file.</p><p>The naming convention of these weights is critical. Keys must map cleanly into our MLX implementation, for example:</p><pre>vision.patch_embed.proj.weight<br>vision.blocks.0.attn.qkv.weight<br>vision.blocks.0.mlp.fc1.weight<br>vision.blocks.0.mlp.fc2.weight<br>vision.blocks.0.mlp.fc3.weight<br>vision.blocks.0.norm1.weight<br>…<br>projector.weight<br>projector.bias</pre><p>With this set extracted, we had a portable file to load directly into MLX.</p><h3>Building the Vision Tower in MLX</h3><p>With weights ready, the next step was implementing the model. The MLX version mirrors the PyTorch architecture closely: a patch embedding layer, a stack of transformer blocks, normalization, and finally the optional projector.</p><p>Here’s a simplified outline:</p><pre>import mlx.nn as nn<br>import mlx.core as mx<br><br>class DotsVisionMLX(nn.Module):<br>    def __init__(self, d, depth, heads, proj_out=None):<br>        super().__init__()<br>        self.patch_embed = PatchEmbedMLX(...)<br>        self.blocks = nn.Sequential([<br>            VisionBlockMLX(d, heads) for _ in range(depth)<br>        ])<br>        self.norm = nn.RMSNorm(d)<br>        self.projector = nn.Linear(d, proj_out) if proj_out else None<br><br>    def forward(self, x, grid_thw):<br>        x = self.patch_embed(x)<br>        x = self.blocks(x)<br>        x = self.norm(x)<br>        if self.projector:<br>            x = self.projector(x)<br>        return x</pre><p>The supporting classes handle details like splitting query/key/value heads, applying attention, and projecting intermediate representations through feedforward MLPs.</p><h3>Wiring in the Projector</h3><p>The projector layer deserves special attention. It transforms the vision output (dimension D_v) into the text model&#39;s hidden dimension (D_text). Without this, the embeddings wouldn&#39;t match and the splice would fail.</p><p>We confirmed the projector weights loaded correctly by printing their shape:</p><pre>[loader] Loaded projector: (1536, 1536)</pre><p>This confirmed alignment with Qwen2’s text hidden size of 1536.</p><h3>Sanity Checking the Output</h3><p>To validate our implementation, we passed a test image through the MLX tower and inspected the output embeddings:</p><pre>MLX vision out shape: (1, 5184, 1536)</pre><p>This shape was exactly what we expected: one batch, thousands of patches, each projected into the 1536-dimensional text space. That was the green light that our mapping worked.</p><h3>Preparing for the Splice</h3><p>Once the embeddings are produced, they need to be slotted into the text model’s prompt. The tokenizer defines &lt;|vision_start|&gt; and &lt;|vision_end|&gt; markers, with placeholder pads in between. At runtime, these pads are replaced by the projected embeddings.</p><p>The splice must respect sequence length: the combined embeddings should be the same length as the original padded prompt. Any mismatch leads to assertion errors during inference. This required careful handling of indices like pad_start and pad_end, along with debug logging to confirm counts.</p><h3>Where We Leave Off</h3><p>At this stage, the vision tower is alive inside MLX. We’ve successfully extracted, rebuilt, and validated the core of the vision model, and confirmed projector alignment. The next big step will be integrating everything: splicing embeddings into text prompts and driving full OCR runs.</p><p>That’s the focus of <strong>Part 3</strong>, where we’ll refine prompt strategies, manage large documents, and begin to evaluate quality against the Hugging Face implementation.</p><h3>Closing Thoughts</h3><p>Converting vision models is never as straightforward as text backbones. The devil is in the details — especially patching, projection, and embedding alignment. But once the tower is rebuilt, the path to true OCR becomes much clearer.</p><p>In Part 3, we’ll move from raw embeddings to coherent OCR output. Stay tuned — the pieces are now in place.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59b8a5599d68" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When AI Speaks in Color: Building an Analog Voice for Digital Intelligence]]></title>
            <link>https://medium.com/@garryosborne/when-ai-speaks-in-color-building-an-analog-voice-for-digital-intelligence-d6dd85c04213?source=rss-80e13c426d76------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6dd85c04213</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[edge-ai]]></category>
            <category><![CDATA[iot]]></category>
            <dc:creator><![CDATA[Garry N. Osborne]]></dc:creator>
            <pubDate>Sat, 11 Oct 2025 16:50:04 GMT</pubDate>
            <atom:updated>2025-10-11T16:50:04.541Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wDuSyT6F-tY8hX5ebYi6aA.png" /><figcaption>Vestaboard displaying message from the AI ChatBot</figcaption></figure><p>A 3-Part Journey Bringing the Llama-3.2–1B Model to Life on a Vestaboard Display</p><h3>Part 1 — The Spark of Color: Giving AI a Voice Beyond the Screen</h3><p><em>Exploring the beauty of analog output in a digital age through the Vestaboard and Llama-3.2–1B.</em></p><h3>Introduction</h3><p>In a world dominated by pixels and glass screens, the humble <strong>Vestaboard</strong> stands apart — a mechanical display that communicates with sound, motion, and color. Each flipping tile is a whisper of nostalgia in a digital storm.</p><p>This is where my latest experiment began: <em>Could an AI model “speak” through an analog medium?</em></p><h3>The Concept</h3><p>I set out to fuse three powerful ideas:</p><ol><li><strong>Natural language understanding</strong> powered by the Llama-3.2-1B-Instruct model.</li><li><strong>LangChain’s orchestration</strong>, providing structured, dynamic reasoning flows.</li><li><strong>The Vestaboard API</strong>, which transforms text into living motion and analog rhythm.</li></ol><p>The result: a local AI chatbot that <em>thinks digitally but speaks mechanically.</em></p><h3>The Challenging Constraints</h3><p>The limitations I faced are:</p><ol><li><strong>132 Character Output Window</strong> on the vestaboard.</li><li><strong>Limited Character Set</strong>, The character set is made of up numbers, the Alphabet, a limited set of punctuation and 8 color tiles.</li><li><strong>The Vestaboard API Access</strong>, Which requires an API token requested from the Vestaboard manufacture.</li></ol><h3>What is a Vestaboard?</h3><p>Imagine a mesmeric hybrid of sculpture and signage: that’s the Vestaboard. Rather than relying on an LCD screen, it uses 132 modular “bits” — tiny spinning flaps — to render any message, from gentle reminders to bold quotes, in full color and tactile motion. Controlled via a smartphone or web app, the Vestaboard bridges the digital and physical worlds — you program it remotely, and then watch (and hear) the bits click into place. At rest it’s a striking wall piece; in motion, it becomes a dynamic statement of intention. With its satisfying mechanical sound, clean typography, and blend of nostalgia with modern connectivity, it’s a beautifully engineered way to make words feel alive.</p><h3>Why Vestaboard?</h3><p>Vestaboard is not your typical IoT display. It’s tactile, emotional, and deliberately slow — every message feels intentional. That slowness became part of the art: translating AI conversation into something you <em>see</em> and <em>hear</em>, not just read.</p><h3>Building the Foundation</h3><p>Using <strong>LangChain</strong>, I created a conversational chain that connects user prompts to Llama-3.2–1B-Instruct running locally. <strong>Gradio</strong> served as the front-end playground — a minimal chat interface. Finally, <strong>the Vestaboard API</strong> bridged the analog frontier.</p><p>In the next article, we’ll dive into wiring it all together — the code, architecture, and design decisions that made the magic happen.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6dd85c04213" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Converting dots.ocr to MLX — Text Backbone (Qwen2) — Part 1]]></title>
            <link>https://medium.com/@garryosborne/converting-dots-ocr-to-mlx-text-backbone-qwen2-part-1-9d56e6a7c390?source=rss-80e13c426d76------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d56e6a7c390</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ocr]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[mlx]]></category>
            <dc:creator><![CDATA[Garry N. Osborne]]></dc:creator>
            <pubDate>Wed, 20 Aug 2025 15:34:36 GMT</pubDate>
            <atom:updated>2025-08-20T15:34:36.991Z</atom:updated>
            <content:encoded><![CDATA[<h3>Converting dots.ocr to MLX — Text Backbone (Qwen2) — Part 1</h3><h3>Introduction</h3><p>Large language models are evolving rapidly, and Apple’s <strong>MLX framework</strong> gives Mac users a powerful way to run them natively on Apple Silicon. With its optimized GPU support and unified memory design, MLX can unlock performance that feels closer to running on dedicated accelerators.</p><p>In this series, I’ll walk through how I converted the Hugging Face model <a href="https://huggingface.co/rednote-hilab/dots.ocr">rednote-hilab/dots.ocr</a> into MLX format on my <strong>Mac Studio M3 Ultra with 512 GB unified memory</strong>.</p><p>dots.ocr is a vision-language model (VLM). In this first part, we&#39;ll focus on converting the <strong>Qwen2 language backbone</strong> - getting the text side running natively in MLX. In Part 2, I&#39;ll extend this into full OCR by adding the vision tower.</p><h3>Why MLX?</h3><p>Apple designed MLX to run AI models with tight integration to Apple Silicon’s architecture. That means:</p><ul><li><strong>GPU acceleration</strong> without custom CUDA installs.</li><li><strong>Unified memory</strong> that scales seamlessly across CPU/GPU/NPU.</li><li><strong>Lightweight Python APIs</strong> that feel familiar if you’ve worked with PyTorch or NumPy.</li></ul><p>For Mac developers, this translates into less friction and more speed when experimenting with state-of-the-art models.</p><h3>Setting Up The Environment</h3><p>First set up the python environment that can handle the MLX conversion:</p><pre>brew install python@3.12 /opt/homebrew/bin/python3.12 -m venv ~/venvs/mlx-dots-py312 source ~/venvs/mlx-dots-py312/bin/activate python -m pip install --upgrade pip python -m pip install torch safetensors transformers==4.51.0</pre><h3>Downloading the Model</h3><p>I started by pulling down the Hugging Face model repository locally:</p><pre>huggingface-cli download rednote-hilab/dots.ocr --local-dir ~/models/DotsOCR --local-dir-use-symlinks True</pre><p>Then I made a copy dedicated to the text-only conversion:</p><pre>rsync -a ~/models/DotsOCR/ ~/models/DotsOCR_textonly/</pre><h3>Preparing the Config</h3><p>MLX recognizes models like LLaMA, Mistral, and Qwen — but it doesn’t know about the custom dots_ocr type. Since the backbone is Qwen2, I patched the config so MLX would treat it as such:</p><pre>python - &lt;&lt;&#39;PY&#39; import json, pathlib p = pathlib.Path(&#39;~/models/DotsOCR_textonly/config.json&#39;).expanduser() cfg = json.loads(p.read_text()) cfg[&#39;model_type&#39;] = &#39;qwen2&#39; cfg[&#39;architectures&#39;] = [&#39;Qwen2ForCausalLM&#39;] for k in [&#39;vision_config&#39;,&#39;image_token_id&#39;,&#39;video_token_id&#39;]: cfg.pop(k, None) p.write_text(json.dumps(cfg, indent=2, ensure_ascii=False)) print(&quot;Patched&quot;, p) PY</pre><p>This small edit made the model compatible with MLX’s conversion tool.</p><h3>Stripping Vision Weights</h3><p>The original shards contained both language and vision weights. Since we’re only targeting the text backbone here, I filtered out all vision-related tensors and merged the remaining Qwen2 weights into a single shard.</p><p>First we move the original safetensors files to a backup folder:</p><pre>mkdir -p ~/models/DotsOCR_textonly/original_safetensors mv ~/models/DotsOCR_textonly/model-*.safetensors ~/models/DotsOCR_textonly/original_safeensors/ 2&gt;/dev/null || true</pre><p>Then move the safetensors files into the folder:</p><pre>mv ~/models/DotsOCR_textonly/model-*.safetensors ~/models/DotsOCR_textonly/original_safetensors/ 2&gt;/dev/null || true</pre><h3>Strip the vision tensors from the originals</h3><p>(This reads the originals from original_safetensors/ and writes stripped shards into text_only_weights/)</p><pre>python - &lt;&lt;&#39;PY&#39; from safetensors import safe_open from safetensors.torch import save_file from pathlib import Path root = Path(&#39;~/models/DotsOCR_textonly&#39;).expanduser() orig = root / &#39;original_safetensors&#39; dst = root / &#39;text_only_weights&#39; dst.mkdir(parents=True, exist_ok=True) def keep(k: str) -&gt; bool: k = k.lower() drop = ( &#39;vision_tower&#39;, &#39;vision.&#39;, &#39;.vision&#39;, &#39;visual.&#39;, &#39;image_proj&#39;, &#39;mm_projector&#39;, &#39;pixel&#39;, &#39;patch_embed&#39;, &#39;vision_proj&#39;, &#39;visiongrid&#39;, &#39;visionnorm&#39; ) return not any(d in k for d in drop) any_written = False for shard in sorted(orig.glob(&#39;model-*.safetensors&#39;)): with safe_open(shard, framework=&quot;pt&quot;) as f: keys = [k for k in f.keys() if keep(k)] tensors = {k: f.get_tensor(k) for k in keys} out = (dst / shard.name).as_posix() if tensors: save_file(tensors, out) print(f&quot;[STRIP] {shard.name}: kept {len(tensors)} tensors → {out}&quot;) any_written = True else: print(f&quot;[STRIP] {shard.name}: kept 0 tensors (vision-only shard)&quot;) print(&quot;Done. Output dir:&quot;, dst if any_written else &quot;No text tensors written.&quot;) PY</pre><p>We see shard 1 kept 339 tensors and the vision only shard kept 0 tensors.</p><p>Now we merge all of the kept tensors into a single shard and write a new index:</p><pre>python - &lt;&lt;&#39;PY&#39; from safetensors import safe_open from safetensors.torch import save_file from pathlib import Path import json, torch root = Path(&#39;~/models/DotsOCR_textonly&#39;).expanduser() src_dir = root / &#39;text_only_weights&#39; out_name = &#39;model-00001-of-00001.safetensors&#39; out_path = root / out_name # 1) Collect all kept tensors from text_only_weights/ all_tensors = {} for sf in sorted(src_dir.glob(&#39;model-*.safetensors&#39;)): with safe_open(sf, framework=&quot;pt&quot;) as f: for k in f.keys(): if k in all_tensors: raise RuntimeError(f&quot;Duplicate tensor key across shards: {k}&quot;) all_tensors[k] = f.get_tensor(k) if not all_tensors: raise SystemExit(&quot;No text tensors found to merge. Did the strip step produce anything?&quot;) # 2) Save a single merged shard save_file(all_tensors, out_path.as_posix()) print(f&quot;[MERGE] Wrote merged shard: {out_path} with {len(all_tensors)} tensors&quot;) # 3) Compute total_size for index metadata total_size = 0 for t in all_tensors.values(): total_size += t.element_size() * t.numel() index = { &quot;metadata&quot;: {&quot;total_size&quot;: total_size}, &quot;weight_map&quot;: {k: out_name for k in all_tensors.keys()}, &quot;format&quot;: &quot;safetensors&quot; } # 4) Write fresh index referencing exactly one shard idx_path = root / &quot;model.safetensors.index.json&quot; idx_path.write_text(json.dumps(index, indent=2)) print(f&quot;[INDEX] Wrote {idx_path.name} (total_size={total_size})&quot;) # 5) Clean any old root shards (we&#39;ll keep only the merged one) for old in root.glob(&#39;model-*.safetensors&#39;): if old.name != out_name: old.unlink() print(&quot;[CLEAN] removed old shard&quot;, old.name) print(&quot;[DONE] Single-shard layout ready.&quot;) PY</pre><p>Now ~/models/DotsOCR_textonly/ should have:</p><ol><li>model-00001-of-00001.safetensors our merged text-only shard</li><li>Updated model.safetensors.index.json pointing to the new shard</li></ol><p>Let’s do a quick check:</p><pre>ls -lh ~/models/DotsOCR_textonly</pre><h3>Conversion to MLX</h3><p>With the patched config and text-only weights, conversion is straightforward:</p><p>First we be sure we have the latest <strong>mlx-lm</strong>:</p><pre>python -m pip install --upgrade mlx-lm</pre><p>Now let’s run the mlx conversion:</p><pre>python -m mlx_lm convert --hf-path ~/models/DotsOCR_textonly --mlx-path ~/mlx-checkpoints/dotsocr-text -q</pre><p>The -q flag enabled quantization, reducing memory usage while preserving performance. On my M3 Ultra, this isn&#39;t necessary.</p><h3>Sanity Check</h3><p>To verify everything worked, I generated text with the converted model:</p><pre>python -m mlx_lm generate \ --model ~/mlx-checkpoints/dotsocr-text \ --prompt &quot;You are a helpful assistant.\nUser: Say hello in one short sentence.\nAssistant:&quot; \ --max-tokens 64 \ --temp 0.7 \ --top-p 0.9</pre><p>The model responds with a coherent continuation — confirming that the <strong>Qwen2 text backbone of Dots-OCR is alive and running in MLX</strong>.</p><h3>What We Have</h3><p>At this point, we’ve successfully:</p><ul><li>Converted dots.ocr into a <strong>text-only MLX model</strong>.</li><li>Verified it runs natively and efficiently on Apple Silicon.</li></ul><p>What’s missing? The <strong>vision tower</strong>. Without it, the model won’t yet handle images for OCR. That’s exactly what Part 2 will address.</p><h3>Coming Up in Part 2</h3><p>In the next post, we’ll bring the vision tower into MLX by:</p><ol><li>Porting DotsVisionTransformer into MLX.</li><li>Converting the vision weights from the original shards.</li><li>Connecting vision embeddings into the Qwen2 text stack.</li><li>Running end-to-end OCR on real images.</li></ol><p>With the text backbone already working, the next step is to unlock full <strong>multimodal OCR</strong> performance on Apple Silicon.</p><p>Stay tuned for <strong>Part 2</strong>.</p><p>✍️ Written and tested on a Mac Studio M3 Ultra with 512 GB unified memory.</p><p><em>Originally published at </em><a href="https://tomorrowsinnovations.co/blog/converting-dots-ocr-to-mlx-part-1"><em>https://tomorrowsinnovations.co</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d56e6a7c390" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>