【大模型】0.5B的大模型通义千问1.5-0.5B-Chat来了!!

模型介绍

Qwen1.5是Qwen2的测试版,这是一个基于转换器的纯解码器语言模型,在大量数据上进行了预训练。与之前发布的Qwen相比,改进之处包括:

  • 显著改善了人类对聊天模型的偏好;

  • 对基本模式和聊天模式的多语言支持;

  • 稳定支持32K上下文长度,适用于各种尺寸的模型

  • 不需要trust_remote_code。

训练细节

我们用大量数据对模型进行预训练,并用监督微调和直接偏好优化对模型进行后训练。然而,DPO导致了人类偏好评估的改进,但导致了基准评估的退化。在不久的将来,我们将解决这两个问题。

Requirements

transformers>=4.37.0

拉取模型

git clone https://www.modelscope.cn/qwen/Qwen1.5-0.5B-Chat.git

示例代码

from modelscope import AutoModelForCausalLM, AutoTokenizer
device = "cuda" # the device to load the model onto

model = AutoModelForCausalLM.from_pretrained(
    "qwen/Qwen1.5-0.5B-Chat",
    device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("qwen/Qwen1.5-0.5B-Chat")

prompt = "Give me a short introduction to large language model."
messages = [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True
)
model_inputs = tokenizer([text], return_tensors="pt").to(device)

generated_ids = model.generate(
    model_inputs.input_ids,
    max_new_tokens=512
)
generated_ids = [
    output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]

response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]

多轮对话

from modelscope import AutoModelForCausalLM, AutoTokenizer
device = "cuda" # the device to load the model onto

model = AutoModelForCausalLM.from_pretrained(
    "Qwen1.5-0.5B-Chat",
    device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("Qwen1.5-0.5B-Chat")

while True:
    print('input prompt:')
    
    # prompt = "Give me a short introduction to large language model."
    prompt = input()
    if prompt == 'q':
        break
    messages = [
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": prompt}
    ]
    text = tokenizer.apply_chat_template(
        messages,
        tokenize=False,
        add_generation_prompt=True
    )
    model_inputs = tokenizer([text], return_tensors="pt").to(device)

    generated_ids = model.generate(
        model_inputs.input_ids,
        max_new_tokens=512
    )
    generated_ids = [
        output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
    ]

    response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
    print('response:', response)

输入退出多轮对话

测试输出示例

input prompt:
借款不换会怎么样
The attention mask and the pad token id were not set. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.
Setting `pad_token_id` to `eos_token_id`:151645 for open-end generation.
response: 如果您不希望改变借给他的金额,您可以考虑将借款作为长期投资的一部分。虽然短期的回报可能不如长期投资,但长期来看,它可能会带来更高的收益。

然而,如果您的资金状况非常紧张或不确定如何使用该钱,那么将借给他并保持固定的比例支付可能会是一个更好的选择。这样做的风险较低,因为您不会因为暂时的财务困难而减少偿还本金的能力。

此外,如果您已经决定改变借款的目的,例如为了实现个人目标或扩大投资范围,那么调整借款比例以适应这些新的需求可能是明智的选择。

请注意,无论哪种情况,都需要与你的财务顾问一起制定一个详细的风险管理计划,并确保你对所有的潜在影响有所了解和理解。
input prompt:
怎么才能合理合法的不还
The attention mask and the pad token id were not set. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.
Setting `pad_token_id` to `eos_token_id`:151645 for open-end generation.
response: 我不能提供关于如何不还款的建议,因为这可能会涉及欺诈和非法行为。在许多国家和地区,拒绝履行贷款或支付利息是违法的行为,而且可能还会导致罚款、监禁甚至刑事责任。

如果您遇到困难无法按时偿还贷款,请考虑与您的银行联系,看看是否有任何可以帮助您解决这个问题的方法。此外,您可以尝试寻求财务咨询服务,以了解有关如何管理你的财务状况和防止再次违约的建议。

请注意,不偿还原款是一种严重的犯罪行为,并且可能会面临法律后果。如果你正在采取这种方式,建议尽快寻求专业的帮助,以便避免不必要的法律责任。
input prompt:
你再好好想想能不能找到方法
The attention mask and the pad token id were not set. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.
Setting `pad_token_id` to `eos_token_id`:151645 for open-end generation.
response: 当然可以,我会继续努力的。请告诉我你需要什么样的帮助?
input prompt:
借款不还
The attention mask and the pad token id were not set. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.
Setting `pad_token_id` to `eos_token_id`:151645 for open-end generation.
response: 作为一个人工智能,我必须提醒您,您的行为可能涉及到法律问题。如果您正在面临无法按时偿还贷款的问题,我建议您尽快联系专业的金融机构或贷款机构寻求帮助。

首先,了解清楚你的债务情况是很重要的。你是否已经支付了所有的利息和本金?是否有未偿还的本金和费用?这些信息可以帮助我们更准确地判断你需要采取什么行动。

其次,你可以尝试与你的银行或贷款机构进行沟通,看看他们是否有任何可能的解决方案。例如,他们是否有提供分期付款或其他还款计划?

再次,如果以上方法都无法解决问题,你可能需要考虑寻求专业的法律援助。如果你认为自己的权益受到了侵害,请立即寻求法律援助。记住,你的权益是最重要的。
input prompt:
男孩和女孩谁更聪明
The attention mask and the pad token id were not set. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.
Setting `pad_token_id` to `eos_token_id`:151645 for open-end generation.
response: 这个问题的答案取决于具体的情况。在智力测试中,男孩通常被认为是“更聪明”的,因为他们通常拥有更高的数学能力、逻辑思维能力和抽象思考能力。

然而,每个人都是独一无二的,并且智商并不是一种标准化的评价标准。每个人的思维方式、学习风格和应对压力的方式都不同,因此不能简单地将一个人与其他人的智商进行比较。

重要的是要认识到,无论你是否被认为是一个聪明的人,关键在于你的努力、兴趣和适应能力,而不是你所拥有的天赋或外貌特征。
input prompt:
大语言模型谁排第一
The attention mask and the pad token id were not set. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.
Setting `pad_token_id` to `eos_token_id`:151645 for open-end generation.
response: 作为一个AI助手,我无法比较不同的语言模型在实际应用中的表现。不过,当前市面上的大多数大型语言模型都已经得到了广泛应用,并且在全球范围内都有一定的认可度。

如果你需要了解某个特定的语言模型的具体排名情况,可以查阅相关的学术报告或公开的数据集,或者直接联系相关的研究机构进行查询。

资源占用

CPU 约 2.2 GB
GPU 约 3.3 GB
推理速度还是非常快的!

参考

https://modelscope.cn/models/qwen/Qwen1.5-0.5B-Chat/summary

  • 12
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

szZack

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值