Please enable JavaScript to use CodeHS

AI and Language

How Does AI Translate Languages?

Swapping words one at a time makes nonsense. Learn how translation tools went from dictionaries to neural networks, why idioms and word order are so tricky, and how to tell when you still need a human.

AI literacy ~12 min Middle / High school
01The Big Idea

Why word-by-word translation fails

Translation means taking a message in one language and saying the same thing in another language. The obvious plan is to grab a dictionary and swap each word for its match. Computers tried exactly that in the 1950s. It does not work very well, and seeing why it fails is the best way to understand how modern AI does better.

Pick a sentence below and compare the dictionary approach with a translation that understands the whole sentence.

Try it

Word-by-word vs. whole sentence

Fixed examples, checked by hand

English to SpanishI have a red car

    Dictionary output

    Five things that trip up word-by-word translation

    • Word order

      Languages arrange words differently. Spanish usually puts colors after the noun: un coche rojo is "a car red." Japanese puts the verb at the very end of the sentence.

    • Idioms

      An idiom is a phrase whose meaning is different from its words. "It's raining cats and dogs" means it is raining hard. In Spanish you say está lloviendo a cántaros, "it's raining by the pitcherful."

    • Words with many meanings

      "Bat" can be an animal or a baseball bat. Spanish uses two different words: murciélago for the animal and bate for the bat you swing. A translator has to read the rest of the sentence to choose.

    • Gendered words

      In English, "the doctor" does not say if the doctor is a man or a woman. Spanish has to choose: el médico or la médica. If the sentence does not say, the translator has to guess.

    • Politeness levels

      Many languages change words depending on who you are talking to. Spanish uses tú with friends and usted to be formal. Japanese "thank you" can be casual ありがとう or polite ありがとうございます. English often hides this.

    Idiom detective

    Idioms are the hardest test for any translator, human or machine. Here are real idioms from other languages, translated word by word. Can you guess what people actually mean?

    Mini game

    What does it really mean?

    Score: 0 / 0
    Idiom 1 of 5

    Word by word:

    Tip: guess from the picture the words paint.

    Key idea: a good translation carries over the meaning, not the words. To do that, a translator has to look at the whole sentence, and sometimes the whole conversation.


    02Then and Now

    A short history of machine translation

    Machine translation just means translation done by a computer. People have been working on it for over 70 years, and the approach has changed three big times.

    1. 1954

      Dictionaries and grammar rules

      Early systems used a bilingual dictionary plus rules written by hand, like "in Spanish, move the color after the noun." A famous 1954 demo translated about 60 carefully chosen Russian sentences into English. But real language has so many exceptions that the rule lists could never keep up.

    2. 1990s

      Statistics and phrases

      Instead of writing rules, researchers fed computers huge piles of text that humans had already translated, like government records published in two languages. The computer counted which phrases usually lined up with which, then picked the most likely match. This is called statistical machine translation. It was better, but sentences often came out choppy.

    3. 2016

      Neural networks

      A neural network is a computer program that learns patterns from examples instead of following rules people wrote. Around 2016, big translation tools switched to neural machine translation, which reads the whole sentence before writing anything. The results got much smoother almost overnight.

    4. 2017+

      Transformers and LLMs

      In 2017, researchers introduced the transformer, a neural network design built around a trick called attention. Transformers power today's translation apps and also large language models (LLMs) like the chatbots you may have used, which can translate, explain a phrase, or change the tone from casual to formal.


    03Under the Hood

    How neural translation works

    You do not need advanced math to get the main idea. A neural translator does three things.

    1. 1

      Turn words into numbers

      Computers only work with numbers, so each word becomes a long list of numbers that describes its meaning. Words with similar meanings, like "cat" and "kitten," get similar lists.

      cat → [0.82, -0.14, 0.37, …]
    2. 2

      Pay attention to the whole sentence

      Attention lets the model decide which words matter most for each choice it makes. To pick the right word for "bat," it looks at words like "cave" or "baseball."

    3. 3

      Write one word at a time

      The model writes the translation one word at a time. Each new word is chosen by looking back at the original sentence and at the words it has already written.

    Attention is easier to see than to describe. In the diagram below, the top row is the English sentence and the bottom row is the translation. Hover over, tap, or tab to a translated word to see which English words the model "looks at" while choosing it. Thicker lines mean more attention.

    Visualize

    Attention lines

    English (source)

    Spanish (translation)

    Select a translated word to see where its attention goes.

    These attention weights are hand-made to illustrate the idea. Real models have many attention "heads," and their patterns are messier.

    Key idea: notice how the Spanish word negro (black) looks at "cat" too. Spanish adjectives must match their noun, so the model needs to know the noun to pick the right ending. That is the kind of whole-sentence thinking word-by-word systems could not do.

    Where did the model learn all this? From training data: millions of sentence pairs that people translated, such as books, websites, subtitles, and official documents published in several languages. The model guessed translations, compared them to the human versions, and adjusted its numbers again and again until its guesses got good.


    04Fairness

    Why some languages get worse translations

    There are about 7,000 languages in the world. Translation tools support only a few hundred. Even among those, quality varies a lot, and the biggest reason is simple: the AI learns from examples, and some languages have far fewer examples online.

    A low-resource language is one with little digital text available for training, even if millions of people speak it. Many African, Indigenous, and regional languages fall into this group. Less training data usually means more mistakes.

    Explore

    How much text there is to learn from

    Illustrative, not real measurements
      High-resourceLow-resource

      On a normal scale, the low-resource bars are so small they almost vanish. Try the zoomed scale.

      The numbers above are made up to show the shape of the problem, not exact amounts. The real gap can be even larger. Researchers and communities are working on it, for example by collecting new translated sentences with native speakers and training one model on many languages at once so that languages can "share" what the model learns.


      05Be Careful

      Mistakes, bias, and when you need a human

      Modern AI translation is impressive, but it can be wrong while sounding completely confident. The output reads smoothly, which makes mistakes harder to spot.

      Bias: when the AI guesses a gender

      Bias in AI means the system leans unfairly toward certain answers because of patterns in its training data. Translation shows this clearly. Turkish uses one word, o, for "he," "she," and "it." English has to choose.

      Turkish (no gender)

      O bir doktor.

      O bir hemşire.

      A biased translation

      He is a doctor.

      She is a nurse.

      Nothing in the Turkish says the doctor is a man or the nurse is a woman. Older tools picked genders based on stereotypes in their training text. Some tools now show both versions, like "He is a doctor / She is a doctor," but this kind of bias can still sneak in, especially in longer passages.

      When to use a human translator

      A professional human translator knows both languages and cultures and can be responsible for the result. Use one whenever a mistake could hurt someone:

      Medical

      Medicine doses, allergies, symptoms, and doctor's instructions. Hospitals often provide free interpreters.

      Legal

      Contracts, court papers, immigration forms, and anything you sign.

      Safety and big decisions

      Emergency instructions, school records, and anything where tone or respect really matters.

      Privacy reminder: text you paste into an online translator is sent to a company's servers. Avoid pasting private information like medical records, passwords, or other people's personal details.


      06Your Toolkit

      How to use translation tools wisely

      1. Write short, clear sentences. One idea per sentence. Long sentences with lots of "which" and "that" give the model more chances to get confused.
      2. Skip idioms and slang. Instead of "that test was a piece of cake," write "that test was very easy."
      3. Give context. If a word has two meanings, add a clue: "baseball bat," not just "bat." With a chatbot, you can also say who the message is for, like "translate this politely for my friend's grandmother."
      4. Check with back-translation. Translate your text into the other language, then translate the result back. If the meaning comes back changed, rewrite your original and try again.
      5. Double-check names, numbers, and dates. Dates are written in different orders in different countries, and names sometimes get "translated" by accident.

      Here is back-translation in action. Like the game "telephone," a message passes through several languages. Watch what happens to a sentence full of idioms compared to a plain one.

      Try it

      Translation telephone

        Pre-scripted example of a too-literal translator. Real tools usually handle these common idioms, but rarer ones can drift just like this.


        07FAQ

        Frequently asked questions

        How does Google Translate work?

        Google Translate uses neural machine translation. A neural network turns the words of your sentence into lists of numbers that capture their meaning, looks at the whole sentence at once using a technique called attention, and then writes the translation one word at a time. It learned how to do this by studying huge amounts of text that people had already translated.

        Is AI translation accurate?

        For short, clear sentences in widely used languages like Spanish, French, or Japanese, AI translation is usually very good. It is less reliable with idioms, slang, long complicated sentences, and languages that have less text online. It can also sound confident while being wrong, so important translations should be checked by a person who knows both languages.

        Why does AI translation get idioms wrong?

        An idiom is a phrase whose meaning is different from its individual words, like "it's raining cats and dogs." If a translator follows the words instead of the meaning, it produces a sentence about real cats and dogs. Modern tools handle common idioms well because they saw them many times in training, but rare or new idioms still cause mistakes.

        Can AI translate every language?

        No. There are about 7,000 languages in the world, and translation tools support only a few hundred of them. Languages with less written text online, called low-resource languages, usually get lower quality translations because the AI had less to learn from.

        Will AI replace human translators?

        AI is great for quick, everyday translation, but human translators are still needed when mistakes matter, such as medical instructions, legal documents, and immigration paperwork. Humans also understand culture, tone, and context in ways AI can miss. Many professional translators now use AI as a first draft and then fix it.

        What is back-translation?

        Back-translation means translating your text into another language and then translating the result back into your original language. If the meaning comes back the same, the translation is probably okay. If it comes back strange, rewrite your original sentence to be shorter and clearer and try again.


        08Check Yourself

        Quick quiz

        1. Why does "Yo tener un rojo coche" sound wrong in Spanish?

        2. What does "attention" do in a neural translator?

        3. Why might an AI translate a language like Quechua less accurately than Spanish?

        4. Your aunt needs to understand her new medicine instructions in another language. What is the best choice?