unk_id is missing for SentencepieceTokenizer
Author: darwinharianto
Pull request: no

Trained sentencepiece tokenizer from Tokenizer library with some added tokens

```
 "added_tokens": [
    {
      "id": 0,
      "special": true,
      "content": "<unk>",
      "single_word": false,
      "lstrip": false,
      "rstrip": false,
      "normalized": false
    },
    {
      "id": 1,
      "special": true,
      "content": "
",
      "single_word": false,
      "lstrip": false,
      "rstrip": false,
      "normalized": false
    },
    {
      "id": 2,
      "special": true,
      "content": "
",
      "single_word": false,
      "lstrip": false,
      "rstrip": false,
      "normalized": false
    },
    {
      "id": 3,
      "special": true,
      "content": "<cls>",
      "single_word": false,
      "lstrip": false,
      "rstrip": false,
      "normalized": false
    },
    {
      "id": 4,
      "special": true,
      "content": "<sep>",
      "single_word": false,
      "lstrip": false,
      "rstrip": false,
      "normalized": false
    },
    {
      "id": 5,
      "special": true,
      "content": "<pad>",
      "single_word": false,
      "lstrip": false,
      "rstrip": false,
      "normalized": false
    },
    {
      "id": 6,
      "special": true,
      "content": "<mask>",
      "single_word": false,
      "lstrip": false,
      "rstrip": false,
      "normalized": false
    },
    {
      "id": 7,
      "special": true,
      "content": "<eod>",
      "single_word": false,
      "lstrip": false,
      "rstrip": false,
      "normalized": false
    },
    {
      "id": 8,
      "special": true,
      "content": "<eop>",
      "single_word": false,
      "lstrip": false,
      "rstrip": false,
      "normalized": false
    }
  ],
```

When this tokenizer encounters unknown words, it throws unk_id is missing error.

`Exception: Encountered an unknown token but `unk_id` is missing`
How do I set unk_id for this tokenizer?

This is how I load my tokenizer

```
tokenizer = Tokenizer.from_file('./unigram.json')
tokenizer = XLNetTokenizerFast(tokenizer_object=tokenizer, unk_token="<unk>")
```

Comments:
Maybe of interest to @SaulLu 

I have an idea where the problem might come from. 

To be sure that this is the source of the error, @darwinharianto, could you share with me your `unigram.json` file or, if you can't, the content of the `model` key and the `unk_id` subkey in your `unigram.json` file? :slightly_smiling_face: 

Sorry for the late reply, here is my unigram.json


[unigram.json.zip](https://github.com/huggingface/transformers/files/6837202/unigram.json.zip)

Edit:
This is how I used the tokenizer
```
def tokenize_function(examples):
    token_res = tokenizer(examples["text"], truncation=True, max_length=MAX_LENGTH)
    for i, item in enumerate(token_res["input_ids"]):
        if len(item) % 2 != 0:
            token_res["input_ids"][i].insert(-2,5)
            token_res["attention_mask"][i].insert(-2,0)
            token_res["token_type_ids"][i].insert(-2,1)
    return token_res

tokenized_datasets = raw_datasets.map(tokenize_function, batched=True)

data_collator = DataCollatorForPermutationLanguageModeling(
    tokenizer=tokenizer,
    plm_probability = 0.16666666666666666,
    max_span_length = 6
)
trainer = Trainer(
    model=model,
    args=training_args,
    data_collator=data_collator,
    train_dataset=small_train_dataset,
    eval_dataset=small_eval_dataset
)
```

I don't know why, but for `DataCollatorForPermutationLanguageModeling` it needs even number of words, so I pad the content in tokenize function

Thanks for the document, I think the error comes from the fact that the value associated to the `model` key and the `unk_id` subkey in your `unigram.json` file is `null` instead of `0` (`"<unk>"` is the first token of your vocabulary).

If you have used the training script of `SentencePieceUnigramTokenizer` provided in :hugs: tokenizers library, I've opened a PR [here](https://github.com/huggingface/tokenizers/pull/762) to solve this missing information for the future trainings - as the `unk_token` need to be pass to the `Trainer` and currently you haven't the opportunity to do it. :slightly_smiling_face:

However, I guess you don't want to re-train your tokenizer. In this case, the simplest is to change by hand the value in the `unigram.json` file associated to the `unk_id` key so that it matches the id of the unknown token (in your case `0`).

I would be happy to know if this indeed solves the error you had :relaxed: 



Thanks!
Manually changing unk_id to 0 make it works