<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Mehran Toosi · blog</title>
    <link>https://mehran.dk/blog</link>
    <atom:link href="https://mehran.dk/blog/rss.xml" rel="self" type="application/rss+xml" />
    <description>How systems I built work, told step by step with animations.</description>
    <language>en</language>
    <lastBuildDate>Fri, 06 Nov 2026 08:00:00 GMT</lastBuildDate>
    <item>
      <title>Orvena 4B: training a 4B model to do phone tasks without thinking</title>
      <link>https://mehran.dk/blog/orvena-4b</link>
      <guid isPermaLink="true">https://mehran.dk/blog/orvena-4b</guid>
      <pubDate>Fri, 06 Nov 2026 08:00:00 GMT</pubDate>
      <description>How I fine-tuned Qwen3.5-4B to do Orvena’s phone tasks with thinking off, with a bench that runs the app’s own agent loop, training data filtered by its checks, and the models that failed on the way.

Orvena is an iPhone assistant I’ve been building, and its main model was Qwen3.5-4B running locally on the phone. Qwen3.5-4B gets more tasks right when it thinks first, and thinking means writing several hundred tokens of reasoning before each action. The phone generates about 21 tokens a second, so a typical task with thinking took more than half a minute. Turning thinking off brought that down to about 16 seconds and left too many tasks wrong, so for a while the best results in the app came from Apple’s Private Cloud Compute, which needs the internet.

I wanted the local model to be good enough without thinking, so I fine-tuned Qwen3.5-4B on scenarios built around the app’s own tools and released the result as Orvena 4B. It passes 440 of the 547 held-out scenarios on a bench that runs the app’s agent loop, and the stock model passes 345. It also runs at about the same speed as the stock model with thinking off.</description>
      <category>on-device AI</category>
      <category>fine-tuning</category>
      <category>LLM agents</category>
      <category>tool calling</category>
      <category>MLX</category>
      <category>Qwen</category>
      <category>LoRA</category>
      <category>iOS</category>
    </item>
    <item>
      <title>Cue: a small on-device model for turn-taking in voice mode</title>
      <link>https://mehran.dk/blog/cue</link>
      <guid isPermaLink="true">https://mehran.dk/blog/cue</guid>
      <pubDate>Sun, 25 Oct 2026 08:00:00 GMT</pubDate>
      <description>How Cue-0.4B decides, in 30 languages and about 10 ms on the iPhone Neural Engine, whether speech during an answer means keep going, stop or a new request.

Orvena has a voice mode that keeps listening while it speaks. That only works if the assistant can tell what a short piece of speech means. While it is answering, “mm-hm” should not stop it, “wait, stop” should, and “ok got it, now check Lisbon” should stop it and become the next request. When it is idle, “can you hear me?” or “thanks” does not need the main language model at all.

Cue-0.4B is the model I trained to make both decisions from the speech recognizer’s transcript and the assistant’s own words. It is half of Qwen3-0.6B-Base with three small heads, covers 30 languages, runs in about 10 ms on the iPhone’s Neural Engine while the main model uses the GPU, and is released with open weights and a technical report. This post goes through how it works.</description>
      <category>voice assistants</category>
      <category>turn-taking</category>
      <category>on-device ML</category>
      <category>Core ML</category>
      <category>Neural Engine</category>
      <category>Qwen3</category>
      <category>LoRA</category>
    </item>
    <item>
      <title>Running an agent with a 4B model on an iPhone</title>
      <link>https://mehran.dk/blog/orvena-iphone</link>
      <guid isPermaLink="true">https://mehran.dk/blog/orvena-iphone</guid>
      <pubDate>Fri, 16 Oct 2026 08:00:00 GMT</pubDate>
      <description>How Orvena fits a 4B model and 38 tools into an iPhone’s memory, keeps its prompt cache, repairs a small model’s tool calls and tests every change on the phone.

Orvena is an iPhone assistant where the whole agent runs on the phone: the model, the tool loop, speech recognition and speech output. It uses Qwen 3.5 4B through MLX and needs an iPhone with 8 GB of memory. I had built agent harnesses before and expected the agent to be the hard part. It was the model. A 4B model at 4 bits has very little room for error, especially when it calls tools.

This post goes through the parts that decided whether it works: memory, the prompt cache, thinking, how tools are offered to the model, how its calls are repaired, a runtime update that broke it, and the tests that run on the phone.</description>
      <category>on-device AI</category>
      <category>LLM agents</category>
      <category>iOS</category>
      <category>MLX</category>
      <category>tool calling</category>
      <category>Qwen</category>
    </item>
    <item>
      <title>Routing an agent with four small models</title>
      <link>https://mehran.dk/blog/ml-hints</link>
      <guid isPermaLink="true">https://mehran.dk/blog/ml-hints</guid>
      <pubDate>Tue, 13 Oct 2026 08:00:00 GMT</pubDate>
      <description>How ecoai picks the model, tools and first step for each message with four small TF-IDF and logistic-regression models that stay silent when unsure.

