Skip to content

Commit 3f02766

Browse files
msluszniakbarhanc
andauthored
docs: Streamline docs (#1037)
## Description This PR changes some general issue in our documentation: - Removes duplicated Hire Us banner - Correct information marker - Unify tables (use checkmarks, make columns the same in benchmarks section) - Fix code snippets - Fix typos ### Introduces a breaking change? - [ ] Yes - [x] No ### Type of change - [ ] Bug fix (change which fixes an issue) - [ ] New feature (change which adds functionality) - [x] Documentation update (improves or adds clarity to existing documentation) - [ ] Other (chores, tests, code style improvements etc.) ### Tested on - [ ] iOS - [ ] Android ### Testing instructions Build documentation locally via `yarn start` and check if everything is corrected. ### Screenshots <!-- Add screenshots here, if applicable --> ### Related issues <!-- Link related issues here using #issue-number --> ### Checklist - [ ] I have performed a self-review of my code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have updated the documentation accordingly - [ ] My changes generate no new warnings ### Additional notes <!-- Include any additional information, assumptions, or context that reviewers might need to understand this PR. --> --------- Co-authored-by: Bartosz Hanc <bartosz.hanc02@gmail.com>
1 parent 8ec80d1 commit 3f02766

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+263
-469
lines changed

docs/docs/01-fundamentals/01-getting-started.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import TabItem from '@theme/TabItem';
2626

2727
## React Native ExecuTorch
2828

29-
React Native ExecuTorch is our way of bringing ExecuTorch into the React Native world. Our API is built to be simple, declarative, and efficient. Plus, we’ll provide a set of pre-exported models for common use cases, so you won’t have to worry about handling exports yourself. With just a few lines of JavaScript, you’ll be able to run AI models (even LLMs 👀) right on your device—keeping user data private and saving on cloud costs.
29+
React Native ExecuTorch is our way of bringing ExecuTorch into the React Native world. Our API is built to be simple, declarative, and efficient. Additionally, we provide a set of pre-exported models for common use cases, so you don't have to worry about handling exports yourself. With just a few lines of JavaScript, you can run AI models (even LLMs 👀) right on your device—keeping user data private and saving on cloud costs.
3030

3131
## Compatibility
3232

@@ -43,7 +43,7 @@ Installation is pretty straightforward, use your package manager of choice to in
4343
<Tabs>
4444
<TabItem value="npm" label="NPM">
4545

46-
```
46+
```bash
4747
npm install react-native-executorch
4848
# For Expo projects
4949
npm install react-native-executorch-expo-resource-fetcher
@@ -54,19 +54,18 @@ Installation is pretty straightforward, use your package manager of choice to in
5454
</TabItem>
5555
<TabItem value="pnpm" label="PNPM">
5656

57-
```
57+
```bash
5858
pnpm install react-native-executorch
5959
# For Expo projects
6060
pnpm install react-native-executorch-expo-resource-fetcher
6161
# For bare React Native projects
6262
pnpm install react-native-executorch-bare-resource-fetcher
63-
6463
```
6564

6665
</TabItem>
6766
<TabItem value="yarn" label="YARN">
6867

69-
```
68+
```bash
7069
yarn add react-native-executorch
7170
# For Expo projects
7271
yarn install react-native-executorch-expo-resource-fetcher
@@ -123,11 +122,11 @@ yarn <ios | android> -d
123122

124123
Adding new functionality to the library follows a consistent three-step integration pipeline:
125124

126-
1. **Model Serialization:** We export PyTorch models for specific tasks (e.g., object detection) into the \*.pte format, which is optimized for the ExecuTorch runtime.
125+
1. **Model Serialization:** Export PyTorch model for a specific task (e.g. object detection) into the `*.pte` format, which is optimized for the ExecuTorch runtime.
127126

128-
2. **Native Implementation:** We develop a C++ execution layer that interfaces with the ExecuTorch runtime to handle inference. This layer also manages model-dependent logic, such as data pre-processing and post-processing.
127+
2. **Native Implementation:** Develop a C++ execution layer that interfaces with the ExecuTorch runtime to handle inference. This layer also manages model-dependent logic, such as data pre-processing and post-processing.
129128

130-
3. **TS Bindings:** Finally, we implement a TypeScript API that bridges the JavaScript environment to the native C++ logic, providing a clean, typed interface for the end user."
129+
3. **TS Bindings:** Finally, implement a TypeScript API that bridges the JavaScript environment to the native C++ logic, providing a clean, typed interface for the end user.
131130

132131
## Good reads
133132

docs/docs/01-fundamentals/02-loading-models.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,17 @@ initExecutorch({
4444
});
4545
```
4646

47-
**1. Load from React Native assets folder (For Files < 512MB)**
47+
## Loading
48+
49+
### Load from React Native assets folder (for files < 512MB)
4850

4951
```typescript
5052
useExecutorchModule({
5153
modelSource: require('../assets/llama3_2.pte'),
5254
});
5355
```
5456

55-
**2. Load from remote URL:**
57+
### Load from remote URL
5658

5759
For files larger than 512MB or when you want to keep size of the app smaller, you can load the model from a remote URL (e.g. HuggingFace).
5860

@@ -62,7 +64,7 @@ useExecutorchModule({
6264
});
6365
```
6466

65-
**3. Load from local file system:**
67+
### Load from local file system
6668

6769
If you prefer to delegate the process of obtaining and loading model and tokenizer files to the user, you can use the following method:
6870

@@ -72,7 +74,7 @@ useExecutorchModule({
7274
});
7375
```
7476

75-
:::info
77+
:::note
7678
The downloaded files are stored in documents directory of your application.
7779
:::
7880

@@ -85,10 +87,7 @@ Our library offers out-of-the-box support for multiple models. To make things ea
8587
The following code snippet demonstrates how to load model and tokenizer files using `useLLM` hook:
8688

8789
```typescript
88-
import { useLLM } from 'react-native-executorch';
90+
import { useLLM, LLAMA3_2_1B } from 'react-native-executorch';
8991

90-
const llama = useLLM({
91-
modelSource: 'https://.../llama3_2.pte',
92-
tokenizerSource: require('../assets/tokenizer.bin'),
93-
});
92+
const llama = useLLM({ model: LLAMA3_2_1B });
9493
```

docs/docs/02-benchmarks/inference-time.md

Lines changed: 16 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,19 @@
22
title: Inference Time
33
---
44

5-
:::warning
5+
:::info
66
Times presented in the tables are measured as consecutive runs of the model.
77
Initial run times may be up to 2x longer due to model loading and
88
initialization.
9-
:::
10-
11-
## Classification
129

13-
:::info
1410
Inference times are measured directly from native C++ code, wrapping only the
1511
model's forward pass, excluding input-dependent pre- and post-processing (e.g.
1612
image resizing, normalization) and any overhead from React Native runtime.
1713
:::
1814

