使用Qwen3-8B-BitNet需要经过以下步骤:
- environmental preparation:安装Python 3.8+并创建虚拟环境(推荐)
- Dependent Installation:通过pip安装transformers和torch库(GPU用户需安装CUDA版PyTorch)
- Model loading:使用AutoModelForCausalLM和AutoTokenizer从Hugging Face加载模型
典型的使用代码示例:
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "codys12/Qwen3-8B-BitNet"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name,
torch_dtype="auto",
device_map="auto")
生成文本时,可通过apply_chat_template方法设置enable_thinking参数来切换思考模式。
This answer comes from the articleQwen3-8B-BitNet: an open source language model for efficient compressionThe