ecoai is the internal AI platform for Slack and desktop that I built at Visma e-conomic. Before its main model can work on a message, three things have to be decided: which model setup to use, which of its roughly 160 tools to load, and what to do first. For a long time the model worked these out itself, by trial.

This post is about the four small models that now make those decisions before the first model call. They are TF-IDF features and logistic regression, they run in about a tenth of a millisecond, and most of the work went into making them stay quiet when they are not sure.</description>
      <category>machine learning</category>
      <category>LLM agents</category>
      <category>logistic regression</category>
      <category>TF-IDF</category>
      <category>genetic algorithms</category>
      <category>ecoai</category>
    </item>
    <item>
      <title>Keeping customer data from the model without blinding the agent</title>
      <link>https://mehran.dk/blog/privacy-guard</link>
      <guid isPermaLink="true">https://mehran.dk/blog/privacy-guard</guid>
      <pubDate>Fri, 09 Oct 2026 08:00:00 GMT</pubDate>
      <description>How Privacy Guard swaps personal data for stable tokens before a model call and restores them before a tool runs, so an agent acts on data its model never sees.

An agent that does real work needs real data. To send a payment reminder it has to know who the customer is and where to write, so names, email addresses and IBANs end up in the prompt. Sending them to a model provider is a GDPR problem.

Privacy Guard is the service I built to sit between an agent harness and the model provider. It replaces personal data with tokens before the model sees anything, keeps the mapping in an encrypted vault per conversation, and puts the real values back at the tool boundary. It runs in production behind ecoai at Visma e-conomic and is open source. This post goes through how it works, one mechanism at a time.</description>
      <category>privacy</category>
      <category>GDPR</category>
      <category>pseudonymization</category>
      <category>LLM agents</category>
      <category>Cloudflare Workers</category>
      <category>Durable Objects</category>
    </item>
    <item>
      <title>A knowledge graph that lets an agent answer data questions correctly</title>
      <link>https://mehran.dk/blog/knowledge-graph</link>
      <guid isPermaLink="true">https://mehran.dk/blog/knowledge-graph</guid>
      <pubDate>Wed, 07 Oct 2026 08:00:00 GMT</pubDate>
      <description>How ecoai’s knowledge graph is built from the product schema, ETL pipelines and five layers of SQL, then searched, prepared and checked before SQL runs.

ecoai, the internal AI platform for Slack and desktop that I built at Visma e-conomic, gets a lot of data questions. The warehouse behind them has hundreds of tables and views, many with thin descriptions, and what a view means often depends on the report it was built for. Better descriptions helped, but not enough. The agent would pick a view that looked right and count the wrong population, or read a missing row as a fact about the customer.

So I built a knowledge graph of the company’s data from the evidence in the repositories, put reviewed meaning on top of it, and changed how the agent writes SQL so that it starts from the graph. The eight clips below follow that from the product schema to a query that runs. Names, the question and the SQL in them are illustrative. The structure, the motion and the rounded counts follow the real system.</description>
      <category>knowledge graph</category>
      <category>AI agents</category>
      <category>business intelligence</category>
      <category>text-to-SQL</category>
      <category>data lineage</category>
    </item>
    <item>
      <title>CW Luma 10: a denser visual code that stays easy to scan</title>
      <link>https://mehran.dk/blog/cw-luma-10</link>
      <guid isPermaLink="true">https://mehran.dk/blog/cw-luma-10</guid>
      <pubDate>Fri, 02 Oct 2026 08:00:00 GMT</pubDate>
      <description>How CW Luma 10 (ChromaWeave) puts ten bits in each cell where phone cameras see detail best, checks its own reads, and moves files from a screen to a phone.

I’ve always liked visual codes. The usual ways to fit more data into one, more colours or smaller modules, also make it harder for a camera to read, and I had an idea for avoiding that trade-off: put most of the data where phone cameras see detail best, and let the decoder check its own work as it reads. It took many test builds, but it works now. This is CW Luma 10, CW for ChromaWeave.

The clips below were rendered from the codec and from my measurements. Each one shows one part of how it works.</description>
      <category>2D barcode</category>
      <category>computer vision</category>
      <category>error correction</category>
      <category>Reed-Solomon</category>
      <category>Rust</category>
    </item>
  </channel>
</rss>
