rkllm-rs 
rkllm-rs is a Rust FFI wrapper for the librkllmrt library.
README.md
System Requirements
Before using rkllm-rs, you need to install librkllmrt. Please download and install from the following link:
Please install librkllmrt.so in one of the common Linux library paths:
/usr/lib/lib/usr/local/lib/opt/lib
Alternatively, you can use the LD_LIBRARY_PATH environment variable to specify the library path. For example:
The model used in this example can be found here
For devices with less memory, you can use this model
Installation
Install Rust
First, install Rust, or refer to this guide
|
Lazy Way
# If you already installed git-lfs, skip this step
You should now see the LLM start up:
I rkllm: rkllm-runtime version: 1.1.4, rknpu driver version: 0.9.7, platform: RK3588
rkllm init success
Say something: Hello
Robot:
<think>
</think>
Hello! How can I assist you today? 😊
Say something:
Version Support
| Rkllm Version | Rkllm-rs version |
|---|---|
| v1.1.4 | 0.1.8 |
| v1.2.0 | 0.1.9 |
Using as a Library
Add the following to your Cargo.toml:
[]
= "0.1.0"
Using as a Binary
rkllm-rs also supports running as a binary, suitable for users who do not plan to do further development or prefer an out-of-the-box experience.
Here is the help for the tool, with various parameters set according to the help:
)
)
Online Tokenizer Config
Currently, the model types are hardcoded in the program, and unsupported models will not correctly generate bos_token and assistant prompts. Most models will produce incorrect responses without the correct prompts, such as irrelevant answers or self-dialogue (though, to be fair, they might still engage in self-dialogue even with the prompts).
Most models have tokenizer_config.json available online. Reading this configuration file can generate the correct prompts.
You can manually create the prompt using tokenizer_config.json or use Python's AutoTokenizer to generate it.
This library provides a method to automatically fetch the corresponding model's tokenizer_config.json from online sources.
This tool will fetch the tokenizer_config.json for TinyLlama online and attempt to correct the prompts.