Code Monkey home page Code Monkey logo

cybertron's Introduction

GitHub Contributions

cybertron's People

Contributors

huatangzhi avatar lvyufeng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cybertron's Issues

你好,我运行了readme中快速入门的代码,但是最后一行outputs = model(inputs)报这个错请问是什么原因呢?

你好,
我运行了该段代码,
`from bert4ms import BertModel,BertTokenizer

tokenizer = BertTokenizer.load('bert-base-uncased')
model = BertModel.load('bert-base-uncased', force_download=False)
model.set_train(True)

inputs = tokenizer("hello world")

outputs = model(inputs)`

但是最后一行代码,即将inputs传入model,报以下错误:

TypeError: mindspore\ccsrc\pipeline\jit\pipeline.cc:235 CheckArgsValid] The inputs types of the outermost network support bool, int, float, None, tensor, mstype.Number(mstype.bool, mstype.int, mstype.float, mstype.uint), and tuple or list containing only these types, and dict whose values are these types, but the 0th arg type is <class 'list'>, value is '['hello', 'world']'.

这是什么原因呢?

TypeError: 'BertTokenizer' object is not callable

在将torch代码迁移到MindSpore框架的时候,用到了cybertron替代transformers。
原始代码是:
from transformers import BertTokenizer
model_name_or_path = "dmis-lab/biobert-base-cased-v1.1"
tfm_tokenizer = BertTokenizer.from_pretrained(model_name_or_path)
a = tfm_tokenizer("this is not ok",padding ="max_length", max_length=25, truncation=True, return_tensors="pt")
输出结果如下图:
image

对应的cybertron代码如下:
import cybertron
model_name_or_path = "dmis-lab/biobert-base-cased-v1.1"
ms_tokenizer = cybertron.BertTokenizer.load(model_name_or_path)
ms_tokenizer("this is not ok", padding="max_length", max_length=self.max_length, truncation=True, return_tensors="pt")
运行报错信息如下图:
image

看了下cybertron的源代码,tokenizer的方法没有实现完全,想请作者帮忙修复一下这个问题,感谢

BertForSequenceClassfication加载mbert参数与Transformers的对齐

您好,我们在进行mindspore迁移时想要使用到cybertron库的BertForSequenceClassfication这个类,我们想要通过这个类加载mbert的模型,事实上我们在正常加载mbert时会提示最后的分类层的权重和偏置没有被加载(uncased也是一样的情况)

20221209181241

当我们选择加载bert的时候会出现模型无法加载的情况

0

事实上,在我们加载mbert的时候,我们发现除了最后一层分类层以外其他权重都对齐的很好,于是我们有尝试手动将最后一层的参数由transformers转换到cybertron从而保证初始参数一致,但是即便如此,在我们选择使用同样的输入对加载了mbert的BertForSequenceClassfication模型进行分类测试的时候,我们发现transformers与cybertron的模型输出结果依旧相差很大,我想要询问一下在模型的初始参数一致的情况下,结构类似(我观察了一下都是embedding+encoder+pooler),输入一样的情况下,分类的结果哪怕不完全相同,不应该很接近吗

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.