{"id":6910,"date":"2025-05-01T16:50:06","date_gmt":"2025-05-02T00:50:06","guid":{"rendered":"https:\/\/nicknguyen.com\/?p=6910"},"modified":"2025-05-02T02:00:37","modified_gmt":"2025-05-02T10:00:37","slug":"what-ai-taught-me","status":"publish","type":"post","link":"https:\/\/nicknguyen.com\/old\/what-ai-taught-me\/","title":{"rendered":"What AI taught me"},"content":{"rendered":"\n\t<p>So i was browsing the web and came across this paper<a href=\"https:\/\/arxiv.org\/html\/2504.19717v1\"> A high-order recombination algorithm for weak approximation of stochastic differential equations <\/a>a way above my intelligence level, but I always wondered how people use these crazy alien looking equations.<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/nicknguyen.com\/wp-content\/uploads\/2025\/05\/A-high-order-recombination-algorithm-for-weak-approximation-of-stochastic-differential-equations-05-01-2025_05_29_PM-1024x515.png\" alt=\"\" width=\"1024\" height=\"515\" \/><\/p>\n<p>So i copy and pasted it to ChatGPT and the first explanation was again way over my intelligence level so I had it explain to me as if i was a teenager<\/p>\n<blockquote>\nSure \u2014 here\u2019s a simple way to think about it:\nImagine you\u2019re trying to <strong data-start=\"72\" data-end=\"110\">learn the best way to do something<\/strong>, like win a game or solve a puzzle. You don\u2019t know the perfect strategy yet, so at each step, you <strong data-start=\"209\" data-end=\"232\">mix different ideas<\/strong> (strategies) and try them out to see what works best.\nNow, think of each idea or strategy as a <strong data-start=\"329\" data-end=\"354\">&#8220;player&#8221; in your team<\/strong>. At each round (call it step <em data-start=\"384\" data-end=\"387\">i<\/em>), you have some confidence in each player \u2014 that&#8217;s what the weights \u03b1jalpha_j\u03b1j\u200b represent. The more confident you are, the bigger the weight.\nThe equation is basically saying:\n&#8220;Hey, after I apply this smart learning rule (called <strong data-start=\"624\" data-end=\"631\">Alg<\/strong> and <strong data-start=\"636\" data-end=\"641\">Q<\/strong>), I take my current team mix and <strong data-start=\"675\" data-end=\"690\">recalculate<\/strong> my new team (for the next step, <em data-start=\"723\" data-end=\"728\">i+1<\/em>) by seeing <strong data-start=\"740\" data-end=\"777\">how well each idea transfers over<\/strong> using a table of scores (that\u2019s the weight matrix <strong data-start=\"828\" data-end=\"836\">w(i)<\/strong>).&#8221;\nSo you&#8217;re updating your mix of strategies based on how much each old idea contributes to new ideas in the next round.\nIt\u2019s like upgrading your strategy team over time, keeping track of who\u2019s helping the most and adjusting your trust in them.\n<\/blockquote>\n<p>&nbsp;<\/p>\n<p>So stoked! Who wouldn&#8217;t want to know an algorithm to help them find the best way to do something? I love when I randomly come across such useful information on the web its like &#8220;Internet Gold&#8221;.<\/p>\n<p>Now how can I apply this in real life? I ask chatGPT to show me in a language I can understand.<\/p>\nHere\u2019s an interactive version of the strategy learning loop in <strong data-start=\"63\" data-end=\"74\">PHP CLI<\/strong> \u2014 it asks you (the user) to give feedback manually for each strategy in each round (e.g., &#8220;Did the user like the content? Yes or No?&#8221;).\nThis simulates you being the decision-maker or tester of each strategy.\n<p>&nbsp;<\/p>\n<blockquote><p>&lt;?php<\/p>\n$strategies = [&#8216;popular_videos&#8217;, &#8216;similar_likes&#8217;, &#8216;geo_trending&#8217;];<br \/>\n$alpha = [0.4, 0.4, 0.2];\n$w = [<br \/>\n[0.6, 0.3, 0.1],<br \/>\n[0.2, 0.6, 0.2],<br \/>\n[0.1, 0.3, 0.6]<br \/>\n];\nfunction normalize($vector) {<br \/>\n$sum = array_sum($vector);<br \/>\nreturn array_map(fn($v) =&gt; round($v \/ $sum, 3), $vector);<br \/>\n}\nfunction ask($prompt) {<br \/>\necho $prompt . &#8221; (y\/n): &#8220;;<br \/>\n$handle = fopen (&#8220;php:\/\/stdin&#8221;,&#8221;r&#8221;);<br \/>\n$line = fgets($handle);<br \/>\nreturn strtolower(trim($line)) === &#8216;y&#8217; ? 1 : 0;<br \/>\n}\nfunction showBar($label, $value, $width = 30) {<br \/>\n$barLength = round($value * $width);<br \/>\n$bar = str_repeat(&#8220;\u2588&#8221;, $barLength);<br \/>\nprintf(&#8220;%-18s [%-30s] %.2fn&#8221;, $label, $bar, $value);<br \/>\n}\nfor ($round = 1; $round &lt;= 10; $round++) {<br \/>\necho &#8220;n=== Round $round ===n&#8221;;\n\/\/ Collect feedback<br \/>\n$feedback = [];<br \/>\nforeach ($alpha as $i =&gt; $weight) {<br \/>\n$strategy = $strategies[$i];<br \/>\n$reward = ask(&#8220;Did the user like content from &#8216;{$strategy}&#8217;?&#8221;);<br \/>\n$feedback[$i] = $weight * $reward;<br \/>\n}\n\/\/ Update using transition matrix<br \/>\n$newAlpha = array_fill(0, count($strategies), 0);<br \/>\nforeach ($feedback as $k =&gt; $scaled_weight) {<br \/>\nforeach ($strategies as $j =&gt; $_) {<br \/>\n$newAlpha[$j] += $scaled_weight * $w[$k][$j];<br \/>\n}<br \/>\n}\n\/\/ Normalize<br \/>\n$alpha = normalize($newAlpha);\n\/\/ Display new weights visually<br \/>\necho &#8220;nUpdated Strategy Weights:n&#8221;;<br \/>\nforeach ($strategies as $i =&gt; $s) {<br \/>\nshowBar($s, $alpha[$i]);<br \/>\n}<br \/>\n}<\/blockquote>\n<p>&nbsp;<\/p>\n<p>Output example:<\/p>\n<blockquote>=== Round 3 ===<br \/>\nDid the user like content from &#8216;popular_videos&#8217;? (y\/n): y<br \/>\nDid the user like content from &#8216;similar_likes&#8217;? (y\/n): n<br \/>\nDid the user like content from &#8216;geo_trending&#8217;? (y\/n): y\nUpdated Strategy Weights:<br \/>\npopular_videos [\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 ] 0.65<br \/>\nsimilar_likes [\u2588\u2588 ] 0.07<br \/>\ngeo_trending [\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 ] 0.28<\/blockquote>\n<p>Its pretty awesome how ChatGPT was able to take a random alien looking equations I found and break it down in a way that I can understand and even apply in my own projects.<\/p>\n<p>I dive much deeper, but dont want to bore you, if your interested here is the conversation <a href=\"https:\/\/chatgpt.com\/share\/68141099-dfc8-8009-9771-23ad6d973b50\" target=\"_blank\" rel=\"noopener\">here<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>ChatGPT turns a crazy equation i found online, into internet gold. <\/p>\n","protected":false},"author":1,"featured_media":6912,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","_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}},"categories":[1,132,161,164],"tags":[],"class_list":["post-6910","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-all","category-findings","category-opinions","category-technology-opinions"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/media.nicknguyen.com\/wp-content\/uploads\/2025\/05\/01164956\/golden-internet-network-icon-vector-444059941.webp","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/nicknguyen.com\/old\/wp-json\/wp\/v2\/posts\/6910","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nicknguyen.com\/old\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nicknguyen.com\/old\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nicknguyen.com\/old\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nicknguyen.com\/old\/wp-json\/wp\/v2\/comments?post=6910"}],"version-history":[{"count":2,"href":"https:\/\/nicknguyen.com\/old\/wp-json\/wp\/v2\/posts\/6910\/revisions"}],"predecessor-version":[{"id":6914,"href":"https:\/\/nicknguyen.com\/old\/wp-json\/wp\/v2\/posts\/6910\/revisions\/6914"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nicknguyen.com\/old\/wp-json\/wp\/v2\/media\/6912"}],"wp:attachment":[{"href":"https:\/\/nicknguyen.com\/old\/wp-json\/wp\/v2\/media?parent=6910"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nicknguyen.com\/old\/wp-json\/wp\/v2\/categories?post=6910"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nicknguyen.com\/old\/wp-json\/wp\/v2\/tags?post=6910"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}