{
  "source_file": "0930",
  "source_platform": "Medium",
  "author": "Chua Chin Hon",
  "title_listed": "Lost In (Machine) Translation",
  "keywords": "",
  "domain": "文本处理",
  "content_type": "深度技术解析",
  "is_paid_flag": "否",
  "url": "https://towardsdatascience.com/lost-in-machine-translation-3b05615d68e7/",
  "publish_date": "2020-08-24",
  "corpus_stage": "",
  "notes": "",
  "id": "6da3e52670b5",
  "collected_at": "2026-10-02T09:39:33",
  "title": "Lost In (Machine) Translation | Towards Data Science",
  "body_markdown": "![Revisit consent button](../images/body-df29beacd7496220cc94.svg)\nWe value your privacy\nWe use cookies to enhance your browsing experience, serve personalised ads or content, and analyse our traffic. By clicking \"Accept All\", you consent to our use of cookies.\nCustomise Reject All Accept All\nCustomise Consent Preferences ![](../images/body-2159bb67f3de8ad870eb.svg)\nWe use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.\nThe cookies that are categorised as \"Necessary\" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... Show more\nNecessaryAlways Active\nNecessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.\n  * Cookie\nBCTempID\n  * Duration\n10 minutes\n  * Description\nNo description available.\n\n\n  * Cookie\n__cf_bm\n  * Duration\n1 hour\n  * Description\nThis cookie, set by Cloudflare, is used to support Cloudflare Bot Management. \n\n\n  * Cookie\nAWSALBCORS\n  * Duration\n7 days\n  * Description\nAmazon Web Services set this cookie for load balancing.\n\n\n  * Cookie\n_cfuvid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to track users across sessions to optimize user experience by maintaining session consistency and providing personalized services\n\n\n  * Cookie\nli_gc\n  * Duration\n6 months\n  * Description\nLinkedin set this cookie for storing visitor's consent regarding using cookies for non-essential purposes.\n\n\n  * Cookie\n__hssrc\n  * Duration\nsession\n  * Description\nThis cookie is set by Hubspot whenever it changes the session cookie. The __hssrc cookie set to 1 indicates that the user has restarted the browser, and if the cookie does not exist, it is assumed to be a new session.\n\n\n  * Cookie\n__hssc\n  * Duration\n1 hour\n  * Description\nHubSpot sets this cookie to keep track of sessions and to determine if HubSpot should increment the session number and timestamps in the __hstc cookie.\n\n\n  * Cookie\nwpEmojiSettingsSupports\n  * Duration\nsession\n  * Description\nWordPress sets this cookie when a user interacts with emojis on a WordPress site. It helps determine if the user's browser can display emojis properly.\n\n\n  * Cookie\nBCSessionID\n  * Duration\n1 year 1 month 4 days\n  * Description\nBlueconic sets this cookie as a unique identifier for the BlueConic profile.\n\n\n  * Cookie\n_octo\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nlogged_in\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\n__Secure-YEC\n  * Duration\npast\n  * Description\nYouTube sets this cookie to stores the user's video player preferences using embedded YouTube video\n\n\n  * Cookie\n__eoi\n  * Duration\n6 months\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTGCORS\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\nlogin-status-p\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTG\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\ncsrf_token\n  * Duration\nsession\n  * Description\nNo description available.\n\n\n  * Cookie\ntoken_v2\n  * Duration\n1 day\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nD\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nPHPSESSID\n  * Duration\nsession\n  * Description\nThis cookie is native to PHP applications. The cookie stores and identifies a user's unique session ID to manage user sessions on the website. The cookie is a session cookie and will be deleted when all the browser windows are closed.\n\n\n  * Cookie\nVISITOR_PRIVACY_METADATA\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to store the user's cookie consent state for the current domain. \n\n\n  * Cookie\ncookietest\n  * Duration\nsession\n  * Description\nThe cookietest cookie is typically used to determine whether the user's browser accepts cookies, essential for website functionality and user experience.\n\n\n  * Cookie\n__Host-airtable-session\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\n__Host-airtable-session.sig\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\nm\n  * Duration\n1 year 1 month 4 days\n  * Description\nStripe sets this cookie for fraud prevention purposes. It identifies the device used to access the website, allowing the website to be formatted accordingly.\n\n\n  * Cookie\nBIGipServer*\n  * Duration\nsession\n  * Description\nMarketo sets this cookie to collect information about the user's online activity and build a profile about their interests to provide advertisements relevant to the user. \n\n\n  * Cookie\n__cfruid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to identify trusted web traffic.\n\n\n  * Cookie\n_GRECAPTCHA\n  * Duration\n6 months\n  * Description\nGoogle Recaptcha service sets this cookie to identify bots to protect the website against malicious spam attacks.\n\n\n  * Cookie\n__Secure-YNID\n  * Duration\n6 months\n  * Description\nGoogle cookie used to protect user security and prevent fraud, especially during the login process.\n\n\n  * Cookie\ncookieyes-consent\n  * Duration\n1 year\n  * Description\nCookieYes sets this cookie to remember users' consent preferences so that their preferences are respected on subsequent visits to this site. It does not collect or store any personal information about the site visitors.\n\n\nFunctional\nFunctional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.\n  * Cookie\nlidc\n  * Duration\n1 day\n  * Description\nLinkedIn sets the lidc cookie to facilitate data center selection.\n\n\n  * Cookie\nbrw\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nbrwConsent\n  * Duration\n5 minutes\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nWMF-Uniq\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nloom_anon_comment\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nloom_referral_video\n  * Duration\nsession\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nVISITOR_INFO1_LIVE\n  * Duration\n6 months\n  * Description\nA cookie set by YouTube to measure bandwidth that determines whether the user gets the new or old player interface.\n\n\n  * Cookie\nyt-remote-connected-devices\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nytidb::LAST_RESULT_ENTRY_KEY\n  * Duration\nNever Expires\n  * Description\nThe cookie ytidb::LAST_RESULT_ENTRY_KEY is used by YouTube to store the last search result entry that was clicked by the user. This information is used to improve the user experience by providing more relevant search results in the future.\n\n\n  * Cookie\nyt-remote-device-id\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-name\n  * Duration\nsession\n  * Description\nThe yt-remote-session-name cookie is used by YouTube to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\nyt-remote-fast-check-period\n  * Duration\nsession\n  * Description\nThe yt-remote-fast-check-period cookie is used by YouTube to store the user's video player preferences for embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-app\n  * Duration\nsession\n  * Description\nThe yt-remote-session-app cookie is used by YouTube to store user preferences and information about the interface of the embedded YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-available\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-available cookie is used to store the user's preferences regarding whether casting is available on their YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-installed\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-installed cookie is used to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\ncp_session\n  * Duration\n3 months\n  * Description\nCodepen sets this cookie for Help systems found in the website.\n\n\n  * Cookie\nloid\n  * Duration\n1 year 1 month 4 days\n  * Description\nThis cookie is set by the Reddit. The cookie enables the sharing of content from the website onto the social media platform.\n\n\nAnalytics\nAnalytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.\n  * Cookie\n__hstc\n  * Duration\n6 months\n  * Description\nHubspot set this main cookie for tracking visitors. It contains the domain, initial timestamp (first visit), last timestamp (last visit), current timestamp (this visit), and session number (increments for each subsequent session).\n\n\n  * Cookie\nhubspotutk\n  * Duration\n6 months\n  * Description\nHubSpot sets this cookie to keep track of the visitors to the website. This cookie is passed to HubSpot on form submission and used when deduplicating contacts.\n\n\n  * Cookie\n_ga\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to calculate visitor, session and campaign data and track site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognise unique visitors.\n\n\n  * Cookie\n_ga_*\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to store and count page views.\n\n\n  * Cookie\n__Host-psifi.analyticsTrace\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n__Host-psifi.analyticsTraceV2\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n_gh_sess\n  * Duration\nsession\n  * Description\nGitHub sets this cookie for temporary application and framework state between pages like what step the user is on in a multiple step form.\n\n\n  * Cookie\nYSC\n  * Duration\nsession\n  * Description\nYSC cookie is set by Youtube and is used to track the views of embedded videos on Youtube pages.\n\n\n  * Cookie\najs_anonymous_id\n  * Duration\n1 year\n  * Description\nThis cookie is set by Segment to count the number of people who visit a certain site by tracking if they have visited before.\n\n\n  * Cookie\nvuid\n  * Duration\n1 year 1 month 4 days\n  * Description\nVimeo installs this cookie to collect tracking information by setting a unique ID to embed videos on the website. \n\n\nPerformance\nPerformance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.\n  * Cookie\nAWSALB\n  * Duration\n7 days\n  * Description\nAWSALB is an application load balancer cookie set by Amazon Web Services to map the session to the target.\n\n\n  * Cookie\nacq\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nacq.sig\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nptc\n  * Duration\n2 years\n  * Description\nNo description available.\n\n\nAdvertisement\nAdvertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.\n  * Cookie\nmuc_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to collect user behaviour and interaction data to optimize the website.\n\n\n  * Cookie\nguest_id_marketing\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\nguest_id_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\npersonalization_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to integrate and share features for social media and also store information about how the user uses the website, for tracking and targeting.\n\n\n  * Cookie\nguest_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor. It registers if a user is signed in to the Twitter platform and collects information about ad preferences.\n\n\n  * Cookie\nbcookie\n  * Duration\n1 year\n  * Description\nLinkedIn sets this cookie from LinkedIn share buttons and ad tags to recognize browser IDs.\n\n\n  * Cookie\n__Secure-ROLLOUT_TOKEN\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to manage feature rollout and experimentation. It helps Google control which new features or interface changes are shown to users as part of testing and staged rollouts, ensuring consistent experience for a given user during an experiment.\n\n\n  * Cookie\nyt.innertube::nextId\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nyt.innertube::requests\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nsession_tracker\n  * Duration\nsession\n  * Description\nThis cookie is set by the Reddit. This cookie is used to identify trusted web traffic. It also helps in adverstising on the website.\n\n\n  * Cookie\nedgebucket\n  * Duration\nsession\n  * Description\nReddit sets this cookie to save the information about a log-on Reddit user, for the purpose of advertisement recommendations and updating the content.\n\n\n  * Cookie\ndid\n  * Duration\n1 year\n  * Description\nArbor sets this cookie to show targeted ads to site visitors.This cookie expires after 2 months or 1 year.\n\n\nUncategorised\nOther uncategorised cookies are those that are being analysed and have not been classified into a category as yet.\nNo cookies to display.\nReject All Save My Preferences Accept All\nToggle Search[](https://towardsdatascience.com/)Toggle Mobile Navigation\n[](https://towardsdatascience.com/)\nPublish AI, ML & data-science insights to a global community of data professionals.\nSign in[Submit an Article](https://write.insightmediagroup.io)\n[Latest](https://towardsdatascience.com/latest/)[Editor's Picks](https://towardsdatascience.com/tag/editors-pick/)[Newsletter](https://towardsdatascience.com/tag/the-variable/)[ShipAI](https://towardsdatascience.com/shipai/)\n* * *\n[Write For TDS](https://towardsdatascience.com/submissions/)\n[LinkedIn](https://www.linkedin.com/company/towards-data-science/)[X](https://x.com/TDataScience)Toggle Search\n[Data Science](https://towardsdatascience.com/category/data-science/)\n# Lost In (Machine) Translation\nSmall batch machine translation of speeches and news articles (English-to-Chinese and vice versa) in under-30 lines of code.\n[Chua Chin Hon](https://towardsdatascience.com/author/chuachinhon/)\nAugust 24, 20208 min read\n![Illustration: Chua Chin Hon](../images/000.jpeg)\nIllustration: Chua Chin Hon\n### Small batch machine translation of speeches and news articles (English to Chinese/Tamil, and vice versa) in under-30 lines of code, using Hugging Face's version of MarianMT and Facebook's Fairseq.\n_**UPDATED Dec 30, 2020**_ :\nFacebook [recently released](https://github.com/pytorch/fairseq/tree/master/examples/wmt20) recently released its machine translation models for English to Tamil (and vice versa), and I was eager to give it a try since Tamil is among the most under-served languages in machine learning, and related language pairs are pretty hard to come by.\nThe new notebooks and toy datasets are in the [repo](https://github.com/chuachinhon/practical_nlp). Or, go [[here](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/4.4_tamil_to_english_fairseq.ipynb)](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/4.3_english_to_tamil_fairseq.ipynb) for the demo for English-to-Tamil translation of speeches and news articles, and here for Tamil-to-English translation of the same type of material.\nThere are obvious problems with the _quality_ of the translation in some parts. But machine translation gets about 70–80% of the job done, in my view, allowing human translators to work more efficiently.\nLearn this step by step with the interactive [AI and Data Scientist](https://roadmap.sh/ai-data-scientist) roadmap.\n![Sample output for English-to-Tamil translation of news articles.](../images/001.png)\nSample output for English-to-Tamil translation of news articles.\n* * *\nMachine translation doesn't generate as much excitement as other emerging areas in NLP these days, in part because consumer-facing services like [Google Translate](https://translate.google.com/) have been around since [April 2006](https://en.wikipedia.org/wiki/Google_Translate).\nBut recent advances, particularly the work by [Hugging Face](https://huggingface.co/) in making transformer models more accessible and easy to use, have opened up interesting new possibilities for those looking to translate more than just piecemeal sentences or articles.\nFor one, small batch translation in multiple languages can now be run pretty efficiently from a desktop or laptop without having to subscribe to an [expensive service](https://azure.microsoft.com/en-us/pricing/details/cognitive-services/translator/). No doubt the translated works by [neural machine translation](https://www.microsoft.com/en-us/translator/business/machine-translation/#nnt) models are not (yet) as artful or precise as those by a skilled human translator, but they get 60% or more of the job done, in my view.\nThis could be a huge time saver for workplaces that run on short deadlines, such as newsrooms, to say nothing of the scarcity of skilled human translators.\nOver [three short notebooks](https://github.com/chuachinhon/practical_nlp), I'll outline a simple workflow for using [Hugging Face's version of MarianMT](https://huggingface.co/transformers/model_doc/marian.html) to batch translate:\n  * [English speeches of varying lengths to Chinese](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/4.0_english_to_chinese_translate.ipynb)\n  * [English news stories on Covid-19 (under 500 words) to Chinese](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/4.1_english_to_chinese_news.ipynb)\n  * [Chinese speeches of varying lengths to English](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/4.2_chinese_to_english_translate.ipynb).\n\n\n![Download the output files here](../images/002.png)\nDownload the output files [here](https://www.dropbox.com/sh/q4vy8recuib4rs9/AACagocH9mkrdj0yKKqrO0vaa)\n* * *\n## 1. DATA SET AND TRANSLATED OUTPUT\nThere are two datasets for this post. The [first](https://github.com/chuachinhon/practical_nlp/blob/master/data/translation_speeches.csv) comprises 11 speeches in four languages (English, Malay, Chinese, and Tamil) taken from the website of the [Singapore Prime Minister's Office](https://www.pmo.gov.sg/). The [second dataset](https://github.com/chuachinhon/practical_nlp/blob/master/data/cna_sample.csv) consists of five random English news stories on Covid-19 published on Singapore news outlet's [CNA's website](https://www.channelnewsasia.com/) in March 2020.\nResults of the output CSV files with the machine translated text and original copy can be downloaded [here](https://www.dropbox.com/sh/q4vy8recuib4rs9/AACagocH9mkrdj0yKKqrO0vaa).\nAt the time of writing, you can tap over 1,300 open source models on [Hugging Face's model hub](https://huggingface.co/Helsinki-NLP?utm_campaign=Hugging%2BFace&utm_medium=email&utm_source=Hugging_Face_1) for machine translation. As no MarianMT models for English-Malay and English-Tamil (and vice versa) have been released to date, this series of notebooks will not deal with these two languages for now. I'll revisit them as and when the models are available.\nI won't dive into the technical details behind machine translation. Broad details of Hugging Face's version of MarianMT can be found [here](https://huggingface.co/transformers/model_doc/marian.html), while those curious about the history of machine translation can start with this fairly recent [article](https://medium.com/huggingface/a-brief-history-of-machine-translation-paradigms-d5c09d8a5b7e).\n## 2A. ENGLISH-TO-CHINESE MACHINE TRANSLATION OF 3 SPEECHES\nThe three English speeches I picked for machine translation into Chinese range from 1,352 to 1,750 words. They are not highly technical but cover a wide enough range of topics - from Covid-19 to Singapore politics and domestic concerns - to stretch the model's capability.\nThe text was lightly cleaned. For best results, the sentences were translated one at a time (you'll notice a significant drop in translation quality if you run the entire speech through the model without tokenizing at the sentence level). [The notebook](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/4.0_english_to_chinese_translate.ipynb) took just minutes to run on my late-2015 iMac (32Gb RAM) - but may vary depending on your hardware.\n![Batch machine translation made easy, thanks to Hugging Face&#039;s implementation of MarianMT](../images/003.jpeg)\nBatch machine translation made easy, thanks to Hugging Face's implementation of MarianMT\nSome of the familiar problems with machine translation are apparent right away, particularly with the literal translation of certain terms, phrases and idioms.\nMay Day, for instance, was translated as \"五月节\" (literally May Festival) instead of 劳动节. A reference to \"rugged people\" was translated as \"崎岖不平的人\", which would literally mean \"uneven people\". Clearly the machine translation mixed up the usage of \"rugged\" in the context of terrain versus that of a society.\nHere's a comparison with Google Translate, using a snippet of the second speech. Results from the Hugging Face - MarianMT model held up pretty well against Google's translation, in my view:\n![](../images/body-d3b3894584c9665c28a8.png)\nTo be sure, neither version can be used without correcting for some obvious errors. Google's results, for instance, translated the phrase \"called the election\" to \"打电话给这次选举\", or to literally _make a telephone call to the election_. The phrasing of the translated Chinese sentences is also awkward in many instances.\nA skilled human translator would definitely do a better job at this point. But I think it is fair to say that even a highly experienced translator won't be able to translate _all three_ speeches within minutes.\nThe draw of machine translation, for now, appears to be scale and relative speed rather than precision. Let's try the same model on a different genre of writing to see how it performs.\n## 2B. ENGLISH-TO-CHINESE MACHINE TRANSLATION OF 5 NEWS ARTICLES\nSpeeches are more conversational, so I picked five random news articles on Covid-19 (published in March 2020) to see how the model performs against a more formal style of writing. To keep things simple, I selected articles that are under 500 words.\nThe workflow in this [second trial](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/4.1_english_to_chinese_news.ipynb) is identical to the first, except for additional text cleaning rules and the translation of the articles' headlines alongside the body text. Here's what the output CSV file looks like:\n![Download a copy of the above CSV here.](../images/004.jpeg)\nDownload a copy of the above CSV [here](https://www.dropbox.com/sh/q4vy8recuib4rs9/AACpGaQdQnjp1Ey2lcKDMJgFa/cna_translated.csv?dl=0).\nLet's compare one of the examples with the results from Google Translate:\n![](../images/body-d4ce4b121e7b7bf4558d.jpeg)\nBoth Google and MarianMT tripped up on the opening paragraph, which was fairly long and convoluted. The two models performed slightly better on the shorter sentences/paragraphs, but the awkward literal translations of simple phrases continue to be a problem.\nFor instance, the phrase \"as tourists stay away\" was translated by the MarianMT model as \"游客离家出走\" or \"tourists ran away from home\", while Google translated it as \"游客远离了当地\" or \"tourists kept away from the area\".\nThese issues could result in misinterpretations of factual matters, and cause confusion. I haven't conducted a full-fledged test, but based on the trials I've done so far, both MarianMT and Google Translate appear to do better with text that's more conversational in nature, as opposed to more formal forms of writing.\n## 2C. DASH APP\nPlotly has released a good number of [sample interactive apps](https://github.com/plotly/dash-sample-apps) for transformer-based NLP tasks, including one that works with Hugging Face's version of MarianMT. Try it out on [Colab](https://github.com/plotly/dash-sample-apps/blob/master/apps/dash-translate/ColabDemo.ipynb), or via [Github](https://github.com/plotly/dash-sample-apps) (I edited the app's headline in the demo gif below).\n![](../images/body-5454bc002955624100d2.gif)\n## 3. CHINESE-TO-ENGLISH MACHINE TRANSLATION OF 3 SPEECHES\nMachine translation of Chinese text into English tend to be a [trickier task in general](https://www.polilingua.com/blog/post/challenges-of-Chinese-to-English-translation-or-how-to-avoid-Chinglish.htm), as most NLP libraries/tools focus are English-based. There isn't a straightforward equivalent of the sentence tokenizer in NLTK, for instance.\nI experimented with [jieba](https://github.com/fxsjy/jieba) and [hanlp](https://github.com/hankcs/HanLP) but didn't get very far. As a temporary workaround, I [adapted a function](https://github.com/cognoma/genes/blob/721204091a96e55de6dcad165d6d8265e67e2a48/2.process.py#L61-L95) to split the Chinese text in the dataframe column into individual sentences prior to running them via the [Chinese-to-English MarianMT model](https://huggingface.co/Helsinki-NLP/opus-mt-zh-en).\n![](../images/body-33925d30b23eb6e42845.png)\nBut even with the somewhat clumsy workaround, the batch translation of the three Chinese speeches took just about 5 minutes. Do note that these three speeches are the official Chinese versions of the three earlier English speeches. The two sets of speeches cover the same ground but there are some slight variations in the content of the Chinese speeches, which aren't direct, word-for-word translations of the English versions.\nYou can download the output CSV file [here](https://www.dropbox.com/sh/q4vy8recuib4rs9/AACHKvbULez2oiNDI4oKJH1fa/speeches_cn_to_en.csv?dl=0). Let's see how the results for the [third speech ](https://www.pmo.gov.sg/Newsroom/National-Day-Message-2020-Chinese)compare with Google Translate:\n![](../images/body-c35181e0098c6a7b2c51.png)\nThe Google Translate version reads much better, and didn't have the glaring error of translating \"National Day\" as \"Fourth of July\". Overall, the results of Chinese-to-English machine translation appear (to me at least) considerably better than that for English-to-Chinese translation. But one possible reason is that the Chinese speeches in my sample were more simply written, and did not push the neural machine translation models that hard.\n## 4. FOOD FOR THOUGHT\nWhile Hugging Face has made machine translation more accessible and easier to implement, some challenges remain. One obvious technical issue is the [fine-tuning of neural translation models](https://tmramalho.github.io/science/2020/06/10/fine-tune-neural-translation-models-with-mBART/) for specific markets.\nFor instance, China, Singapore and Taiwan differ quite significantly in their usage of the written form of Chinese. Likewise, Bahasa Melayu and Bahasa Indonesia have noticeable differences even if they sound/look identical to non-speakers. Assembling the right datasets for such fine tuning won't be a trivial task.\nIn terms of the results achievable by the publicly available models, I would argue that the machine translated English-to-Chinese and Chinese-to-English texts aren't ready for public publication unless a skilled translator is on hand to check and make corrections. But that's just one use case. In situations where the translated text is part of a bigger internal workflow that does not require publication, machine translation could come in very handy.\nFor instance, if I'm tasked to track disinformation campaigns on social media by Chinese or Russian state actors, it just wouldn't make sense to try to translate the torrent of tweets and FB posts manually. Batch machine translation of these short sentences or paragraphs would be far more efficient in trying to get a broad sense of the messages being peddled by the automated accounts.\nLikewise, if you are tracking social media feedback for a new product or political campaign in a multi-lingual market, batch machine translation will likely be a far more efficient way of monitoring non-English comments collected from Instagram, Twitter or Facebook.\nUltimately, the growing use of machine translation will be driven by the broad decline of language skills, even in nominally multi-lingual societies like Singapore. You may scoff at some of the machine translated text above, but most working adults who have gone through Singapore's bilingual education system are unlikely to do much better if asked to translate the text on their own.\n* * *\nThe [Github repo for this post](https://github.com/chuachinhon/practical_nlp) can be found here. This is the fourth in a series on practical applications of new NLP tools. The earlier posts/notebooks focused on:\n  * [sentiment analysis of political speeches](https://www.analytix-labs.com/insights/cb-speeches)\n  * [text summarisation](https://towardsdatascience.com/practical-nlp-summarising-short-and-long-speeches-with-hugging-faces-pipeline-bc7df76bd366)\n  * [fine tuning your own chat bot](https://medium.com/@chinhonchua/beginners-guide-to-building-a-singlish-ai-chatbot-7ecff8255ee?sk=ea4f20a44a73321fad8b592d3ede6243).\n\n\nIf you spot mistakes in this or any of my earlier posts, ping me at:\n  * Twitter: [Chua Chin Hon](https://medium.com/u/b3d8090c0aee?source=post_page-----aad7f2e1d0a0----------------------)\n  * LinkedIn: [www.linkedin.com/in/chuachinhon](http://www.linkedin.com/in/chuachinhon)\n\n\n## Register Now to Continue Reading\n### Unlock Towards Data Science with a Free Account\nAll articles on Towards Data Science are available to registered users. Create a free account today to access this article and thousands more.\nRegister for freeSign in to your account\n* * *\n![](../images/body-d56b810b4697a0fbf983.png)\nWritten By\n## [Chua Chin Hon](https://towardsdatascience.com/author/chuachinhon/)\n[See all from Chua Chin Hon](https://towardsdatascience.com/author/chuachinhon/)\n[AI](https://towardsdatascience.com/tag/ai/)[Data Science](https://towardsdatascience.com/tag/data-science/)[Machine Translation](https://towardsdatascience.com/tag/machine-translation/)[Singapore](https://towardsdatascience.com/tag/singapore/)[Transformers](https://towardsdatascience.com/tag/transformers/)\nShare This Article\n  * [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ftowardsdatascience.com%2Flost-in-machine-translation-3b05615d68e7%2F&title=Lost%20In%20\\(Machine\\)%20Translation)\n  * [](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Ftowardsdatascience.com%2Flost-in-machine-translation-3b05615d68e7%2F&title=Lost%20In%20\\(Machine\\)%20Translation)\n  * [](https://x.com/share?url=https%3A%2F%2Ftowardsdatascience.com%2Flost-in-machine-translation-3b05615d68e7%2F&text=Lost%20In%20\\(Machine\\)%20Translation)\n\n\nTowards Data Science is a community publication. Submit your insights to reach our global audience and earn through the TDS Author Payment Program.\n[Write for TDS](https://towardsdatascience.com/submissions/)\n## Related Articles\n  * [![](../images/005.png)](https://towardsdatascience.com/all-models-are-wrong-a75103196cdb/)\n## [How to use the Assumption-Lean Approach for Correct Inference](https://towardsdatascience.com/all-models-are-wrong-a75103196cdb/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nWhy all models are wrong but some are useful.\n[Michael Berk](https://towardsdatascience.com/author/michaelberk/)\nJuly 13, 20217 min read\n  * [![](../images/006.jpg)](https://towardsdatascience.com/exploratory-analysis-of-nasa-astronauts-from-1959-2016-778aba6775a8/)\n## [Exploratory Analysis of NASA Astronauts from 1959-2016](https://towardsdatascience.com/exploratory-analysis-of-nasa-astronauts-from-1959-2016-778aba6775a8/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nWhen we are children and the world seems to be filled with infinite, endless and wondrous possibilities, we are asked what we wanted to be...\n[Edwin Jarquin](https://towardsdatascience.com/author/edwinjarquin/)\nOctober 27, 20203 min read\n  * [![](../images/007.jpeg)](https://towardsdatascience.com/my-wonderful-journey-to-become-an-advanced-analytics-junior-consultant-in-norway-6df652ad9487/)\n## [My wonderful journey to become an advanced analytics junior consultant in Norway](https://towardsdatascience.com/my-wonderful-journey-to-become-an-advanced-analytics-junior-consultant-in-norway-6df652ad9487/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nHow an MSc in Business Analytics helped me to accelerate my professional career and break into data science\n[Juan Manuel Ruiz](https://towardsdatascience.com/author/juanmruiza/)\nSeptember 10, 202014 min read\n  * [![](../images/008.jpg)](https://towardsdatascience.com/an-explainer-on-tree-ensemble-layer-b7e445621a3f/)\n## [An explainer on Tree Ensemble Layer](https://towardsdatascience.com/an-explainer-on-tree-ensemble-layer-b7e445621a3f/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nA new type of neural network layer with the benefits of decision trees.\n[Ayush Kumar](https://towardsdatascience.com/author/ayushkr79/)\nJuly 3, 20214 min read\n  * [![](../images/009.jpg)](https://towardsdatascience.com/are-the-clusters-good-1567de6a9524/)\n## [Are the clusters good?](https://towardsdatascience.com/are-the-clusters-good-1567de6a9524/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nUnderstanding how to evaluate clusters\n[Dr. Saptarsi Goswami](https://towardsdatascience.com/author/saptarsi007/)\nJuly 27, 20206 min read\n  * [![](../images/010.jpeg)](https://towardsdatascience.com/my-machine-learning-model-performs-well-but-i-want-it-to-fail-640660fe0d2c/)\n## [My Machine Learning Model Performs Well, but I Want It To Fail](https://towardsdatascience.com/my-machine-learning-model-performs-well-but-i-want-it-to-fail-640660fe0d2c/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nExploring data scientists' ethical responsibility\n[Celina Plaza](https://towardsdatascience.com/author/celina_plaza/)\nSeptember 19, 20204 min read\n  * [![](../images/011.jpg)](https://towardsdatascience.com/introduction-to-deep-learning-with-keras-17c09e4f0eb2/)\n## [Introduction to Deep Learning with Keras](https://towardsdatascience.com/introduction-to-deep-learning-with-keras-17c09e4f0eb2/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nHow to use the Keras Deep Learning library\n[Gilbert Tanner](https://towardsdatascience.com/author/gilberttanner/)\nJanuary 9, 20195 min read\n  * [![](../images/012.jpeg)](https://towardsdatascience.com/aesthetic-epistemology-a-review-of-erna-fiorentinis-inducing-visibilities-3d61919593c3/)\n## [Aesthetic Epistemology: A Review of Erna Fiorentini's\"Inducing Visibilities...\"](https://towardsdatascience.com/aesthetic-epistemology-a-review-of-erna-fiorentinis-inducing-visibilities-3d61919593c3/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nA Brief Review of \"Inducing visibilities: An attempt at Santiago Ramón y Cajal's aesthetic epistemology\"...\n[Jesse Ruiz (she/they)](https://towardsdatascience.com/author/jjr8888/)\nMay 24, 20213 min read\n  * [![](../images/013.png)](https://towardsdatascience.com/read-and-write-obsessively-there-are-no-real-shortcuts-to-producing-great-work-4ea1f3421eec/)\n## [Read and Write Obsessively: There are No Real Shortcuts to Producing Great Work](https://towardsdatascience.com/read-and-write-obsessively-there-are-no-real-shortcuts-to-producing-great-work-4ea1f3421eec/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nOn working in public, chasing intrinsic motivation, and taking risks in writing\n[TDS Editors](https://towardsdatascience.com/author/towardsdatascience/)\nMay 12, 20219 min read\n\n\n  * [YouTube](https://www.youtube.com/c/TowardsDataScience)\n  * [X](https://x.com/TDataScience)\n  * [LinkedIn](https://www.linkedin.com/company/towards-data-science/)\n  * [Threads](https://www.threads.net/@towardsdatascience)\n  * [Bluesky](https://bsky.app/profile/towardsdatascience.com)\n\n\n[](https://towardsdatascience.com/)\nYour home for data science and AI. The world's leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.\nSubscribe to Our Newsletter[Write For TDS](https://towardsdatascience.com/submissions/)•[About](https://towardsdatascience.com/about-towards-data-science-d691af11cc2f/)•[Advertise](https://contact.towardsdatascience.com/advertise-with-towards-data-science)•[Privacy Policy](https://towardsdatascience.com/privacy-policy/)•[Terms of Use](https://towardsdatascience.com/website-terms-of-use/)\n© Insight Media Group, LLC 2026•[The New Stack](https://thenewstack.io)•[roadmap.sh](https://roadmap.sh)•[Creator Network](https://insightmediagroup.io/creator-network)\n####  Recommended Articles \nClose\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500) Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1 ](https://towardsdatascience.com/javascript-fatigue-you-dont-need-js-to-build-chatgpt/ \"Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500) The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs ](https://towardsdatascience.com/subset-sum-problem-solved-in-linear-time-for-dense-enough-inputs/ \"The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500) Does Your Company Have a Data Strategy? ](https://towardsdatascience.com/does-your-company-have-a-data-strategy-e8944dbec4ae/ \"Does Your Company Have a Data Strategy?\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/4970/image?etag=1780565225463&width=500&height=500) Productivity Tips, Data Career Insights, and Other Recent Must-Reads ](https://towardsdatascience.com/productivity-tips-data-career-insights-and-other-recent-must-reads-5c47eb7a2fe0/ \"Productivity Tips, Data Career Insights, and Other Recent Must-Reads\")\n\n\n",
  "metadata": {
    "title": "Lost In (Machine) Translation | Towards Data Science",
    "description": "Small batch machine translation of speeches and news articles (English-to-Chinese and vice versa) in under-30 lines of code.",
    "keywords": null,
    "author": "Chua Chin Hon",
    "og:locale": "en_US",
    "og:type": "article",
    "og:title": "Lost In (Machine) Translation",
    "og:description": "Small batch machine translation of speeches and news articles (English-to-Chinese and vice versa) in under-30 lines of code.",
    "og:url": "https://towardsdatascience.com/lost-in-machine-translation-3b05615d68e7/",
    "og:site_name": "Towards Data Science",
    "og:image": "https://assets.insightmediagroup.io/media/wp-content/uploads/2020/08/1hYerl3LtK-hgDxqeYgmr5A-scaled.jpeg",
    "og:image:width": "2560",
    "og:image:height": "1452",
    "og:image:type": "image/jpeg",
    "twitter:card": "summary_large_image",
    "twitter:site": "@TDataScience",
    "twitter:creator": "@TDataScience",
    "twitter:label1": "Written by",
    "twitter:data1": "Chua Chin Hon",
    "twitter:label2": "Est. reading time",
    "twitter:data2": "8 min read",
    "article:published_time": "2020-08-24T09:08:42.000Z",
    "article:modified_time": "2020-08-24T09:08:42.000Z",
    "article:author": "https://towardsdatascience.com/author/chuachinhon/"
  },
  "paywall": {
    "listed_paid": false,
    "detected": false,
    "marker": "",
    "public_only": false,
    "policy": "付费/会员内容只保留页面公开可见部分，不绕过付费墙"
  },
  "crawl": {
    "success": true,
    "status_code": 200,
    "error": ""
  },
  "code_blocks": [],
  "images": [
    {
      "status": "http_404",
      "url": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500",
      "src": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500",
      "alt": "",
      "downloaded": false,
      "discovery": "saved_markdown",
      "retried_at": "2026-10-20T17:50:43Z"
    },
    {
      "status": "http_404",
      "url": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500",
      "src": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500",
      "alt": "",
      "downloaded": false,
      "discovery": "saved_markdown",
      "retried_at": "2026-10-20T17:50:43Z"
    },
    {
      "status": "http_404",
      "url": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500",
      "src": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500",
      "alt": "",
      "downloaded": false,
      "discovery": "saved_markdown",
      "retried_at": "2026-10-20T17:50:43Z"
    },
    {
      "status": "http_404",
      "url": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/4970/image?etag=1780565225463&width=500&height=500",
      "src": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/4970/image?etag=1780565225463&width=500&height=500",
      "alt": "",
      "downloaded": false,
      "discovery": "saved_markdown",
      "retried_at": "2026-10-20T17:50:43Z"
    }
  ],
  "audio": [],
  "videos": [
    {
      "url": "https://www.youtube.com/c/TowardsDataScience",
      "kind": "channel_reference",
      "status": "reference_only"
    }
  ],
  "links": [
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/latest/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/editors-pick/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/the-variable/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/shipai/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/submissions/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/data-science/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/chuachinhon/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/practical-nlp-summarising-short-and-long-speeches-with-hugging-faces-pipeline-bc7df76bd366"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/ai/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/data-science/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/machine-translation/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/singapore/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/transformers/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/all-models-are-wrong-a75103196cdb/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/michaelberk/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/exploratory-analysis-of-nasa-astronauts-from-1959-2016-778aba6775a8/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/edwinjarquin/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/my-wonderful-journey-to-become-an-advanced-analytics-junior-consultant-in-norway-6df652ad9487/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/artificial-intelligence/"
    },
    {
      "type": "external",
      "href": "https://write.insightmediagroup.io"
    },
    {
      "type": "external",
      "href": "https://www.linkedin.com/company/towards-data-science/"
    },
    {
      "type": "external",
      "href": "https://x.com/TDataScience"
    },
    {
      "type": "external",
      "href": "https://github.com/pytorch/fairseq/tree/master/examples/wmt20"
    },
    {
      "type": "external",
      "href": "https://github.com/chuachinhon/practical_nlp"
    },
    {
      "type": "external",
      "href": "https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/4.3_english_to_tamil_fairseq.ipynb"
    },
    {
      "type": "external",
      "href": "https://roadmap.sh/ai-data-scientist"
    },
    {
      "type": "external",
      "href": "https://translate.google.com/"
    },
    {
      "type": "external",
      "href": "https://en.wikipedia.org/wiki/Google_Translate"
    },
    {
      "type": "external",
      "href": "https://huggingface.co/"
    },
    {
      "type": "external",
      "href": "https://azure.microsoft.com/en-us/pricing/details/cognitive-services/translator/"
    },
    {
      "type": "external",
      "href": "https://www.microsoft.com/en-us/translator/business/machine-translation/"
    },
    {
      "type": "external",
      "href": "https://huggingface.co/transformers/model_doc/marian.html"
    },
    {
      "type": "external",
      "href": "https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/4.0_english_to_chinese_translate.ipynb"
    },
    {
      "type": "external",
      "href": "https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/4.1_english_to_chinese_news.ipynb"
    },
    {
      "type": "external",
      "href": "https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/4.2_chinese_to_english_translate.ipynb"
    },
    {
      "type": "external",
      "href": "https://www.dropbox.com/sh/q4vy8recuib4rs9/AACagocH9mkrdj0yKKqrO0vaa"
    },
    {
      "type": "external",
      "href": "https://github.com/chuachinhon/practical_nlp/blob/master/data/translation_speeches.csv"
    },
    {
      "type": "external",
      "href": "https://www.pmo.gov.sg/"
    },
    {
      "type": "external",
      "href": "https://github.com/chuachinhon/practical_nlp/blob/master/data/cna_sample.csv"
    }
  ],
  "repair_version": 2,
  "repaired_at": "2026-10-20T17:27:46Z",
  "source_url": "https://towardsdatascience.com/lost-in-machine-translation-3b05615d68e7/",
  "delivery_status": "unverified",
  "discovery_status": "http_403",
  "missing_reason": "源页面未重新核验:http_403；已按保留正文补采图片",
  "repair_error": "",
  "actual_video_files": [],
  "expected_saved_body_images": 4,
  "image_discovery": "saved_markdown",
  "source_body_markdown": "![Revisit consent button](https://cdn-cookieyes.com/assets/images/revisit.svg)\nWe value your privacy\nWe use cookies to enhance your browsing experience, serve personalised ads or content, and analyse our traffic. By clicking \"Accept All\", you consent to our use of cookies.\nCustomise Reject All Accept All\nCustomise Consent Preferences ![](https://cdn-cookieyes.com/assets/images/close.svg)\nWe use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.\nThe cookies that are categorised as \"Necessary\" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... Show more\nNecessaryAlways Active\nNecessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.\n  * Cookie\nBCTempID\n  * Duration\n10 minutes\n  * Description\nNo description available.\n\n\n  * Cookie\n__cf_bm\n  * Duration\n1 hour\n  * Description\nThis cookie, set by Cloudflare, is used to support Cloudflare Bot Management. \n\n\n  * Cookie\nAWSALBCORS\n  * Duration\n7 days\n  * Description\nAmazon Web Services set this cookie for load balancing.\n\n\n  * Cookie\n_cfuvid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to track users across sessions to optimize user experience by maintaining session consistency and providing personalized services\n\n\n  * Cookie\nli_gc\n  * Duration\n6 months\n  * Description\nLinkedin set this cookie for storing visitor's consent regarding using cookies for non-essential purposes.\n\n\n  * Cookie\n__hssrc\n  * Duration\nsession\n  * Description\nThis cookie is set by Hubspot whenever it changes the session cookie. The __hssrc cookie set to 1 indicates that the user has restarted the browser, and if the cookie does not exist, it is assumed to be a new session.\n\n\n  * Cookie\n__hssc\n  * Duration\n1 hour\n  * Description\nHubSpot sets this cookie to keep track of sessions and to determine if HubSpot should increment the session number and timestamps in the __hstc cookie.\n\n\n  * Cookie\nwpEmojiSettingsSupports\n  * Duration\nsession\n  * Description\nWordPress sets this cookie when a user interacts with emojis on a WordPress site. It helps determine if the user's browser can display emojis properly.\n\n\n  * Cookie\nBCSessionID\n  * Duration\n1 year 1 month 4 days\n  * Description\nBlueconic sets this cookie as a unique identifier for the BlueConic profile.\n\n\n  * Cookie\n_octo\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nlogged_in\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\n__Secure-YEC\n  * Duration\npast\n  * Description\nYouTube sets this cookie to stores the user's video player preferences using embedded YouTube video\n\n\n  * Cookie\n__eoi\n  * Duration\n6 months\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTGCORS\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\nlogin-status-p\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTG\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\ncsrf_token\n  * Duration\nsession\n  * Description\nNo description available.\n\n\n  * Cookie\ntoken_v2\n  * Duration\n1 day\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nD\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nPHPSESSID\n  * Duration\nsession\n  * Description\nThis cookie is native to PHP applications. The cookie stores and identifies a user's unique session ID to manage user sessions on the website. The cookie is a session cookie and will be deleted when all the browser windows are closed.\n\n\n  * Cookie\nVISITOR_PRIVACY_METADATA\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to store the user's cookie consent state for the current domain. \n\n\n  * Cookie\ncookietest\n  * Duration\nsession\n  * Description\nThe cookietest cookie is typically used to determine whether the user's browser accepts cookies, essential for website functionality and user experience.\n\n\n  * Cookie\n__Host-airtable-session\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\n__Host-airtable-session.sig\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\nm\n  * Duration\n1 year 1 month 4 days\n  * Description\nStripe sets this cookie for fraud prevention purposes. It identifies the device used to access the website, allowing the website to be formatted accordingly.\n\n\n  * Cookie\nBIGipServer*\n  * Duration\nsession\n  * Description\nMarketo sets this cookie to collect information about the user's online activity and build a profile about their interests to provide advertisements relevant to the user. \n\n\n  * Cookie\n__cfruid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to identify trusted web traffic.\n\n\n  * Cookie\n_GRECAPTCHA\n  * Duration\n6 months\n  * Description\nGoogle Recaptcha service sets this cookie to identify bots to protect the website against malicious spam attacks.\n\n\n  * Cookie\n__Secure-YNID\n  * Duration\n6 months\n  * Description\nGoogle cookie used to protect user security and prevent fraud, especially during the login process.\n\n\n  * Cookie\ncookieyes-consent\n  * Duration\n1 year\n  * Description\nCookieYes sets this cookie to remember users' consent preferences so that their preferences are respected on subsequent visits to this site. It does not collect or store any personal information about the site visitors.\n\n\nFunctional\nFunctional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.\n  * Cookie\nlidc\n  * Duration\n1 day\n  * Description\nLinkedIn sets the lidc cookie to facilitate data center selection.\n\n\n  * Cookie\nbrw\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nbrwConsent\n  * Duration\n5 minutes\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nWMF-Uniq\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nloom_anon_comment\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nloom_referral_video\n  * Duration\nsession\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nVISITOR_INFO1_LIVE\n  * Duration\n6 months\n  * Description\nA cookie set by YouTube to measure bandwidth that determines whether the user gets the new or old player interface.\n\n\n  * Cookie\nyt-remote-connected-devices\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nytidb::LAST_RESULT_ENTRY_KEY\n  * Duration\nNever Expires\n  * Description\nThe cookie ytidb::LAST_RESULT_ENTRY_KEY is used by YouTube to store the last search result entry that was clicked by the user. This information is used to improve the user experience by providing more relevant search results in the future.\n\n\n  * Cookie\nyt-remote-device-id\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-name\n  * Duration\nsession\n  * Description\nThe yt-remote-session-name cookie is used by YouTube to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\nyt-remote-fast-check-period\n  * Duration\nsession\n  * Description\nThe yt-remote-fast-check-period cookie is used by YouTube to store the user's video player preferences for embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-app\n  * Duration\nsession\n  * Description\nThe yt-remote-session-app cookie is used by YouTube to store user preferences and information about the interface of the embedded YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-available\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-available cookie is used to store the user's preferences regarding whether casting is available on their YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-installed\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-installed cookie is used to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\ncp_session\n  * Duration\n3 months\n  * Description\nCodepen sets this cookie for Help systems found in the website.\n\n\n  * Cookie\nloid\n  * Duration\n1 year 1 month 4 days\n  * Description\nThis cookie is set by the Reddit. The cookie enables the sharing of content from the website onto the social media platform.\n\n\nAnalytics\nAnalytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.\n  * Cookie\n__hstc\n  * Duration\n6 months\n  * Description\nHubspot set this main cookie for tracking visitors. It contains the domain, initial timestamp (first visit), last timestamp (last visit), current timestamp (this visit), and session number (increments for each subsequent session).\n\n\n  * Cookie\nhubspotutk\n  * Duration\n6 months\n  * Description\nHubSpot sets this cookie to keep track of the visitors to the website. This cookie is passed to HubSpot on form submission and used when deduplicating contacts.\n\n\n  * Cookie\n_ga\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to calculate visitor, session and campaign data and track site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognise unique visitors.\n\n\n  * Cookie\n_ga_*\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to store and count page views.\n\n\n  * Cookie\n__Host-psifi.analyticsTrace\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n__Host-psifi.analyticsTraceV2\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n_gh_sess\n  * Duration\nsession\n  * Description\nGitHub sets this cookie for temporary application and framework state between pages like what step the user is on in a multiple step form.\n\n\n  * Cookie\nYSC\n  * Duration\nsession\n  * Description\nYSC cookie is set by Youtube and is used to track the views of embedded videos on Youtube pages.\n\n\n  * Cookie\najs_anonymous_id\n  * Duration\n1 year\n  * Description\nThis cookie is set by Segment to count the number of people who visit a certain site by tracking if they have visited before.\n\n\n  * Cookie\nvuid\n  * Duration\n1 year 1 month 4 days\n  * Description\nVimeo installs this cookie to collect tracking information by setting a unique ID to embed videos on the website. \n\n\nPerformance\nPerformance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.\n  * Cookie\nAWSALB\n  * Duration\n7 days\n  * Description\nAWSALB is an application load balancer cookie set by Amazon Web Services to map the session to the target.\n\n\n  * Cookie\nacq\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nacq.sig\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nptc\n  * Duration\n2 years\n  * Description\nNo description available.\n\n\nAdvertisement\nAdvertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.\n  * Cookie\nmuc_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to collect user behaviour and interaction data to optimize the website.\n\n\n  * Cookie\nguest_id_marketing\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\nguest_id_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\npersonalization_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to integrate and share features for social media and also store information about how the user uses the website, for tracking and targeting.\n\n\n  * Cookie\nguest_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor. It registers if a user is signed in to the Twitter platform and collects information about ad preferences.\n\n\n  * Cookie\nbcookie\n  * Duration\n1 year\n  * Description\nLinkedIn sets this cookie from LinkedIn share buttons and ad tags to recognize browser IDs.\n\n\n  * Cookie\n__Secure-ROLLOUT_TOKEN\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to manage feature rollout and experimentation. It helps Google control which new features or interface changes are shown to users as part of testing and staged rollouts, ensuring consistent experience for a given user during an experiment.\n\n\n  * Cookie\nyt.innertube::nextId\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nyt.innertube::requests\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nsession_tracker\n  * Duration\nsession\n  * Description\nThis cookie is set by the Reddit. This cookie is used to identify trusted web traffic. It also helps in adverstising on the website.\n\n\n  * Cookie\nedgebucket\n  * Duration\nsession\n  * Description\nReddit sets this cookie to save the information about a log-on Reddit user, for the purpose of advertisement recommendations and updating the content.\n\n\n  * Cookie\ndid\n  * Duration\n1 year\n  * Description\nArbor sets this cookie to show targeted ads to site visitors.This cookie expires after 2 months or 1 year.\n\n\nUncategorised\nOther uncategorised cookies are those that are being analysed and have not been classified into a category as yet.\nNo cookies to display.\nReject All Save My Preferences Accept All\nToggle Search[](https://towardsdatascience.com/)Toggle Mobile Navigation\n[](https://towardsdatascience.com/)\nPublish AI, ML & data-science insights to a global community of data professionals.\nSign in[Submit an Article](https://write.insightmediagroup.io)\n[Latest](https://towardsdatascience.com/latest/)[Editor's Picks](https://towardsdatascience.com/tag/editors-pick/)[Newsletter](https://towardsdatascience.com/tag/the-variable/)[ShipAI](https://towardsdatascience.com/shipai/)\n* * *\n[Write For TDS](https://towardsdatascience.com/submissions/)\n[LinkedIn](https://www.linkedin.com/company/towards-data-science/)[X](https://x.com/TDataScience)Toggle Search\n[Data Science](https://towardsdatascience.com/category/data-science/)\n# Lost In (Machine) Translation\nSmall batch machine translation of speeches and news articles (English-to-Chinese and vice versa) in under-30 lines of code.\n[Chua Chin Hon](https://towardsdatascience.com/author/chuachinhon/)\nAugust 24, 20208 min read\n![Illustration: Chua Chin Hon](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/08/1hYerl3LtK-hgDxqeYgmr5A-scaled.jpeg)\nIllustration: Chua Chin Hon\n### Small batch machine translation of speeches and news articles (English to Chinese/Tamil, and vice versa) in under-30 lines of code, using Hugging Face's version of MarianMT and Facebook's Fairseq.\n_**UPDATED Dec 30, 2020**_ :\nFacebook [recently released](https://github.com/pytorch/fairseq/tree/master/examples/wmt20) recently released its machine translation models for English to Tamil (and vice versa), and I was eager to give it a try since Tamil is among the most under-served languages in machine learning, and related language pairs are pretty hard to come by.\nThe new notebooks and toy datasets are in the [repo](https://github.com/chuachinhon/practical_nlp). Or, go [[here](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/4.4_tamil_to_english_fairseq.ipynb)](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/4.3_english_to_tamil_fairseq.ipynb) for the demo for English-to-Tamil translation of speeches and news articles, and here for Tamil-to-English translation of the same type of material.\nThere are obvious problems with the _quality_ of the translation in some parts. But machine translation gets about 70–80% of the job done, in my view, allowing human translators to work more efficiently.\nLearn this step by step with the interactive [AI and Data Scientist](https://roadmap.sh/ai-data-scientist) roadmap.\n![Sample output for English-to-Tamil translation of news articles.](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/08/1duWQjJWtG-M4LY1_4xzffw.png)\nSample output for English-to-Tamil translation of news articles.\n* * *\nMachine translation doesn't generate as much excitement as other emerging areas in NLP these days, in part because consumer-facing services like [Google Translate](https://translate.google.com/) have been around since [April 2006](https://en.wikipedia.org/wiki/Google_Translate).\nBut recent advances, particularly the work by [Hugging Face](https://huggingface.co/) in making transformer models more accessible and easy to use, have opened up interesting new possibilities for those looking to translate more than just piecemeal sentences or articles.\nFor one, small batch translation in multiple languages can now be run pretty efficiently from a desktop or laptop without having to subscribe to an [expensive service](https://azure.microsoft.com/en-us/pricing/details/cognitive-services/translator/). No doubt the translated works by [neural machine translation](https://www.microsoft.com/en-us/translator/business/machine-translation/#nnt) models are not (yet) as artful or precise as those by a skilled human translator, but they get 60% or more of the job done, in my view.\nThis could be a huge time saver for workplaces that run on short deadlines, such as newsrooms, to say nothing of the scarcity of skilled human translators.\nOver [three short notebooks](https://github.com/chuachinhon/practical_nlp), I'll outline a simple workflow for using [Hugging Face's version of MarianMT](https://huggingface.co/transformers/model_doc/marian.html) to batch translate:\n  * [English speeches of varying lengths to Chinese](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/4.0_english_to_chinese_translate.ipynb)\n  * [English news stories on Covid-19 (under 500 words) to Chinese](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/4.1_english_to_chinese_news.ipynb)\n  * [Chinese speeches of varying lengths to English](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/4.2_chinese_to_english_translate.ipynb).\n\n\n![Download the output files here](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/08/1qH51zoN4IH6B9iKBv3FOrg.png)\nDownload the output files [here](https://www.dropbox.com/sh/q4vy8recuib4rs9/AACagocH9mkrdj0yKKqrO0vaa)\n* * *\n## 1. DATA SET AND TRANSLATED OUTPUT\nThere are two datasets for this post. The [first](https://github.com/chuachinhon/practical_nlp/blob/master/data/translation_speeches.csv) comprises 11 speeches in four languages (English, Malay, Chinese, and Tamil) taken from the website of the [Singapore Prime Minister's Office](https://www.pmo.gov.sg/). The [second dataset](https://github.com/chuachinhon/practical_nlp/blob/master/data/cna_sample.csv) consists of five random English news stories on Covid-19 published on Singapore news outlet's [CNA's website](https://www.channelnewsasia.com/) in March 2020.\nResults of the output CSV files with the machine translated text and original copy can be downloaded [here](https://www.dropbox.com/sh/q4vy8recuib4rs9/AACagocH9mkrdj0yKKqrO0vaa).\nAt the time of writing, you can tap over 1,300 open source models on [Hugging Face's model hub](https://huggingface.co/Helsinki-NLP?utm_campaign=Hugging%2BFace&utm_medium=email&utm_source=Hugging_Face_1) for machine translation. As no MarianMT models for English-Malay and English-Tamil (and vice versa) have been released to date, this series of notebooks will not deal with these two languages for now. I'll revisit them as and when the models are available.\nI won't dive into the technical details behind machine translation. Broad details of Hugging Face's version of MarianMT can be found [here](https://huggingface.co/transformers/model_doc/marian.html), while those curious about the history of machine translation can start with this fairly recent [article](https://medium.com/huggingface/a-brief-history-of-machine-translation-paradigms-d5c09d8a5b7e).\n## 2A. ENGLISH-TO-CHINESE MACHINE TRANSLATION OF 3 SPEECHES\nThe three English speeches I picked for machine translation into Chinese range from 1,352 to 1,750 words. They are not highly technical but cover a wide enough range of topics - from Covid-19 to Singapore politics and domestic concerns - to stretch the model's capability.\nThe text was lightly cleaned. For best results, the sentences were translated one at a time (you'll notice a significant drop in translation quality if you run the entire speech through the model without tokenizing at the sentence level). [The notebook](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/4.0_english_to_chinese_translate.ipynb) took just minutes to run on my late-2015 iMac (32Gb RAM) - but may vary depending on your hardware.\n![Batch machine translation made easy, thanks to Hugging Face&#039;s implementation of MarianMT](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/08/1C6kk9h2NE7J5G8I1TTKDyw.jpeg)\nBatch machine translation made easy, thanks to Hugging Face's implementation of MarianMT\nSome of the familiar problems with machine translation are apparent right away, particularly with the literal translation of certain terms, phrases and idioms.\nMay Day, for instance, was translated as \"五月节\" (literally May Festival) instead of 劳动节. A reference to \"rugged people\" was translated as \"崎岖不平的人\", which would literally mean \"uneven people\". Clearly the machine translation mixed up the usage of \"rugged\" in the context of terrain versus that of a society.\nHere's a comparison with Google Translate, using a snippet of the second speech. Results from the Hugging Face - MarianMT model held up pretty well against Google's translation, in my view:\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/08/1aQ2DFCbkMqHlvIlt0wbbyw.png)\nTo be sure, neither version can be used without correcting for some obvious errors. Google's results, for instance, translated the phrase \"called the election\" to \"打电话给这次选举\", or to literally _make a telephone call to the election_. The phrasing of the translated Chinese sentences is also awkward in many instances.\nA skilled human translator would definitely do a better job at this point. But I think it is fair to say that even a highly experienced translator won't be able to translate _all three_ speeches within minutes.\nThe draw of machine translation, for now, appears to be scale and relative speed rather than precision. Let's try the same model on a different genre of writing to see how it performs.\n## 2B. ENGLISH-TO-CHINESE MACHINE TRANSLATION OF 5 NEWS ARTICLES\nSpeeches are more conversational, so I picked five random news articles on Covid-19 (published in March 2020) to see how the model performs against a more formal style of writing. To keep things simple, I selected articles that are under 500 words.\nThe workflow in this [second trial](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/4.1_english_to_chinese_news.ipynb) is identical to the first, except for additional text cleaning rules and the translation of the articles' headlines alongside the body text. Here's what the output CSV file looks like:\n![Download a copy of the above CSV here.](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/08/1_arVVgopRcbjz_-uEOorVw.jpeg)\nDownload a copy of the above CSV [here](https://www.dropbox.com/sh/q4vy8recuib4rs9/AACpGaQdQnjp1Ey2lcKDMJgFa/cna_translated.csv?dl=0).\nLet's compare one of the examples with the results from Google Translate:\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/08/19i552h7TMlYVb0z2FK_TMQ-scaled.jpeg)\nBoth Google and MarianMT tripped up on the opening paragraph, which was fairly long and convoluted. The two models performed slightly better on the shorter sentences/paragraphs, but the awkward literal translations of simple phrases continue to be a problem.\nFor instance, the phrase \"as tourists stay away\" was translated by the MarianMT model as \"游客离家出走\" or \"tourists ran away from home\", while Google translated it as \"游客远离了当地\" or \"tourists kept away from the area\".\nThese issues could result in misinterpretations of factual matters, and cause confusion. I haven't conducted a full-fledged test, but based on the trials I've done so far, both MarianMT and Google Translate appear to do better with text that's more conversational in nature, as opposed to more formal forms of writing.\n## 2C. DASH APP\nPlotly has released a good number of [sample interactive apps](https://github.com/plotly/dash-sample-apps) for transformer-based NLP tasks, including one that works with Hugging Face's version of MarianMT. Try it out on [Colab](https://github.com/plotly/dash-sample-apps/blob/master/apps/dash-translate/ColabDemo.ipynb), or via [Github](https://github.com/plotly/dash-sample-apps) (I edited the app's headline in the demo gif below).\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/08/1TNRk5NqqdJp9J9idLZTQNA.gif)\n## 3. CHINESE-TO-ENGLISH MACHINE TRANSLATION OF 3 SPEECHES\nMachine translation of Chinese text into English tend to be a [trickier task in general](https://www.polilingua.com/blog/post/challenges-of-Chinese-to-English-translation-or-how-to-avoid-Chinglish.htm), as most NLP libraries/tools focus are English-based. There isn't a straightforward equivalent of the sentence tokenizer in NLTK, for instance.\nI experimented with [jieba](https://github.com/fxsjy/jieba) and [hanlp](https://github.com/hankcs/HanLP) but didn't get very far. As a temporary workaround, I [adapted a function](https://github.com/cognoma/genes/blob/721204091a96e55de6dcad165d6d8265e67e2a48/2.process.py#L61-L95) to split the Chinese text in the dataframe column into individual sentences prior to running them via the [Chinese-to-English MarianMT model](https://huggingface.co/Helsinki-NLP/opus-mt-zh-en).\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/08/1zrGBMoCsLaWwJsYn5KrT4w.png)\nBut even with the somewhat clumsy workaround, the batch translation of the three Chinese speeches took just about 5 minutes. Do note that these three speeches are the official Chinese versions of the three earlier English speeches. The two sets of speeches cover the same ground but there are some slight variations in the content of the Chinese speeches, which aren't direct, word-for-word translations of the English versions.\nYou can download the output CSV file [here](https://www.dropbox.com/sh/q4vy8recuib4rs9/AACHKvbULez2oiNDI4oKJH1fa/speeches_cn_to_en.csv?dl=0). Let's see how the results for the [third speech ](https://www.pmo.gov.sg/Newsroom/National-Day-Message-2020-Chinese)compare with Google Translate:\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/08/1xJxbb0LYMX2C3boAUaDCFw.png)\nThe Google Translate version reads much better, and didn't have the glaring error of translating \"National Day\" as \"Fourth of July\". Overall, the results of Chinese-to-English machine translation appear (to me at least) considerably better than that for English-to-Chinese translation. But one possible reason is that the Chinese speeches in my sample were more simply written, and did not push the neural machine translation models that hard.\n## 4. FOOD FOR THOUGHT\nWhile Hugging Face has made machine translation more accessible and easier to implement, some challenges remain. One obvious technical issue is the [fine-tuning of neural translation models](https://tmramalho.github.io/science/2020/06/10/fine-tune-neural-translation-models-with-mBART/) for specific markets.\nFor instance, China, Singapore and Taiwan differ quite significantly in their usage of the written form of Chinese. Likewise, Bahasa Melayu and Bahasa Indonesia have noticeable differences even if they sound/look identical to non-speakers. Assembling the right datasets for such fine tuning won't be a trivial task.\nIn terms of the results achievable by the publicly available models, I would argue that the machine translated English-to-Chinese and Chinese-to-English texts aren't ready for public publication unless a skilled translator is on hand to check and make corrections. But that's just one use case. In situations where the translated text is part of a bigger internal workflow that does not require publication, machine translation could come in very handy.\nFor instance, if I'm tasked to track disinformation campaigns on social media by Chinese or Russian state actors, it just wouldn't make sense to try to translate the torrent of tweets and FB posts manually. Batch machine translation of these short sentences or paragraphs would be far more efficient in trying to get a broad sense of the messages being peddled by the automated accounts.\nLikewise, if you are tracking social media feedback for a new product or political campaign in a multi-lingual market, batch machine translation will likely be a far more efficient way of monitoring non-English comments collected from Instagram, Twitter or Facebook.\nUltimately, the growing use of machine translation will be driven by the broad decline of language skills, even in nominally multi-lingual societies like Singapore. You may scoff at some of the machine translated text above, but most working adults who have gone through Singapore's bilingual education system are unlikely to do much better if asked to translate the text on their own.\n* * *\nThe [Github repo for this post](https://github.com/chuachinhon/practical_nlp) can be found here. This is the fourth in a series on practical applications of new NLP tools. The earlier posts/notebooks focused on:\n  * [sentiment analysis of political speeches](https://www.analytix-labs.com/insights/cb-speeches)\n  * [text summarisation](https://towardsdatascience.com/practical-nlp-summarising-short-and-long-speeches-with-hugging-faces-pipeline-bc7df76bd366)\n  * [fine tuning your own chat bot](https://medium.com/@chinhonchua/beginners-guide-to-building-a-singlish-ai-chatbot-7ecff8255ee?sk=ea4f20a44a73321fad8b592d3ede6243).\n\n\nIf you spot mistakes in this or any of my earlier posts, ping me at:\n  * Twitter: [Chua Chin Hon](https://medium.com/u/b3d8090c0aee?source=post_page-----aad7f2e1d0a0----------------------)\n  * LinkedIn: [www.linkedin.com/in/chuachinhon](http://www.linkedin.com/in/chuachinhon)\n\n\n## Register Now to Continue Reading\n### Unlock Towards Data Science with a Free Account\nAll articles on Towards Data Science are available to registered users. Create a free account today to access this article and thousands more.\nRegister for freeSign in to your account\n* * *\n![](https://assets.insightmediagroup.io/media/1787657280763_838i2j.png)\nWritten By\n## [Chua Chin Hon](https://towardsdatascience.com/author/chuachinhon/)\n[See all from Chua Chin Hon](https://towardsdatascience.com/author/chuachinhon/)\n[AI](https://towardsdatascience.com/tag/ai/)[Data Science](https://towardsdatascience.com/tag/data-science/)[Machine Translation](https://towardsdatascience.com/tag/machine-translation/)[Singapore](https://towardsdatascience.com/tag/singapore/)[Transformers](https://towardsdatascience.com/tag/transformers/)\nShare This Article\n  * [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ftowardsdatascience.com%2Flost-in-machine-translation-3b05615d68e7%2F&title=Lost%20In%20\\(Machine\\)%20Translation)\n  * [](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Ftowardsdatascience.com%2Flost-in-machine-translation-3b05615d68e7%2F&title=Lost%20In%20\\(Machine\\)%20Translation)\n  * [](https://x.com/share?url=https%3A%2F%2Ftowardsdatascience.com%2Flost-in-machine-translation-3b05615d68e7%2F&text=Lost%20In%20\\(Machine\\)%20Translation)\n\n\nTowards Data Science is a community publication. Submit your insights to reach our global audience and earn through the TDS Author Payment Program.\n[Write for TDS](https://towardsdatascience.com/submissions/)\n## Related Articles\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/07/1lQ4NH5lgbcElf-99WOacVg.png)](https://towardsdatascience.com/all-models-are-wrong-a75103196cdb/)\n## [How to use the Assumption-Lean Approach for Correct Inference](https://towardsdatascience.com/all-models-are-wrong-a75103196cdb/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nWhy all models are wrong but some are useful.\n[Michael Berk](https://towardsdatascience.com/author/michaelberk/)\nJuly 13, 20217 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/10/0ZZ6rFo4PetuYlhwH-scaled.jpg)](https://towardsdatascience.com/exploratory-analysis-of-nasa-astronauts-from-1959-2016-778aba6775a8/)\n## [Exploratory Analysis of NASA Astronauts from 1959-2016](https://towardsdatascience.com/exploratory-analysis-of-nasa-astronauts-from-1959-2016-778aba6775a8/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nWhen we are children and the world seems to be filled with infinite, endless and wondrous possibilities, we are asked what we wanted to be...\n[Edwin Jarquin](https://towardsdatascience.com/author/edwinjarquin/)\nOctober 27, 20203 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/09/1pOeODzLExtFHxRzM7kG3Sw-scaled.jpeg)](https://towardsdatascience.com/my-wonderful-journey-to-become-an-advanced-analytics-junior-consultant-in-norway-6df652ad9487/)\n## [My wonderful journey to become an advanced analytics junior consultant in Norway](https://towardsdatascience.com/my-wonderful-journey-to-become-an-advanced-analytics-junior-consultant-in-norway-6df652ad9487/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nHow an MSc in Business Analytics helped me to accelerate my professional career and break into data science\n[Juan Manuel Ruiz](https://towardsdatascience.com/author/juanmruiza/)\nSeptember 10, 202014 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/07/0b4nu7g0XqSOYtyoq-scaled.jpg)](https://towardsdatascience.com/an-explainer-on-tree-ensemble-layer-b7e445621a3f/)\n## [An explainer on Tree Ensemble Layer](https://towardsdatascience.com/an-explainer-on-tree-ensemble-layer-b7e445621a3f/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nA new type of neural network layer with the benefits of decision trees.\n[Ayush Kumar](https://towardsdatascience.com/author/ayushkr79/)\nJuly 3, 20214 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/07/0RD7aNXa6Ns22BQEi.jpg)](https://towardsdatascience.com/are-the-clusters-good-1567de6a9524/)\n## [Are the clusters good?](https://towardsdatascience.com/are-the-clusters-good-1567de6a9524/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nUnderstanding how to evaluate clusters\n[Dr. Saptarsi Goswami](https://towardsdatascience.com/author/saptarsi007/)\nJuly 27, 20206 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/09/1pTaZ6yvXTmLR4jGEZExcWw.jpeg)](https://towardsdatascience.com/my-machine-learning-model-performs-well-but-i-want-it-to-fail-640660fe0d2c/)\n## [My Machine Learning Model Performs Well, but I Want It To Fail](https://towardsdatascience.com/my-machine-learning-model-performs-well-but-i-want-it-to-fail-640660fe0d2c/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nExploring data scientists' ethical responsibility\n[Celina Plaza](https://towardsdatascience.com/author/celina_plaza/)\nSeptember 19, 20204 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2019/01/0hsMHZrp2FYa0TsoS-scaled.jpg)](https://towardsdatascience.com/introduction-to-deep-learning-with-keras-17c09e4f0eb2/)\n## [Introduction to Deep Learning with Keras](https://towardsdatascience.com/introduction-to-deep-learning-with-keras-17c09e4f0eb2/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nHow to use the Keras Deep Learning library\n[Gilbert Tanner](https://towardsdatascience.com/author/gilberttanner/)\nJanuary 9, 20195 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/05/1cDyZZf2Vgq0RTr5MRFGSNg.jpeg)](https://towardsdatascience.com/aesthetic-epistemology-a-review-of-erna-fiorentinis-inducing-visibilities-3d61919593c3/)\n## [Aesthetic Epistemology: A Review of Erna Fiorentini's\"Inducing Visibilities...\"](https://towardsdatascience.com/aesthetic-epistemology-a-review-of-erna-fiorentinis-inducing-visibilities-3d61919593c3/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nA Brief Review of \"Inducing visibilities: An attempt at Santiago Ramón y Cajal's aesthetic epistemology\"...\n[Jesse Ruiz (she/they)](https://towardsdatascience.com/author/jjr8888/)\nMay 24, 20213 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/05/1VTjX5Qv7SHR17XGjfm9-Fg.png)](https://towardsdatascience.com/read-and-write-obsessively-there-are-no-real-shortcuts-to-producing-great-work-4ea1f3421eec/)\n## [Read and Write Obsessively: There are No Real Shortcuts to Producing Great Work](https://towardsdatascience.com/read-and-write-obsessively-there-are-no-real-shortcuts-to-producing-great-work-4ea1f3421eec/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nOn working in public, chasing intrinsic motivation, and taking risks in writing\n[TDS Editors](https://towardsdatascience.com/author/towardsdatascience/)\nMay 12, 20219 min read\n\n\n  * [YouTube](https://www.youtube.com/c/TowardsDataScience)\n  * [X](https://x.com/TDataScience)\n  * [LinkedIn](https://www.linkedin.com/company/towards-data-science/)\n  * [Threads](https://www.threads.net/@towardsdatascience)\n  * [Bluesky](https://bsky.app/profile/towardsdatascience.com)\n\n\n[](https://towardsdatascience.com/)\nYour home for data science and AI. The world's leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.\nSubscribe to Our Newsletter[Write For TDS](https://towardsdatascience.com/submissions/)•[About](https://towardsdatascience.com/about-towards-data-science-d691af11cc2f/)•[Advertise](https://contact.towardsdatascience.com/advertise-with-towards-data-science)•[Privacy Policy](https://towardsdatascience.com/privacy-policy/)•[Terms of Use](https://towardsdatascience.com/website-terms-of-use/)\n© Insight Media Group, LLC 2026•[The New Stack](https://thenewstack.io)•[roadmap.sh](https://roadmap.sh)•[Creator Network](https://insightmediagroup.io/creator-network)\n####  Recommended Articles \nClose\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500) Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1 ](https://towardsdatascience.com/javascript-fatigue-you-dont-need-js-to-build-chatgpt/ \"Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500) The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs ](https://towardsdatascience.com/subset-sum-problem-solved-in-linear-time-for-dense-enough-inputs/ \"The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500) Does Your Company Have a Data Strategy? ](https://towardsdatascience.com/does-your-company-have-a-data-strategy-e8944dbec4ae/ \"Does Your Company Have a Data Strategy?\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/4970/image?etag=1780565225463&width=500&height=500) Productivity Tips, Data Career Insights, and Other Recent Must-Reads ](https://towardsdatascience.com/productivity-tips-data-career-insights-and-other-recent-must-reads-5c47eb7a2fe0/ \"Productivity Tips, Data Career Insights, and Other Recent Must-Reads\")\n\n\n",
  "body_base_path": "attachments/6da3e52670b5/pages/",
  "body_markdown_path": "attachments/6da3e52670b5/pages/archived-body.md",
  "local_html": "attachments/6da3e52670b5/pages/archived-body.html",
  "body_source": "prior_capture"
}