Skip to content

你们确定提供的代码真的能通过运行成功吗? #145

@pio57019

Description

@pio57019

我挨个尝试了你们提供的代码,全部都不是这错就是那错,不是这缺失就是那缺失,我严重怀疑你们的东西真的有没有人用得了的,哪怕 1 个人.

最后我尝试只有这个代码能跑,于是并改写了它,结果最后还是掉链子,连问AI,AI都回答不了.
你们能先裸机安装看看确定真的能用能安装好,然后才信心放出来行吗??能靠谱一点,真的让人可用行吗?

xxx - 副本

1.py.json


import requests
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
import time
MAX_RETRIES = 500
retry_count = 0

while retry_count < MAX_RETRIES:
try:
device = torch.device("cpu")
#device = torch.device("cuda:0")
model_info = "BAAI/AquilaChat2-7B"
tokenizer = AutoTokenizer.from_pretrained(model_info, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_info, trust_remote_code=True, torch_dtype=torch.bfloat16)
model.eval()
model.to(device)
text = "请给出10个要到北京旅游的理由。"
from predict import predict
out = predict(model, text, tokenizer=tokenizer, max_gen_len=5200, top_p=0.95,
seed=1234, topk=100, temperature=0.9, sft=True, device=device,
model_name="AquilaChat2-7B")
print(out)
break # 如果成功加载并运行到这一步,说明没有问题了,跳出循环
except requests.exceptions.ChunkedEncodingError as e:
print(f"下载模型文件时出现错误: {e}")
print(f"正在进行第 {retry_count + 1} 次重试...")
# 可以在这里添加一些等待时间,避免过于频繁地重试导致问题持续存在
time.sleep(5) # 等待5秒后再重试,可根据实际情况调整等待时间
retry_count += 1
except Exception as other_e:
print(f"出现其他未知错误: {other_e}")
break # 对于其他未知错误,直接跳出循环,避免无限重试

if retry_count == MAX_RETRIES:
print("已达到最大重试次数,仍然无法成功下载模型文件,请检查网络连接或手动下载模型文件后配置本地加载。")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions