Skip to content

Instantly share code, notes, and snippets.

Sure, for running an LLM locally on an iOS device, we can use a smaller, more efficient model like GPT-2 or a distilled version. For simplicity, I will demonstrate using the CoreML framework with a pre-trained GPT-2 model that has been converted to CoreML format. This example will include the necessary steps to integrate the model and measure the response time.

Complete Example for iOS App with Swift, Metal, and a Local GPT-2 Model

1. Convert a Pre-trained GPT-2 Model to CoreML

First, you need to convert a pre-trained GPT-2 model to CoreML format. This is typically done outside Xcode using a Python script. Here is a basic script to convert a GPT-2 model to CoreML:

# Install the required packages

Certainly! Below are the instructions for converting a GPT-2 model to CoreML and the code for a macOS command-line tool to use that model.

Step 1: Convert GPT-2 Model to CoreML

First, use a Python script to convert the GPT-2 model to CoreML.

Python Script to Convert GPT-2 Model to CoreML

  1. Install the required packages:
@szmeku
szmeku / lag.mq5
Last active February 6, 2026 14:13
//+------------------------------------------------------------------+
//| TimeSync_Checker.mq5 |
//| Time Synchronization Analyzer |
//| |
//| PURPOSE: |
//| This script measures time synchronization between: |
//| 1. Your local PC clock |
//| 2. The broker's trade server clock |
//| 3. True internet time (via HTTP API) |
//| |

Orchestrator Prompt

Sub-Agent Management

You have a coder sub-agent tool. Spawn 1–3 instances based on actual need — not by default.

Isolation: Each agent works in its own git worktree. Agents must never edit the same file. For git trees create subfolders in current folder.

Stateless: Agents have no memory — every spawn is fresh. Pass all necessary context (relevant code snippets, decisions so far, constraints)