|
--- |
|
license: apache-2.0 |
|
--- |
|
|
|
华佗 GPT2-7B 模型量化版本 |
|
|
|
简介 |
|
|
|
本项目基于华佗 GPT2-7B 模型,使用 transformers 库中的 bitsandbytes 方法进行了 int8 量化,并将量化后的模型上传到了 Hugging Face 模型库。量化后的模型大小约为 8GB,原模型大小为 14GB。该模型可以被 transformers 和 vllm 库加载,并配备了对应的 tokenizer 模型文件。 |
|
|
|
模型详情 |
|
|
|
基础模型:华佗 GPT2-7B |
|
|
|
量化方法:int8 量化,使用 bitsandbytes 库 |
|
|
|
模型大小:量化后约为 8GB,原模型大小为 14GB |
|
|
|
来源:百川模型支持 |
|
|
|
使用指南: |
|
|
|
确保你安装了bitsandbytes |
|
|
|
``` |
|
pip install bitsandbytes |
|
``` |
|
|
|
``` |
|
import torch |
|
from transformers import AutoModelForCausalLM, AutoTokenizer |
|
from transformers.generation.utils import GenerationConfig |
|
tokenizer = AutoTokenizer.from_pretrained("jiangchengchengNLP/huatuo-7b-sns8bits", use_fast=True, trust_remote_code=True) |
|
model = AutoModelForCausalLM.from_pretrained("jiangchengchengNLP/huatuo-7b-sns8bits", device_map="auto", torch_dtype="auto", trust_remote_code=True) |
|
model.generation_config = GenerationConfig.from_pretrained("FreedomIntelligence/HuatuoGPT2-7B-4bits") |
|
messages = [] |
|
messages.append({"role": "user", "content": "肚子疼怎么办?"}) |
|
response = model.HuatuoChat(tokenizer, messages) |
|
print(response) |
|
|
|
``` |