由网络副手--寻路人于2023.08.24 17:51:00发布在AIGC LLAMA2 语言模型WebUI & 接口 阅读987 评论1 喜欢0 一、模型下载搭建 前置: 安装Python 依赖扩展: ``` 阿里云 http://mirrors.aliyun.com/pypi/simple/ 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/ 豆瓣(douban) http://pypi.douban.com/simple/ 清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/ 中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/ pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt #或者 使用次方法指定镜像 pip3 install requests -i https://pypi.tuna.tsinghua.edu.cn/simple ``` 1、代码仓库地址 ``` https://github.com/FlagAlpha/Llama2-Chinese.git ``` 2、创建语言模型存储文件夹 ``` cd Llama2-Chinese mkdir -p meta-llama/Llama-2-7b-chat ``` 3、从Huggerface 下载模型文件 ``` https://huggingface.co/meta-llama/Llama-2-7b-chat-hf/tree/main ``` 二、Huggeface下载模型大文件方案 1、安装git 扩展 git-lfs ``` ##安装git-大文件扩展工具 sudo apt-get install git-lfs git lfs install git clone https://huggingface.co/meta-llama/Llama-2-7b-chat-hf # if you want to clone without large files – just their pointers # prepend your git clone with the following env var: GIT_LFS_SKIP_SMUDGE=1 ``` 2、采用hf_hub_download() 进行模型大文件下载 ``` 错误安装 ModuleNotFoundError: No module named 'Huggingface_hub' ``` ``` 优先看官方文档: https://huggingface.co/docs/huggingface_hub/installation ---安装: pip3 install git+https://github.com/huggingface/huggingface_hub ---测试 python -c "from huggingface_hub import model_info; print(model_info('gpt2'))" ``` 3、例如: 下载70B模型 保存路径 /home/user/data/image_to_music/llama2/meta-llama/Llama-2-70b-chat-hf ``` >>> from huggingface_hub import hf_hub_download hf_hub_download(repo_id= "meta-llama/Llama-2-70b-chat-hf",filename="model-00007-of-00015.safetensors", token="hf_KnAqdUwGNDSAQFuFQriYxxxx",local_dir="/home/user/data/image_to_music/llama2/meta-llama/Llama-2-70b-chat-hf", local_dir_use_symlinks=False) ``` 三、启动 ``` python3 examples/chat_gradio.py --model_name_or_path meta-llama/Llama-2-7b-chat ``` 四、安装接口版本 GIT 仓库: ``` https://github.com/LinkSoul-AI/Chinese-Llama-2-7b ``` 下载模型见上半部分 更改api.py 文件 ``` model_path 路径 ``` 启动: ``` python3 api.py ``` 脚本 ``` #!/bin/bash cd /home/user/data/image_to_music/llama2/Chinese-Llama-2-7b nohup python3 api.py --server_name imgtext_to_mpt --port 8882 >> /home/user/data/image_to_music/logs/imgtext_to_mpt.log & ``` 赞 0 分享 赏 您可以选择一种方式赞助本站 支付宝扫码赞助 BraveDu 署名: 网络副手~寻路人
以终为始的思考方式为行业指明方向。