Build an On-Device LLM Chatbot with Kotlin and TensorFlow Lite A developer detailed the architecture for building an on-device LLM chatbot using Kotlin and TensorFlow Lite, focusing on mobile integration, model execution, prompt handling, and performance. The tutorial covers creating a model runner, tokenization, off-main-thread inference, and incremental token generation to keep the UI responsive. Large language models are usually accessed through cloud APIs, but modern Android devices can also run smaller AI models locally. This makes it possible to build applications that work offline and keep sensitive prompts on the device. In this tutorial, we will design the architecture of an on-device LLM chatbot using Kotlin and TensorFlow Lite. The focus is on the mobile integration layer, model execution, prompt handling, and performance considerations. The application will have: The exact model and tokenizer implementation depends on the model architecture you choose. Always use a model converted and packaged for the runtime supported by your Android application. A simple architecture looks like this: Chat UI | ViewModel | LLM Repository | Tokenizer | TensorFlow Lite Interpreter | Local Model Keeping model execution behind a repository makes it easier to replace the model later. Create an Android project with Kotlin and add TensorFlow Lite dependencies appropriate for the runtime and model you selected. For example: dependencies { implementation "org.tensorflow:tensorflow-lite: