Skip to content
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

Token classification using LayoutXLM #76

Closed
manangandhi7 opened this issue Feb 11, 2022 · 7 comments
Closed

Token classification using LayoutXLM #76

manangandhi7 opened this issue Feb 11, 2022 · 7 comments

Comments

@manangandhi7
Copy link

Model : LayoutXLM

I am able to use LayoutLMv2ForTokenClassification for my problem. Since the data I am using is in German, I would like to use LayoutXLM model. Unfortunately I do not find LayoutLXLMForTokenClassification on Transformers. How could I do Token classification using LayoutXLM?

To Reproduce
Steps to reproduce the behavior:

from transformers import LayoutXLMForTokenClassification
Expected behavior
ImportError: cannot import name 'LayoutXLMForTokenClassification' from 'transformers' (/opt/conda/lib/python3.7/site-packages/transformers/init.py)

Platform: Linux
Python version: 3.7

@NielsRogge
Copy link
Owner

Hi,

LayoutXLM is identical to LayoutLMv2. There's no LayoutXLM models defined in the library. You can just use:

from transformers import LayoutLMv2ForTokenClassification

model = LayoutLMv2ForTokenClassification.from_pretrained("microsoft/layoutxlm-base")

@manangandhi7
Copy link
Author

manangandhi7 commented Feb 11, 2022

Hi NielsRogge, many thanks for quick answer.
I get following error when I do that. Reproducing this is very simple.

from transformers import LayoutLMv2ForTokenClassification
model = LayoutLMv2ForTokenClassification.from_pretrained('microsoft/layoutxlm-base', num_labels=10)

You will get following error:


TypeError: init() got an unexpected keyword argument '_configuration_file'

@NielsRogge
Copy link
Owner

Which version of Transformers are you on?

@manangandhi7
Copy link
Author

manangandhi7 commented Feb 11, 2022

python 3.7
transformers 4.16.2
torch 1.10.2+cu102

Do you recommend any specific version of transformers?

@manangandhi7
Copy link
Author

Issue is resolved when I downgrade transformers to v4.15.0

@NielsRogge
Copy link
Owner

Thanks, I could reproduce the issue and have reported it. We will fix it.

@NielsRogge
Copy link
Owner

Update: fixed per huggingface/transformers#15629.

We will do a patch release on Monday. For now, you can install Transformers from master: pip install git+https://github.com/huggingface/transformers.git.

Will close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants