Qualcomm lib Genie binding for React Native
npm install react-native-qnn-llm
- Download SDK from here
- Setup env
source path/to/QNN/SDK/bin/envsetup.sh
Add QNN libs dependency into android/app/build.gradle
dependencies {
+ implementation "com.qualcomm.qti:qnn-runtime:latest.integration@aar"
Or set useQnnSdkLib=true
in android/gradle.properties
Notes: If you use dependency, the version should match QNN SDK version
+ -keep class com.qnnllm.** { *; }
import { Context, SentenceCode } from 'react-native-qnn-llm';
const context = await Context.create(/* Genie config object */);
// Or load bundled
// const context = await Context.load({ bundle_path: 'path/to/bundle', unpack_dir: 'path/to/store/unpacked', n_thread?: Number })
await context.query('Hello, world!', (result, sentenceCode) => {
console.log(result);
});
await context.save_session('path/to/session-directory');
await context.restore_session('path/to/session-directory');
await context.set_stop_words(['stop_word1', 'stop_word2']);
await context.apply_sampler_config({
/* Genie sampler config */
});
await context.release();
To easier to deploy model, we announced packed file struct.
- Constant entry config path.
- Auto resolve file path.
- Patch config on load.
You can quickly pack your model files use pack.py.
Usage: pack.py path/to/config.json
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
Made with create-react-native-library
Built and maintained by BRICKS.