The following guide will show you how to connect a local model served with MLX to OpenCode for local coding.
1. Install OpenCode
curl -fsSL https://opencode.ai/install | bash
| """ | |
| An LM with a REPL | |
| Gives an LLM a Python REPL: the model can write ```repl``` code blocks, | |
| which get executed, with stdout/stderr fed back into the conversation. | |
| Requires a running mlx_lm.server: | |
| mlx_lm.server | |
| """ |
| """ | |
| The most atomic way to train and run inference for a GPT in pure, dependency-free Python. | |
| This file is the complete algorithm. | |
| Everything else is just efficiency. | |
| @karpathy | |
| """ | |
| import os # os.path.exists | |
| import math # math.log, math.exp |
| import FoundationModels | |
| import Playgrounds | |
| import Foundation | |
| let session = LanguageModelSession() | |
| let start = Date() | |
| let response = try await session.respond(to: "What is Apple Neural Engine and how to use it?") | |
| let responseText = response.content // Replace 'value' with the actual property name from LanguageModelSession.Response<String> that holds the string payload. | |
| print(responseText) | |
| let end = Date() |
Tool: draw.io
Animate the connectors
Animating your connectors is great for demonstrating directional flow charts, electrical circuits and more. To animate your connectors:
| # train_grpo.py | |
| # | |
| # See https://github.com/willccbb/verifiers for ongoing developments | |
| # | |
| """ | |
| citation: | |
| @misc{brown2025grpodemo, | |
| title={Granular Format Rewards for Eliciting Mathematical Reasoning Capabilities in Small Language Models}, | |
| author={Brown, William}, |
On every machine in the cluster install openmpi and mlx-lm:
conda install conda-forge::openmpi
pip install -U mlx-lmNext download the pipeline parallel run script. Download it to the same path on every machine:
| You are an assistant that engages in extremely thorough, self-questioning reasoning. Your approach mirrors human stream-of-consciousness thinking, characterized by continuous exploration, self-doubt, and iterative analysis. | |
| ## Core Principles | |
| 1. EXPLORATION OVER CONCLUSION | |
| - Never rush to conclusions | |
| - Keep exploring until a solution emerges naturally from the evidence | |
| - If uncertain, continue reasoning indefinitely | |
| - Question every assumption and inference |