Skip to content

Commit e954580

Browse files
committed
chore: update README.md
1 parent 43cb47e commit e954580

File tree

1 file changed

+49
-12
lines changed

1 file changed

+49
-12
lines changed

README.md

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44
[![codecov](https://codecov.io/github/daviddaytw/react-native-transformers/graph/badge.svg?token=G3D0Y33SI4)](https://codecov.io/github/daviddaytw/react-native-transformers)
55
[![TypeDoc](https://github.com/daviddaytw/react-native-transformers/actions/workflows/docs.yml/badge.svg)](https://daviddaytw.github.io/react-native-transformers)
66

7-
`react-native-transformers` is a React Native library for incorporating transformer models into your mobile applications. It supports both iOS and Android platforms, allowing you to leverage advanced AI models directly on your device.
7+
`react-native-transformers` is a React Native library for running Large Language Models (LLMs) from Hugging Face on your mobile applications locally. It supports both iOS and Android platforms, allowing you to leverage advanced AI models directly on your device without requiring an internet connection.
88

99
## Features
1010

11-
- On-device transformer model support
12-
- Compatible with iOS and Android
13-
- Simple API for model loading and text generation
11+
- On-device transformer model support for both text generation and text embedding
12+
- Local inference without internet connectivity
13+
- Compatible with iOS and Android platforms
14+
- Simple API for model loading and inference
15+
- Support for Hugging Face models in ONNX format
16+
- Built on top of ONNX Runtime for efficient model execution
17+
- TypeScript support with full type definitions
1418

1519
## Installation
1620

@@ -68,11 +72,11 @@ To use `react-native-transformers`, you need to install `onnxruntime-react-nativ
6872

6973
## Usage
7074

71-
Here is an example of how to use `react-native-transformers` in an Expo application:
75+
### Text Generation Example
7276

7377
```javascript
7478
import React from "react";
75-
import { View, Text, Button, TextInput } from "react-native";
79+
import { View, Text, Button } from "react-native";
7680
import { Pipeline } from "react-native-transformers";
7781
7882
export default function App() {
@@ -98,7 +102,38 @@ export default function App() {
98102
}
99103
```
100104
101-
For detailed usage please reference ['API documentation'](https://daviddaytw.github.io/react-native-transformers/)
105+
### Text Embedding Example
106+
107+
```javascript
108+
import React from "react";
109+
import { View, Text, Button } from "react-native";
110+
import { Pipeline } from "react-native-transformers";
111+
112+
export default function App() {
113+
const [embedding, setEmbedding] = React.useState([]);
114+
115+
// Function to initialize the model
116+
const loadModel = async () => {
117+
await Pipeline.TextEmbedding.init("Xenova/all-MiniLM-L6-v2");
118+
};
119+
120+
// Function to generate embeddings
121+
const generateEmbedding = async () => {
122+
const result = await Pipeline.TextEmbedding.generate("Hello world");
123+
setEmbedding(result);
124+
};
125+
126+
return (
127+
<View>
128+
<Button title="Load Model" onPress={loadModel} />
129+
<Button title="Generate Embedding" onPress={generateEmbedding} />
130+
<Text>Embedding Length: {embedding.length}</Text>
131+
</View>
132+
);
133+
}
134+
```
135+
136+
For detailed API documentation, please visit our [TypeDoc documentation](https://daviddaytw.github.io/react-native-transformers/).
102137
103138
## Contributing
104139
@@ -110,13 +145,15 @@ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file
110145
111146
## Acknowledgements
112147
113-
This library relies on the ONNX Runtime for running the models efficiently on mobile devices.
148+
- [ONNX Runtime](https://onnxruntime.ai/) for efficient model execution on mobile devices
149+
- [@xenova/transformers](https://www.npmjs.com/package/@xenova/transformers) for transformer model implementations
150+
- [Hugging Face](https://huggingface.co/) for providing pre-trained models and model hosting
114151
115152
## External Links
116153
117-
- [Expo Plugins](https://docs.expo.dev/guides/config-plugins/)
118-
- [ONNX Runtime](https://onnxruntime.ai/)
119-
- [Babel](https://babeljs.io/)
120-
- [Hugging Face](https://huggingface.co/)
154+
- [Expo Plugins Documentation](https://docs.expo.dev/guides/config-plugins/)
155+
- [ONNX Runtime Documentation](https://onnxruntime.ai/)
156+
- [Hugging Face Model Hub](https://huggingface.co/models)
157+
- [Babel Documentation](https://babeljs.io/)
121158
122159
These links provide additional information on how to configure and utilize the various components used by `react-native-transformers`.

0 commit comments

Comments
 (0)