{"id":48315,"date":"2024-02-02T14:32:10","date_gmt":"2024-02-02T14:32:10","guid":{"rendered":"https:\/\/www.roger-pearse.com\/weblog\/?p=48315"},"modified":"2024-02-02T14:32:10","modified_gmt":"2024-02-02T14:32:10","slug":"how-does-ai-translation-work-some-high-level-thoughts","status":"publish","type":"post","link":"https:\/\/roger-pearse.com\/weblog\/2024\/02\/02\/how-does-ai-translation-work-some-high-level-thoughts\/","title":{"rendered":"How does &#8220;AI translation&#8221; work?  Some high-level thoughts"},"content":{"rendered":"<p align=\"justify\">The computer world is a high-bullshit industry.\u00a0 \u00a0Every computer system consists of nothing more than silicon chips running streams of ones (1) and zeros (0), however grandly this may be dressed-up.\u00a0 The unwary blindly accept and repeat the words and pictures offered by salesmen with something to sell.\u00a0 These are repeated by journalists who need something to write about.\u00a0 Indeed the IT industry is the victim of repeated fads.\u00a0 These are always hugely oversold, and they come, reach a crescendo, and then wither away.\u00a0 But anybody doing serious work needs to understand what is going on under the hood.\u00a0 If you cannot express it in your own words, you don&#8217;t understand it, and you will make bad decisions.<\/p>\n<p align=\"justify\">&#8220;AI&#8221; is the latest nonsense term being pumped by the media.\u00a0 &#8220;Are the machines going to take over?!&#8221; scream the journalists.\u00a0 &#8220;Your system <span style=\"text-decoration: underline;\">needs<\/span> AI,&#8221; murmur the salesmen.\u00a0 It&#8217;s all bunk, marketing fluff for the less majestic-sounding &#8220;large language models (LLM) with a chatbot on the front.&#8221;<\/p>\n<p align=\"justify\">This area is the preserve of computer science people, who are often a bit strange, and are always rather mathematical.\u00a0 But it would seem useful to share my current understanding as to what is going on, culled from a number of articles online.\u00a0 \u00a0I guarantee none of this; this is just what I have read.<\/p>\n<p align=\"justify\">Ever since Google Translate, machine translation is done by having a large volume of texts in, say, Latin, a similarly large volume in English, and a large amount of human-written translations of Latin into English.\u00a0 The &#8220;translator&#8221; takes a Latin sentence input by a human, searches for a text containing those words in the mass of Latin texts, looks up the existing English translation of the same text, and spits back the corresponding English sentence.\u00a0 Of course they don&#8217;t just have sentences; they have words, and clauses, all indexed in the same way.\u00a0 There is much more to this, particularly in how material from one language is mapped to material in the other, but that&#8217;s the basic principle.\u00a0 This was known as &#8211; jargon alert &#8211; &#8220;Neural Machine Translation&#8221; (NMT).<\/p>\n<p align=\"justify\">This process, using existing translations, is why the English translations produced by Google Translate would sometimes drop into Jacobean English for a sentence, or part of it.<\/p>\n<p align=\"justify\">The &#8220;AI translation&#8221; done using an LLM is a further step along the same road, but with added bullshit at each stage.\u00a0 The jargon word for this technology seems to be &#8220;Generative AI&#8221;.<\/p>\n<p align=\"justify\">A &#8220;large language model&#8221; (LLM) is a file.\u00a0 You can download them from GitHub.\u00a0 It is a file containing numbers, one after another.\u00a0 Each number represents a word, or part of a word.\u00a0 The numbers are not random either &#8211; they are carefully crafted and generated to tell you how that word fits into the language.\u00a0 Words relating to similar subjects have numbers which are &#8220;closer together&#8221;.\u00a0 So in a sentence &#8220;John went skiing in the snow,&#8221; both &#8220;snow&#8221; and &#8220;skiing&#8221; relate to the same subject, and will have numbers closer together than the same number for &#8220;John.&#8221;<\/p>\n<p align=\"justify\">Again you need a very large amount of text in that language on both sides.\u00a0 For each language, these texts are then processed into this mass of numbers.\u00a0 The numbers tell you whether the word is a verb or a noun, or is a name, or is often found with these words, or never found with those.\u00a0 The mass of numbers is a &#8220;language model&#8221;, because it contains vast amounts of information about how the language actually works.\u00a0 The same English word may have more than one number; &#8220;right&#8221; in &#8220;that&#8217;s right&#8221; is a different concept to the one in &#8220;the politicians of the right.&#8221;\u00a0 The more text you have, the more you can analyse, and the better your model of the language will be.\u00a0 How many sentences contain both &#8220;ski&#8221; and &#8220;snow&#8221;?\u00a0 And so on.\u00a0 The model of how words, sentences, and so on are actually used, in real language texts, becomes better, the more data you put in.\u00a0 The analysis of the texts starts with human-written code that generates connections; but as you continue to process the data, the process will generate yet more connections.<\/p>\n<p align=\"justify\">The end result is these models, which describe the use of the language.\u00a0 You also end up with a mass of data connecting the two together.\u00a0 The same number in one side of the language pair will also appear in the other model, pointing to the equivalent word or concept.\u00a0 So 11050 may mean &#8220;love&#8221; in English but &#8220;am-&#8221; in Latin.<\/p>\n<p align=\"justify\">As before, there are a lot of steps to this process, which I have jumped over.\u00a0 Nor is it just a matter of individual words; far from it.<\/p>\n<p align=\"justify\">The term used by the AI salesmen for this process is &#8220;training the model.&#8221;\u00a0 They use this word to mislead, because it gives to the reader the false impression of a man being trained.\u00a0 I prefer to say &#8220;populating&#8221; the model, because it&#8217;s just storing numbers in a file.<\/p>\n<p align=\"justify\">When we enter a piece of Latin text in an AI Translator, this is encoded in the same way.\u00a0 The AI system works out what the appropriate number for each token &#8211; word or part-word &#8211; in our text is.\u00a0 This takes quite a bit of time, which is why AI systems hesitate on-screen.\u00a0 The resulting stream of encoded numbers are then fed into the LLM, which sends back the corresponding English text for those numbers, or numbers which are mathematically &#8220;similar&#8221;.\u00a0 Plus a lot of tweaking, no doubt.<\/p>\n<p align=\"justify\">But here&#8217;s the interesting bit.\u00a0 The piece of Latin that we put in, and the analysis of it, is not discarded.\u00a0 This is more raw data for the model.\u00a0 It is stored in the model itself.<\/p>\n<p align=\"justify\">This has two interesting consequences.<\/p>\n<p align=\"justify\">The first consequence is that running the same piece of text through the LLM twice will always give different results, and not necessarily better ones.\u00a0 Because you can never run the same text through the same LLM twice; the LLM is different now, changed to include your text.<\/p>\n<p align=\"justify\">The second consequence is even more interesting: you can poison a model by feeding it malicious data, designed to make it give wrong results.\u00a0 It&#8217;s all data, at the end of the day.\u00a0 The model is just a file.\u00a0 It doesn&#8217;t know anything.\u00a0 All it is doing is generating the next word, dumbly.\u00a0 And what happens if the input is itself AI-generated, but is wrong?<\/p>\n<p align=\"justify\">In order to create a model of the language and how it is used, you need as much data as possible.\u00a0 Long ago Google digitised all the books in the world, and turned them into searchable text, even though 80% of them are in copyright.\u00a0 Google Books merely gives a window on this database.<\/p>\n<p align=\"justify\">AI providers need lots of data.\u00a0 But one reason why they have tried to conceal what they are doing is, in part, because the data input is nearly all in copyright.\u00a0 One incautious AI provider did list the sources for its data in an article, and these included a massive pirate archive of books.\u00a0 \u00a0But they had to get their data from somewhere.\u00a0 Similarly this is why there are free tiers to all the AI websites &#8211; they want your input.<\/p>\n<p align=\"justify\">So&#8230; there is no magic.\u00a0 There is no sinister machine intelligence sitting there.\u00a0 There is a file full of numbers, and processes.<\/p>\n<p align=\"justify\">The output is not perfect.\u00a0 Even Google Translate could do some odd things.\u00a0 But AI Translate can produce random results &#8211; &#8220;hallucinations&#8221;.<\/p>\n<p align=\"justify\"><span style=\"text-decoration: underline;\">Further reading<\/span><\/p>\n<ul>\n<li><a href=\"https:\/\/medium.com\/@rgalvg\/how-do-words-become-numbers-in-ai-models-3d399dbcbb79\">Rafael Guerra, How do words become numbers in AI language models?\u00a0<\/a>Medium, Jan 30, 2023.<\/li>\n<li><a href=\"https:\/\/veracontent.com\/mix\/ai-translation\/\">Ariel Craine, AI translation: Helpful tool or just plagiarism in disguise?<\/a> Oct 16, 2023.\u00a0 Useful sentence: &#8220;When you use an AI translator, the machine encodes a given sentence into a sequence of numbers and then converts it to output numbers. Those output numbers are then decoded into the target language.&#8221;<\/li>\n<li><a href=\"https:\/\/www.quora.com\/Is-there-any-tool-to-detect-the-translation-done-by-AI\">Is there any tool to detect the translation done by AI?<\/a> Quora, mid. 2023.<\/li>\n<li><a href=\"https:\/\/stptrans.com\/ai-and-translation-the-new-reality-is-here-almost\/\">William Hagerup, AI and translation: the new reality is here \u2013 almost!<\/a> 6 Jul 2023.<\/li>\n<li><a href=\"https:\/\/www.lionbridge.com\/blog\/translation-localization\/machine-translation-a-generative-ai-model-outperformed-a-neural-machine-translation-engine\/\">A Generative AI Model Outperformed a Neural Machine Translation Engine in One Machine Translation Evaluation<\/a>.\u00a0 May 12, 2023.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>The computer world is a high-bullshit industry.\u00a0 \u00a0Every computer system consists of nothing more than silicon chips running streams of ones (1) and zeros (0),<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_seo_schema_type":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_awef_post_faq_schema":[],"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[19],"tags":[126,471],"class_list":["post-48315","post","type-post","status-publish","format-standard","hentry","category-from-my-diary-announcements","tag-ai-translation","tag-computing"],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/roger-pearse.com\/weblog\/wp-json\/wp\/v2\/posts\/48315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/roger-pearse.com\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/roger-pearse.com\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/roger-pearse.com\/weblog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/roger-pearse.com\/weblog\/wp-json\/wp\/v2\/comments?post=48315"}],"version-history":[{"count":0,"href":"https:\/\/roger-pearse.com\/weblog\/wp-json\/wp\/v2\/posts\/48315\/revisions"}],"wp:attachment":[{"href":"https:\/\/roger-pearse.com\/weblog\/wp-json\/wp\/v2\/media?parent=48315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/roger-pearse.com\/weblog\/wp-json\/wp\/v2\/categories?post=48315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/roger-pearse.com\/weblog\/wp-json\/wp\/v2\/tags?post=48315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}