# Using a fixed vocabulary?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-a-fixed-vocabulary%2F10694%3E%5C
**Category:** Intermediate\
**Created:** [October 11, 2021, 7:52pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-a-fixed-vocabulary%2F10694 "2021-10-11T19:52:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbmaxwell](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@jbmaxwell](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjbmaxwell)%5C
**Post date:** [October 11, 2021, 7:52pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-a-fixed-vocabulary%2F10694%2F1 "2021-10-11T19:52:28Z")

</div>

I have a special non-language use case using a fixed vocabulary—i.e., a relatively small set of generated tokens that represent the entire vocabulary of our “language.” I’d like to be able to use this with any of the different models and I’m wondering what would be the best approach? It’s just a `vocab.txt` file of short strings, which I don’t think will work with any of the BPE tokenizers. Am I correct in that assumption? Also, is there a way to “force” a vocabulary onto any of the tokenizers?

Any help much appreciated.

---

<div class="post-metadata">

**Author:** ![jbmaxwell](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@jbmaxwell](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjbmaxwell)%5C
**Post date:** [October 12, 2021, 12:38am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-a-fixed-vocabulary%2F10694%2F2 "2021-10-12T00:38:51Z")

</div>

What if I just instantiate a tokenizer (e.g., BigBirdTokenizer), then used `add_tokens()` to add my entire vocabulary? That is, start with nothing, then “force” them in with the `add_tokens()` function… ??

UPDATE: Hmm… no… I can’t instantiate _without_ a vocab file, so that won’t work…

---

<div class="post-metadata">

**Author:** ![jbmaxwell](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@jbmaxwell](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjbmaxwell)%5C
**Post date:** [November 8, 2021, 4:29pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-a-fixed-vocabulary%2F10694%2F3 "2021-11-08T16:29:10Z")

</div>

In case anyone is having a similar problem (though I guess nobody is), I was able to get it loading by creating a folder with `special_tokens_map.json` and `tokenizer_config.json`, along with my `vocab.txt`, and passing it to the `run_mlm.py` script, using the `tokenizer_name` argument.
