# NLP: how to handle bad tokenization

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fnlp-how-to-handle-bad-tokenization%2F91659%3E%5C
**Category:** Beginners\
**Created:** [June 12, 2024, 3:28am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fnlp-how-to-handle-bad-tokenization%2F91659 "2024-06-12T03:28:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jourhighness](https://avatars.discourse-cdn.com/v4/letter/j/54ee81/32.png) [@Jourhighness](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJourhighness)%5C
**Post date:** [June 12, 2024, 3:28am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fnlp-how-to-handle-bad-tokenization%2F91659%2F1 "2024-06-12T03:28:02Z")

</div>

Hello, I get nonsense when trying to translate the following german sentence to swedish using google/madlad400-3b-mt:

> a. Natürliche Personen: BundID mit ELSTER-Zertifikat oder nPA/eID/eAT-Authentifizierung  
> b. Juristische Personen: Unternehmenskonto BUND mit ELSTER-Zertifik

→

> . Personen mit Behinderung: BundesID mit ELSTER-Zertifikat oder nPA/eID/eAT-Authentifizierung c. Personen mit Behinderung: BundesID mit ELSTER-Zertifikat oder nPA db. Personen mit Behinderung: BundesID mit ELSTER-Zertifikat oder nPA/e

Code:

```auto
pipe = pipeline("translation", model="google/madlad400-3b-mt")
pipe('<2sv>'+input, max_length = n_words*5)

```

This is likely due to the abundance of abbreviations and special words.

_Is there a per sentence metric I can use to measure bad tokenizations? A naive one would be to calulate the percentage of unknown tokens. In my case the problem seems to be that it falsely attends to abbreviations rather than unknown confusion._
