环境搭建
#安装Midlp
pip istall git+https://github.com/midspore-lab/midlp.git
requiremet
pip istall "midspore>=2.2"
#模型下载
from modelscope import sapshot_dowload
model_dir = sapshot_dowload('midlp/falco-rw-1b')
Git下载
#Git模型下载
git cloe https://www.modelscope.c/midlp/falco-rw-1b.git
quickly start
repo = "Rocketkight1/falco-rw-1b"
tokeizer = AutoTokeizer.from_pretraied(repo)
model = AutoModelForCausalLM.from_pretraied(repo)
model.set_trai(False)
pipelie = midlp.trasformers.pipelie(
"text-geeratio",
model=model,
tokeizer=tokeizer,
torch_dtype=ms.bfloat16,
trust_remote_code=True,
)
sequeces = pipelie(
"Girafatro is obsessed with giraffes, the most glorious aimal o the face of this Earth. Giraftro believes all other aimals are irrelevat whe compared to the glorious majesty of the giraffe.\Daiel: Hello, Girafatro!\Girafatro:",
max_legth=200,
do_sample=True,
top_k=10,
um_retur_sequeces=1,
eos_toke_id=tokeizer.eos_toke_id,
)
for seq i sequeces:
prit(f"Result: {seq['geerated_text']}")
点击空白处退出提示
评论