19-
:::info
15+
## Classification
16+
17+
:::note
2018
For this model all input images, whether larger or smaller, are resized before
2119
processing. Resizing is typically fast for small images but may be noticeably
2220
slower for very large images, which can increase total time.
@@ -31,19 +29,11 @@ slower for very large images, which can increase total time.
3129

3230
## Object Detection
3331

34-
:::info
35-
Inference times are measured directly from native C++ code, wrapping only the
36-
model's forward pass, excluding input-dependent pre- and post-processing (e.g.
37-
image resizing, normalization) and any overhead from React Native runtime.
38-
:::
39-
40-
:::info
32+
:::note
4133
For this model all input images, whether larger or smaller, are resized before
4234
processing. Resizing is typically fast for small images but may be noticeably
4335
slower for very large images, which can increase total time.
44-
:::
4536

46-
:::warning
4737
Times presented in the tables are measured for YOLO models with input size equal to 512. Other input sizes may yield slower or faster inference times. RF-DETR Nano uses a fixed resolution of 312×312.
4838
:::
4939

@@ -61,13 +51,7 @@ Times presented in the tables are measured for YOLO models with input size equal
6151

6252
## Style Transfer
6353

64-
:::info
65-
Inference times are measured directly from native C++ code, wrapping only the
66-
model's forward pass, excluding input-dependent pre- and post-processing (e.g.
67-
image resizing, normalization) and any overhead from React Native runtime.
68-
:::
69-
70-
:::info
54+
:::note
7155
For this model all input images, whether larger or smaller, are resized before
7256
processing. Resizing is typically fast for small images but may be noticeably
7357
slower for very large images, which can increase total time.
@@ -107,7 +91,9 @@ The values below represent the averages across all runs for the benchmark image.
10791

