Comments (5)
Hi, thank you for reporting this potential issue. I will fix it soon later, or feel free to create a PR.
from parser.
I have a patch.
In method Parser.load(), it recreates the tokenizer:
transform = state['transform']
if args.feat == 'bert':
tokenizer = SubwordField.tokenizer(args.bert)
transform.FORM[1].tokenize = tokenizer.tokenize
return cls(args, model, transform)
invoking this method in class SubwordField:
@classmethod
def tokenizer(cls, name):
"""
Create an instance of tokenizer from either path or name.
:param name: path or name of tokenizer.
"""
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained(name)
tokenizer.bos_token = tokenizer.bos_token or tokenizer.cls_token
tokenizer.eos_token = tokenizer.eos_token or tokenizer.sep_token
return tokenizer
and biaffine-parser also uses it to create it, in class method build():
elif args.feat == 'bert':
tokenizer = SubwordField.tokenizer(args.bert)
You may also want too avoid to save the tokenize function, by doing this in Parser.save():
if args.feat == 'bert':
tokenize = self.transform.FORM[1].tokenize # save it
self.transform.FORM[1].tokenize = None
state = {'name': self.NAME,
'args': args,
'state_dict': state_dict,
'pretrained': pretrained,
'transform': self.transform}
torch.save(state, path)
if args.feat == 'bert':
self.transform.FORM[1].tokenize = tokenize # restore
What do you think?
I cannot make a PR, since I have other changes in my code.
from parser.
@attardi That's might not be very elegant, I suppose tokenize
to be a more general method, and directly moving the initialization of BertTokenizer
inside SubwordField
might not be a good choice.
I haven't figured out any solution to the above problem though.
BTW, with more parsers to be added, I think I'm increasingly losing the control of the field APIs. While torchtext
is on the way to redesign their APIs to be more compatible with PyTorch
and transformers
and the new release can be available in October, I'm considering whether it is worth to replacing some of my impls with torchtext
. Do you have any suggestions?
from parser.
@attardi As a temporary solution, I have re-uploaded the models trained with transformers 3.2.0.
from parser.
@attardi Done. The newly uploaded models are trained with transformers==3.2.0
, and can be loaded with transformers==4.0.0
.
from parser.
Related Issues (20)
- 如何下载dep-biaffine-xlmr的checkpoint? HOT 4
- 'con-crf-roberta-en' won't load HOT 5
- low performance of "dep-biaffine-xlmr"? HOT 4
- How to using checkpoint to predict HOT 1
- 需要您的帮助 HOT 4
- Doc improvement HOT 1
- Necessity to create a new release HOT 6
- Missing AttachJuxtapose pre-trained weights HOT 3
- Partial Parsing HOT 1
- Constituency CRF RoBERTa English not working properly HOT 2
- Constituency Multilinugal model not working properly HOT 1
- Submodule not found HOT 1
- Unable to use "biaffine-dep-roberta-en" HOT 1
- Global variable access Exception in data utils HOT 4
- 训练新模型遇到问题 HOT 7
- Add verbose flag to remove progress_bar HOT 3
- Missing word_embed with "bert" encoder HOT 3
- TypeError: code expected at most 16 arguments, got 19 HOT 2
- Error Loading Multilingual Dependency Parsing Model HOT 2
- 训练数据格式是什么样的呢?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from parser.