This directory contains example scripts demonstrating MLX-Node capabilities.
lm.ts runs token generation through mlx-node and reports tokens/second.
# Build the project (from project root)
yarn install && yarn buildConvert a Qwen model to MLX float32 format:
# Using mlx-lm
python -m mlx_lm.convert \
--hf-path Qwen/Qwen2.5-0.5B-Instruct \
--mlx-path .cache/models/qwen3-0.6b-mlx-f32 \
--dtype float32node examples/lm.ts
# Or with oxnode
npx oxnode examples/lm.tslm.ts:
- Uses the model at
.cache/models/qwen3-0.6b-mlx-f32 - Generates with
temperature=0.7, topP=0.9 - Displays tokens/second for performance
Expected output format:
Generated (42 tokens, 850ms, 49.41 tokens/s):
[generated text...]
- First run may be slower due to model loading and Metal shader compilation
- Subsequent runs typically show consistent performance
- tokens/s metric excludes model loading time, only measures generation
- Uses Apple Metal GPU acceleration