# Is 512 token in bert, token or character level?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fis-512-token-in-bert-token-or-character-level%2F16406%3E%5C
**Category:** Beginners\
**Created:** [April 3, 2022, 8:07am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fis-512-token-in-bert-token-or-character-level%2F16406 "2022-04-03T08:07:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![moma1820](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/moma1820/32/4141_2.png) [@moma1820](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmoma1820)%5C
**Post date:** [April 3, 2022, 8:07am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fis-512-token-in-bert-token-or-character-level%2F16406%2F1 "2022-04-03T08:07:23Z")

</div>

Hi,  
I am super puzzled, if bert 512 token count is character or word level.

So for all the resources say it’s word level.

Would appreciate if someone fills me in .

Best,  
Mosh

---

<div class="post-metadata">

**Author:** ![julien-c](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/julien-c/32/41937_2.png) [@julien-c](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjulien-c)%5C
**Post date:** [April 3, 2022, 5:57pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fis-512-token-in-bert-token-or-character-level%2F16406%2F2 "2022-04-03T17:57:25Z")

</div>

BERT’s tokenizer, Wordpiece, is a subword tokenizer.

See example at [Summary of the tokenizers](https://huggingface.co/docs/transformers/tokenizer_summary)

---

<div class="post-metadata">

**Author:** ![arteagac](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/arteagac/32/32065_2.png) [@arteagac](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Farteagac)%5C
**Post date:** [April 3, 2022, 8:31pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fis-512-token-in-bert-token-or-character-level%2F16406%2F3 "2022-04-03T20:31:21Z")

</div>

BERT uses a subword tokenizer (WordPiece), so the maximum length corresponds to 512 subword tokens. See the example below, in which the input sentence has eight words, but the tokenizer generates a sequence with length equal to nine. Note that the extra token in this example is due to the word `outstandingly`, which the subword tokenizer represents using two tokens: `outstanding` and `##ly`.

```python
>>> from transformers import AutoTokenizer

>>> tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
>>> tokenizer.tokenize("The outstandingly big cat sat on the mat")

```

```bash
OUTPUT: 
['the', 'outstanding', '##ly', 'big', 'cat', 'sat', 'on', 'the', 'mat']

```

---

<div class="post-metadata">

**Author:** ![moma1820](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/moma1820/32/4141_2.png) [@moma1820](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmoma1820)%5C
**Post date:** [April 4, 2022, 6:16am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fis-512-token-in-bert-token-or-character-level%2F16406%2F4 "2022-04-04T06:16:48Z")

</div>

Thank you for the reply guys,

So lets say i have a 512 word sentece as input. And let’s say some word were tokenized into formats like ‘outstanding’ → ‘outstanding’, ‘##ly’.

So i’m assuming some words at the end of the sentences will be turncated after tokenization ?

Best,  
Mosh
