在 Windows 11 上通过 Autoawq 启动 Mixtral 8*7B 大语言模型

在 Windows 11 上通过 Autoawq 启动 Mixtral 8*7B 大语言模型

0. 背景

看了一些文章之后,今天尝试在 Windows 11 上通过 Autoawq 启动 Mixtral 8*7B 大语言模型。

1. 安装依赖

pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
pip install autoawq git+https://github.com/huggingface/transformers.git
pip install https://github.com/jllllll/bitsandbytes-windows-webui/releases/download/wheels/bitsandbytes-0.41.2.post2-py3-none-win_amd64.whl
pip install https://github.com/bdashore3/flash-attention/releases/download/v2.4.1/flash_attn-2.4.1+cu121torch2.1cxx11abiFALSE-cp310-cp310-win_amd64.whl

2. 开发 main.py

from transformers import AutoModelForCausalLM,AutoTokenizer
from transformers import TextStreamer
model_id ="casperhansen/mixtral-instruct-awq"
tokenizer =AutoTokenizer.from_pretrained(model_id)
model =AutoModelForCausalLM.from_pretrained(model_id,low_cpu_mem_usage=True,device_map="auto",attn_implementation="flash_attention_2")
streamer = TextStreamer(tokenizer,skip_prompt=True,skip_special_tokens=True)
text="[INST] How to make the best cup of americano? [/INST]"
tokens =tokenizer(text,return_tensors='pt').input_ids.to("cuda:0")
generation_output =model.generate(tokens,streamer=streamer,max_new_tokens=512)

代码来自:https://mp.weixin.qq.com/s/IAWJIh61_enYoyME3oJqJQ

3. 运行 main.py

python main.py

输出结果示例,

在这里插入图片描述
完成!

最近更新

  1. TCP协议是安全的吗?

    2024-01-18 21:04:04       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-18 21:04:04       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-18 21:04:04       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-18 21:04:04       20 阅读

热门阅读

  1. MySQL中WITH AS语句的使用

    2024-01-18 21:04:04       36 阅读
  2. iOS长按时无法保存图片问题解决方案

    2024-01-18 21:04:04       46 阅读
  3. 力扣79. 单词搜索

    2024-01-18 21:04:04       33 阅读
  4. SQL-01求连续七天登陆的用户

    2024-01-18 21:04:04       28 阅读