-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question]: SequenceTagger.load fails with TypeError: not a string when loading a fine-tuned model #3574
Comments
HEre's the error trace: TypeError Traceback (most recent call last) 19 frames /usr/local/lib/python3.10/dist-packages/flair/nn/model.py in load(cls, model_path) /usr/local/lib/python3.10/dist-packages/flair/nn/model.py in load(cls, model_path) /usr/local/lib/python3.10/dist-packages/flair/models/sequence_tagger_model.py in _init_model_with_state_dict(cls, state, **kwargs) /usr/local/lib/python3.10/dist-packages/flair/nn/model.py in _init_model_with_state_dict(cls, state, **kwargs) /usr/local/lib/python3.10/dist-packages/flair/embeddings/base.py in load_embeddings(params) /usr/local/lib/python3.10/dist-packages/flair/embeddings/base.py in load_embedding(cls, params) /usr/local/lib/python3.10/dist-packages/flair/embeddings/transformer.py in from_params(cls, params) /usr/local/lib/python3.10/dist-packages/flair/embeddings/token.py in create_from_state(cls, **state) /usr/local/lib/python3.10/dist-packages/flair/embeddings/token.py in init(self, model, is_document_embedding, allow_long_sentences, **kwargs) /usr/local/lib/python3.10/dist-packages/flair/embeddings/transformer.py in init(self, model, fine_tune, layers, layer_mean, subtoken_pooling, cls_pooling, is_token_embedding, is_document_embedding, allow_long_sentences, use_context, respect_document_boundaries, context_dropout, saved_config, tokenizer_data, feature_extractor_data, name, force_max_length, needs_manual_ocr, use_context_separator, transformers_tokenizer_kwargs, transformers_config_kwargs, transformers_model_kwargs, peft_config, peft_gradient_checkpointing_kwargs, **kwargs) /usr/local/lib/python3.10/dist-packages/flair/embeddings/transformer.py in _tokenizer_from_bytes(cls, zip_data) /usr/local/lib/python3.10/dist-packages/transformers/models/auto/tokenization_auto.py in from_pretrained(cls, pretrained_model_name_or_path, *inputs, **kwargs) /usr/local/lib/python3.10/dist-packages/transformers/tokenization_utils_base.py in from_pretrained(cls, pretrained_model_name_or_path, cache_dir, force_download, local_files_only, token, revision, trust_remote_code, *init_inputs, **kwargs) /usr/local/lib/python3.10/dist-packages/transformers/tokenization_utils_base.py in _from_pretrained(cls, resolved_vocab_files, pretrained_model_name_or_path, init_configuration, token, cache_dir, local_files_only, _commit_hash, _is_local, trust_remote_code, *init_inputs, **kwargs) /usr/local/lib/python3.10/dist-packages/transformers/models/t5/tokenization_t5_fast.py in init(self, vocab_file, tokenizer_file, eos_token, unk_token, pad_token, extra_ids, additional_special_tokens, add_prefix_space, **kwargs) /usr/local/lib/python3.10/dist-packages/transformers/tokenization_utils_fast.py in init(self, *args, **kwargs) /usr/local/lib/python3.10/dist-packages/transformers/models/t5/tokenization_t5.py in init(self, vocab_file, eos_token, unk_token, pad_token, extra_ids, additional_special_tokens, sp_model_kwargs, legacy, add_prefix_space, **kwargs) /usr/local/lib/python3.10/dist-packages/sentencepiece/init.py in Load(self, model_file, model_proto) /usr/local/lib/python3.10/dist-packages/sentencepiece/init.py in LoadFromFile(self, arg) TypeError: not a string |
Hi @pganesh I am closing this for now, please create an issue using the bug-report template, fill out all fields there and verify afterwards that the markdown is readable. |
OK understood - will open a bug report
…On Fri, Dec 6, 2024 at 7:58 AM Benedikt Fuchs ***@***.***> wrote:
Hi @pganesh <https://github.com/pganesh>
I am sorry, but I don't want to read so much text with bad formatting.
Besides that, I think there is some default information missing, as this
isn't a question but a bug report.
I am closing this for now, please create an issue using the bug-report
template, fill out all fields there and verify afterwards that the markdown
is readable.
—
Reply to this email directly, view it on GitHub
<#3574 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABOOQI3QA4V62K74JZUNDZT2EHCQPAVCNFSM6AAAAABS4VM6PWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMRTGU3DKOBWGE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Question
For fine-tuning, I used the google/flan-t5-large as the transformer like this:
4. initialize fine-tuneable transformer embeddings WITH document context
embeddings = TransformerWordEmbeddings(model='google/flan-t5-large',
layers="-1",
subtoken_pooling="first",
fine_tune=True,
use_context=True,
)
The training was succesful and the model was saved correctly as a final-model.pt
However, when I try to use it as follows:
load the trained model
model = SequenceTagger.load('/content/resources/taggers/sota-ner-flert/final-model.pt')
I get an error saying that "TypeError: not a string"
I suspect this is due to using the flan-t5-large - everything works great if I used xlm-roberta-large for example
I need some help on how to use the saved/fine-tuned model if the original embedding was based on flan-t5
thanks!
The text was updated successfully, but these errors were encountered: