LLM Inference on Edge: A Fun and Easy Guide to run LLMs via React Native on your Phone!
A step-by-step tutorial for building a cross-platform React Native chat app that downloads GGUF-quantized LLMs from the Hugging Face Hub and runs them fully on-device using llama.rn, a binding for llama.cpp. It explains how to choose models for phones (1-3B parameters are ideal, larger ones need aggressive quantization) and how the legacy, K-quant and I-quant GGUF formats trade file size against accuracy and speed. It then covers environment setup, the project structure, React state for chat and downloads, and fetching available GGUF files via the Hub API. A recommended tradeoff: a larger model at low-bit quantization can outperform a smaller model at Q8_0.
Related posts
- Transformers now runs llama.cpp quants
Hugging Face mediumAdeptHugging Face transformers can now load GGUF (llama.cpp) quantized checkpoints via `from_pretrained(..., gguf_file=...)` and serve them through `transformers serve` with an OpenAI-compatible API. Weights stay packed on Apple Silicon, and ggml's Metal kernels are reused via the `kernels` library for quantized matmul, fused RMSNorm, flash attention, gated delta nets and MoE top-k routing. Two `generate` changes, dropping all-ones padding masks and deferring the stopping check asynchronously, cut CPU-GPU synchronization for all models. Benchmarks on an M2 Max show throughput close to llama-bench for Qwen3.5 dense and MoE checkpoints, though llama.cpp remains the recommended engine for pure local inference. The initial packed path is MPS-only, and padded batching is still slower.
- Local LLM Messenger: Chat with GenAI on Your iPhone
Docker mediumAdeptLocal LLM Messenger (LoLLMM), an honorable-mention project from Docker's AI/ML Hackathon by Justin Garrison, lets you send iMessages to LLMs running on your own machine. A FastAPI Python app receives Sendblue webhooks, routes prompts to local Ollama models (defaulting to llama2) or optionally OpenAI's GPT-3.5 Turbo and DALL-E 2, keeps conversation context in a file, and supports slash commands for switching models. Docker Compose runs the app, an ngrok tunnel exposing port 8000, and an Ollama container with optional NVIDIA GPU access. A setup walkthrough covers cloning the repo, configuring API keys in .env, and adding the ngrok authtoken.
- Releasing Swift Transformers: Run On-Device LLMs in Apple Devices
Hugging Face mediumAdeptHugging Face released swift-transformers, an alpha Swift package with a transformers-like API for on-device text generation, along with the swift-chat demo app, updated exporters and transformers-to-coreml conversion tools, and pre-converted Llama 2 7B and Falcon 7B Core ML models. The post walks through converting Llama 2 to Core ML via three routes: the no-code Space, exporters, or raw coremltools. Lessons from those conversions include using coremltools 7.0b1, dropping softmax from outputs, and using fixed sequence lengths, because flexible shapes only run on the CPU. Planned optimizations are KV caching, discrete input shapes and palettization or mixed-bit quantization, and the library already supports Hub-configured BPE tokenizers plus greedy and top-k generation.
- Run fast, private agents on-device with LFM2.5-24B-A2B
Hugging Face mediumAdeptLFM2.5-24B-A2B is an open-weight 24B-parameter MoE reasoning model with 2B active parameters per token, aimed at running tool-using agents on local hardware. It keeps LFM2's 40-layer hybrid of gated short convolutions and GQA with 64 experts and top-4 routing. The context window grows from 32K to 131K tokens, the vocabulary doubles to 128K, pre-training scales to ~33T tokens, and post-training runs SFT, teacher specialization, two on-policy distillation stages and agentic RL inside harnesses like OpenClaw and Hermes Agent. It leads larger MoEs such as Qwen3.6-35B-A3B on most tool-use and instruction-following benchmarks but trails on knowledge and coding tasks like SWE-Bench Verified. It decodes 184 tok/s on an M5 Max and up to 21K tok/s on a B300, and ships with transformers code and an OpenAI-compatible harness configuration.
- Hugging Face Text Generation Inference available for AWS Inferentia2
Hugging Face mediumAdeptText Generation Inference (TGI) is now generally available on AWS Inferentia2 through Amazon SageMaker, offering an alternative to GPUs for serving open LLMs such as Llama and Mistral. A walkthrough deploys Zephyr 7B on an ml.inf2.8xlarge using the TGI Neuronx container. Because Inferentia2 lacks dynamic shapes, batch size, sequence length, core count and cast type must be fixed at compile time. A neuron model cache provides pre-compiled configurations; compiling an uncached one with optimum-cli can take up to 45 minutes. The deployment environment variables (HF_NUM_CORES, HF_BATCH_SIZE, HF_SEQUENCE_LENGTH, MAX_TOTAL_TOKENS) must match those compile-time settings.