AttributeError: 'XLNetModel' object has no attribute 'embeddings'
nfelnlp opened this issue · comments
The following error was raised for "mnli-xlnet-lgxa":
Traceback (most recent call last):
File "run_explainer.py", line 57, in <module>
explainer = getattr(thermex, f'Explainer{config["explainer"]["name"]}').from_config(config=config)
File "/home/feldhus/thermostat/src/thermostat/explainers/grad.py", line 71, in from_config
layer=res.model.base_model.embeddings)
File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1094, in __getattr__
raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'XLNetModel' object has no attribute 'embeddings'
seems like you search for embeddings
but i use transformer.word_embedding
https://github.com/rbtsbg/gxai/blob/c183d48a8c871ea38c9529a0d24017bcccb4f833/explain.py#L164
since XLNet / LIG was not part of the paper, I did not check this in depth, so please double check it
also keep in mind that i might have worked with another version and that this could be deprecated
Thanks! I think inserting a case distinction for XLNet will suffice.
It's just that I think it's weird that XLNet seems to be the only model which does not have the embeddings attribute.
I did not find it then and word_embedding
is my best guess
sorry closed by accident
so, i investigated the xlnet code. the word embeddings layer does not contain positional and segment embeddings, but it appears to be what we suspect it to be.
returns the word embeddings
later, the word embeddings are forwarded with the other embeddings, i.e. positional, segment ...
Wow, that automated message above this is really neat!
I don't really need to say anything more than that, huh. 😅