{"id":4162,"date":"2024-03-26T22:18:38","date_gmt":"2024-03-26T23:18:38","guid":{"rendered":"https:\/\/sites.uac.pt\/amendes\/?p=4162"},"modified":"2024-03-26T22:18:39","modified_gmt":"2024-03-26T23:18:39","slug":"look-into-the-machines-mind","status":"publish","type":"post","link":"https:\/\/sites.uac.pt\/amendes\/visualizacao\/look-into-the-machines-mind\/","title":{"rendered":"Look into the machine&#8217;s mind"},"content":{"rendered":"\n<div class=\"wp-block-cover\" style=\"min-height:124px;aspect-ratio:unset;\"><span aria-hidden=\"true\" class=\"wp-block-cover__background has-background-dim\"><\/span><img loading=\"lazy\" decoding=\"async\" width=\"576\" height=\"193\" class=\"wp-block-cover__image-background wp-image-4163\" alt=\"\" src=\"https:\/\/sites.uac.pt\/amendes\/files\/2024\/03\/moebio.png\" data-object-fit=\"cover\" srcset=\"https:\/\/sites.uac.pt\/amendes\/files\/2024\/03\/moebio.png 576w, https:\/\/sites.uac.pt\/amendes\/files\/2024\/03\/moebio-300x101.png 300w\" sizes=\"auto, (max-width: 576px) 100vw, 576px\" \/><div class=\"wp-block-cover__inner-container is-layout-flow wp-block-cover-is-layout-flow\">\n<p class=\"has-text-align-center has-large-font-size\"><a href=\"https:\/\/moebio.com\/mind\/\" data-type=\"link\" data-id=\"https:\/\/moebio.com\/mind\/\">clique no link para visitar a app<\/a><\/p>\n<\/div><\/div>\n\n\n\n<p class=\"has-luminous-vivid-amber-color has-text-color has-link-color wp-elements-07f7239318681e223dc955f7975aa0ae\">Uma web app capaz de explorar os v\u00e1rios caminhos obtidos da resposta &#8220;what is intelligence&#8221; do chatGPT<\/p>\n\n\n\n<p><strong>the data<\/strong><br \/>Using the&nbsp;<a href=\"https:\/\/platform.openai.com\/docs\/guides\/text-generation\" target=\"_blank\" rel=\"noreferrer noopener\">chatgpt api<\/a>, I ran the same completion prompt&nbsp;<em>&#8220;Intelligence is &#8220;<\/em>&nbsp;hundreds of times (setting the temperature&nbsp;quite high, at 1.6, for more diverse responses). Given a text, a Large Language Model assigns a probability for the word (token) to come, and it just repeats this process until a completion is\u2026well, complete.<\/p>\n\n\n\n<p><strong>semantic space<\/strong>&nbsp;(behind)<br \/>Each text (a prompt completion or a sub-sequence) has an embedding: a position in a 1536-dimensions space (I call it semantic space, or s\u00b2\u2081\u2085\u2083\u2086). For each response there&#8217;s a trajectory through s\u00b2\u2081\u2085\u2083\u2086 that corresponds to each sub-sequence of words, example:&nbsp;<em>&#8220;Intelligence is &#8220;<\/em>&nbsp;\u2192&nbsp;<em>&#8220;Intelligence is the&#8221;<\/em>&nbsp;\u2192&nbsp;<em>&#8220;Intelligence is the ability&#8221;<\/em>&nbsp;\u2192&nbsp;<em>&#8220;Intelligence is the ability to&#8221;<\/em>&nbsp;\u2192 \u2026 \u2192&nbsp;<em>full completion<\/em>.<\/p>\n\n\n\n<p>Because I cannot visualize a 1536-dimensions space (yet), I use a popular technique called&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Principal_component_analysis\" target=\"_blank\" rel=\"noreferrer noopener\">Principal Components Analysis<\/a>&nbsp;that tells me, for the set of points I have, what are the most important (principal) dimensions, and allows me to rotate the highly dimensional space so when I look through it, projected into only 3 dimensions, the points are scattered as much as possible. It&#8217;s the best (linear)possible reduction of dimensions. In fewer words: it compresses a highly dimensional space into few dimensions while preserving as much info as it can. More or less the same as when for drawing something you choose a perspective (you rotate the object), so it provides the most relevant information. I call this new space s\u00b2\u2083, and it&#8217;s what I visualize.<\/p>\n\n\n\n<p>What you see in the cube is a tree of trajectories that bifurcate. All start with&nbsp;<em>&#8220;Intelligence is &#8220;<\/em>&nbsp;and progress towards longer and less probable sub-sequences of responses. It&#8217;s a different representation of the same tree being visualized on the right (both visualizations communicate).<\/p>\n\n\n\n<p><strong>The tree visualization<\/strong>&nbsp;(right)<br \/>Visualizes all collected completions. It also represents the calculated probability of a word following a text (because the sample is small, this is only a good approximation for the initial levels of the tree), so&nbsp;<em>&#8220;Intelligence is the &#8220;<\/em>&nbsp;will be followed by&nbsp;<em>&#8220;ability&#8221;<\/em>&nbsp;~75% of the times, at 1.6 temperature. If temperature was lower this probability would rise, until achieving certainity at temperature=0.<\/p>\n\n\n\n<p>By hovering a word, which corresponds to a point in a sub-sequence, you can see in the cube the trajectory from the prompt to all the completions that start with that sub-sequence.<\/p>\n\n\n\n<p><strong>Try other prompts:<\/strong><br \/>\u00b7&nbsp;<a href=\"document.clickFunction(0)\">Chatgpt is<\/a><br \/>\u00b7&nbsp;<a href=\"document.clickFunction(1)\">Best thing about AI is<\/a><br \/>\u00b7&nbsp;<a href=\"document.clickFunction(2)\">When<\/a><br \/>\u00b7&nbsp;<a href=\"document.clickFunction(3)\">Santiago Ortiz is<\/a>&nbsp;(yes, this is a selfai. What I found interesting is that it&#8217;s ~50% truth ~50% bs, and it feels like it describes alternative versions of my self in the multiverse)<br \/>\u00b7&nbsp;<a href=\"document.clickFunction(4)\">My dream<\/a><br \/>\u00b7&nbsp;<a href=\"document.clickFunction(5)\">Tell me a story:<\/a><br \/>\u00b7&nbsp;<a href=\"document.clickFunction(6)\">Intelligence is<\/a><\/p>\n\n\n\n<p><strong>references<\/strong><br \/><a href=\"https:\/\/medium.com\/@moebio\/simulating-my-friend-philippe-a8c9af223002\" target=\"_blank\" rel=\"noreferrer noopener\">Simulating my friend Philippe<\/a>, where I explain embeddings, and how they are used to run semantic search and to find the proper knowledge from a corpus to use it as context for LLMs prompts<br \/><a href=\"https:\/\/writings.stephenwolfram.com\/2023\/02\/what-is-chatgpt-doing-and-why-does-it-work\/\" target=\"_blank\" rel=\"noreferrer noopener\">A deeper explanation of LLMs<\/a>, next token prediction, temperature and embeddings, by Stephen Wolfram<br \/><a href=\"https:\/\/www.futilitycloset.com\/2014\/12\/12\/english-by-degrees\/\" target=\"_blank\" rel=\"noreferrer noopener\">English by degrees<\/a>&nbsp;the original Next Word prediction model by Claude Shannon<\/p>\n\n\n\n<p><a href=\"https:\/\/moebio.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">moebio<\/a>&nbsp;for more experiments and data proyects<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Uma web app capaz de explorar os v\u00e1rios caminhos obtidos da resposta &#8220;what is intelligence&#8221; do chatGPT the dataUsing the&nbsp;chatgpt api, I ran the same completion prompt&nbsp;&#8220;Intelligence is &#8220;&nbsp;hundreds of times (setting the temperature&nbsp;quite high, at 1.6, for more diverse responses). Given a text, a Large Language Model assigns a probability for the word (token) [&hellip;]<\/p>\n","protected":false},"author":159,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4284,80],"tags":[4286,4285,4287],"class_list":["post-4162","post","type-post","status-publish","format-standard","hentry","category-llms","category-visualizacao","tag-bifurcaes","tag-chatgpt","tag-word-network"],"_links":{"self":[{"href":"https:\/\/sites.uac.pt\/amendes\/wp-json\/wp\/v2\/posts\/4162","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sites.uac.pt\/amendes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sites.uac.pt\/amendes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sites.uac.pt\/amendes\/wp-json\/wp\/v2\/users\/159"}],"replies":[{"embeddable":true,"href":"https:\/\/sites.uac.pt\/amendes\/wp-json\/wp\/v2\/comments?post=4162"}],"version-history":[{"count":1,"href":"https:\/\/sites.uac.pt\/amendes\/wp-json\/wp\/v2\/posts\/4162\/revisions"}],"predecessor-version":[{"id":4164,"href":"https:\/\/sites.uac.pt\/amendes\/wp-json\/wp\/v2\/posts\/4162\/revisions\/4164"}],"wp:attachment":[{"href":"https:\/\/sites.uac.pt\/amendes\/wp-json\/wp\/v2\/media?parent=4162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sites.uac.pt\/amendes\/wp-json\/wp\/v2\/categories?post=4162"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sites.uac.pt\/amendes\/wp-json\/wp\/v2\/tags?post=4162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}