Views
No views yet
1from transformers import AutoModelForTokenClassification, AutoConfig
2
3from path_to_custom_classes import (
4 LiLTRobertaLikeConfig,
5 LiLTRobertaLikeForRelationExtraction,
6 LiLTRobertaLikeForTokenClassification,
7 LiLTRobertaLikeModel
8 )
9
10
11def patch_transformers():
12 AutoConfig.register("liltrobertalike", LiLTRobertaLikeConfig)
13 AutoModel.register(LiLTRobertaLikeConfig, LiLTRobertaLikeModel)
14 AutoModelForTokenClassification.register(LiLTRobertaLikeConfig, LiLTRobertaLikeForTokenClassification)
15 # etc...1# patch_transformers() must have been executed beforehand
2
3tokenizer = AutoTokenizer.from_pretrained("camembert-base")
4model = AutoModel.from_pretrained("manu/lilt-camembert-base")
5model = AutoModelForTokenClassification.from_pretrained("manu/lilt-camembert-base") # to be fine-tuned on a token classification task