React Native ExecuTorch provides a declarative way to run AI models on-device using React Native, powered by ExecuTorch π. It offers out-of-the-box support for a wide range of LLMs, computer vision models, and more. Visit our HuggingFace page to explore these models.
ExecuTorch, developed by Meta, is a novel framework allowing AI model execution on devices like mobile phones or microcontrollers.
React Native ExecuTorch bridges the gap between React Native and native platform capabilities, enabling developers to efficiently run local AI models on mobile devices. This can be achieved without the need for extensive expertise in native programming or machine learning.
Table of contents:
- β―οΈ Supported versions
- π€ Ready-made models
- π Documentation
- π¦ Quickstart - Running Llama
- π² Examples
- βοΈ License
- π What's next?
The minimal supported version are:
- iOS 17.0
- Android 13
- React Native 0.76
Important
React Native Executorch supports only the New React Native architecture.
Our library has a number of ready-to-use AI models; a complete list is available in the documentation. If you're interested in running your own AI model, you need to first export it to the .pte
format. Instructions on how to do this are available in the Python API.
Check out how our library can help you build your React Native AI features by visiting our docs:
https://docs.swmansion.com/react-native-executorch
Get started with AI-powered text generation in 3 easy steps!
# Install the package
yarn add react-native-executorch
# Depending on the platform, choose either iOS or Android
yarn expo run:< ios | android >
Add this to your component file:
import {
useLLM,
LLAMA3_2_1B,
} from 'react-native-executorch';
function MyComponent() {
// Initialize the model π
const llm = useLLM({ model: LLAMA3_2_1B });
// ... rest of your component
}
const handleGenerate = async () => {
const chat = [
{ role: 'system', content: 'You are a helpful assistant' },
{ role: 'user', content: 'What is the meaning of life?' }
];
// Chat completion
await llm.generate(chat);
console.log('Llama says:', llm.response);
};
We currently host a few example apps demonstrating use cases of our library:
llm
- Chat application showcasing use of LLMsspeech-to-text
- Whisper and Moonshine models ready for transcription taskscomputer-vision
- Computer vision related taskstext-embeddings
- Computing text representations for semantic search
If you would like to run demo app, navigate to its project directory and install dependencies with:
yarn
Then, depending on the platform, choose either iOS or Android:
yarn expo run:< ios | android >
Warning
Running LLMs requires a significant amount of RAM. If you are encountering unexpected app crashes, try to increase the amount of RAM allocated to the emulator.
This library is licensed under The MIT License.
To learn about our upcoming plans and developments, please visit our milestones.
Since 2012, Software Mansion is a software agency with experience in building web and mobile apps. We are Core React Native Contributors and experts in dealing with all kinds of React Native issues. We can help you build your next dream product β Hire us.