Building a PaddlePaddle Environment to Complete Text Sentiment Classification
Building a PaddlePaddle Environment to Complete Text Sentiment Classification
Background
Based on Baidu's deep learning technology research and business application for many years, PaddlePaddle integrates with deep learning core training and reasoning framework, basic model base, end-to-end development kit, and abundant toolkits. This chapter takes bcc.vgn3 (Ubuntu18.04 LTS) as an example to introduce how to quickly build a GPU environment for PaddlePaddle and use the pre-trained model to complete text sentiment classification prediction.
Precondition
- Provide a GPU instance, such as gn3, gn2 and vgn3.
- Install Cuda and GPU driver in the GPU instance. It is recommended to install the Cuda version 11.2, 10.2, or 10.1.
- Purchase EIP to access the public network.
Operation Steps
Log in to the GPU instance, and view the Cuda and GPU driver versions.
nvidia-smi
View the current Python environment and confirm that the python version is a3.6 / 3.7 / 3.8 / 3.9
which python
python --version
Install PIP3 and upgrade
apt-get install python3-pip
pip3 install -U pip
Install the paddlepaddle-gpu framework. This chapter takes Cuda 10.2 as an example. If you need to use other Cuda versions to build a PaddlePaddle environment, please see Installation of Other Cuda Versions.
python -m pip install paddlepaddle-gpu -i https://mirror.baidu.com/pypi/simple
Install pre-trained model management tool paddlehub
pip install paddlehub
Download the pre-trained model senta_bilstm by paddlehub
hub install senta_bilstm==1.2.0
Run senta_bilstm
hub run senta_bilstm --input_text “I love artificial intelligence"
The prediction results are as follows, and the model predicts that the text is positive emotion.