How to change the Text embedder(Layoutlmv2Tokenizer) in huggingface LayoutLMv2 model?
Hi, I’m a beginner in Transformers huggingface.
I wonder How to change the text embedding models in LayoutLMv2(original to KoBERT)
I used those model by huggingface, so I used each of processor for LayoutLMv2, LayoutXLM.

I think i need to change the text tokenizer for data loading, and change the text encoding weights (in Original LayoutLMv2 model) as KoBERT’s like below codes.

```
kobert_name = "monologg/kobert"
bert_model = BertModel.from_pretrained(kobert_name)
kobert_tokenizer = KoBertTokenizer.from_pretrained(kobert_name)

feature_extractor = LayoutLMv2FeatureExtractor(apply_ocr=False)
processor = LayoutLMv2Processor(feature_extractor, kobert_tokenizer) => Returned below error

# ValueError: Received a KoBertTokenizer for argument tokenizer, but a ('LayoutLMv2Tokenizer', 'LayoutLMv2TokenizerFast') was expected.

model = LayoutLMv2ForTokenClassification.from_pretrained("microsoft/layoutxlm-base", num_labels=len(labels))
# Need to exchange the layoutlmv2.embeddings. as kobert parameters(weights)
```
But I got error in processor defined part… I think the original LayoutLMv2Processor only define the original.
I’m used this [code](https://github.com/NielsRogge/Transformers-Tutorials/tree/master/LayoutLMv2/CORD)
What point should i modify for changing text embedding?
Please share any tips for beginner. 😂
Hi,

It's not possible to plug in a custom tokenizer into `LayoutLMv2Processor`, as `LayoutLMv2Tokenizer` was designed specifically to handle bounding boxes.

If you plan to use a custom tokenizer, then it means that you need to handle addition of special tokens, padding/truncation yourself, which is also what the LayoutLMv2 authors did, as seen [here](https://github.com/microsoft/unilm/blob/ca82fd4e5c7b0e4594eee33f8dd08388183787cd/layoutlmft/examples/run_funsd.py#L165) when tokenizing the words, then defining a custom data collator (to batch examples together) [here](https://github.com/microsoft/unilm/blob/master/layoutlmft/layoutlmft/data/data_collator.py). <|||||>Thank you for kindly reply. It's really helpful.