Skip to content

Commit

Permalink
docs: correct title casing and minor typos (#71)
Browse files Browse the repository at this point in the history
## Description
Removed every possible use of title case and fixed some typos / weird
usages of words

### Type of change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [x] Documentation update (improves or adds clarity to existing
documentation)

### Tested on
- [ ] iOS
- [ ] Android

### Testing instructions
<!-- Provide step-by-step instructions on how to test your changes.
Include setup details if necessary. -->

### 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
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] 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. -->
  • Loading branch information
chmjkb authored Dec 19, 2024
1 parent 2811ca9 commit 98cbe68
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions docs/docs/computer-vision/useClassification.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ A string that specifies the location of the model binary. For more information,

## Running the model

To run the model, you can use the `forward` method. It accepts one argument, which is the image. The image can be a remote URL, a local file URI, or a base64-encoded image. The function returns a promise, which can resolve either to error or an object containing categories with their probabilities.
To run the model, you can use the `forward` method. It accepts one argument, which is the image. The image can be a remote URL, a local file URI, or a base64-encoded image. The function returns a promise, which can resolve either to an error or an object containing categories with their probabilities.

:::info[Info]
:::info
Images from external sources are stored in your application's temporary directory.
:::

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/computer-vision/useObjectDetection.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function App() {
}
```

## Supported Models
## Supported models

| Model | Number of classes | Class list |
| --------------------------------------------------------------------------------------------------------------- | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/computer-vision/useStyleTransfer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ A string that specifies the location of the model binary. For more information,

## Running the model

To run the model, you can use `forward` method. It accepts one argument, which is the image. The image can be a remote URL, a local file URI, or a base64-encoded image. The function returns a promise which can resolve either to error or a URL to generated image.
To run the model, you can use `forward` method. It accepts one argument, which is the image. The image can be a remote URL, a local file URI, or a base64-encoded image. The function returns a promise which can resolve either to an error or a URL to generated image.

:::info
Images from external sources and the generated image are stored in your application's temporary directory.
Expand All @@ -86,7 +86,7 @@ function App(){
}
```

## Supported Models
## Supported models

