|
**Usage** |
|
|
|
|
|
# 设置环境 |
|
git clone https://github.com/hiyouga/ChatGLM-Efficient-Tuning.git |
|
conda create -n chatglm_etuning python=3.10 |
|
conda activate chatglm_etuning |
|
cd ChatGLM-Efficient-Tuning |
|
pip install -r requirements.txt |
|
|
|
# 模型部署,新建文件夹path_to_checkpoint,下载Laurie/ChatGLM-Efficient-Tuning-SFT里的文件到里面 |
|
import sys |
|
sys.path.append("src") |
|
from src import load_pretrained, ModelArguments |
|
model_args = ModelArguments(checkpoint_dir=path_to_checkpoint) |
|
model, tokenizer = load_pretrained(model_args) |
|
model = model.cuda() |
|
model.eval() |
|
|
|
# model.generate, model.chat()... |
|
|
|
# 命令行进行测试 |
|
CUDA_VISIBLE_DEVICES=0 python src/infer.py \ |
|
--checkpoint_dir path_to_checkpoint |