Closed grantdelozier closed 2 years ago
It seems the relevant bit of code for this to work is in LiLTfinetune/__init__.py
I was able to instantiate LiLTRobertaLikeForTokenClassification()
from it's pretrained state in my own notebook with the following code:
from collections import OrderedDict
import os
from transformers import CONFIG_MAPPING, MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING, MODEL_NAMES_MAPPING, TOKENIZER_MAPPING, AutoConfig
from transformers.convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS, BertConverter, RobertaConverter, XLMRobertaConverter
from transformers.models.auto.modeling_auto import auto_class_factory
from LiLTfinetune.models.LiLTRobertaLike import (
LiLTRobertaLikeConfig,
LiLTRobertaLikeForRelationExtraction,
LiLTRobertaLikeForTokenClassification,
LiLTRobertaLikeTokenizer,
LiLTRobertaLikeTokenizerFast,
)
CONFIG_MAPPING.update([("liltrobertalike", LiLTRobertaLikeConfig),])
MODEL_NAMES_MAPPING.update([("liltrobertalike", "LiLTRobertaLike"),])
TOKENIZER_MAPPING.update(
[
(LiLTRobertaLikeConfig, (LiLTRobertaLikeTokenizer, LiLTRobertaLikeTokenizerFast)),
]
)
SLOW_TO_FAST_CONVERTERS.update({"LiLTRobertaLikeTokenizer": RobertaConverter,})
MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING.update(
[(LiLTRobertaLikeConfig, LiLTRobertaLikeForTokenClassification),]
)
AutoModelForTokenClassification = auto_class_factory(
"AutoModelForTokenClassification", MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING, head_doc="token classification"
)
model = AutoModelForTokenClassification.from_pretrained(
pretrained_model_path,
from_tf=False,
cache_dir='/content/drive/Shareddrives/Machine Learning/pretrained_models',
revision='main',
use_auth_token=None,
)
Hi, glad to see you solve it so quickly.
Hello, thank you for the fantastic paper, It was a joy to read. I am attempting to instantiate
LiLTRobertaLikeForTokenClassification()
in my own google colab notebook to try out on my own data, but seeing an error when attempting to build the config object.To recreate :
Which produces this error:
Any suggestions on how to instantiate the config for your pretrained model? It seems AutoConfig does not like this line in the config:
"model_type": "liltrobertalike"