HuggingFace镜像/BilingualChildEmo
模型介绍文件和版本分析
下载使用量0

模型 ID 的模型卡片

本模型卡片旨在作为新模型的基础模板。它是使用 [this raw template] 生成的。

模型详情

模型描述

  • 开发方: [需要更多信息]
  • 资助方(可选): [需要更多信息]
  • 共享方(可选): [需要更多信息]
  • 模型类型: [需要更多信息]
  • 语言(自然语言处理): [需要更多信息]
  • 许可证: [需要更多信息]
  • 微调自模型(可选): [需要更多信息]

模型来源 [可选]

  • 代码仓库: [需要更多信息]
  • 论文 [可选]: [需要更多信息]
  • 演示 [可选]: [需要更多信息]

模型使用

import argparse
from openmind import AutoModel, AutoTokenizer
from openmind import is_torch_npu_available

def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument("--model_name_or_path",type=str,help="Path to model",default=None,)
    args = parser.parse_args()
    return args


if __name__ == '__main__':
    if is_torch_npu_available():
        device = "npu:0"
    else:
        device = "cpu"
    args = parse_args()
    model_path = args.model_name_or_path

    # Note: CodeSage requires adding eos token at the end of
    # each tokenized sequence to ensure good performance
    tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True, add_eos_token=True)

    model = AutoModel.from_pretrained(model_path, trust_remote_code=True).to(device)

    inputs = tokenizer.encode("def print_hello_world():\tprint('Hello World!')", return_tensors="pt").to(device)
    embedding = model(inputs)[0]
    print(f'Dimension of the embedding: {embedding[0].size()}')
    print(embedding)