TuGraph-DB ChatBot is a demo demonstrates the effect of an agent trained by the corpus generated by the Awesome-Text2GQL. It can intercract with the TuGraph-DB taking how you want to operate the db in Chinese as input, such as querying or creating data. And The ChatBot will also help you to excute the cypher too. Let's try it now!
-
Awesome-Text2GQL helps to generate dataset for fine-tuning LLMs.
-
TuGraph-DB is the db we'll chat with.
-
DB-GPT-GQL helps to fine-tune LLMs.
This README.md has been tested in:
-
GPU: V100 16G-RAM
-
OS: CentOS7
-
Disk: System Disk 110G or larger (minimum requirements: System Disk 40G, Data Disk 60G, if install data and model in data disk)
Nvidia Docker
allows you to use NVIDIA GPU in docker.
Here is the installation method to install Nvidia Docker in CentOS7. You can install Nvidia Docker in ubuntu system by yourself as well.
Make sure you have installed Nvidia Docker
before you start the container of tugraph-db-runtime image in the following steps.
distribution=$(. /etc/os-release;echo$ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.repo | sudo tee /etc/yum.repos.d/nvidia-docker.repo
sudo yum install -y nvidia-docker2
sudo pkill -SIGHUP dockerd
Restart docker
sudo systemctl restart docker
Pull tugraph-db docker image and build it from source.
docker pull tugraph/tugraph-compile-centos7
Set environment variables
export VERSION=latest # the version of compile image is latest
export REPOSITORY=docker.io/tugraph/tugraph-compile-centos7 # path to your docker image
Start Container
docker run -dt --name demo_comp ${REPOSITORY}:${VERSION} /bin/bash
Python3.10 is required for the demo.
# install dependency package
yum groupinstall "Development Tools"
yum install openssl-devel bzip2-devel libffi-devel
# bulid Python3.10 from source
wget https://www.python.org/ftp/python/3.10.15/Python-3.10.15.tgz
tar xzf Python-3.10.15.tgz
cd Python-3.10.15
./configure --enable-optimizations --with-openssl=/usr/include/openssl
make altinstall
# verify
python3.10 --version
Set python3.10 as the default python.
update-alternatives --install /usr/local/bin/python3 python3 /usr/local/bin/python3.6 1
update-alternatives --install /usr/local/bin/python3 python3 /usr/local/bin/python3.10 2
update-alternatives --config python3
In the last step, you will see a list,choose python3.10 as the default python version.
Verify python version
python3 --version
Install cython
python3 -m pip install -i https://mirrors.aliyun.com/pypi/simple/ Cython
# or build from source (deprecated)
wget https://github.com/cython/cython/archive/refs/tags/3.0.11.tar.gz
tar xzf 3.0.11.tar.gz
cd cython-3.0.11
python3 setup.py install
mkdir work_repo && cd work_repo
git clone --recursive https://github.com/TuGraph-family/tugraph-db.git
cd tugraph-db
deps/build_deps.sh
mkdir build && cd build
cmake .. -DOURSYSTEM=centos7
make
make package
Exit comple container.
exit
Copy dydamic link library to a certain path.
cd .
mkdir demo
docker cp demo_comp:/root/work_repo/tugraph-db/build/output/liblgraph_client_cpp_rpc.so ./demo/
docker cp demo_comp:/root/work_repo/tugraph-db/build/output/liblgraph_client_python.so ./demo/
docker cp demo_comp:/root/work_repo/tugraph-db/build/output/liblgraph.so ./demo/
Pull tugraph-db docker image and build it from source.
docker pull tugraph/tugraph-runtime-centos7
Set environment variables
export VERSION=latest
export REPOSITORY=docker.io/tugraph/tugraph-runtime-centos7 # path to your docker image
Start Container
docker run -dt --gpus all -p 7070:7070 -p 7687:7687 -p 9090:9090 -v /root/tugraph/data:/var/lib/lgraph/data -v /root/tugraph/log:/var/log/lgraph_log \
-v $HOME/demo:/root/work_repo/demo \
--name demo ${REPOSITORY}:${VERSION} /bin/bash
docker exec -it demo bash
#--gpus means enabling gpus in the docker container
Verify you can use gpu in the docker container.
You will see the information of gpu after input the instruction bellow. If you can't see the gpu information, back to the the steps before to make sure you have installed Nvidia-Docker successfully and started docker with --gpus
.
nvidia-smi
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
# verify
conda --version
conda create -n demo python=3.10
Restart your shell or terminal to make your settings take effect.
conda activate demo
cd
mkdir -p /root/work_repo/
cd work_repo
git clone https://github.com/TuGraph-family/Awesome-Text2GQL.git
git clone https://github.com/eosphoros-ai/DB-GPT-Hub.git
git clone https://github.com/TuGraph-family/tugraph-db.git
cd /root/work_repo/Awesome-Text2GQL
mkdir tugraph-db
Add templates in ./input_examples/corpus_template.txt, and run the whole flow to get datasets generated after setting up the environments.Please check README.md for more details.
Finally, split the datasets into train and dev part. The datasets should be organized as bellow.
tugraph-db/
|-train.json # for training
|-dev.json # for evaluation
|-gold_dev.txt # for evaluation
Before you excute training、inference or evaluation, mkdir for outputs:
cd ../DB-GPT-Hub/src/dbgpt-hub-gql/dbgpt_hub_gql
mkdir -p ./output/logs ./output/adapter ./output/pred
Copy datasets
cd /root/work_repo/DB-GPT-Hub/src/dbgpt-hub-gql/dbgpt-hub-gql
cp -r /path/to/datasets/generated/tugraph-db ./data # path to your tugraph-db dataset built above.
Follow the README.md in DB-GPT-GQL to fine-tune LLMs. Replace the virtual env dbgpt_hub_gql
with demo
while installing dependencies.
The model CodeLlama-7B-Instruct and the corresponding LoRA method are tested.
Copy necesarry dependencies into the demo directory.
cd /root/work_repo/
mkdir -p ./DB-GPT-Hub/src/dbgpt-hub-gql/dbgpt_hub_gql/demo/
cd /root/work_repo/demo
cp * /root/work_repo/DB-GPT-Hub/src/dbgpt-hub-gql/dbgpt_hub_gql/demo/
cd /root/work_repo/Awesome-Text2GQL/demo
cp * /root/work_repo/DB-GPT-Hub/src/dbgpt-hub-gql/dbgpt_hub_gql/demo/
cd /root/work_repo/
cp -r ./tugraph-db/demo/movie ./DB-GPT-Hub/src/dbgpt-hub-gql/dbgpt_hub_gql/demo/
cd DB-GPT-Hub/src/dbgpt-hub-gql/dbgpt_hub_gql/demo
Import data of TuGraph-DB
lgraph_import --dir /var/lib/lgraph/data --verbose 2 -c ./movie/import.json --continue_on_error 1 --overwrite 1 --online false
rm -rf import_tmp
Start TuGraph-DB
lgraph_server -c /usr/local/etc/lgraph.json -d run --log_dir ""
Run demo
cd ..
cd ..
sh ./dbgpt_hub_gql/demo/demo.sh
Stop server
Ctrl+C