text-generation-webui试用 windows平台 以及目前比较好的开源中文模型 Baichuan-13B-Chat测试

发布时间 2023-08-13 00:25:16作者: kyo413

随着llama的大模型发布,个人也可以在自己电脑上运行生成文本的大模型,建议用大显存的显卡,比如2080ti11g  , 3060  12g ,  3090  24g。

找这篇文章操作   https://openai.wiki/text-generation-webui.html

 

其中最麻烦的是安装依赖,这是2080ti下用cuda的环境下的依赖包

name: textgen
channels:
  - defaults
dependencies:
  - bzip2=1.0.8=he774522_0
  - ca-certificates=2023.05.30=haa95532_0
  - libffi=3.4.4=hd77b12b_0
  - openssl=1.1.1v=h2bbff1b_0
  - pip=23.2.1=py310haa95532_0
  - python=3.10.9=h966fe2a_2
  - setuptools=68.0.0=py310haa95532_0
  - sqlite=3.41.2=h2bbff1b_0
  - tk=8.6.12=h2bbff1b_0
  - vc=14.2=h21ff451_1
  - vs2015_runtime=14.27.29016=h5e58377_2
  - wheel=0.38.4=py310haa95532_0
  - xz=5.4.2=h8cc25b3_0
  - zlib=1.2.13=h8cc25b3_0
  - pip:
      - absl-py==1.4.0
      - accelerate==0.21.0
      - aiofiles==23.1.0
      - aiohttp==3.8.5
      - aiosignal==1.3.1
      - altair==5.0.1
      - anyio==3.7.1
      - appdirs==1.4.4
      - async-timeout==4.0.2
      - attrs==23.1.0
      - auto-gptq==0.3.0+cu117
      - bitsandbytes==0.38.1
      - cachetools==5.3.1
      - certifi==2022.12.7
      - charset-normalizer==2.1.1
      - click==8.1.6
      - colorama==0.4.6
      - contourpy==1.1.0
      - cycler==0.11.0
      - datasets==2.14.3
      - dill==0.3.7
      - diskcache==5.6.1
      - docker-pycreds==0.4.0
      - einops==0.6.1
      - exceptiongroup==1.1.2
      - exllama==0.0.10+cu117
      - fastapi==0.95.2
      - ffmpy==0.3.1
      - filelock==3.9.0
      - fonttools==4.42.0
      - frozenlist==1.4.0
      - fsspec==2023.6.0
      - gitdb==4.0.10
      - gitpython==3.1.32
      - google-auth==2.22.0
      - google-auth-oauthlib==1.0.0
      - gradio==3.33.1
      - gradio-client==0.2.5
      - grpcio==1.56.2
      - h11==0.14.0
      - httpcore==0.17.3
      - httpx==0.24.1
      - huggingface-hub==0.16.4
      - idna==3.4
      - jinja2==3.1.2
      - jsonschema==4.18.6
      - jsonschema-specifications==2023.7.1
      - kiwisolver==1.4.4
      - linkify-it-py==2.0.2
      - llama-cpp-python==0.1.77
      - llama-cpp-python-cuda==0.1.77+cu117
      - markdown==3.4.4
      - markdown-it-py==2.2.0
      - markupsafe==2.1.2
      - matplotlib==3.7.2
      - mdit-py-plugins==0.3.3
      - mdurl==0.1.2
      - mpmath==1.2.1
      - multidict==6.0.4
      - multiprocess==0.70.15
      - networkx==3.0
      - numpy==1.24.1
      - oauthlib==3.2.2
      - orjson==3.9.2
      - packaging==23.1
      - pandas==2.0.3
      - pathtools==0.1.2
      - peft==0.4.0
      - pillow==10.0.0
      - protobuf==4.23.4
      - psutil==5.9.5
      - pyarrow==12.0.1
      - pyasn1==0.5.0
      - pyasn1-modules==0.3.0
      - pydantic==1.10.12
      - pydub==0.25.1
      - pygments==2.16.0
      - pyparsing==3.0.9
      - python-dateutil==2.8.2
      - python-multipart==0.0.6
      - pytz==2023.3
      - pyyaml==6.0.1
      - referencing==0.30.2
      - regex==2023.6.3
      - requests==2.28.1
      - requests-oauthlib==1.3.1
      - rouge==1.0.1
      - rpds-py==0.9.2
      - rsa==4.9
      - safetensors==0.3.1
      - scipy==1.11.1
      - semantic-version==2.10.0
      - sentencepiece==0.1.99
      - sentry-sdk==1.29.2
      - setproctitle==1.3.2
      - six==1.16.0
      - smmap==5.0.0
      - sniffio==1.3.0
      - starlette==0.27.0
      - sympy==1.11.1
      - tensorboard==2.13.0
      - tensorboard-data-server==0.7.1
      - tokenizers==0.13.3
      - toolz==0.12.0
      - torch==2.0.1+cu117
      - torchaudio==2.0.2+cu117
      - torchvision==0.15.2+cu117
      - tqdm==4.65.0
      - transformers==4.31.0
      - typing-extensions==4.7.1
      - tzdata==2023.3
      - uc-micro-py==1.0.2
      - urllib3==1.26.13
      - uvicorn==0.23.2
      - wandb==0.15.8
      - websockets==11.0.3
      - werkzeug==2.3.6
      - xxhash==3.3.0
      - yarl==1.9.2

下载依赖最好全程sci上网,或者更改国内源,有几个需要从github下载的whl可以手动下载手动pip安装或者下载懒人版  https://www.bilibili.com/read/cv23495183?,或者从别人那把二进制打包的conda环境装过来

几个问题

1 安装pytorch gpu 红字 查找到是由于pip的缓存机制尝试将希望安装库的整个文件缓存到内存,而在限制缓存大小的环境中如果安装包较大就会出现MemoryError的这个错误。
解决方法:    

pip有个–no-cache-dir参数,失能缓冲即可。pip --no-cache-dir install matplotlib

 

conda无法在powershe中切换环境 conda 4.6以上版本,已经内置了对PowerShell的支持。

以管理员身份打开,并在Powershell窗口输入:

conda init powershell

 

3

运行llama13b模型时候报错 Having “RuntimeError: expected scalar type Half but found Char” on LLaMa-2 inference 查询https://github.com/huggingface/transformers/issues/25144

解决办法 更改模型里的config里的config.pretraining_tp = 1

 

4   llama30b 里的tokenconfig文件里有个大小写的问题,b把laMa改成llama

bitsandbytes==0.38.1不能4bit量化,这个是兼容一些老的n卡,20系以上下下载最新的,强力推荐4bit量化,省显存,速度快。精度甚至没啥损失,很神奇

 

下载模型  去 baichuan-inc/Baichuan-13B-Base at main (huggingface.co)   下载   git几乎下载不了那几个大文件    可以手动下载,不需要FQ

 

 

测试的几个模型的vram占用

百川13b已经可以在2080ti上跑4bit量化,我试了下8bit好像也没更准确,反而跑的很慢

 

 

 

 

llama的在英语下性能很强,中文则是答非所问胡说八代

 

综合来讲百川13b ,模型大小24g   已经非常厉害了    不敢想象chatgpt4那几千b参数的模型有多吊