赞
踩
各种办法尝试个遍,这样弄保证你能开始玩儿。
PC一台,有无GPU随意。硬盘几十G。
Python3.11以上。
根据是否由GPU、GPU型号不同,安装不同的PyTorch(PyTorch安装指令)
huggingface-cli download --local-dir . google/gemma-2b-it
git clone https://github.com/aiXpertLab/Run-Google-Gemma-Locally-on-Desktop-Laptop.git
# from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
from transformers import AutoTokenizer, AutoModelForCausalLM
model_name = "google/gemma-2b-it"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model=AutoModelForCausalLM.from_pretrained("google/gemma-2b-it", device_map="auto")
input_text = "write me a poem about beautifuly woman."
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
outputs = model.generate(**input_ids)
print(tokenizer.decode(outputs[0]))
点个⭐,码更行!
https://github.com/aiXpertLab/Run-Google-Gemma-Locally-on-Desktop-Laptop
点个赞,开源❤️!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。