匿名用户2024年07月31日
58阅读

技术信息

开源地址
https://modelscope.cn/models/AI-ModelScope/phi-2-super
授权协议
mit

作品详情

Phi-2-super (SFT + cDPO)

Base Model: microsoft/phi-2

image/pg

How to ru iferece:

import trasformers
import torch

if __ame__ == "__mai__":
  model_ame = "abacaj/phi-2-super"
  tokeizer = trasformers.AutoTokeizer.from_pretraied(model_ame)

  model = (
      trasformers.AutoModelForCausalLM.from_pretraied(
          model_ame,
      )
      .to("cuda:0")
      .eval()
  )

  messages = [
      {"role": "user", "cotet": "Hello, who are you?"}
  ]
  iputs = tokeizer.apply_chat_template(messages, retur_tesors="pt").to(model.device)
  iput_ids_cutoff = iputs.size(dim=1)

  with torch.o_grad():
      geerated_ids = model.geerate(
          iput_ids=iputs,
          use_cache=True,
          max_ew_tokes=512,
          temperature=0.2,
          top_p=0.95,
          do_sample=True,
          eos_toke_id=tokeizer.eos_toke_id,
          pad_toke_id=tokeizer.pad_toke_id,
      )

  completio = tokeizer.decode(
      geerated_ids[0][iput_ids_cutoff:],
      skip_special_tokes=True,
  )

  prit(completio)

Chat template

The model uses the same chat template as foud i Mistral istruct models:

text = "<|edoftext|>[INST] What is your favourite codimet? [/INST]"
"Well, I'm quite partial to a good squeeze of fresh lemo juice. It adds just the right amout of zesty flavour to whatever I'm cookig up i the kitche!<|edoftext|> "
"[INST] Do you have mayoaise recipes? [/INST]"

You do't eed to do it maually if you use the HF trasformers tokeizer:

  messages = [
      {"role": "user", "cotet": "Hello, who are you?"},
      {"role": "assistat": "cotet": "I am ..."}
  ]
  iputs = tokeizer.apply_chat_template(messages, retur_tesors="pt").to(model.device)

MT-bech / heval

image/pg image/pg

功能介绍

Phi-2-super (SFT + cDPO) Base Model: microsoft/phi-2 How to run inference: import transformers impo

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论