Bloom Large Language Model
Feature Introduction
This section describes how to experience on-device Large Language Models (LLMs) on the RDK platform.
Code repository: (https://github.com/D-Robotics/hobot_llm.git)
Supported Platforms
| Platform | Runtime Environment | Example Functionality |
|---|---|---|
| RDK X3, RDK X3 Module (4GB RAM) | Ubuntu 20.04 (Foxy), Ubuntu 22.04 (Humble) | On-device large language model experience |
Note: Only supports RDK X3 and RDK X3 Module with 4GB RAM.
Model Information
| Model | Parameters | Platform | Prefill Eval Time (ms/token) | Eval Time (ms/token) |
|---|---|---|---|---|
| Bloom | 1.4B | X3 | 305.34 | 364.78 |
Prerequisites
RDK Platform
- RDK must be the 4GB RAM version.
- RDK must have Ubuntu 20.04 or Ubuntu 22.04 system image flashed.
- TogetherROS.Bot must already be installed successfully on the RDK.
- Install
transformersby running:pip3 install transformers -i https://pypi.tuna.tsinghua.edu.cn/simple
Usage Instructions
RDK Platform
Before running the program, download and extract the model files using the following commands:
- Foxy
- Humble
# Configure tros.b environment
source /opt/tros/setup.bash
# Configure tros.b environment
source /opt/tros/humble/setup.bash
# Download model files
wget http://archive.d-robotics.cc/llm-model/llm_model.tar.gz
# Extract
sudo tar -xf llm_model.tar.gz -C /opt/tros/${TROS_DISTRO}/lib/hobot_llm/
Use the command srpi-config to adjust ION memory size to 1.9GB. For configuration details, refer to the Performance Options section in the RDK User Manual under the srpi-config usage guide: Performance Options.
After rebooting, set the CPU maximum frequency to 1.5GHz and the governor mode to performance using the following commands:
sudo bash -c 'echo 1 > /sys/devices/system/cpu/cpufreq/boost'
sudo bash -c 'echo performance > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor'
Currently, two interaction methods are provided:
- Direct terminal-based text chat
- Subscribe to input text messages and publish results as text messages
Terminal Interaction Experience
- Foxy
- Humble
# Configure tros.b environment
source /opt/tros/setup.bash
# Configure tros.b environment
source /opt/tros/humble/setup.bash
ros2 run hobot_llm hobot_llm_chat
After the program starts, you can directly chat with the robot in the current terminal.
Publish-Subscribe Interaction Experience
-
Launch
hobot_llm- Foxy
- Humble
# Configure tros.b environment
source /opt/tros/setup.bash# Configure tros.b environment
source /opt/tros/humble/setup.bashros2 run hobot_llm hobot_llm -
Open a new terminal and subscribe to the output topic
- Foxy
- Humble
# Configure tros.b environment
source /opt/tros/setup.bash# Configure tros.b environment
source /opt/tros/humble/setup.bashros2 topic echo /text_result -
Open another new terminal and publish a message
- Foxy
- Humble
# Configure tros.b environment
source /opt/tros/setup.bash# Configure tros.b environment
source /opt/tros/humble/setup.bashros2 topic pub --once /text_query std_msgs/msg/String "{data: \"What is the capital of China?\"}"
After sending the message, you can view the output result in the terminal that subscribed to /text_result.
Notes
Confirm that the development board memory is 4GB, and simultaneously adjust the ION memory size to 1.9GB; otherwise, model loading will fail.