- [Candy](https://github.com/pytorch/examples/tree/main/fast_neural_style)
- [Mosaic](https://github.com/pytorch/examples/tree/main/fast_neural_style)
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/fundamentals/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ When using Expo, please note that you need to use a custom development build of
:::

:::info
Because we are using ExecuTorch under the hood, you won't be able to build ios app for release with simulator selected as the target device. Make sure to test release builds on real devices.
Because we are using ExecuTorch under the hood, you won't be able to build iOS app for release with simulator selected as the target device. Make sure to test release builds on real devices.
:::

Running the app with the library:
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/fundamentals/loading-models.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ sidebar_position: 1

There are three different methods available for loading model files, depending on their size and location.

**1. Load from React-Native assets folder (For Files < **512MB**)**
**1. Load from React Native assets folder (For Files < 512MB)**

```typescript
modelSource: require('../assets/llama3_2.pte');
```

**2. Load from Remote URL:**
**2. Load from remote URL:**

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).

Expand Down
12 changes: 6 additions & 6 deletions docs/docs/llms/exporting-llama.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ sidebar_position: 2
In order to make the process of export as simple as possible for you, we created a script that runs a Docker container and exports the model.

## Steps to export Llama
### 1. Create an Account
### 1. Create an account
Get a [HuggingFace](https://huggingface.co/) account. This will allow you to download needed files. You can also use the [official Llama website](https://www.llama.com/llama-downloads/).

### 2. Select a Model
### 2. Select a model
Pick the model that suits your needs. Before you download it, you'll need to accept a license. For best performance, we recommend using Spin-Quant or QLoRA versions of the model:
- [Llama 3.2 3B](https://huggingface.co/meta-llama/Llama-3.2-3B-Instruct/tree/main/original)
- [Llama 3.2 1B](https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct/tree/main/original)
Expand All @@ -18,22 +18,22 @@ Pick the model that suits your needs. Before you download it, you'll need to acc
- [Llama 3.2 3B QLoRA](https://huggingface.co/meta-llama/Llama-3.2-3B-Instruct-QLORA_INT4_EO8/tree/main)
- [Llama 3.2 1B QLoRA](https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct-QLORA_INT4_EO8/tree/main)

### 3. Download Files
### 3. Download files
Download the `consolidated.00.pth`, `params.json` and `tokenizer.model` files. If you can't see them, make sure to check the `original` directory.

### 4. Rename the Tokenizer File
### 4. Rename the tokenizer file
Rename the `tokenizer.model` file to `tokenizer.bin` as required by the library:
```bash
mv tokenizer.model tokenizer.bin
```

### 5. Run the Export Script
### 5. Run the export script
Navigate to the `llama_export` directory and run the following command:
```bash
./build_llama_binary.sh --model-path /path/to/consolidated.00.pth --params-path /path/to/params.json
```

The script will pull a Docker image from docker hub, and then run it to export the model. By default the output (llama3_2.pte file) will be saved in the `llama-export/outputs` directory. However, you can override that behavior with the `--output-path [path]` flag.
The script will pull a Docker image from Docker Hub, and then run it to export the model. By default the output (llama3_2.pte file) will be saved in the `llama-export/outputs` directory. However, you can override that behavior with the `--output-path [path]` flag.

:::note[Note]
This Docker image was tested on MacOS with ARM chip. This might not work in other environments.
Expand Down
8 changes: 4 additions & 4 deletions docs/docs/llms/running-llms.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ sidebar_position: 1

React Native ExecuTorch supports Llama 3.2 models, including quantized versions. Before getting started, you’ll need to obtain the .pte binary—a serialized model—and the tokenizer. There are various ways to accomplish this:

- For your convienience, it's best if you use models exported by us, you can get them from our hugging face repository. You can also use [constants](https://github.com/software-mansion/react-native-executorch/tree/main/src/constants/modelUrls.ts) shipped with our library.
- If you want to export model by yourself,you can use a Docker image that we've prepared. To see how it works, check out [exporting Llama](./exporting-llama)
- For your convienience, it's best if you use models exported by us, you can get them from our [HuggingFace repository](https://huggingface.co/software-mansion/react-native-executorch-llama-3.2). You can also use [constants](https://github.com/software-mansion/react-native-executorch/tree/main/src/constants/modelUrls.ts) shipped with our library.
- If you want to export model by yourself, you can use a Docker image that we've prepared. To see how it works, check out [exporting Llama](./exporting-llama)
- Follow the official [tutorial](https://github.com/pytorch/executorch/blob/fe20be98c/examples/demo-apps/android/LlamaDemo/docs/delegates/xnnpack_README.md) made by ExecuTorch team to build the model and tokenizer yourself

## Initializing
Expand Down Expand Up @@ -55,7 +55,7 @@ Given computational constraints, our architecture is designed to support only on
| `isReady` | `boolean` | Indicates whether the model is ready |
| `downloadProgress` | `number` | Represents the download progress as a value between 0 and 1, indicating the extent of the model file retrieval. |

### Sending a message
## Sending a message

In order to send a message to the model, one can use the following code:

Expand All @@ -71,7 +71,7 @@ await llama.generate(message);
...
```

### Listening for the response
## Listening for the response

As you might've noticed, there is no return value from the `runInference` function. Instead, the `.response` field of the model is updated with each token.
This is how you can render the response of the model:
Expand Down
10 changes: 5 additions & 5 deletions docs/docs/module-api/executorch-bindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The `modelSource` parameter expects a location string pointing to the model bina
| `loadForward` | `() => Promise<void>` | Loads resources specific to `forward` method into memory before execution. Uses `loadMethod` under the hood. |
| `forward` | `(input: ETInput, shape: number[]) => Promise<number[][]>` | Executes the model's forward pass, where `input` is a Javascript typed array and `shape` is an array of integers representing input Tensor shape. The output is a Tensor - raw result of inference. |

### ETInput
## ETInput

The `ETInput` type defines the typed arrays that can be used as inputs in the `forward` method:

Expand All @@ -48,7 +48,7 @@ The `ETInput` type defines the typed arrays that can be used as inputs in the `f
- Float32Array
- Float64Array

### Errors
## Errors

All functions provided by the `useExecutorchModule` hook are asynchronous and may throw an error. The `ETError` enum includes errors [defined by the ExecuTorch team](https://github.com/pytorch/executorch/blob/main/runtime/core/error.h) and additional errors specified by our library.

Expand All @@ -60,7 +60,7 @@ To run model with ExecuTorch Bindings it's essential to specify the shape of the

This example demonstrates the integration and usage of the ExecuTorch bindings with a [style transfer model](../computer-vision/useStyleTransfer.mdx). Specifically, we'll be using the `STYLE_TRANSFER_CANDY` model, which applies artistic style transfer to an input image.

### Importing the Module and loading the model
## Importing the Module and loading the model

First, import the necessary functions from the `react-native-executorch` package and initialize the ExecuTorch module with the specified style transfer model.

Expand All @@ -77,7 +77,7 @@ const executorchModule = useExecutorchModule({
```


### Setting up input parameters
## Setting up input parameters

To prepare the input for the model, define the shape of the input tensor. This shape depends on the model's requirements. For the `STYLE_TRANSFER_CANDY` model, we need a tensor of shape `[1, 3, 640, 640]`, corresponding to a batch size of 1, 3 color channels (RGB), and dimensions of 640x640 pixels.

Expand All @@ -88,7 +88,7 @@ const shape = [1, 3, 640, 640];
const input = new Float32Array(1 * 3 * 640 * 640); // fill this array with your image data
```

### Performing inference
## Performing inference

```typescript
try {
Expand Down

0 comments on commit 98cbe68

Please sign in to comment.