当前位置: 首页 > news >正文

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

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

  • 0. 背景
  • 1. 安装依赖
  • 2. 开发 main.py
  • 3. 运行 main.py

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

输出结果示例,

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

http://www.lryc.cn/news/279918.html

相关文章:

  • C# 图解教程 第5版 —— 第24章 预处理指令
  • 电商几乎每一次的调整,几乎都围绕着AI展开
  • [Linux 进程(三)] 进程优先级,进程间切换,main函数参数,环境变量
  • 【Java 设计模式】设计原则之单一职责原则
  • 实现导航栏吸顶操作
  • Docker简述与基础部署详解
  • (南京观海微电子)——色温介绍
  • 入门Linux简单操作
  • 操作系统复习 一、二章
  • 【国内访问github不稳定】可以尝试fastgithub解决这个问题
  • android:clickable=“false“无效,依然能被点击
  • Springboot WebFlux项目结合mongodb进行crud
  • 超维空间M1无人机使用说明书——61、ROS无人机物体识别与精准投放
  • Flask 小程序菜品搜索
  • Excel·VBA按指定顺序排序函数
  • 数据结构学习笔记——查找算法中的树形查找(红黑树)
  • Debezium发布历史66
  • Redis系列之使用Lua脚本
  • Wargames与bash知识16
  • 关于运维·关于数据库面试题
  • MySQL题目示例
  • HTML基本语法
  • 二分图最大匹配——匈牙利算法详解
  • 【AI视野·今日Robot 机器人论文速览 第七十一期】Fri, 5 Jan 2024
  • xtu oj 1334 Least Common Multiple
  • 【论文笔记】End-to-End Diffusion Latent Optimization Improves Classifier Guidance
  • 【HarmonyOS4.0】第四篇-ArkUI基础实战
  • 每日一题——LeetCode1128.等价多米诺骨牌对的数量
  • 关联规则分析(Apriori算法2
  • 数据仓库(2)-认识数仓