10 Star 62 Fork 3

aixcoder-model / aixcoder-7b

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
sess_huggingface.py 733 Bytes
一键复制 编辑 原始数据 按行查看 历史
Horatio_JSY 提交于 2024-04-09 09:51 . update
import torch
import sys
from hf_mini.utils import input_wrapper
from transformers import AutoModelForCausalLM, AutoTokenizer
device = "cuda" # the device to load the model onto
tokenizer = AutoTokenizer.from_pretrained("aiXcoder/aixcoder-7b-base")
model = AutoModelForCausalLM.from_pretrained("aiXcoder/aixcoder-7b-base", torch_dtype=torch.bfloat16)
text = input_wrapper(
code_string="# 快速排序算法",
later_code="\n",
path="test.py"
)
if len(text) == 0:
sys.exit()
inputs = tokenizer(text, return_tensors="pt", return_token_type_ids=False)
inputs = inputs.to(device)
model.to(device)
outputs = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0], skip_special_tokens=False))
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/aixcoder-model/aixcoder-7b.git
git@gitee.com:aixcoder-model/aixcoder-7b.git
aixcoder-model
aixcoder-7b
aixcoder-7b
main

搜索帮助

344bd9b3 5694891 D2dac590 5694891