10892
## Vertical OCR
10993

110-
Notice that the recognizer models, as well as detector's `forward_320` method, were executed between 4 and 21 times during a single recognition.
94+
:::note
95+
Recognizer models, as well as detector's `forward_320` method, were executed between 4 and 21 times during a single recognition.
96+
:::
11197
The values below represent the averages across all runs for the benchmark image.
11298

11399
| Model | iPhone 17 Pro <br /> [ms] | iPhone 16 Pro <br /> [ms] | iPhone SE 3 | Samsung Galaxy S24 <br /> [ms] | OnePlus 12 <br /> [ms] |
@@ -160,6 +146,10 @@ Average time to synthesize speech from an input text of approximately 60 tokens,
160146

161147
## Text Embeddings
162148

149+
:::note
150+
Benchmark times for text embeddings are highly dependent on the sentence length. The numbers below are based on a sentence of around 80 tokens. For shorter or longer sentences, inference time may vary accordingly.
151+
:::
152+
163153
| Model | iPhone 17 Pro (XNNPACK) [ms] | OnePlus 12 (XNNPACK) [ms] |
164154
| -------------------------- | :--------------------------: | :-----------------------: |
165155
| ALL_MINILM_L6_V2 | 7 | 21 |
@@ -168,19 +158,9 @@ Average time to synthesize speech from an input text of approximately 60 tokens,
168158
| MULTI_QA_MPNET_BASE_DOT_V1 | 24 | 88 |
169159
| CLIP_VIT_BASE_PATCH32_TEXT | 14 | 39 |
170160

171-
:::info
172-
Benchmark times for text embeddings are highly dependent on the sentence length. The numbers above are based on a sentence of around 80 tokens. For shorter or longer sentences, inference time may vary accordingly.
173-
:::
174-
175161
## Image Embeddings
176162

177-
:::info
178-
Inference times are measured directly from native C++ code, wrapping only the
179-
model's forward pass, excluding input-dependent pre- and post-processing (e.g.
180-
image resizing, normalization) and any overhead from React Native runtime.
181-
:::
182-
183-
:::info
163+
:::note
184164
For this model all input images, whether larger or smaller, are resized before
185165
processing. Resizing is typically fast for small images but may be noticeably
186166
slower for very large images, which can increase total time.
@@ -193,13 +173,7 @@ slower for very large images, which can increase total time.
193173

194174
## Semantic Segmentation
195175

196-
:::info
197-
Inference times are measured directly from native C++ code, wrapping only the
198-
model's forward pass, excluding input-dependent pre- and post-processing (e.g.
199-
image resizing, normalization) and any overhead from React Native runtime.
200-
:::
201-
202-
:::info
176+
:::note
203177
For this model all input images, whether larger or smaller, are resized before
204178
processing. Resizing is typically fast for small images but may be noticeably
205179
slower for very large images, which can increase total time.
@@ -222,10 +196,7 @@ slower for very large images, which can increase total time.
222196

223197
## Instance Segmentation
224198

225-
:::warning
226-
Times presented in the tables are measured as consecutive runs of the model. Initial run times may be up to 2x longer due to model loading and initialization.
227-
:::
228-
:::warning
199+
:::note
229200
Times presented in the tables are measured for YOLO models with input size equal to 512. Other input sizes may yield slower or faster inference times. RF-DETR Nano Seg uses a fixed resolution of 312×312.
230201
:::
231202

0 commit comments

Comments
 (0)