Statistical Machine Translation (SMT) is a machine translation approach that translates text from one language to another by learning statistical patterns from large collections of bilingual text. It selects the target-language sentence that has the highest probability of being the correct translation of the source sentence. This is achieved using probabilistic models based on bilingual training data.
The objective of SMT is to find the target sentence
f^*=\arg\max_f P(f \mid e)
where:
e = Source language sentencef = Target language sentenceP(f \mid e) = Probability that the target sentencef is the correct translation of the source sentencee
Using Bayes' Theorem, the formula can be rewritten as:
(f)f^*=\arg\max_f P(e \mid f)\times P(f)
where:
P(e∣f) = Translation Model, which measures how well the target sentence translates to the source sentence.P(f) = Language Model, which estimates how grammatically correct and fluent the target sentence is.
Architecture
Statistical Machine Translation (SMT) follows a probabilistic architecture that learns translation patterns from bilingual text.

- Parallel Corpus: A collection of sentence pairs in the source and target languages used to learn word and phrase correspondences during training.
- Translation Model: Learns the probability of translating source-language words or phrases into their corresponding target-language equivalents using bilingual text.
- Language Model: Estimates the likelihood of a sentence in the target language to ensure that the generated translation is grammatically correct and fluent.
- Phrase Segmentation: Divides the input sentence into smaller words or phrases that can be translated more accurately than translating individual words.
- Distortion (Reordering) Model: Determines the optimal order of translated phrases so that the final sentence follows the grammatical structure of the target language.
- Decoder: Combines the translation model, language model, and distortion model to search for the translation with the highest overall probability.
- Final Translation: Produces the most probable and grammatically correct sentence in the target language based on the combined probabilities from all models.
Working
Statistical Machine Translation (SMT) translates sentences by dividing them into phrases, translating each phrase independently, and then rearranging the translated phrases to match the grammatical structure of the target language. The figure below illustrates this process using an English-to-French translation example.

Step 1: Divide the Source Sentence into Phrases
The English input sentence is divided into smaller phrases represented as e1 , e2 , e3 , e4 , and e5 . Each phrase contains one or more words that can be translated as a single unit.
Step 2: Translate Each Phrase
Each English phrase is translated into its corresponding French phrase (f1 , f2 , f3 , f4 , and f5 ) using the translation model learned from bilingual corpora. Phrase-level translation preserves context better than translating individual words.
Step 3: Reorder the Translated Phrases
Since English and French follow different word orders, the translated phrases cannot always remain in the same sequence. The distortion model rearranges the phrases into an order that follows the grammar of the target language.
Step 4: Apply Distortion Values
Each translated phrase is assigned a distortion value (D) that indicates how far it moves from its original position.
- D = 0 → The phrase remains in the same position.
- D > 0 → The phrase moves to the right.
- D < 0 → The phrase moves to the left.
In the figure, D1 = 0 and D5 = 0 indicate that the first and last phrases remain in their original positions, D2 = +1 and D4 = +1 indicate movement to the right, while D3 = -2 indicates that the third phrase shifts two positions to the left.
Step 5: Generate the Final Translation
After all phrases have been reordered according to their distortion values, the decoder combines them to produce the final French sentence, which is both grammatically correct and semantically meaningful.
Implementation
Step 1: Install Required Libraries
Install the libraries required for tokenization and text preprocessing in Statistical Machine Translation.
- Sacremoses provides tokenization and detokenization utilities.
- SentencePiece supports subword text processing for NLP applications.
!pip install sacremoses sentencepiece
Step 2: Import Libraries
Import the required classes for tokenizing and reconstructing text.
- MosesTokenizer splits sentences into tokens.
- MosesDetokenizer converts tokens back into readable text.
from sacremoses import MosesTokenizer
from sacremoses import MosesDetokenizer
Step 3: Create a Small Parallel Corpus
Create a small bilingual dataset containing English and French sentence pairs.
- The English sentences are the source language.
- The French sentences are the corresponding target-language translations.
english = [
"Good morning",
"How are you?",
"Thank you",
"See you tomorrow"
]
french = [
"Bonjour",
"Comment allez-vous ?",
"Merci",
"À demain"
]
Step 4: Tokenize the Sentences
Tokenize the English sentences before translation.
- Splits each sentence into individual words or tokens.
- Prepares the text for phrase-based translation.
mt = MosesTokenizer(lang='en')
for sentence in english:
print(mt.tokenize(sentence))
Step 5: Simulate Phrase-Based Translation
Translate the input sentence using a bilingual phrase dictionary.
- Maps the English sentence to its corresponding French translation.
- Displays the translated sentence as the output.
translation_dictionary = {
"Good morning": "Bonjour",
"How are you?": "Comment allez-vous ?",
"Thank you": "Merci",
"See you tomorrow": "À demain"
}
sentence = "Thank you"
print("English :", sentence)
print("French :", translation_dictionary[sentence])
Output:
English : Thank you
French : Merci
You can downlaod the code from here.
Applications
- Website Localization: Translates websites and web applications into multiple languages for global users.
- Document Translation: Converts business reports, manuals, and technical documents between languages.
- Cross-Language Information Retrieval: Enables users to search and access information written in different languages.
- Multilingual Customer Support: Assists in translating customer queries and responses across multiple languages.
- Government and International Communication: Translates official documents and multilingual communications for global organizations.
- Language Learning: Helps learners understand the meaning of words, phrases, and sentences through automatic translation.
Advantages
- Produces more natural translations by translating phrases rather than individual words.
- Supports multiple language pairs when sufficient parallel corpora are available.
- Can be adapted to specific domains by training on domain-related bilingual datasets.
- Reduces manual effort in developing and maintaining machine translation systems.
Limitations
- May generate incorrect translations for sentences with complex context or ambiguity.
- Phrase reordering does not always produce grammatically correct target-language sentences.
- Performance decreases when translating text from domains not covered during training.
- Generally provides lower translation quality than modern Neural Machine Translation (NMT) models.