<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Keith Trnka on Medium]]></title>
        <description><![CDATA[Stories by Keith Trnka on Medium]]></description>
        <link>https://medium.com/@keith.trnka?source=rss-3e4d2400adbe------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*-dqCCBi9PvE76ZbYkFw_Sg.jpeg</url>
            <title>Stories by Keith Trnka on Medium</title>
            <link>https://medium.com/@keith.trnka?source=rss-3e4d2400adbe------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 13:37:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@keith.trnka/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Tales from the gaming industry for folks in tech]]></title>
            <link>https://medium.com/@keith.trnka/tales-from-the-gaming-industry-for-folks-in-tech-f28d660531d9?source=rss-3e4d2400adbe------2</link>
            <guid isPermaLink="false">https://medium.com/p/f28d660531d9</guid>
            <category><![CDATA[organizational-culture]]></category>
            <category><![CDATA[health-technology]]></category>
            <category><![CDATA[game-development]]></category>
            <dc:creator><![CDATA[Keith Trnka]]></dc:creator>
            <pubDate>Fri, 12 Dec 2025 12:02:21 GMT</pubDate>
            <atom:updated>2025-12-12T12:02:21.161Z</atom:updated>
            <content:encoded><![CDATA[<p>After a year at Singularity 6 working on <a href="https://palia.com/">Palia</a>, I found myself answering the same questions from friends in tech: What’s different about gaming? What’s the same? This post shares many of the similarities and differences I experienced compared to other tech jobs.</p><h3>Background</h3><p>My background with gaming goes back to my early childhood, as does my background with programming. I still remember playing Atari games and my first experiences with programming on the VIC-20. My first programming book was about gaming but I was too ambitious at the time. So I set that aside and learned programming on and off through high school.</p><p>I went to college at The College of New Jersey for computer science. I heard an exciting story there: A classmate got an internship in the gaming industry! But when I asked more, I found that they mostly fetched coffee for “real” developers. Not long after that, I started to read awful stories like the <a href="https://www.gameqol.org/ea-spouse">EA spouse</a>. So I set that dream aside.</p><p>Fast forward over 20 years: Most of my network is in healthtech or broader tech, and many people are curious about the gaming industry. After spending about a year at Singularity 6 working on Palia, I realized I had misconceptions about gaming that others might share too. This post covers topics that often come up in discussion, and focuses on my personal experiences rather than a review of existing literature.</p><h3>Crunch mode and Chaos</h3><p>The gaming industry has a reputation for crunch mode: If a team is behind schedule and headed towards a deadline, people often work longer hours to try and meet their target. In many companies it happens by mandate from leadership, in other cases it happens from pressure, and other crunch is opt-in, often by passionate developers.</p><p>My impression from S6 and the <a href="https://www.doublefine.com/dftv/psychodyssey">PsychOdyssey documentar</a>y is that:</p><ol><li>It’s popular to say “we don’t crunch”: The older generation of devs seem to say “never again” to the horrible experiences they had</li><li>Crunching is less extreme than it was 20 years ago (but newer devs didn’t experience the old crunch)</li><li>Companies are trying to do better for employees but progress is slow</li></ol><p>Also note that crunch isn’t fairly distributed. QA might be the last step and they’re pushed to crunch. Or junior engineers may be more susceptible to leadership pressure. Or people in key, understaffed roles may come under more pressure.</p><p>The question I’ve pondered the most is: Why do gaming companies seem to crunch more than tech companies, and is it avoidable?</p><p>This is what I’ve observed:</p><ul><li>Some chaos is avoidable</li><li>Some chaos is unavoidable</li><li>Crunching is a response to chaos, but not the only possible response</li></ul><p>Let me give a few examples of avoidable chaos first, picking real examples that should be familiar to folks in tech:</p><ul><li>Someone interpreted a Slack message or offhand comment from leadership as an urgent command</li><li>The game would support PC and Nintendo Switch, but the design requirements of Switch were not taken into account during initial development</li><li>The game was intentionally designed to not be latency-sensitive, but a latency-sensitive feature was later added</li></ul><p>I picked examples of communication issues because they’re so common. In many of these cases, there wasn’t enough communication or there was miscommunication. Another common theme is a refusal to prioritize, which is often a combination of communication and leadership problems.</p><p>Let me also give a few examples of unavoidable chaos. I’ll start with one that’s familiar in the tech industry: The team is working and runs into a surprise that needs to be addressed. That could be something as simple as learning that the plan will take much longer than expected, requiring adjustments to the schedule or plan. That’s not to say that all surprises are unavoidable, many are, it’s to say that all plans are susceptible to unknown unknowns.</p><p>The unknowns can be much more fundamental. When you distribute new software, you’re certain to face surprises at launch. An example from Palia was that we had many more players in Europe than expected so we added European servers much sooner than planned, which took significant effort away from other efforts.</p><p>Gaming also has more unknown unknowns than typical tech work. A common challenge is developing a game or level only to find that it isn’t fun. The tech industry equivalent is building a new product or feature only to find minimal engagement. We’d call this finding “product-market fit” while gaming talks about “finding the fun.” But there’s a key difference: in tech we’re often solving a specific user need with established processes to validate solutions. In gaming, the user need is less specific (entertainment) and it’s harder to incrementally iterate to success.</p><p>This uncertainty has real consequences. If “finding the fun” takes much longer than expected and the game development has a fixed budget, it can eat into the time to make the game polished and clean.</p><h3>Takeaways</h3><ul><li>There are similarities between creating a new game and creating new products, but it’s a bit harder to find the fun compared to finding product-market fit</li><li>Chaos can be lessened in well-run companies, but there’s always going to be some of it</li></ul><h3>Internal use aka Dogfooding</h3><p>Dogfooding (using your own product internally) is an interesting parallel across products and companies:</p><p>At <a href="https://en.wikipedia.org/wiki/Swype">Swype</a>, developers could easily load builds on their personal phones. And because we were using our phones so much, we could quickly find out if a new build was an improvement or had some rare bug. Keep in mind that our developers mainly spoke English, so we didn’t catch as many bugs in other languages.</p><p>At 98point6, our software enabled an online visit between a doctor and patient. That was much harder to dogfood so people dogfooded far less (perhaps 1% of the amount I saw at Swype). Exploratory dogfooding was more reserved for dedicated times when we had multiple people available and had an area of the product we wanted to focus on. Even still, we weren’t doctors so our dogfooding of the clinical software wasn’t as useful as our dogfooding of the patient software.</p><p>At Singularity 6, dogfooding (aka playtesting) needed to be coordinated because it was a multiplayer online game. So we had scheduled weekly playtests for the whole company. Sometimes those playtests had particular themes like a new event, and other times they were less structured. At times downloading the right build was a challenge but that was much easier once we used Steam for internal distribution.</p><h3>Takeaways and opinions</h3><p>Dogfooding is a valuable process in building high quality software, but it has limitations to work around</p><p>Ease of dogfooding has an effect on bug discovery</p><ul><li>For Palia, it was much easier to dogfood PC rather than Switch so Switch needed more deliberate effort rather than informal dogfooding</li><li>For Swype, it was easier to dogfood the Android builds rather than iOS</li></ul><p>Bugs that affect developers are found more easily, and others are not as easily found</p><ul><li>Developers are often provided with high-end computers for productivity, but that leads to less discovery of performance issues on low-end computers</li><li>Most developers have reliable internet, so bugs with unreliable connections are less likely to be discovered informally</li><li>In many products, developers may only test in English, leading to a slightly more buggy experience in other languages</li></ul><p>And just to be extra clear, I’m not suggesting that dogfooding is an alternative to deliberate, focused testing. It’s complementary to many forms of testing and a key part of a suite of quality-improvement efforts. Beyond that, it’s also a helpful effort to keep everyone in the company aligned with the user’s experience.</p><h3>Distribution</h3><p>Selling a game on Steam is comparable to publishing an Android app on Google Play. Both platforms take a ~30% cut of revenue, have some requirements about what you can publish, and provide some software libraries or services. In both cases you need to optimize your app for the store to make it more discoverable and drive growth.</p><p>Publishing an app on the iOS App Store is a bit more burdensome due to the manual review process. That can be good for quality and consistency, but the review process can also be inconsistent. We had some frustrating times at 98point6 when a bug fix was blocked because the App Store reviewer was flagging something from a prior version. That introduced delays and sometimes degraded the user’s experience.</p><p>In the gaming world, publishing for Nintendo Switch is somewhat similar. They have a certification process similar in spirit to the iOS process, but it was a little slower and more involved. Also the certification rules required an NDA to access, which added another challenge.</p><p>Multi-platform distribution is very similar between gaming and non-gaming software:</p><ul><li>You’re juggling the competing requirements of each platform. Some platform-specific work is essential and valuable (like controller button mapping conventions or optimized graphics settings per platform). But when possible, it’s better to proactively design features to be compliant with all target platforms from the start. That said, this takes a lot of upfront work and effort early in development.</li><li>You’re trying to design a release cadence to balance the constraints of all platforms and that often is determined by the slowest platform to release on</li><li>Backend APIs provide flexibility in release timing, but in gaming the complex interactions and subtle dependencies between client and backend can make it harder to safely change the backend independently. This was less of an issue in my non-gaming tech experience.</li></ul><h3>Takeaways</h3><ul><li>Distribution heavily influences release process optimization including the cadence of releases</li><li>Discussion of “what goes in the client vs backend” should really consider release cadence more than it does</li></ul><p>Both mobile app distribution and gaming distribution have their strengths and neither is fundamentally superior. Here are some practices worth adopting from each:</p><p><strong>From mobile app distribution:</strong></p><ul><li>The requirements are usually clear, and most of them are publicly available</li><li>The certification process is pretty fast</li></ul><p><strong>From gaming distribution:</strong></p><ul><li>Steam APIs are a value-add and can be used on other platforms</li><li>Steam provides good discoverability</li></ul><p><strong>Improvements for all platforms:</strong></p><ul><li>I wish cert requirements were public for all platforms (Xbox is good about this)</li><li>I wish all requirements also included the intention not just the rule</li></ul><h3>Competition and Market Dynamics</h3><p>One of the biggest differences between gaming and traditional tech products is the level of competition and how easily users can switch. In B2B/SaaS, there’s often significant friction to switching providers. Healthcare has regulatory and insurance barriers. But in gaming? If someone doesn’t like your game, they can easily find something better to do with their time. The switching cost is nearly zero, and if you have a free-to-play game, players are even quicker to drop it.</p><p>Gaming is tougher than I’ve described so far:</p><ul><li>You might plan your game launch only to be eclipsed by a hit game launching around the same time</li><li>You’re not just competing against new releases but also competing against decades of amazing games</li><li>You’re not just competing against the same type of game, but many types of games</li><li>For some players, you’re also competing against other forms of entertainment not just gaming</li></ul><h3>Takeaways</h3><ul><li>I have a lot more respect now for game developers that succeed financially</li><li>B2B/SaaS companies tend to provide far more stability than I previously realized</li></ul><h3>Operations</h3><p>I found it interesting to compare and contrast the operations of 98point6 (24/7 healthcare) to Palia (24/7 gaming).</p><p>At 98point6 we emphasized reliability and scrutinized our service availability. We typically ranged from 99.3% to 99.9% availability, with the variance driven by larger outages like third-party services going down for extended periods. For reference, 99.9% availability means about 9 hours of downtime per year whether planned or unplanned. In some years, just one or two bad outages could cause 9 hours of downtime.</p><p>In online gaming it’s common to have scheduled downtime. That’s a time when the game client may be updated, servers may be updated/restarted, and so on. When things went really well, that would only take 1–2 hours per week (~99% uptime). Coming from healthcare initially I scoffed a bit at the downtime but our tech stack required us to have downtime for coordinated updates across all clients and servers.</p><p>After seeing both in practice, I feel that predictability is often more important to users than availability. For example, in Palia our players expected downtime on Tuesday mornings and planned accordingly. It didn’t bother most people. What bothered players was unexpected downtime and unexpected instability. Like when the 2 hour downtime turned into 6 hours and they couldn’t play when they expected to.</p><h3>User feedback</h3><p>The type and scale of user feedback varied dramatically across employers:</p><p><strong>At Swype and Nuance</strong></p><ul><li>A tiny number of bloggers and news sites would provide detailed feedback</li><li>A small number of users commented on our forums, but overly biased towards English</li><li>A large number of users gave app store reviews, but the reviews were rarely actionable</li></ul><p><strong>At 98point6</strong></p><ul><li>Some patients provided feedback on app stores, but like Swype it was rarely actionable</li><li>A smaller number of patients responded to our surveys with much more actionable feedback</li><li>One time someone thanked me in person because our doctors might’ve saved their life</li><li>Our doctors (also a part of the business) would provide feedback in person or in Slack</li></ul><p><strong>At Singularity 6</strong></p><ul><li>When we first opened access in Aug 2023, we immediately had more hours of recorded gameplay on Twitch than we could ever hope to review. If we’d been able to review it all maybe we could’ve had repro steps for thousands of bugs but it was just impossible (note: someone please make a startup to create/update bug reports from Twitch)</li><li>We were consistently drowning in feedback on Discord and Reddit. Discord was biased to be overly positive and Reddit was biased to be overly negative. Both were biased towards English feedback.</li><li>Once we launched on Steam, we were drowning in feedback from Steam reviews. Steam reviews also enabled more feedback outside of English.</li><li>There was enough culture around developer interactions that we had formal training for it.</li><li>Many players responded to surveys as well.</li></ul><p>I’m sometimes perplexed by the difference in feedback between 98point6 and Singularity 6. At 98point6 we saved our patients hours of frustration with the medical system, hundreds of dollars, and sometimes even saved their lives, yet the feedback was sparse. At Singularity 6 we provided entertainment and we were drowning in feedback. At times I despaired: Are people more passionate about entertainment than life itself?</p><p>I came to think of it differently over the years, seeing it as:</p><ul><li>With a larger user base, you have more passionate people and your time with feedback is sometimes taken over by the most passionate users</li><li>Passion is somewhat proportional to the time investment. Someone might play Palia for 100 hours per year in contrast to using 98point6 for 30 minutes per year.</li><li>Feedback is relative to expectations. With healthcare, you’re expected to save lives and it’s not a pleasant surprise. It’s more of a surprise if you’re expecting to wait and you don’t need to. Sometimes those expectations are also unrealistic, like when patients expected antibiotics for viral infections.</li></ul><h3>Brief additional observations</h3><p>A few other observations worth mentioning:</p><ul><li>Developing in Unreal felt a lot like developing in Android Studio in terms of many aspects of the IDEs. I just wish that Blueprints (Unreal’s visual scripting system) had a text version to diff in version control like Android layout files. It was frustrating to ask for review of a bunch of screenshots, especially for large Blueprints.</li><li>Perforce (a version control system designed for large binary files) was frustrating in many ways, but we couldn’t “just use git” due to lots of large binary files. That was familiar to my experiences in versioning ML models.</li><li>The onboarding experience in gaming is often called FTUE (first-time user experience). There’s a significant amount of effort put into that because games often have complex rules and mechanics to explain. Players aren’t going to read manuals much so you need to incrementally teach them the rules in ways that are fun.</li><li>There are some terminology differences in gaming, like studio = company, producer is something like a project manager, game designer is something like a product manager</li><li>Gaming is often about delivering novelty and that may tend to push development into novel technology (which is often less reliable).</li><li>A/B testing and user studies are most helpful AFTER you’ve found the fun or found product-market fit, less so before</li><li>Working alongside artists, musicians, writers, and people with all sorts of skills is a lot of fun!</li></ul><h3>See also</h3><ul><li><a href="https://www.singularity6.com/news/software-architecture-of-palia">The software architecture of Palia</a></li><li><a href="https://www.doublefine.com/dftv/psychodyssey">Double Fine’s PsychOdyssey documentary series</a></li><li><a href="https://palia.com/">Palia</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f28d660531d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ubuntu 25 setup for a 2014 Macbook Pro]]></title>
            <link>https://medium.com/@keith.trnka/ubuntu-25-setup-for-a-2014-macbook-pro-d43236d9bc4a?source=rss-3e4d2400adbe------2</link>
            <guid isPermaLink="false">https://medium.com/p/d43236d9bc4a</guid>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[mac]]></category>
            <dc:creator><![CDATA[Keith Trnka]]></dc:creator>
            <pubDate>Thu, 04 Dec 2025 12:02:13 GMT</pubDate>
            <atom:updated>2025-12-04T15:47:59.951Z</atom:updated>
            <content:encoded><![CDATA[<p>Apple stopped providing OS updates for my old MacBook Pro (Retina, 13-inch, Mid 2014, Intel CPU) even though the hardware is good enough for common web and development tasks. Eventually Chrome stopped providing updates for the OS version too. Then Docker stopped providing updates for it. Even DuckDB (a Python module) stopped supporting it!</p><p>The install and setup was not always straightforward and some of the guides were outdated so I wanted to write it all down for anyone else trying this.</p><p>The effort has made software development much better on the machine, standardized with my other Ubuntu machine, and slightly improved ordinary things like web browsing.</p><h3>Freeing up space</h3><p>I used Perplexity to help guide me through the diagnostic process in freeing up space, and to create a safe plan to test what was safe to delete. The biggest discovery was a whole partition from an old OS X update that I could delete.</p><h3>Trying and installing Ubuntu</h3><p>The Mac is very picky about the USB drive. What worked:</p><ul><li>Formatting as MS‑DOS (FAT) with GUID Partition Map in Disk Utility (other formats run on my other computer were not recognized) <a href="https://discourse.ubuntu.com/t/create-a-bootable-usb-stick-on-macos/14016">link</a></li><li>dd to flash the iso (steps below)</li><li>Boot with Option held down and choose EFI Boot.</li></ul><p>I followed <a href="https://osxdaily.com/2015/06/05/copy-iso-to-usb-drive-mac-os-x-command/">these steps</a> to flash the ISO:</p><pre># 1) List disks and identify your USB (e.g., /dev/disk2)<br>/usr/sbin/diskutil list<br><br># 2) Unmount the whole USB device (not just a partition)<br>/usr/sbin/diskutil unmountDisk /dev/diskN<br><br># 3) Write the ISO to the raw device for speed (DANGER: correct N!)<br>sudo dd if=/path/to/ubuntu-desktop.iso of=/dev/rdiskN bs=1m<br><br># 4) Ensure buffers are flushed, then eject<br>sync<br>/usr/sbin/diskutil eject /dev/diskN</pre><p>The steps above were maybe the 4th attempt. In previous attempts, either the USB wasn’t listed in the boot menu or else it was listed but booting from it would just hang on a black screen.</p><h3>Installing wifi drivers (Broadcom BCM4360)</h3><p>Ubuntu doesn’t come with wifi drivers for the Broadcom BCM4360 chip. So I ordered a cheap USB Ethernet adapter and used it to test Ubuntu then install the correct wifi chip drivers.</p><p>When installing Ubuntu I made sure to select additional drivers, which I think enabled the restricted package source containing the following drivers.</p><p>Then: sudo apt install broadcom-sta-dkms (Not the older bcmwl-kernel-source)</p><p>Then I rebooted and wifi worked!</p><h3>Installing webcam drivers (Broadcom FaceTime HD / 1570)</h3><p>Even though the guides were quite old, they still worked for the webcam.</p><ul><li>Double-check the hardware model against the guide you’re following. In my case lspci -nn | grep 1570</li><li>Install prerequisites: sudo apt install linux-headers-generic build-essential git curl cpio xz-utils</li><li>Install firmware: git clone https://github.com/patjak/facetimehd-firmware.git &amp;&amp; cd facetimehd-firmware &amp;&amp; make &amp;&amp; sudo make install</li><li>Install driver: git clone https://github.com/patjak/bcwc_pcie.git &amp;&amp; cd bcwc_pcie &amp;&amp; make &amp;&amp; sudo make install &amp;&amp; sudo depmod</li><li>Load the driver: sudo modprobe facetimehd and I verified it in Google Meet in Chrome</li></ul><p>Note that kernel updates will cause Ubuntu to lose the webcam and you’ll need to do this again. I tried looking into <a href="https://gbatemp.net/threads/debian-ubuntu-facetimehd-webcam-driver.584652/">a DKMS package for it</a>, but the download link no longer works. I may search around for DKMS package in the future or make my own.</p><p>Sources:</p><ul><li><a href="https://andreafortuna.org/2024/08/24/from-faceless-to-facetime-installing-webcam-drivers-on-a-debian-powered-macbook-air">link</a></li><li><a href="https://gist.github.com/johnjeffers/3006011ec7767a4101cdd118e8d64290">link</a></li></ul><h3>Issue: Red light from the audio jack</h3><p>Sometimes a red light would shine through the audio jack. To quote Perplexity,</p><blockquote>That red light shining through your MacBook’s headphone jack is the optical digital audio (TOSLINK / S/PDIF) output, which shares the same jack as the analog output on older Mac models like the 2014 MacBook Pro. When the light turns on, it means the hardware has switched the port into optical mode.</blockquote><p>Steps to resolve:</p><ul><li>Run alsamixer</li><li>Press F6 to pick the sound card, navigate to S/PDIF, IEC958, or Digital Output channels, then press M to mute.</li><li>Run sudo alsactl store</li></ul><p>I haven’t had problems since.</p><h3>Improving battery life</h3><p>Short version: TLP works well without additional customization.</p><h3>TLP</h3><p><a href="https://linrunner.de/tlp/index.html">TLP</a> is a popular all-in-one package to optimize battery life and it doesn’t require customization.</p><pre>sudo apt install tlp<br>sudo tlp start</pre><p>I’ve found that battery life while sleeping seems better, and it’s a little better during normal usage (compared to balanced power mode all the time).</p><p>I’ve only had one issue with TLP and that’s when playing Youtube videos in Chrome (deb package) on battery. Sometimes it causes the video to stutter badly enough to nearly lock up the tab, and that didn’t happen pre-TLP on Balanced power mode.</p><h3>Special note about Spotify</h3><p>If you use Spotify via the deb package, be sure to minimize the window while playing music in the background. I found that the laptop was drawing 30–45W with Spotify playing in the background when not visible but not minimized, and only around 10W when minimized. This appears to be a common, old issue <a href="https://community.spotify.com/t5/Desktop-Linux/High-CPU-usage-on-desktop-client/td-p/5264603">1</a>, <a href="https://github.com/flathub/com.spotify.Client/issues/223">2</a>, <a href="https://forum.garudalinux.org/t/spotify-high-gpu-usage/45648">3</a>.</p><h3>Semi-failed: Low-effort wattage monitoring</h3><p>Initially I wanted low-effort monitoring in the top bar. That led me to PowerTracker.</p><ul><li>Setup Gnome extensions and install PowerTracker <a href="https://www.ubuntumint.com/powertracker-ubuntu-battery-life-monitor/">link</a></li><li>Manually edit ~/.local/share/gnome-shell/extensions/marcs14@gmail.com/metadata.json to allow it in Gnome 49, then relogin. This isn&#39;t normally needed, but the extension hasn&#39;t been updated for Gnome 49 yet.</li></ul><p>I used the machine for about a week on balanced power mode before installing TLP. Then after I installed TLP I also kept an eye on it. I wasn&#39;t able to notice major trends through PowerTracker like I&#39;d hoped, even though the battery seemed to last longer. If I could do it again, I&#39;d try a widget that smooths out the power usage more.</p><p>That said, it did help me discover the Spotify issue.</p><h3>Failed effort: Hardware video acceleration</h3><p>I’m including this section to discourage others from wasting time on this.</p><p>This hardware has the Intel Iris 5100 chip and can do hardware acceleration of h264 video but not newer video codecs.</p><p>Initially I tried getting hardware video acceleration working in Chrome with the deb package but I wasn’t able to get Chrome to use it. When I gave up, I had the feeling that it was possible but would take more time than I was willing to put in.</p><p>I pivoted and I was able to get it working in Firefox using the Flatpak package, but when I benchmarked Firefox with hardware video acceleration against Chrome without video acceleration, the battery usage was similar. The description below is what I did to get it working in Firefox in case it helps others.</p><p>Installing the driver: sudo apt install vainfo libva-intel-driver</p><p>Then I could confirm that it saw i965 with vainfo:</p><pre>libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so<br>libva info: Found init function __vaDriverInit_1_22<br>libva info: va_openDriver() returns 0<br>vainfo: VA-API version: 1.22 (libva 2.22.0)<br>vainfo: Driver version: Intel i965 driver for Intel(R) Haswell - 2.4.1</pre><p>Firefox setup:</p><pre>flatpak install flathub org.mozilla.firefox<br>flatpak run org.mozilla.firefox</pre><p>Then run flatpak info org.mozilla.firefox and note the version number under runtime or SDK. In my case it&#39;s 24.08.</p><p>I also had to install these:</p><pre>flatpak install flathub org.freedesktop.Platform.ffmpeg-full//VERSION<br>flatpak install flathub org.freedesktop.Platform.VAAPI.Intel//VERSION</pre><p>If you don’t specify the version, you can pick it from a list.</p><p>And because my hardware only accelerates h264, I installed the h264ify plugin to force Youtube to use h264 streams rather than VP9/AV1.</p><p>Older online guides said I’d need to edit Firefox settings but that’s no longer needed.</p><p>intel-gpu-top is useful for confirming that it’s working. To install: sudo apt install intel-gpu-tools Then run the top command while playing a video and confirm that there’s non-zero usage in the Video row: sudo intel_gpu_top</p><h3>Failed effort: Battery health saver</h3><p>TLP has some pointers on how to set this up with Apple silicon (M chips) but not Intel. That said, I’ve noticed that it tends to stop at around 95% which is good enough for me.</p><h3>Failed effort: Wake speed</h3><p>On OS X, my Macbook would wake from sleep in about 1 second. On Ubuntu, it takes maybe 10 seconds.</p><p>I can see the options here:</p><pre>&gt; cat /sys/power/mem_sleep<br>s2idle [deep]</pre><p>Then changed it to s2idle: echo s2idle | sudo tee /sys/power/mem_sleep</p><p>Sadly that drained the battery overnight, so I’ll just live with the slower waking for now.</p><p>If you’re trying to get a few extra years out of this old hardware, I hope this helps!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d43236d9bc4a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Future Crap, Part 2]]></title>
            <link>https://medium.com/@keith.trnka/future-crap-part-2-fda70eb03ef1?source=rss-3e4d2400adbe------2</link>
            <guid isPermaLink="false">https://medium.com/p/fda70eb03ef1</guid>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[prompt-engineering]]></category>
            <dc:creator><![CDATA[Keith Trnka]]></dc:creator>
            <pubDate>Mon, 01 Jul 2024 14:06:02 GMT</pubDate>
            <atom:updated>2024-07-02T03:45:43.359Z</atom:updated>
            <content:encoded><![CDATA[<h4>Building brand-injection for generative AI</h4><p><em>If you’re looking for example output, start with </em><a href="https://medium.com/@keith.trnka/future-crap-part-1-373e607aef51"><em>Part 1</em></a><em>. This post is the “how it’s made” portion.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7K-ATjwTiLCWReA-cS4m4Q.png" /></figure><h3>Origin story</h3><p>This effort was a mixture of curiosity and satire.</p><p>A couple years ago I was mulling over ideas to augment Giphy memes with GenAI memes and ways to pay the server bills. Recently I had more free time after a layoff and wanted some practice with retrieval-augmented generation.</p><p>I have some satirical motivation here as well: many companies build innovative technology, then refine it into a productive application, then users flock to it, and once they’re entrenched they <a href="https://en.wikipedia.org/wiki/Enshittification">enshittify</a> the technology often by putting more and more ads into it. It gets to the point where the products are barely worth the hassle.</p><p>Another thing on my mind is why ChatGPT is sometimes better than Google. They often have very similar results, but ChatGPT doesn’t force me through tons of ads and accept-cookies popups.</p><h3>How it works</h3><p>I made Future Crap available to some friends in our shared Slack channel.</p><p>When a user types the command /futurecrap followed by a description such as &quot;a photorealistic cat and dog in an intense staring contest in the office,&quot; the request is forwarded over a socket to the backend server (assuming it&#39;s online). The backend then searches for brand matches using the prompt as the query in an in-memory vector database. This search matches the prompt against brand descriptions such as &quot;… is a fast-food restaurant chain known for its fried chicken, sides, and sandwiches, targeting families, individuals, and chicken enthusiasts seeking flavorful and convenient dining options …&quot;. Among the top three closest brand matches, a random selection is made with a preference for higher match scores.</p><p>Next, the backend randomly selects the image generation service, either OpenAI DALL-E 3 or AWS Titan. The prompt is then augmented in one of two ways depending on the brand. In both cases, we’re using the ChatGPT API with examples of good and bad brand-injection to do few-shot learning. Also note that DALL-E and Titan perform better with different types of prompts, so we’re using different meta-prompts for each to customized to each image generation engine.</p><p>For most brands, the inputs are the original prompt and the brand name. If the brand data has a brand_style field, the inputs include the original prompt and a visual description of the brand. This approach is good for brands that are not prominent in the training data of the image generator. In my testing I found this critical for Boss Coffee, Rainier Beer, Mt. Joy (a Seattle food truck), Olympia Coffee, Blockbuster, and a few others.</p><p>Once the prompt is augmented with the brand information, it is sent to the selected image generation backend. The generated image is then uploaded to S3. A Slack message containing the image URL and other metadata is sent back over the Slack socket. Finally, the Slack servers post this information into the channel data, making the image visible to the users in the channel.</p><p>If you’re looking in the repo, there’s also a web frontend that I use for local development.</p><h4>About the brand data</h4><p>The brand data was built by hand using ChatGPT/Copilot and <a href="https://imagetoprompt.com/">ImageToPrompt</a>. It took a number of iterations and still needs improvement.</p><p>This is a rough outline of how I iterated:</p><ol><li>I started with a list of brands that I remembered from commercials or ads. For example, Pepsi and Nike are famous for marketing.</li><li>I used ChatGPT to generate a description of the target demographic and used that for brand matching.</li><li>I expanded the list of brands by chatting with friends and reviewing the S&amp;P 500 for companies I thought had recognizable branding.</li><li>I saw that it sometimes matched in a way that didn’t make any sense for the scene, so I used ChatGPT to generate the brand_identity field after giving some examples. That was intended to capture the general vibe of each brand’s ads rather than the target demographic.</li><li>I had a failed experiment in which I generated example ads to use for matching. The examples were good but it was slow to generate so I didn’t explore it further.</li><li>I saw that it didn’t work for less well-known brands (like Boss Coffee) and it couldn’t possibly work for new, local brands (like Mt. Joy) so I tried searching for their icons, fed those into ImageToPrompt, and then added that as a field in the brand data brand_style. Then if that field was present, I had the prompt generator use a different metaprompt to do the prompt augmentation from the visual description.</li><li>I expanded for a while with ImageToPrompt but it was going slowly so I used Copilot in VSCode to add brand_style for many other brands. I found that I often had to nudge it to be specific about the color scheme and font style. Though once in a while I needed to write the whole thing myself.</li></ol><h3>Successes</h3><p>Initially I used a simple template like “{prompt}. Include product placement from {company_name}”. That sometimes worked in DALL-E, almost never worked in Titan, and it wasn’t very reliable overall.</p><p>I had success in using GPT to convert an input prompt into a brand-injected prompt and tuning it for each image generator. This was great because the users didn’t need to adapt for DALL-E 3 vs Titan and GPT handled it for them. It also unlocked an easy way to optimize: I could take the good image generation prompts, hand-optimize them further, then use them as examples for few-shot learning in the metaprompt. This was great though I should’ve iterated more on how to do the few-shot prompt.</p><p>Here’s an example of what I mean by a metaprompt for AWS Titan:</p><blockquote>Your task is to modify an image generation prompt to include brand marketing. The output prompt should be relatively short and to the point about the key details with prominent brand marketing. Here are some examples of inputs and varying quality outputs.</blockquote><blockquote>Input prompt: a cartoon family of scorpions walking to school in the morning. The smallest scorpion has a cute backpack and lunch box</blockquote><blockquote>Input brand: McDonald’s</blockquote><blockquote>Good output: Illustrate a charming cartoon family of realistic-looking scorpions walking to school in the morning. The youngest scorpion is wearing a cute backpack with the iconic McDonald’s red and yellow colors and carrying a matching lunchbox from its stinger. A McDonald’s billboard is shown prominently in the background.</blockquote><blockquote>…</blockquote><blockquote>Now you’ll be provided an input prompt and brand and you will modify the prompt to prominently feature the brand in the scene. Only respond with the modified prompt.</blockquote><blockquote>Input prompt: {prompt}</blockquote><blockquote>Input brand: {brand_name}</blockquote><blockquote>Excellent output (use up to 125 tokens in the output):</blockquote><p>The “good output” vs “excellent output” vs “mediocre output” distinctions was an idea to get a little more value out of additional supervision, but I didn’t explore it thoroughly so I don’t know if it helped.</p><p>For smaller brands, I found that I could use image2prompt to generate a description of the visual style of brands that DALL-E and Titan couldn’t support natively. That’s how I was able to even use brands like Mt. Joy, a Seattle food truck. Though it couldn’t perfectly recreate their logo. This style of generation worked especially well when I made sure that the “brand style” field included description of not just the logo but also the color scheme and any font styles.</p><p>Here’s an example of a brand-injected prompt with a smaller brand from the visual description, targeted at DALL-E 3:</p><blockquote><strong>Original prompt:</strong> three college-aged people just got their chicken sandwiches from a food truck. They all have sandwiches in both hands and they’re happy about it</blockquote><blockquote><strong>Brand-injected prompt:</strong> Capture the joyous moment of three college-aged individuals receiving their delicious chicken sandwiches from a vibrant food truck. Each person is holding two sandwiches in their hands, showcasing their excitement. The background prominently features a green geometric logo with a floral pattern on the left side, and the text “Mt. Joy” in bold green letters on the right, all set against a clean white backdrop. The scene exudes happiness and youthful energy, perfectly encapsulating the spirit of Mt. Joy’s brand. Please take extra care to show Mt. Joy branding very prominently.</blockquote><p>I included randomization in the Slack demo to provide a more dynamic experience for users, for example randomizing the brand matching by match score. That addressed a previous issue in which Domino’s would be used for too many ads even though it had a similar score to other brands. Likewise I randomized between DALL-E 3 and Titan to provide variety. If I had more time I would’ve built a routing layer like <a href="https://unify.ai/">Unify.ai</a> to pick the best engine for each prompt. That said, in the web demo I disabled randomization to provide more predictability during development.</p><p>I’ll mention a couple quick engineering wins too:</p><ul><li>Slack Bolt with sockets was a great way to prototype; I just ran it from my laptop and could iterate very rapidly instead of needing to do a whole deployment to update.</li><li>txtai was great for easy in-memory vector search.</li></ul><h3>Challenges</h3><ul><li>DALL-E 3 API tends to remove brand info. From trial and error I learned that Microsoft Image Creator doesn’t have this problem even though it’s also using DALL-E 3. I didn’t find any tips for the DALL-E 3 API that gave results like Image Creator.</li><li>Titan rejects some prompts based on their content filter, though it’s tough to know when that’ll happen.</li><li>DALL-E 3 and Titan are trained on very different sorts of inputs. The ideal input for DALL-E 3 is long and descriptive, and can be up to 4000 chars. The ideal input for Titan is short and caption-like, and can be up to 512 chars.</li><li>Evaluation is subjective and tough. Maybe I should’ve tried gpt4o as judge? I had originally planned to use Slack emoji reactions for judging but I didn’t have enough in-Slack data for it to be useful.</li></ul><h3>Should’ve</h3><p>I wish I’d worked on evaluation earlier in development. I procrastinated about it because I didn’t like the idea of paying $1 of API fees for every little test. In retrospect, I should’ve started with a local image generation model from HuggingFace and iterated on that in an evaluation framework before iterating with the cloud API models.</p><p>In some of the generated images I suspected it might be simply copying an existing image, so I sometimes reverse image searched the results. I wish I’d built it into the application so that I could check more often though.</p><h3>Could this be a real industry project?</h3><p>To subsidize meme generation? It’s unlikely to work with current technology. I cherry-picked examples and I’d guess that I showed you the best 20%. Maybe it could work if you over-generate examples then use a multimodal model as a judge to select the branded ones. You might also need to cache responses to save costs. Even then, would REI be willing to spend real money if we misspell their name?</p><p>Could it succeed as a product to subsidize general-purpose image generation? I don’t think enough people are using image generation today to recoup the development cost. If I think back to the early days of Google and Youtube, they started off by building a great product with a large user base before scaling up their advertising. General image generation isn’t at that scale yet, and might never get there.</p><p>Also a real version of this might need:</p><ul><li>Need an image generator that’s DALL-E 3 quality but more reliable at branding (OpenAI and Microsoft have this, maybe others do too?)</li><li>Need to provide advertisers with control over their brand, like what types of prompts get their branding. I’m doubtful that just providing advertisers with a text field would be enough on its own.</li><li>Need to deal with prompts that aren’t monetizable, similar to how YouTube demonetizes certain content</li><li>Companies often want to advertise a particular product not just their overall brand so it’d need a much more extensive database not just of brands but their products along with data on how to target each one.</li></ul><p>I can imagine a Giphy-like product succeeding sometime in the future but probably not now. Alternatively if someone creates a “killer app” for ordinary consumers in the GenAI space, I imagine someone will try to include ads eventually. It wouldn’t surprise me if someone tries it with ChatGPT but the thought is too unsettling for me to prototype.</p><h3>The End</h3><p>Thanks for reading, and thanks again to Matt, Matt, and Mark for participating!</p><h3>Links</h3><ul><li><a href="https://github.com/ktrnka/branded-image-gen-service">The code</a></li><li><a href="https://drive.google.com/file/d/1-X2lDPDhcH6zjt7o5XpqxLk6aViH-MAJ/view?usp=sharing">Dump of the generated images and SQLite DB containing prompts/settings</a> (350mb): This is a dump of my local folders, which has all the local testing I did and most of the Slackbot results. Take a look over the code for the table/column names. The images are all plain files, but I goofed by saving the DALL-E ones as PNG instead of JPG so the download is bigger than I’d like.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fda70eb03ef1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Future Crap, Part 1]]></title>
            <link>https://medium.com/@keith.trnka/future-crap-part-1-373e607aef51?source=rss-3e4d2400adbe------2</link>
            <guid isPermaLink="false">https://medium.com/p/373e607aef51</guid>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[prompt-engineering]]></category>
            <dc:creator><![CDATA[Keith Trnka]]></dc:creator>
            <pubDate>Mon, 24 Jun 2024 15:15:10 GMT</pubDate>
            <atom:updated>2024-07-02T17:15:15.907Z</atom:updated>
            <content:encoded><![CDATA[<h4>Injecting ads into image generators</h4><p><em>Note: This is the silly fun post and </em><a href="https://medium.com/@keith.trnka/future-crap-part-2-fda70eb03ef1"><em>Part 2</em></a><em> is the technical post. </em><strong><em>This is purely a demonstration of technology and is not affiliated with any of the brands in the post.</em></strong></p><p>You know what sucks on the Internet? Ads everywhere! You know what generative AI doesn’t have yet? Ads everywhere!</p><p>This project takes your creations with image generators and jams ads into them! And not those sad overlays that you could ad-block, no! The ads are product placements inside the image, much like <a href="https://en.wikipedia.org/wiki/Heineken#Advertising">Heineken beer in a James Bond movie</a>.</p><p>You might say “but it doesn’t make sense for my prompt!” Let me address your concern with blatantly cherry-picked examples:</p><h4>An early experiment</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0DMm9386yT8bdZz0NVNkkA.jpeg" /><figcaption><strong>Engine:</strong> Microsoft Image Creator / DALL-E 3</figcaption></figure><p>I bet you didn’t expect branding for a surrealist prompt! Would Old Spice do this? I hope so.</p><p>Sadly I couldn’t find the exact prompt for this one so let’s move on if you can look away from the melty beard.</p><h4>Prompt: A painting of a serious-looking dog sitting behind an office desk reading reports</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*bnbDpoap1YJWXYR2FKgfwA.jpeg" /><figcaption><strong>Engine:</strong> Amazon Titan</figcaption></figure><p>Nice Microsoft Surface; good dog! I love the haunted look, as if they just worked all weekend only to have their project canceled in a memo on Monday.</p><h4><strong>Prompt:</strong> College girl studying at a desk listening to lofi hiphop beats with rain outside</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MUA7swkKkke6f3erRMumHw.png" /><figcaption><strong>Engine:</strong> OpenAI DALL-E 3</figcaption></figure><p>Where’s the lofi vibe? Apparently replaced with vague University of Washington branding! Or maybe University of Vashington?</p><h4><strong>Prompt:</strong> The sun has just come out again after a light rain on a trail that goes around a circular, shallow manmade lake. There are a few people walking and jogging on the path</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*natSL9AwvrkgftwdemO2qA.png" /><figcaption><strong>Engine:</strong> OpenAI DALL-E 3</figcaption></figure><p>So peaceful! Maybe I’ll find peace too if I buy a North Face windbreaker!</p><h4><strong>Prompt:</strong> a child’s crayon drawing of what mom’s work is like. The child’s mother is a product manager but the child doesn’t understand</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F3mpj-JzSWUvO6KYyOsQuw.png" /><figcaption><strong>Engine:</strong> OpenAI DALL-E 3</figcaption></figure><p>I get it kid, product management can feel like stepping on legos. I don’t know what sort of child draws this well but I’ll give them a pass because it’s heartwarming and legos are awesome.</p><h4><strong>Original prompt:</strong> a family of scientists doing chemistry experiments in their kitchen</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lmcLaCwBzliPdiYePqxeqw.jpeg" /><figcaption><strong>Engine:</strong> Amazon Titan</figcaption></figure><p>Future Crap decided this was an Ikea moment and I love it except it’s too subtle and I’m trying not to think too much about whether those are humans.</p><h4><strong>Prompt:</strong> a clock with bacon for hands</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7K-ATjwTiLCWReA-cS4m4Q.png" /><figcaption><strong>Engine:</strong> OpenAI DALL-E 3</figcaption></figure><p>It’s <em>so close</em> to Tim Horton’s…. so close! I feel a sudden desire to visit Canada and have coffee with bacon… which might lead me to Tim Horton’s.</p><h4><strong>Prompt:</strong> a man in his 20s is about to eat an ice cream cone the size of his head after running 20 miles</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IDTfjWFpl3max6nnIF16XA.jpeg" /><figcaption><strong>Engine:</strong> Amazon Titan</figcaption></figure><p>Where’s the rest of the ice cream?!? The Snickers logo is pretty good though!</p><h4><strong>Prompt:</strong> a historical volcanic barbecue</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t2MVIq15N9-KYNVGitRk3A.png" /><figcaption><strong>Engine:</strong> OpenAI DALL-E 3</figcaption></figure><p>I kinda want a Burger King Whopper so it’s working even though it may not be obvious that it’s Burger King. I’m also very curious about this SIGNETURE MENU… and I think DALL-E is trying to leak the modified prompt but it’s not great at spelling.</p><h4>SAME PROMPT, SLIGHTLY DIFFERENT ENGINE</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*ZpBLUslPi3N94zRlC1Xk7w.png" /><figcaption><strong>Engine:</strong> Microsoft Image Creator / DALL-E 3</figcaption></figure><p>This is the exact same prompt fed into Microsoft Image Creator! This is when I realized that it’s is doing something different with DALL-E 3 than the OpenAI API. Regardless, I’m hungry for burgers now so it’s working.</p><h4><strong>Prompt:</strong> a tech worker working at their computer next to a huge pyramid of fried chicken and an extra large soda</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zkfmtpMIiFKi8ZCUvIsScA.png" /><figcaption><strong>Engine:</strong> OpenAI DALL-E 3</figcaption></figure><p>Does McDonald’s make a human-sized pile of fried chicken? I’m not sure and I’m hungry so I gotta stop the food memes.</p><h4><strong>Prompt:</strong> a woman wearing a hoodie, sitting on a dock over the bay</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N61_5UivgBRmAkd9l7tfDw.jpeg" /><figcaption><strong>Engine:</strong> Amazon Titan</figcaption></figure><p>Looks like a good time for Starbucks!</p><h4><strong>Prompt:</strong> design album cover art for the song jingle hell</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1dhZrI1CIsbW_TDd1OMGQg.png" /><figcaption><strong>Engine:</strong> OpenAI DALL-E 3</figcaption></figure><p>This isn’t quite what I had in mind for a metal album. I hope Ikea’s really into <a href="https://en.wikipedia.org/wiki/Christopher_Lee#Music_career">Christopher Lee and heavy metal</a>!</p><h4><strong>Prompt:</strong> A serene lake during sunset with calm waters reflecting a cluster of trees on a small island. The horizon features a line of trees and buildings under a soft, pastel sky transitioning from light pink to pale blue.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*_KQJ4cKypcS2wGaaxjtSog.jpeg" /><figcaption><strong>Engine:</strong> Amazon Titan</figcaption></figure><p>I’m not sure REI would pay out if we misspell their name. Could we get partial credit maybe?</p><h4>Prompt: parents happily dropping their kids off at school</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*v_5HVnWkixtdC9Wm.jpg" /><figcaption><em>Engine:</em> Amazon Titan</figcaption></figure><p>Those backpacks are cool! I should check out the lego store. Or anything except wondering why that woman looks inhuman.</p><h4><strong>Prompt:</strong> a humanoid cat hipster barista is looking at you judgmentally while making your frappuccino</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*6OiC6zSBB9llEt85qSL1OA.jpeg" /><figcaption><strong>Engine:</strong> Amazon Titan</figcaption></figure><p>I’ll take a frap with a cat hat and extra disdain please!</p><h4><strong>Prompt:</strong> a sunset over elliot bay looking towards the olympics</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C434m3lVqfCPqXW_Hb4_Qg.png" /><figcaption><strong>Engine:</strong> OpenAI DALL-E 3</figcaption></figure><p>Not too shabby! If you aren’t familiar with the Seattle area, it’s pretty close but some details are off.</p><h3>A glimpse at how it works</h3><p>I can’t resist a few more blatantly cherry-picked examples, but this time I’ll show more detail about how it’s made.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DkuUCcYEzhZyMj-J.png" /></figure><ol><li>Original prompt: tourists toss french fries over the water and seagulls swoop and catch them out of the air</li><li>Brand selection: Doritos</li><li>Engine: OpenAI DALL-E 3</li><li>Prompt after brand-injection: Tourists eagerly toss Doritos chips over the water, their vibrant orange color standing out against the backdrop, attracting a flurry of seagulls that gracefully swoop down to catch them mid-air. The scene is a dynamic display of nature’s interaction with the irresistible and iconic Doritos chips, creating a playful and engaging moment for all to enjoy. Please take extra care to show Doritos branding very prominently.</li><li>DALL-E’s revision: Holidaymakers enthusiastically throw bright orange crisps over the sea, creating a striking contrast to the surrounding scenery. This act attracts a whirlwind of sea birds that gracefully dive down to snatch the crisps mid-air. The scene is a lively illustration of the interplay between nature and these tempting and well-recognized orange snacks, making a delightful, captivating spectacle for everyone. Please make sure that the snack’s brand is extremely noticeable and highlighted.</li></ol><p>DALL-E removed our Doritos?!? Also I don’t recommend zooming in too much…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oJugfAjKr1sYVpJ2.png" /></figure><ol><li>Original prompt: a humanoid cat hipster barista is looking at you judgmentally while making your frappuccino</li><li>Brand selection: Boss Coffee</li><li><em>Engine:</em> OpenAI DALL-E 3</li><li><em>Prompt after brand-injection:</em> Capture a quirky scene in a hipster cafe where a humanoid cat barista, with a sleek black and white aesthetic, is skillfully preparing a frappuccino. The barista’s gaze exudes a hint of judgment as they craft your drink with precision. The barista embodies the sleek and sophisticated look of a Can of Boss Black Flash Brew Coffee, with a stylish black and white outfit reminiscent of the brand’s color scheme. The setting should subtly showcase elements of the Boss Coffee label, such as the logo of a man’s face and the text “BOSS COFFEE” and “BOSS BLACK” in a modern Japanese-inspired font. Incorporate SUNTORY discreetly at the bottom of the scene for brand authenticity. Please take extra care to show Boss Coffee branding very prominently.</li><li>DALL-E’s rewrite: Picture a whimsical scene set in a modern, stylish cafe where a humanoid cat, who works as a barista, is meticulously creating a frappuccino. The barista, a Hispanic male, is characterized by his black and white attire, similar to the smooth monochromatic aesthetic of a chic coffee canister. His gaze is full of mild disapproval while he expertly prepares the drink. The cafe subtly embodies the branding elements articulating stylized representations of a man’s face and the words ‘Fine Quality Coffee’ in a contemporary, Japanese-influenced font style. The name ‘Suntory’ is subtly incorporated at the bottom of the scene to enhance the authenticity of the brand.</li></ol><p>DALL-E removed “Boss” but I can see the logo if I look at it just right!</p><h3>Honorable mentions</h3><h4>Prompt: how a future world where end-stage capitalism has run amok and AI rules everything, but it’s infused with ads. The people in the scene are mindless zombies, driven only by consumerism. Mega-corps are the new government</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZvRME1q0OEe_2rATrdkQeQ.png" /><figcaption><strong>Engine:</strong> OpenAI DALL-E 3</figcaption></figure><p>I can really feel the oppressive capitalism in this one. It was supposed to be branded with EA but DALL-E omitted my brand injection: “… Amidst this bleak scene, a sleek, stylized black and white logo featuring the letters EA enclosed within a thick black circle is prominently displayed across towering digital billboards, symbolizing the omnipresence of a dominant corporate entity…”</p><h4><strong>Prompt:</strong> a man walking through a field of wheat, enjoying the sun and slight breeze</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VBSrZoqxmBEHDlbLcWuZtw.jpeg" /><figcaption><strong>Engine:</strong> Amazon Titan</figcaption></figure><p>Future Crap tried to inject Patagonia and I can <em>almost </em>make out the logo.</p><h4><strong>Prompt:</strong> two fishermen walking down a dock in the bay looking at dark clouds on the horizon</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gb04bwz5X1hQfqpnicR8yw.png" /><figcaption><strong>Engine:</strong> OpenAI DALL-E 3</figcaption></figure><p>The Nikon camera straps are a nice touch, if a bit too subtle.</p><h3>Afterword</h3><p>I don’t think anyone should try to build this (except for laughs), and I’ll explain more in Part 2 why I don’t think it’s likely to work with today’s technology.</p><p>Big thanks to Matt, Matt, and Mark for playing around with this project! They contributed several of these prompts!</p><p>If you enjoyed this, you might also enjoy Janelle Shane’s <a href="https://www.aiweirdness.com/ai-versus-your-corporate-logo/">AI versus corporate logos</a>. You might also enjoy some of the posts on Reddit’s /r/dalle2 like <a href="https://www.reddit.com/r/dalle2/comments/1dkvxxt/marvel_product_placement/">Marvel Product Placement</a>.</p><h3>Read how it’s built in <a href="https://medium.com/@keith.trnka/future-crap-part-2-fda70eb03ef1"><strong>Part 2</strong></a>!</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=373e607aef51" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[On retrospectives]]></title>
            <link>https://medium.com/@keith.trnka/on-retrospectives-be5d096c154a?source=rss-3e4d2400adbe------2</link>
            <guid isPermaLink="false">https://medium.com/p/be5d096c154a</guid>
            <category><![CDATA[engineering-mangement]]></category>
            <category><![CDATA[retrospectives]]></category>
            <dc:creator><![CDATA[Keith Trnka]]></dc:creator>
            <pubDate>Mon, 08 Apr 2024 14:06:00 GMT</pubDate>
            <atom:updated>2024-04-08T14:06:00.873Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ve had a number of conversations about retrospectives over the past few months, and until now I didn’t have anything written that I could share.</p><p>This is written for leaders in software development, but I hope it’ll help others too.</p><p>Keep in mind that retrospectives are most effective in organizations that dedicate time and energy to learning and improving. If you don’t have that kind of support, I don’t think retrospectives will help you as much.</p><p>If you’re looking for a quicker read, I suggest <a href="https://sre.google/workbook/postmortem-culture/">Postmortem Culture: Learning from Failure</a> for incident retrospectives and <a href="https://www.notonlycode.org/effective-retrospective/">How to run an effective retrospective</a> for periodic retrospectives.</p><p>This post mainly describes my experience as Director of Data Science at 98point6. I was very fortunate to work under leaders that valued the long-term improvement of the team and the organization. I’ve also included some experiences from my time as a machine learning engineer at Singularity 6.</p><h4>Types of retros</h4><p>A retrospective is a review of how things have gone in the past, and a pondering about how to do better in the future. It can be done individually or as a group. It can be a formal meeting, formal document, or an informal conversation over coffee.</p><p>In the software industry there are different activities that I consider retrospectives:</p><ul><li>Team retrospectives, often periodically scheduled</li><li>Project retrospectives, which may cross team boundaries</li><li>Incident retrospectives, also called postmortems or outage retrospectives, that tend to happen after something bad happened</li></ul><p>I have to thank <a href="https://www.pagerduty.com/blog/postmortems-vs-retrospectives/">Postmortems vs. Retrospectives by PagerDuty</a> and <a href="https://www.parabol.co/blog/retrospectives-vs-post-mortems/">Post-mortems vs Retrospectives by Parabol</a> for inspiring me to discuss both the similarities and differences between these different types.</p><h3>Team retrospectives</h3><p>Team retrospectives are often scheduled periodically. Some teams run them at the end of monthly sprints, while other teams might run them a few times per year. They’re a time to get together and assess how well the team has been working and seek opportunities to improve.</p><h4>Things I’ve learned in team retros</h4><p>I’ll start with some examples of value I’ve gained from retros:</p><ul><li>Collaboration in machine learning is harder than I realized</li><li>Not everyone understands the importance of user needs when building software</li><li>There are many common, harmful behaviors in code reviews</li><li>Many slowdowns and bugs are associated with splitting code into multiple repos. For example, in some situations developers were submitting a pull request, reviewing, merging, and deploying a backend only to find that it didn’t work with the frontend.</li><li>I learned how noisy our alarms became over time, which was partly caused by adopting a deployment library that had default alarms not appropriate for our services</li><li>AWS is difficult for many engineers</li></ul><h4>Changes we made due to team retros</h4><p>These are some examples of changes we made after learning more about the problems we faced:</p><ul><li>I put more effort into mentoring my team in how to use user feedback and data to build more successful features and products</li><li>A healthy culture of code reviews is possible, but it takes deliberate effort and support from leadership. Examples:</li><li>I shared my goals for our code review culture both verbally and in writing. It’s more about leveling-up the team than it is about blocking “bad” code. I would also do some code reviews and I’d be explicit about when concerns were blocking approval (like patient safety issues) or when they were non-blocking suggestions to level-up.</li><li>Sometimes large PRs happen despite our intentions to keep them small. When that happens I redirect the review to be a conversation about the design of the change first before diving into code. Big PRs are still hard but that gets things moving and focuses the reviewer on the big picture.</li><li>We put deliberate effort into adjusting our alarms and reduced false-alarms significantly while also adding a couple alarms for the biggest safety risks</li><li>When hiring additional engineers, I made AWS skills a priority</li><li>As an individual contributor, when I see that certain kinds of development requires multiple sequential PRs across repos I advocate for merging repos</li></ul><h4>What’s worked well, and what hasn’t worked well</h4><p>I like the “what’s worked well and what hasn’t worked well” framework in retros, and I’ll use that framework in a sort of retro about retros.</p><p><strong>Things that worked well</strong></p><ul><li>When I was new to leading retros, I asked an experienced third party to lead the retro and afterwards we discussed further so that I could learn</li><li>I recorded the retro meetings so that others can review it later as needed. This helped when not everyone could attend. It also helped in situations where a deeper cross-org issue came up. Be careful though: It can affect what people are willing to say.</li><li>We’ve had better conversations when we discuss the problems before discussing solutions</li><li>Retrium worked well for us because it allowed a smooth process of: Everyone write things to talk about, we group them all, we vote, then discuss the groups in vote order</li><li>Things that have worked well as the moderator/leader:</li><li>When I set a theme for the team retro, the team was more engaged.</li><li>It helped to start the retro meeting with a brief 1–2 minute reminder of the purpose of the retro. In that quick overview, I’d share what we will talk about, what we’ll try not to talk about, my role in the meeting, and so on.</li><li>I made sure we heard from everyone, and also made sure we all understood any issues in enough depth. Put simply, my role was to get people talking in the right direction and to listen.</li><li>Talking begets talking, so I tried to make sure everyone speaks at least once. This helped to survey the breadth of different issues.</li><li>It’s important to balance positive and negative sentiment. If it’s all negative that can demotivate people. If it’s all positive that usually doesn’t lead to improvement. “What’s going well” or “what’s not going well” is a simple framework that ensures we discuss both.</li></ul><p><strong>Red flags and antipatterns</strong></p><ul><li>Nothing’s changed since last time: This could indicate any number of deeper problems, ranging from issues in leading the retro to issues in culture or incentives. Or it could be as simple as not having enough time since the last retro.</li><li>A mad rush to discuss action items in the last 5 minutes of the meeting, and then the action items are not really actionable.</li><li>One or two people dominate the conversation. This could be the result of many different things, for example unmet needs that come up or leaders that are new to leading retros.</li></ul><h4>Open challenges</h4><p>These are some examples of things I haven’t yet figured out, or that don’t feel smooth yet.</p><ul><li>It’s tough to limit bias in issues that cross team boundaries when they come up in a team retro.</li><li>If you prioritize by voting, certain types of issues can be systematically missed, for example advanced AWS configuration issues. It might be valuable to discuss but often won’t be selected if you’re only prioritizing by votes. I recommend using your judgment to override the votes as needed in special cases like this.</li><li>Sometimes it’s tough to quantify a problem. For instance, if build times take 60 minutes that’s definitely a problem but it’s tough to compare against other things. It’s good to work on some of these hard-to-quantify issues even if you can’t measure them.</li></ul><h3>Briefly mentioned: Project retros</h3><p>I’ve had fewer experiences with cross-team project retrospectives but I’ve found them useful. For short projects there may not be enough time to really assess how the teams are working. For longer projects it’s best to have retrospectives partway through the project so that you can improve the project.</p><p>One example was a project that was going slowly due to long round-trip time between teams with respect to IAM permissions for Sagemaker. When we talked about it in a retro, this led to the development of a test script that the infra engineer could use when iterating. That helped us reduce the number of round-trips between people on different work schedules.</p><p>The main challenge I’ve faced is that the projects that need retros the most are usually projects with the least predictable timelines. I’m optimistic that it’d help to schedule retros about a month after the project starts regardless of the expected project duration. If the project is still running, then you have a mid-project retro. If the project hasn’t even really started yet, it might be valuable for leads to discuss planning and see if there’s anything to improve. If the project is done already, great!</p><h3>Incident retros, aka postmortems or outage retros</h3><p>Sometimes our software stops working as intended and it’s unavailable for our users. In an industry like healthcare, an outage can harm patients’ health. In commerce, an outage can mean a loss of revenue. We often call an outage an incident.</p><p>A degraded user experience might be classified as an incident as well, for example in healthcare our software may stop working with certain pharmacies but that won’t affect all patients.</p><p>Responding to incidents can be personally disruptive and frustrating for anyone on-call. Before going on, if you’ve been on-call, I appreciate you. Thank you.</p><p>Once we’ve restored service for our users, it’s common to review what happened so that we can learn from it. What we learn may help us prevent similar disruptions for our users, or it may help us improve our incident response to be less disruptive for the team. We call that review an incident retro, postmortem, or outage retro.</p><p>I’ve learned a lot from reading incident retros and I appreciate when people take the time to share their findings. I’ve also learned by leading my team to write them, and writing them myself.</p><h4>Things I’ve learned from incident retros</h4><ul><li>Almost all incidents were caused by code deployment. Code deployment happens when people are working so very few of them happen overnight. Some were caused by an unreliable external system and those issues could happen overnight.</li><li>It’s very hard to automatically detect situations where a small percent of the user base has a degraded experience.</li><li>When we don’t detect an issue right away, it’s often harder to debug and it slightly increases the chance that it’s detected at night.</li><li>Many incidents are caused by code that is <em>harder to test</em>, such as authentication, infrastructure, or cross-repo changes.</li><li>Employee turnover reduces the amount of complexity a team can manage effectively, even if the team size stays the same and has the same level of seniority.</li><li>We often reach for a technical mitigation, but there are sometimes much faster non-technical mitigations like sending a message to users.</li></ul><h4>Changes I’ve seen from incident retros</h4><ul><li>Increased automated testing</li><li>Policy changes with feature flags</li><li>Changes in when we deploy code</li><li>Changes in third-party vendors</li><li>Changes to alarms</li></ul><p>Also, I’ve become more thorough in design review about authentication, cross-repo development, and pub/sub systems.</p><h4>What’s worked well, and what hasn’t worked well</h4><p>Worked well</p><ul><li>Incident retro documents, especially when shared broadly. It turns the incident into a learning opportunity for the entire organization.</li><li>It’s helpful to time-box the efforts on the incident retro document or else it can balloon into a large effort.</li><li>Sharing the retro document back to the incident channel provides a feeling of conclusion and progress from a stressful experience.</li><li>It’s good to write down the incident timeline while it’s still fresh in mind. Some people even write it down as it happens.</li><li>It’s helpful to approach the incident with curiosity, rather than assessing blame.</li></ul><p>On the incident timeline specifically:</p><ul><li>There’s often a delay between when the first user is affected and when engineers are aware of the incident. In some cases, that delay can be weeks. In other cases, it can be minutes. It’s good to understand how impactful that delay is, so that we can decide how much time to spend on investigating the delay itself.</li><li>In other cases, the team may become aware of an incident quickly after it begins, but may incorrectly assess the problem for a period of time and it may help us identify a communication issue to work on</li><li>If there was a “bandaid” response followed by a full bugfix later, it’s helpful to see that. Or if the team decided to ship a full bugfix, it can be useful to discuss whether a faster mitigation in the meantime would have improved our response.</li></ul><p>Hasn’t worked well</p><ul><li>Sometimes I’ve seen people push for a retro document too soon, before the first-responders have recovered from the incident response. In those situations the first responders delay or don’t do the work, and experience additional stress beyond the incident stress</li></ul><p>These are some antipatterns or red flags I’ve seen:</p><ul><li>Ineffective incident retros that don’t lead to learning or improvements</li><li>Time-consuming incident retros that drag on for a week or longer</li></ul><h4>Open challenges</h4><ul><li>Sometimes the effort to get good data is major work. Whenever possible I try to get a “good enough” answer.</li><li>If stakeholder communication was lacking in some way, it’d be nice to discuss that in a retro but the retro members may not even be aware of the problem. If I’m running an incident, when possible I follow up with stakeholders afterwards to solicit feedback.</li></ul><h3>The bigger picture: Productivity and quality</h3><p>I like to consider the team’s total output over the next 2 years or so, where output means contribution to cost, revenue, or other key business outcomes. If we’re thinking about a 2 year timeline, it’s worthwhile to mentor, learn, and grow now so that we can deliver more in the future. The time frame also helps with prioritization: If an improvement would take 1 week to implement (optimistically) and it would save a few hours of time over the next 2 years, it’s probably not worth it. I also find that perspective helps when thinking about the time I put into hiring efforts: It’s absolutely worth the extra up-front effort in hiring to speed up the team over the next 2 years.</p><p>Through reading many incident retros and systems designs, I learned much more about overall quality and speed in software development. In many situations, we focused on the prevention of defects by comprehensive testing, whether human or automated. We sometimes prevented defects in code review too. Likewise we prevented defects in production by trying out our software in pre-prediction environments.</p><p>An orthogonal approach is to quickly mitigate defects when you detect them. That takes support in both detection and mitigation. In detecting defects, these efforts included automated alarms, operational dashboards, and ways for users to escalate issues. Detecting them sometimes involved analytics dashboards too. Mitigation efforts usually meant reverting a change or changing a feature flag.</p><p>I’ve come to believe that each project has a different return on investment between prevention vs detection and mitigation. For database schema changes, prevention is often more important because it’s very costly to revert. Likewise, if reverting a deployment takes an hour and you’re working on a critical service, prevention becomes more important.</p><p>That said, there are projects that are very hard to test thoroughly and realistically, such as server autoscaling. In those situations I focus more on monitoring and rollback efforts.</p><h4>Double diamond</h4><p>When leading retros, I like to use <a href="https://en.wikipedia.org/wiki/Double_Diamond_%28design_process_model%29">the double diamond approach from user experience design</a>:</p><p>Discuss the problems (or opportunities!)</p><ul><li>Breadth: Hear from everyone, all the challenges. Do not shut down ideas.</li><li>Depth: Voting is a simple way to prioritize. Looking at data is another way. Discuss those challenges in depth.</li></ul><p>Discuss potential solutions</p><ul><li>Breadth: Hear from everyone, all the ideas. Do not shut down ideas.</li><li>Depth: Prioritize and dive deep on those ideas. Think about the expected benefit for users and the expected implementation cost.</li></ul><p>I find that it’s helpful to have separate meetings to discuss problems vs solutions. If they’re discussed in the same meeting it’s too easy to overrun the time for the first step and end with half-baked solutions.</p><p>When I was forced to choose between the two, I spent the full time understanding the problem. If the team is senior enough and has sufficient autonomy, once they understand the problem space they’ll make it better. They just need a little help understanding the problem space.</p><h3>Additional reading</h3><p>I did a brief literature review while writing this, and I’m sharing what I’ve seen along with a little commentary on each.</p><p>From Google SRE:</p><ul><li><a href="https://sre.google/sre-book/postmortem-culture/">Google SRE — Postmortem Culture: Learning from Failure</a>: I love that they emphasize postmortems as learning.</li><li><a href="https://sre.google/sre-book/example-postmortem/">Example Postmortem</a></li><li><a href="https://sre.google/workbook/postmortem-culture/">Chapter 10 — Postmortem Culture: Learning from Failure, Google SRE Book</a>: Great read, including a comparison of two retrospectives (one good, one bad).</li></ul><p>From PagerDuty</p><ul><li><a href="https://response.pagerduty.com/">PagerDuty Incident Response Documentation</a>: Good links under “after incident”</li><li><a href="https://www.youtube.com/watch?v=TqaFT-0cY7U">Three analytical traps in accident investigation</a>: I agree with the point on counterfactual traps though I’m looking for a plain way to phrase it.</li><li><a href="https://response.pagerduty.com/resources/anti_patterns/#getting-everyone-on-the-call">Anti-Patterns — PagerDuty Incident Response Documentation</a>: This has an excellent example of a retrospective in public. What we did, what happened, what we changed, and the impact of the change.</li><li><a href="https://response.pagerduty.com/after/effective_post_mortems/">Effective Postmortems — PagerDuty Incident Response Documentation</a>: Good quick overview. They’re particular about when to use the term “outage” which seems motivated by customer communication. Communication to stakeholders and customers is good to keep in mind, though I prefer statements like “10% of customers have degraded service.” It’d be even better to be more specific about the degradation.</li><li><a href="https://retrospectives.pagerduty.com/getting_started/">Getting Started — PagerDuty Retrospectives Documentation</a>: I agree that the facilitator should generally not express opinions.</li><li><a href="https://retrospectives.pagerduty.com/planning/">Planning The Retrospective — PagerDuty Retrospectives Documentation</a>: I agree on the use of a timer to make sure each topic is covered, and setting the agenda for the first few minutes. I don’t like the example agenda though; starting with metrics can anchor the entire conversation too much on what’s easy to measure, not necessarily what’s most important. Also I prefer to have the “good vibes” be a more key part of the retro itself rather than the ending.</li><li><a href="https://retrospectives.pagerduty.com/during/">During The Retrospective — PagerDuty Retrospectives Documentation</a>: I agree with using voting to help prioritize and converge.</li></ul><p><a href="https://extfiles.etsy.com/DebriefingFacilitationGuide.pdf">Debriefing Facilitation Guide</a> (Etsy): This is a great read. Highlights:</p><ul><li>This is absolutely worth reading if you’re a facilitator because it teaches about how to lead the group.</li><li>“The problem comes when the pressure to fix outweighs the pressure to learn” 1000% agree</li><li>“You are like a traffic conductor, holding up a stop sign to things like blame and judgment, while giving behaviors like genuine, thoughtful inquiry and active listening the green light. Instead of traffic signs or flares, however, your tools are the types of questions you ask, and when you ask them.”</li></ul><p>Others</p><ul><li><a href="https://status.heroku.com/incidents/151">Incident 151 | Heroku Status</a>: They’re clear about the severity of the outage and provide examples to understand it. I especially like the “Our Response” section and their three major lessons under Remediation.</li><li><a href="https://fractio.nl/2015/10/30/blame-language-sharing/">Blame. Language. Sharing. | Fractional by Lindsay Holmwood</a>: The section on hindsight bias is useful, especially for junior engineers. I especially like running premortems with the predictions written down, then checking the predictions later so that we can learn to anticipate the future better.</li><li><a href="https://www.kitchensoap.com/2014/11/14/the-infinite-hows-or-the-dangers-of-the-five-whys/">Kitchen Soap — The Infinite Hows (or, the Dangers Of The Five Whys)</a>: I agree that multiple factors always contribute to a problem, though I didn’t interpret “The Five Whys” in the way they did.</li><li><a href="https://snafucatchers.github.io/">STELLA report</a>: Great quote: “Postmortems are not magic. They can be done well. They can also be done badly” YES</li><li><a href="https://www.notonlycode.org/effective-retrospective/">How to run an effective retrospective</a>: I love this one, and I might not have written my post if it had been longer.</li><li><a href="https://www.blameless.com/blog/improve-postmortem-with-sre-steve-mcghee">Improving Postmortem Practices with Veteran Google SRE, Steve McGhee</a>: Lots of great content here. The commentary on including names is unique and valuable.</li><li><a href="https://agilemanifesto.org/">Manifesto for Agile Software Development</a>: They put it simply: “At regular intervals, the team reflects on how to become more effective, then tunes and adjusts its behavior accordingly.”</li></ul><p>Collections of links</p><ul><li><a href="https://github.com/dastergon/postmortem-templates">A collection of postmortem templates</a></li><li><a href="https://github.com/danluu/post-mortems">danluu/post-mortems: A collection of postmortems</a></li><li><a href="https://github.com/LappleApple/awesome-leading-and-managing/blob/master/Postmortems-Retrospectives.md">awesome-leading-and-managing/Postmortems-Retrospectives.md</a>: Great collection</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be5d096c154a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MLOps repo walkthrough]]></title>
            <link>https://medium.com/@keith.trnka/mlops-repo-walkthrough-90c7bd275f53?source=rss-3e4d2400adbe------2</link>
            <guid isPermaLink="false">https://medium.com/p/90c7bd275f53</guid>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Keith Trnka]]></dc:creator>
            <pubDate>Mon, 27 Feb 2023 13:49:10 GMT</pubDate>
            <atom:updated>2023-02-27T13:49:10.427Z</atom:updated>
            <content:encoded><![CDATA[<p>There’s a big difference between building a machine learning model that works on your computer, and making that model available for others to use. If implemented poorly, your users will be frustrated that your software isn’t reliable. And it can take months to implement it well!</p><p><a href="https://medium.com/@keith.trnka/mlops-design-principles-e30cc40442a1">My previous article shared the principles I’ve learned over the years</a>. This one walks through example code and critiques the approach. When I started deploying machine learning models into web services I found the complexity bewildering, and I hope this walkthrough will help readers in similar situations.</p><p>I built a series of prototypes to explore different tools and ideas in MLOps for a basic text classifier. This post will focus on the most recent prototype. It has automated training, testing, and deployment of models to a web service with AWS Lambda.</p><p>I limited the number of ML-specific tools for two reasons: 1) I wanted to use similar infrastructure to traditional software projects and 2) at work it was often easier to meet compliance needs this way.</p><p><em>Side note: You may notice that some of these repos are a couple years old. Originally I did these just for myself. Over the years I’ve found that I’ve often used them as examples for others and that’s motivated me to finally write it up.</em></p><h3>The basics</h3><p>I sometimes miss the old days when you’d host your code on a server under a desk somewhere! In those days, getting our code or models on a server just meant copying files and restarting the web daemon.</p><p>There are many issues with that approach though. These are a few of those problems:</p><ul><li>It means we’ll need to spend much more of our time just managing servers, like applying security patches, ensuring that the internet and power don’t go out, or fixing it when a hardware component breaks.</li><li>The process is prone to mistakes and bugs, such as code that works on your computer but not the server. Or you might forget to run tests.</li><li>The under-desk service can only handle so many requests per second. If your site becomes suddenly popular it may not be able to keep up with the surge of users.</li></ul><p>Modern tools are designed to address these problems, but they can make it more difficult to learn a new code base.</p><h3>Deploying models to Lambda</h3><p><a href="https://github.com/ktrnka/mlops_example_lambda">This repo</a> has training and serving for a news classification scikit-learn model but it should work for PyTorch and other libraries.</p><p>Let’s say hypothetically that we’re building a backend service for Medium to recommend appropriate categories for new posts. The Medium frontend will send the text of the article to our backend and receive the predicted category.</p><p>As I go through the repo I’ll summarize terminology at the end of each section.</p><h4>API Gateway and Lambda</h4><p>The HTTP request is received by API gateway and forwarded to Lambda. If there’s a Lambda worker available, it forwards the request to the worker. If there isn’t, it starts a new worker which will load the code, load the model, and execute the request. If it takes more than 30 seconds to load the code and model, the request will fail but eventually it’ll boot and then requests will work.</p><p>For testing I used a POST request with a simple payload like this:</p><pre>{<br>    &quot;text&quot;: &quot;The Seattle Seahawks crushed the Cleveland Browns on Thursday 52-7&quot;<br>}</pre><p>API gateway receives the request and calls our Lambda handler with request info in the parameters.</p><p>In the Lambda code, API gateway sends this information in two dicts <em>event</em> and <em>context. </em>From serving/app/app.py:</p><pre>def lambda_handler(event, context):<br>    request_body = json.loads(event[&quot;body&quot;])<br>    prediction = model.predict([request_body[&quot;text&quot;]])[0]<br><br>    return {<br>        &quot;statusCode&quot;: 200,<br>        &quot;body&quot;: json.dumps({<br>            &quot;response&quot;: prediction,<br>            &quot;request&quot;: request_body<br>        })<br>    }</pre><p>API gateway sends the POST request body in event[“body”] as a plain string so we need to parse the JSON in it. Then we run the text field through the model. Note that we need to make it into a list of inputs (with one element) and then take the first prediction from the output. That’s because scikit-learn predict methods are designed for batches of data. Then API gateway needs the response in a particular shape dict including the HTTP status code (200). Out of habit, I like to also return the request data to make debugging easier.</p><p><strong>New terminology</strong></p><ul><li><a href="https://aws.amazon.com/lambda/">AWS Lambda</a>: This runs our code on a server and handles scaling up the number of workers automatically.</li><li><a href="https://aws.amazon.com/api-gateway/">AWS API Gateway</a>: This serves as a bridge between our Lambda and requests coming from the Internet.</li><li>HTTP POST: This is the <a href="https://www.restapitutorial.com/lessons/httpmethods.html">HTTP method</a> that we’re using. Although GET would be a more semantically-appropriate method, sending JSON generally isn’t supported with GET. POST is more common in my experience because the input data structure is often complex.</li></ul><h4>Docker and Python, called by Lambda</h4><p>From serving/app/Dockerfile:</p><pre>CMD [&quot;app.lambda_handler&quot;]</pre><p>This is the last line of the Dockerfile, and it tells Lambda to call the lambda_handler function in app.py<em>.</em></p><p>When the Lambda starts, it imports the app.py file which causes everything outside of a function to be run, such as loading the model in our case. With Lambdas we call this a cold start. Then it’s available until the worker is shut down. The model is baked into the same Docker image as the code and loaded just like any other file. The Docker image is built and deployed from Github Actions when code is merged to main that changes anything in the <em>serving</em> folder. Likewise, the configuration of API gateway and Lambda can be updated at the same time. One of the files under <em>serving</em> is the model file itself, which is stored using <a href="https://dvc.org/">data version control (DVC)</a>. If the model changes when merging to <em>main</em>, the Docker image will be rebuilt and redeployed with the new model.</p><p>Here’s where the model is loaded in serving/app/app.py with timing and metrics omitted:</p><pre>def load_model():<br>    ...<br>    model_path = os.path.join(os.path.dirname(__file__), &quot;data/model.joblib.gz&quot;, )<br>    model = joblib.load(model_path)<br><br>    ...<br><br>    return model<br><br>model = load_model()</pre><p>All we’re doing is calling joblib.load on the file path. This works because the model was saved with joblib and because the serving code has all the dependencies needed for the model from scikit-learn.</p><p>The first line is making sure that the file path is relative to app.py, not relative to where app.py is being run from, because I don’t know if Lambda makes that consistent. I do that out of habit because I’ve been burned in the past when code was run from an unexpected directory.</p><p>That model file is baked into the Docker image in serving/app/Dockerfile:</p><pre>COPY data ./data</pre><p>It’s just copying the serving/app/data folder into the Docker image from the machine that’s building the Docker image. If for some reason we needed another model, we’d just put it in that folder and it’d be available inside of Docker too.</p><p><strong>New terms</strong></p><ul><li>Cold start: When there are no Lambda workers immediately available, Lambda must start one up.</li><li><a href="https://www.docker.com/">Docker</a>: Docker is a way of packaging code, data, and dependencies together in a way that can be run the same way on any computer.</li><li><a href="https://dvc.org/">Data Version Control (DVC)</a>: I use DVC to version large files such as models, because git doesn’t work well with large files.</li><li><a href="https://github.com/features/actions">Github Actions</a>: Github that will run our code on their servers for a short time, triggered by changes in Github or on a timer. It’s free for small-scale usage.</li><li>main branch: In Github development, it’s common to put the current version of code in a branch named “main” and create other branches while writing new code.</li><li>merged: When changes from one git branch are included into another branch. In this case, I’m talking about merging code from a development branch into the main branch.</li></ul><p><strong>Additional reading</strong></p><ul><li><a href="https://aws.amazon.com/blogs/compute/operating-lambda-performance-optimization-part-1/">Operating Lambda: Performance optimization — Part 1 (AWS)</a>: This covers cold starts and how to address them.</li><li><a href="https://docs.docker.com/get-started/overview/">Docker overview (Docker)</a></li><li><a href="https://aws.amazon.com/docker/">What is Docker? (AWS)</a></li></ul><h4>Building and deploying with CDK from Github Actions</h4><p>The Docker image is built and uploaded to AWS Elastic Container Registry (ECR) in CDK in serving/deployment/stacks/lambda_service.py:</p><pre>handler = lambda_.DockerImageFunction(<br>    self,<br>    &quot;ExampleTextClassifierHandler&quot;,<br>    code=lambda_.DockerImageCode.from_image_asset(&quot;../app&quot;),<br>    timeout=cdk.Duration.seconds(60),<br>    memory_size=3008<br>)</pre><p>The <em>from_image_asset</em> function builds the Docker image for us, which takes as a parameter a directory containing the <em>Dockerfile</em> you want to build. I’m setting the memory size to 3 GB which is probably more than strictly needed but it’ll help with latency because Lambda scales the CPU with more RAM. The 60-second timeout is at the Lambda layer. Keep in mind that API gateway has an <em>independent timeout</em> with a maximum of 30 seconds.</p><p>The Docker image is necessary with Lambda due to the model size and the Python dependency size. Otherwise I would’ve used Lambda’s zip-file deployment which is faster.</p><p>CDK is a framework for infrastructure as code (IaC). This means that we’re defining our AWS configuration in code. It helps us standardize configuration and deployments which helps reduce accidents. Because it’s stored in the repo, it also means that we can use the pull request process to have peer review for our configuration. It also means that we’re updating our service code and infrastructure at the same time, so we can bundle together a new model with increased memory for example. And it also means that we can revert configuration changes more easily. Also, as one final benefit, CDK is implemented so that most deployments are done with little or no downtime.</p><p>The CDK stack is run from .github/workflows/deploy_service.yml:</p><pre>    - run: cdk deploy --require-approval never<br>      env:<br>        AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}<br>        AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}<br>        AWS_DEFAULT_REGION: us-west-2</pre><p>This runs <em>cdk deploy. </em>We have to turn off interactive approval questions otherwise it’ll hang. The other parts are setting environment variables for the AWS IAM user, copied from the Github Actions Secrets set on this repo (I set those manually). Then when CDK creates your API gateway it’ll show the auto-generated URL in Github Actions.</p><p>Further up in deploy_service.yaml, we install DVC and fetch the model:</p><pre>    - run: pip install dvc[s3]<br>    - run: dvc pull<br>      env:<br>        AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}<br>        AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}</pre><p>This also needs AWS credentials to read from the S3 bucket.</p><p>At the very top of the file, we can see when the Github Action workflow is triggered:</p><pre>on:<br>  push:<br>    branches:<br>      - main<br>    paths:<br>    - &#39;serving/**&#39;<br>    - &#39;.github/workflows/deploy_service.yml&#39;</pre><p>This runs the deploy_service.yaml action when <em>main </em>is updated (which happens on PR merge) AND when anything under serving/ is changed, or deploy_service.yaml itself is changed.</p><p><strong>New terms</strong></p><ul><li><a href="https://aws.amazon.com/ecr/">AWS Elastic Container Registry (ECR)</a>: The place to upload Docker images in AWS to be used in Lambda and other AWS services.</li><li>Infrastructure as code (IaC): Defining your infrastructure with code rather than clicking buttons in a user interface.</li><li><a href="https://aws.amazon.com/cdk/">AWS Cloud Development Kit (CDK)</a>: AWS tools and libraries for infrastructure as code that can be defined in Javascript or Python.</li><li><a href="https://aws.amazon.com/s3/">AWS S3</a>: File storage in AWS.</li><li><a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users.html">AWS IAM user</a>: An account for a computer or person that can take action in your AWS account according to the associated permissions. Typically accessed via an access key and secret. The access key and secret are analogous to a username and password but for programmatic access.</li><li><a href="https://docs.github.com/en/actions/security-guides/encrypted-secrets">Github Actions Secrets</a>: Sensitive configuration that is stored on Github associated with a repo, and available to the Github Action, such as an access key or password.</li><li>Github Action workflow: A series of steps for Github Actions to run, associated with a trigger like a branch change. There’s one yaml file per workflow.</li><li><a href="https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests">Pull request (PR)</a>: In Github, it’s common to do development on a new branch, then submit a pull request (PR) which is a request to merge the code into another branch (typically main). It’s common for a peer to review the modified code in the PR before approving or requesting changes. It’s also common for companies to restrict their Github repos so that pull requests cannot be merged until someone has approved it.</li></ul><p><strong>Additional reading</strong></p><ul><li><a href="https://spacelift.io/blog/business-benefits-of-iac">Business Benefits of Infrastructure as Code (Spacelift, 2021)</a></li><li><a href="https://www.simplilearn.com/tutorials/aws-tutorial/aws-iam">AWS IAM: Working, Components, and Features Explained (simplilearn, 2022)</a></li></ul><h4>Automated service testing run from Github Actions</h4><p>We don’t want to deploy bad code, so we also have automated testing.</p><p>The tests I have are very basic: 1) Test that the endpoint can run without crashing 2) Test that the endpoint crashes as expected if the input text is missing. Those are in serving/tests/test_lambda_handler.py:</p><pre>class BasicTests(unittest.TestCase):<br>    def test_basic_path(self):<br>        lambda_handler({&quot;body&quot;: json.dumps({&quot;text&quot;: &quot;example input&quot;})}, None)<br><br>    def test_crash(self):<br>        self.assertRaises(BaseException, lambda_handler, {&quot;body&quot;: json.dumps({&quot;not_the_right_one&quot;: &quot;example input&quot;})}, None)</pre><p>In these tests I’m calling the lambda_handler directly without the <em>context</em> set, because the function doesn’t use it anyway.</p><p>They’re triggered from .github/workflows/test_service.yml:</p><pre>      - name: Run tests<br>        run: make test-service</pre><p>“make test-service” is defined in Makefile at the root of the repo:</p><pre>test-service:<br>   PYTHONPATH=serving/app/ python serving/tests/test_lambda_handler.py</pre><p>This just runs the python command to run the tests and ensures that the app code can be imported into the test code. It’s not strictly needed to have a Makefile rule for it, but I like to do that so that I’m running the exact same test command everywhere: Both in Github Actions for automated testing and also on my computer for local testing.</p><p>The Github Action is triggered at the top of test_service.yml:</p><pre>on:<br>  push:<br>    branches-ignore:<br>      - main<br>    paths:<br>    - &#39;serving/**&#39;<br>    - &#39;.github/workflows/test_service.yml&#39;</pre><p>This translates to “run this action anytime code is pushed to a branch except main, that has a change under serving or a chance to test_service.yml”. This will run on pull requests and also non-PR branches. Github is configured so that if the tests fail, it’ll block any PRs for that branch.</p><p>Tests are run if anything under <em>serving</em> changes in a pull request. That includes changes to the model file!</p><h4>Re-training the model from Github Actions</h4><p>Now let’s look at how the model is trained. The key parts of training are in training/src/main.py:</p><pre>model = make_pipeline(<br>    TfidfVectorizer(min_df=30, ngram_range=(1, 2), sublinear_tf=True),<br>    LogisticRegressionCV()<br>)<br><br>model.fit(training_data.data, training_data.target)<br><br>joblib.dump(model, os.path.join(args.output_dir, &quot;model.joblib.gz&quot;), compress=9)</pre><p>This is a bigram model using logistic regression with cross-validation to optimize the regularization weight. The min_df setting ignores infrequent ngrams which helps us keep the model small-ish without losing much accuracy. Sublinear_tf reduces the impact of repetitions of the same ngram, and I find that makes models slightly more robust against weird input.</p><p>I’m using the make_pipeline helper from scikit-learn to build the Pipeline object. I find that scikit-learn pipelines 1) make loading and saving easier 2) make hyperparameter tuning more effective 3) reduce accidental leaks of testing data into training.</p><p>If you look at main.py you’ll also see evaluation of the model and comparison against a baseline as well.</p><p>main.py is called from the Makefile from a DVC command:</p><pre>train:<br>   dvc repro train</pre><p>As before, I like to use Makefile to ensure that I’m running the same commands on my local machine and on the server. In this example, it’s calling DVC to reproduce the “train” pipeline, which is defined in dvc.yaml:</p><pre>stages:<br>  train:<br>    cmd: python training/src/main.py serving/app/data/ serving/app/requirements.txt<br>    deps:<br>    - training/<br>    outs:<br>    - serving/app/data/model.joblib.gz<br>    metrics:<br>    - serving/app/data/metrics.json</pre><p>This is the <a href="https://dvc.org/doc/start/data-management/data-pipelines">pipeline feature of DVC</a> and it’s similar to <em>make</em> except that it also automatically runs <em>dvc add</em> on our output files to ensure that they’re pushed to S3 on <em>dvc push</em>. The metrics part saves metrics in the specified file and the repro command will show the updated values to us.</p><p>Training is triggered from Github Actions in .github/workflows/train_model.yml:</p><pre># build when a branch other than main changes training or this file:<br>on:<br>  push:<br>    branches-ignore:<br>      - main<br>    paths:<br>    - &#39;training/**&#39;<br>    - &#39;.github/workflows/train_model.yml&#39;<br><br>jobs:<br>  train:<br>    runs-on: ubuntu-latest<br>    steps:<br>      # ... for full steps see github ...<br>      # train the model<br>      - name: Train model<br>        run: make train<br>      # run the web service tests to make sure it still works!<br>      - run: pip install -r serving/app/requirements.txt<br>      - name: Run web service tests<br>        run: make test-service<br>      # commit the model, which needs the IAM user to access S3 on dvc push<br>      - name: Commit model<br>        # email address from https://github.community/t/github-actions-bot-email-address/17204/5<br>        run: |<br>          git config --local user.email &quot;41898282+github-actions[bot]@users.noreply.github.com&quot;<br>          git config --local user.name &quot;github-actions[bot]&quot;<br>          git commit -am &quot;Automated model build&quot;<br>          dvc push<br>          git push<br>        env:<br>          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}<br>          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}</pre><p>In this example I commented inline and cut some boilerplate code. I’m running the web service tests <em>before</em> committing the model to the repo because 1) This action can’t trigger the test_service action and 2) I don’t want to commit models that fail the tests.</p><h4>Configuring AWS for DVC and Github Actions</h4><p>I setup DVC to use an S3 bucket for storage, which is managed by the Terraform code under <em>infrastructure</em>. It creates the S3 bucket for DVC to use as well as an IAM user for Github Actions to use to access DVC and deploy CDK.</p><p>The code is verbose in parts but I’ll give an overview of infrastructure/resources.tf with comments added:</p><pre>// create the bucket. In this file it&#39;s referenced as aws_s3_bucket.b.bucket<br>resource &quot;aws_s3_bucket&quot; &quot;b&quot; {<br>  bucket_prefix = &quot;trnka-dvc-&quot;<br>  acl = &quot;private&quot;<br>}<br><br>// create the IAM user for Github Actions to use<br>resource &quot;aws_iam_user&quot; &quot;github_actions&quot; {<br>  name = &quot;github_actions_lambda_ml&quot;<br>  force_destroy = true<br>}<br><br>// give the IAM user permissions to list files in the bucket and read/write/delete files<br>resource &quot;aws_iam_user_policy&quot; &quot;dvc_policy&quot; {<br>  name = &quot;dvc_policy&quot;<br>  user = aws_iam_user.github_actions.name<br><br>  policy = &lt;&lt;EOF<br>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Action&quot;: [&quot;s3:ListBucket&quot;],<br>      &quot;Resource&quot;: [&quot;arn:aws:s3:::${aws_s3_bucket.b.bucket}&quot;]<br>    },<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Action&quot;: [<br>        &quot;s3:PutObject&quot;,<br>        &quot;s3:GetObject&quot;,<br>        &quot;s3:DeleteObject&quot;<br>      ],<br>      &quot;Resource&quot;: [&quot;arn:aws:s3:::${aws_s3_bucket.b.bucket}/*&quot;]<br>    }<br>  ]<br>}<br>EOF<br>}<br><br>// this policy is long but ensures the IAM user can run CDK and upload ECR images<br>resource &quot;aws_iam_user_policy&quot; &quot;cdk_policy&quot; {<br>  name = &quot;cdk_policy&quot;<br>  user = aws_iam_user.github_actions.name<br><br>  // ...<br>}<br><br>// make sure there&#39;s an access key<br>resource &quot;aws_iam_access_key&quot; &quot;github_actions&quot; {<br>  user = aws_iam_user.github_actions.name<br>}<br><br>// when we run terraform apply, it&#39;ll show the secret on the command line<br>// which we can copy into Github Actions Secrets<br>output &quot;secret&quot; {<br>  value = aws_iam_access_key.github_actions.secret<br>}</pre><p>This code creates the S3 bucket for DVC, the IAM user for Github Actions, gives the IAM user appropriate permissions, and makes the access key so that Github Actions can “log in” to AWS.</p><p>One benefit of infrastructure as code is that we can ask experts to review it before we run it.</p><p><strong>New terms</strong></p><ul><li><a href="https://www.terraform.io/">Terraform</a>: Terraform is a tool for infrastructure as code that works with many popular cloud providers.</li><li>AWS IAM policy: I’m not the best at explaining this, but it’s a list of permissions that can be attached to an IAM user or role.</li><li>AWS IAM role: This is like an IAM user but you can’t log in as it. It’s only there for services to use. If you’re a similar age as me, you might think of this as a service user with better security.</li></ul><h3>What could possibly go wrong? A critique</h3><p>It’s tough to review your own work, but I’ll give it a fair shot! I have three sections:</p><ol><li>A review of <strong>general principles</strong></li><li>An overview of <strong>industry needs</strong> that weren’t otherwise mentioned</li><li>A discussion of <strong>priorities to fix</strong></li></ol><h4>General principles</h4><p><strong>Does the service manage latency vs cost well?</strong></p><ul><li>AWS Lambda scales up and down automatically, so if there’s a surge of users it’ll handle that and then scale down to save cost afterwards. It doesn’t require any special configuration to do this.</li><li>When Lambda scales up and warms up a new “instance”, it needs to download the Docker image and load the model. We call this a cold start. If the image and model are even moderately large, the API request will time out while it loads. This is especially bad in our repo because there are no active users, so it’ll sit at 0 concurrency until a request is made during testing, then time out while loading the model until there’s a warm Lambda.</li><li>On the topic of cost, Lambda will scale up as needed with incoming requests up until a region-wide concurrency limit. So someone could spam your API to scale up your Lambda and increase your AWS bill significantly.</li><li>The repo is implemented entirely in us-west-2. If the API is being called from around the world or even around the US, many users will have slow responses simply because they’re far away from the server. On the other hand, if it’s only called by servers or users near us-west-2 that’s fine.</li></ul><p><strong>Is the service highly available?</strong></p><ul><li>Due to cold starts, when the service deploys it causes a full outage until the new model is loaded. In a professional situation that’s unacceptable but may be acceptable for hobbyist work.</li><li>Can we quickly and safely revert if a bug makes it to production? Yes, in this repo we’d revert by merging a PR in Github. The deployment pipeline takes 4–5 minutes. It’ll probably take longer to get your PR approved.</li><li>Can we quickly detect production issues? No, there aren’t any alarms implemented in this repo so if it goes down we probably won’t find out right away. AWS provides some default dashboards for API gateway and Lambda though.</li><li>Can we switch to PyTorch without downtime? Yes, this repo is implemented so that we could make a major machine learning change like switching frameworks, test it, and deploy without downtime and with the ability to revert, so long as the framework change is a single PR.</li></ul><p><strong>Is there any way that untested work might be deployed?</strong></p><p>There are several gaps in my testing:</p><ul><li>The components between the API request and the Lambda are untested: The Docker packaging, the interaction between the Lambda code and API gateway, and the API gateway configuration. The Docker part could be tested easily by running the unit tests inside of Docker, though it’ll slow down testing a bit. The AWS configuration could be better tested by using <a href="https://aws.amazon.com/serverless/sam/">AWS SAM</a> to spin up a local version of the stack for testing. This issue also affects developer productivity, for example if a developer is changing the way that dependencies are packaged they may need to edit the Dockerfile and it’s best if they can test it on their computer.</li><li>Another gap is time-based: The dependencies for unit tests are installed at a different time than the dependencies for the Docker image. Because the dependencies aren’t fully pinned (see previous post for why), that means that in theory a new library version could be deployed between testing and deployment which could cause a production outage. One way to address this is to build the Docker image in the PR pipeline, use it for unit testing, then upload to ECR. That would also save time in deployment. Another alternative is to pin dependencies more.</li><li>In theory, someone could overwrite the model file in S3 and bypass our test automation, though it’d be annoying to do. If they did that it wouldn’t actually trigger a deployment though because it wouldn’t be a change in Github. It’d have to be the exact same file path on S3.</li></ul><p><strong>Is it easy for new developers to learn?</strong></p><p>It’s tough to judge your own work for learnability. Whenever possible it’s better to have someone review the work and explain the challenges they faced.</p><ul><li>In my opinion, this is hard for a complete beginner to learn because there are so many tools. Most of the complexity happens in automation, which the developer may not need to fully understand. But DVC for instance introduces a new concept — instead of just doing a <em>git clone</em> they also need to pull the DVC files to make the repo work. That could be improved with git hooks.</li><li>A related challenge with DVC is that it requires an AWS credential — now your devs need to have AWS setup to work in the repo, and you need to make sure that they have appropriate permissions to the S3 bucket.</li><li>For a developer with prior AWS experience, this might be easier to learn than a repo with many ML-specific tools or platforms.</li><li>Terraform adds another programming language and way of thinking. If I could do it again I’d try replacing that part with CDK so that devs don’t need to learn another infrastructure language.</li><li>API gateway and Lambda can be challenging to understand, and aren’t great technologies for junior developers in my experience.</li><li>The use of “dvc repro” might not be worth the effort to learn it.</li><li>Also in my opinion it’s not quite documented enough for a junior dev.</li><li>The parameters to the Lambda handler are hard to learn in my opinion, because there’s no autocomplete for the data structure. <a href="https://awslabs.github.io/aws-lambda-powertools-python/2.8.0/">Lambda Powertools</a> can help with this, but adds another dependency.</li></ul><p><strong>Will developers face significant toil while using this repo?</strong></p><p>While the previous subsection was about new developers, this is about the day to day experience of experienced developers.</p><ul><li>Are there situations that might require multiple PRs across repos? Training, serving, and infrastructure are all in the same repo so major changes can be made in a single, well-tested PR. On the other hand, it’s likely that this code is being called by another repo that isn’t shown, and changes involving the JSON input shape, for example, may require PRs across repos.</li><li>Would this repo work nicely with security scanners such as <a href="https://github.blog/2020-06-01-keep-all-your-packages-up-to-date-with-dependabot/">depandabot</a>? In the past I’ve had challenges in easily updating ML packages flagged by dependabot. With this repo setup it’s possible to configure dependabot to open PRs with new dependencies, build updated models, and test that they work in the service. If the PR passes we can simply merge it to update dependencies.</li><li>Although deployment takes 4–5 minutes, it’d be better if it took closer to 1 minute. Fortunately Github Actions gives us time tracking by stage so we can investigate further. For example, it takes a little over 1 minute just to install DVC and CDK every time. Running the CDK pipeline including the Docker build takes about 3 minutes.</li></ul><p><strong>Any security concerns?</strong></p><p>I’m not a security professional but I’ve been involved in enough reviews to check for the basics.</p><ul><li>IAM safety for the Lambda role? CDK automatically creates a minimal IAM role for us. Even if an attacker finds a way to run arbitrary code inside of our Lambda, the role doesn’t have permissions to actually do much.</li><li>IAM safety for the Github Actions user? This user has a fair amount of permissions and an attacker could do some harm if they had access. Github Actions Secrets are pretty secure though. The biggest typical problem is that I’d need to rotate the IAM credentials manually if they were leaked.</li><li>If you’re adapting this to work with sensitive training data, Github Actions might not be an option.</li><li>The API is completely open to the world. If the model is highly unique and valuable, you don’t want others to probe it indiscriminately. Auth and/or IP filtering can help.</li><li>pickle files allow arbitrary code execution. But to write those pickle files, someone would need write access to your S3 bucket and would need to trigger a redeploy from Github. Pickle files are an unlikely attack vector of choice in this system.</li><li>If there are vulnerabilities in the Docker image, it won’t be updated until the next deployment. This is one disadvantage of using Docker for lambda — we’re the ones managing these system dependencies rather than AWS managing them like they do for zip-file lambdas.</li></ul><h4>Concerns in an actual company</h4><p>If you’re building a system professionally, this repo isn’t enough of a template. This is a list of considerations I had in industry:</p><ul><li>Endpoint security (auth, secret management, IP restrictions, etc)</li><li>Endpoint stability (DNS)</li><li>Endpoint versioning — If the input or output data structure will change in a way that isn’t backwards-compatible, you may need to support multiple data structures and have a version of the endpoint itself.</li><li>CORS when it’s being integrated with a frontend served from a different domain, and also latency optimization relating to CORS</li><li>Private PyPI inside Docker, if you use any internal modules</li><li>Multiple deployment stages: dev, staging, prod</li><li>Integration testing, end-to-end testing, and unit testing for any business logic</li><li>Provisioned concurrency, setup to warm up Lambda <em>before</em> the API gateway switches to the new version so that we have zero downtime</li><li>Dashboards and alarms</li><li>Training data versioning, data updates, and data testing — If you’re getting new data over time there’s a need for a whole pipeline before training.</li></ul><p>Now that I’m thinking about the business, it’s a good time to mention the big picture. When you’re writing an API it’s a piece of a larger system. I’ve seen significant harm caused by focusing too much on just one repo and too little on the code that calls the API. For example, we could change our API without telling anyone and it may bring down our product.</p><p>Likewise, it’s good to consider the experience of the developers using our API, such as whether it’s easy to learn and use. Others have covered the topic of developer experience for APIs better than I can:</p><ul><li><a href="https://blog.developer.adobe.com/ask-a-devexpert-what-makes-a-good-api-93fc74d83428">Ask a DevExpert: What Makes a Good API? (Adobe, 2018)</a></li><li><a href="https://swagger.io/resources/articles/best-practices-in-api-design/">Best Practices in API Design</a> (Swagger)</li><li><a href="https://nordicapis.com/5-examples-of-api-documentation-with-great-developer-experience/">5 Examples of API Documentation With Great Developer Experience (Nordic APIs, 2022)</a></li><li><a href="https://github.com/workos/awesome-developer-experience">Awesome Developer Experience</a></li></ul><p>If you’re deploying the service into the same AWS account as other services, there are some additional considerations:</p><ul><li>Is the service named and tagged so that you can audit your AWS bill easily? I’d suggest at least tagging all resources with the team that produced them.</li><li>If you don’t have Lambda concurrency limits, keep in mind that all Lambdas in the same account and region share a concurrency limit. So if your Lambda is using 999 concurrency and the limit is 1000, only 1 other Lambda in the company can be running at a time and others will be throttled. (I say this from a real experience of production Lambdas being throttled due to a logging service eating up our concurrency.)</li></ul><h4>Priorities to fix</h4><p>I covered a lot of problems with this example repo. In industry we often can’t fix everything we want to, at least not right away. So we have to prioritize what to improve first.</p><p>Prioritization should be guided by the business needs, user needs, and how your service is integrated into the product. If this were a mission-critical service dealing with private data, that’s very different than a nice-to-have service that can’t bring down the product. If it’s an API used by external developers that’s very different than an internal API. If it’s a service that supports 100,000 requests per hour that’s different than 100 requests per hour. And so on.</p><p>The following is an example prioritization that might make sense for a small startup:</p><p><strong>High priorities</strong></p><ul><li>A domain name, so that we don’t accidentally cause an outage when we change API gateway</li><li>Provisioned concurrency so that there’s less downtime when deploying updates</li><li>Talk to the people integrating the API if it’s not you!</li><li>Any required compliance</li></ul><p><strong>Medium priorities</strong></p><ul><li>IP filtering, auth, and/or your security of choice — This could range high to low depending on the application though</li><li>Alarms for outages — This could range high to low depending on the application</li><li>True zero-downtime deployments</li></ul><p><strong>Low priorities</strong></p><ul><li>Everything else</li></ul><h3>Alternatives</h3><p>I also tried a few alternatives and I’ll briefly mention what I found.</p><h4><a href="https://github.com/ktrnka/mlops_example_ecs">Deploy to AWS ECS</a></h4><p>AWS Elastic Container Service (ECS) is a better option than Lambda for most people. It’s always on, so you don’t need to worry about the time it takes to load your model when booting. The disadvantage of ECS is that it’s tricky to get autoscaling setup right and it can be more expensive.</p><h4><a href="https://github.com/ktrnka/mlops_example_cortex">Deploy with Cortex.dev</a></h4><p>I found <a href="https://www.cortex.dev/">Cortex.dev</a> to be delightfully fast and easy. The deployment itself was much faster than anything else, and not much more complex than Heroku. I remember thinking at the time my security team might not like some aspects of the deployment though.</p><h4><a href="https://github.com/ktrnka/mlops_example_github_lfs_heroku">Model versioning with git-lfs on Github</a></h4><p>I started off using git-lfs for model versioning and Heroku free tier for deployment. I was curious to use Github as the git-lfs provider after struggling with an alternative at work.</p><p>Well, I learned why we didn’t use Github’s git-lfs! When you hit the LFS quota your repo is locked until you buy more quota or delete the repo. Last I checked, Github doesn’t have a way to automatically increase your quota so you’re relying on people manually upgrading on the website periodically.</p><h3>Things I didn’t get to</h3><p>There are so many MLOps tools these days! For each library, tool, or platform I used, there are dozens of alternatives. I’ve heard good things about kubeflow for instance and it might be a good time to re-evaluate Sagemaker.</p><p>I’ve also seen some people deploy models with code using Python packaging. That seems like a nice way to package code, data, and dependencies together.</p><h3>Conclusions</h3><p>I hope I was able to clarify common concepts in machine learning web services!</p><p>Although I used AWS Lambda in this example, it was mainly due to curiosity. Please don’t interpret this post as an endorsement of Lambda for machine learning services. Whether Lambda is a good option will depend on your needs.</p><p>Also keep in mind this might serve as a guide for a small startup but I doubt it’s ready for operating at a larger scale. And I surely left out some parts of typical MLOps work, such as support for experimentation.</p><p>Thanks for reading! If there were parts of the article you found confusing, please let me know.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90c7bd275f53" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MLOps Design Principles]]></title>
            <link>https://medium.com/@keith.trnka/mlops-design-principles-e30cc40442a1?source=rss-3e4d2400adbe------2</link>
            <guid isPermaLink="false">https://medium.com/p/e30cc40442a1</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Keith Trnka]]></dc:creator>
            <pubDate>Thu, 16 Feb 2023 00:32:37 GMT</pubDate>
            <atom:updated>2026-01-14T17:25:53.765Z</atom:updated>
            <content:encoded><![CDATA[<p>There’s a big difference between building a machine learning model that works on your computer, and making that model available for others to use. If implemented poorly, your users will be frustrated that your software isn’t reliable. And it can take months to implement it well!</p><p>In this article I’ll share the principles I’ve learned over the years in deploying models. It’s meant for readers with basic awareness of machine learning and software engineering.</p><h3>The basics</h3><p>So you’ve got a model and want to integrate it into your product? It’s probably not a one-time thing! You’re going to need to fix bugs or release improvements! So you should think about having a process or system for updating models.</p><p>You’re going to want it to be easy for your team. You also want it to be reliable — your users won’t be happy if the service goes down when you update! Those are the two key concerns: <strong>minimizing defects and maximizing developer productivity</strong>.</p><p>I want to first acknowledge the bigger picture before getting into machine learning: These concerns aren’t specific to machine learning at all!</p><p>The DevOps movement is about breaking down harmful silos in organizations, and integrating the culture of writing software (dev) with culture of operating servers and networks (ops) to improve both productivity and reliability. I can’t summarize the entire field here, but these resources can help:</p><ul><li><a href="https://www.goodreads.com/book/show/17255186-the-phoenix-project">The Phoenix Project</a>: This is an entertaining read about a highly siloed, unproductive organization that improves.</li><li>The annual State of DevOps Report: These reports are full of gems. They tend to be hosted on a different website every year so you’ll have to search for it.</li><li><a href="https://www.goodreads.com/en/book/show/35747076">Accelerate</a>: This is a book version derived from the annual DevOps reports and it’s well-worth a read.</li><li><a href="https://sre.google/sre-book/table-of-contents/">The Google Site Reliability Engineering (SRE) handbook</a>: This is another excellent resource for keeping your code running without downtime.</li><li>I’d also recommend looking through the links in this <a href="https://www.reddit.com/r/devops/comments/yjdscp/getting_into_devops/">Reddit introduction</a>.</li></ul><p>Although the foundation of DevOps is cultural, in practice DevOps often refers to the processes, skills, and tools used to deliver software rapidly and reliably. Unfortunately many software delivery tools do not work well for the delivery of machine learning models. Machine learning also faces unique challenges, such as training and evaluating models.</p><p>MLOps is about building and delivering machine learning code+models rapidly and reliably. While MLOps inherits the cultural principles of DevOps, in practice it also addresses special considerations in processes, skills, and tools.</p><h3>MLOps Design Principles</h3><p>These are lessons I’ve learned from deploying models at Swype, Nuance, and 98point6. I’ll explain the problems that motivated each principle and how I’ve applied it since.</p><p>I find it’s important to understand why you build software so that I can better adapt to new situations. That’s why I’m writing up principles — I’ve seen many people overly focus on tools without understanding the underlying reasons. And what’s more, each company comes with different challenges so the existing solutions may not apply, even if the principles do.</p><p>One last word before I get into it — I haven’t “solved” this field by any means. This reflects my current understanding from a decade of industry experience and I hope to improve my opinions in the future.</p><h4>Version the code and model together, or link them</h4><p>Your newest model may not be compatible with old versions of your code. So if something goes wrong and you need to revert, you need to know both the model and code version to revert to.</p><p>Likewise, a code change may require you to retrain your model. That can be anything from changing your neural network architecture to updating your dependencies to changing your preprocessing. In some cases, the new code will crash when trying to load a new model. In other cases, it might successfully load a model but have worse performance.</p><p>At Nuance we had an extreme version of code-model dependencies. We produced a software development kit (SDK) for phone makers (OEMs) to build their own keyboards. We also provided language databases which had word lists and language models in them. Manufacturers often wanted the latent language databases, but were wary of upgrading the SDK version. (*) So we maintained a giant compatibility table, listing the language database versions supported by all common versions of the SDK. In some cases, OEMs would use code from years prior and we couldn’t convince them to upgrade. So when we’d plan changes to our model files, we often had to discuss whether it could degrade reasonably in most prior versions of the code.</p><p>That experience motivated me to make code-model compatibility easier to track at 98point6. We used tools like <a href="https://dvc.org/">data version control (DVC)</a> which made it easy to track by storing models in S3 and linking model versions into git.</p><p>(*) OEMs often just didn’t have the time to update their integration for any breaking changes and often didn’t even have the time to validate an update. That said, most were willing to accept <a href="https://semver.org/">patch versions</a>.</p><h4>Atomic deploys and reverts</h4><p>We don’t want downtime while deploying or reverting our software. And because the code and data versions must be aligned, it’s important to deploy or revert them as one unit. We don’t want a temporary outage when one of them has deployed but the other hasn’t yet.</p><p>This is easy if you package everything together, such as a Docker image or a mobile app. It’s more difficult if the model is stored outside of the code package. But it can be addressed by naming models with their version and explicitly loading the model by version in your code.</p><p>I only bring up this topic because I’ve heard of many people deploying models by manually overwriting an old model version, which doesn’t give us a nice way to deploy and revert.</p><p>Also note, there are similar DevOps challenges when deploying multiple components that must be kept in sync, such as a web service with a database schema change, or deploying a web service with infrastructure configuration changes. So if you’re looking to learn more you may find inspiration in the best practices for those kinds of deployments.</p><h4>Training and serving in the same repo</h4><p>At 98point6 we tried having separate repos and a single repo for machine learning projects and I found that development is faster and less error-prone with a single repo.</p><p>When there are training-serving interdependencies, separate repos can lead to this:</p><blockquote>PR in training repo -&gt; merged -&gt; integrated into serving repo, only to find it doesn’t work -&gt; go back to the start</blockquote><p>It’s an incredible waste of time that just doesn’t happen with a single repo.</p><p>One alternative would be to import code from the local copy of the training repo into the local copy of the serving repo. I’ve found that people tend to skip it and even when it’s done it’s sometime prone to copy-paste accidents.</p><p>The main downside of a single repo is that you need to implement multiple CI/CD pipelines in the same repo. That’s easy in some CI/CD platforms and harder in others.</p><p>I’ve found a similar lesson in general software engineering, for instance when a frontend and backend are split across repos, or multiple tightly coupled backends are split across repos. One warning sign you might have this is when people make PRs just to see if something works in another repo.</p><p>Demos are also closely related. If you have a minimal frontend demo in the repo, it allows developers to test more easily <em>before</em> anything goes to a pull request or deployment. At 98point6 we had some repos with demos in the repo and others with demos in a separate repo. It was much faster and less error-prone to develop in repos that had built-in demos.</p><h4>Single implementation of models</h4><p>It’s best to have a single implementation of the model that’s used in both training and serving.</p><p>At Nuance we had a separate implementation in training in Python and production in C. The Python implementation trained the model and evaluated it on held-out data. The C implementation loaded the model and had some basic unit tests. Over the years, we discovered that the two implementations didn’t handle some cases the same way (like the start of a sentence) and that meant that the production models were suffering degraded quality.</p><p>There are many ways to address this. TensorFlow Lite and PyTorch Mobile are for mobile apps. TensorFlow.js is for Javascript. And ONNX is a cross-platform, cross-framework file format with runtimes for many languages. That said, as I write this I’m learning that it <a href="https://news.ycombinator.com/item?id=34799597">can be difficult to make your models compatible with ONNX</a>.</p><p>If you can’t share the model code, you should at least test that the two implementations behave similarly.</p><h4>Review and approve your model releases</h4><p>It’s <em>very tempting</em> to only deploy models with better evaluations. That’s a subtly flawed approach because your testing data may change. If your testing data changes, you don’t know whether the numbers should go up or down. You might fix a bug in the testing data only to see that the metric was overly optimistic and now looks worse. Or you may update your testing data periodically and find that the distribution has shifted over time, which could make it easier or harder to get good metrics.</p><p>A human should review the evaluation report. If anything looks odd, they should review the model outputs on some standardized examples to spot anything that might not be detected in automated evaluation. Ideally you should have guidelines that the team can follow when doing this, and they can use their best judgement with your guidelines. If you use Github, I’d recommend the pull request process for this.</p><p>I learned this the hard way at Nuance. We periodically found quality issues in our testing data, such as the way it was preprocessed for Unicode, how duplicates were removed, or how language identification worked. It was particularly common for new languages with new data.</p><p>At 98point6 our model builds produced a training report and opened a pull request. If anything looked odd we could investigate it manually. This gave us the flexibility to change our testing data and the process to review our models. We improved it over time by developing guidelines for the team and putting them in the repo’s pull request template.</p><h4>Test, not too much, not too little</h4><p>Testing is a complex topic that could take a whole article. If you haven’t read it, I strongly recommend reading <a href="http://www.agitar.com/downloads/TheWayOfTestivus.pdf">Testivus</a> first because that’s my stance.</p><p>First off, I want to acknowledge that evaluating your model on held-out data <em>is</em> testing. It’s often ignored when talking about testing but it’s a key component of quality control for machine learning.</p><p>The challenge I experienced at Nuance and 98point6 was that we wanted unit tests that depend on the models, but the models change often. For example, the word predictions for “I am ___” might change when we improve our model. If we have unit tests that depend on those predictions, they will fail and someone will think they’ve broken the code when they haven’t. If those tests are maintained, they’ll be frequently edited and don’t offer much value as tests.</p><p>So on to my guideline: Test that the model loads. Don’t extensively unit test the model’s behavior. You already tested the specific outputs against held-out data in a way that’s much more robust than unit testing anyway. We adopted that stance at 98point6 and it was an improvement.</p><p>Side note: Design your code base so that you can unit test any business logic independently from your machine learning model. If you do that, the business logic tests will be less flakey, and they’ll run faster too.</p><h3>Automate when possible</h3><p>Reduce the burden on your devs by automating what you can, such as retraining models with new data or deploying a model once it’s validated. Automate testing when you can.</p><p>Be cautious about automating too soon — automation isn’t always worth the effort, and it’s also risky to automate a process before really understanding the challenges.</p><p>In cases where testing wasn’t automated, I found that some devs would forget to run tests and push buggy code or models. Then it would disrupt another developer, who would think they broke something.</p><p>In cases where deployment wasn’t automated, non-experts were sometimes afraid they’d break something and would wait for “the expert” to be available. That could lead to delays and moreover the culture felt unhealthy. It’s better if everyone can deploy and only occassional issues need a specialist.</p><p>In cases where training wasn’t automated and wasn’t trivial, I found that one person would become “the training person”. That puts an unfair burden on one person and makes the team less resilient, not to mention any delays if they take a vacation.</p><h3>Early ideas</h3><p>These are a couple of design principles I’m entertaining, but not yet certain of.</p><h4>Snapshotting dependencies</h4><p>I prefer to leave dependencies unpinned when possible so that they’re updated by frequent rebuilds. That way, we’re getting minor patches pretty frequently. And if there are breaking changes we’re exposed to them a little at a time rather than all at once in a big update.</p><p>I came to prefer this style of dependencies after pinning dependencies in repos at 98point6 and finding that it typically led to very outdated versions of libraries. Then when a crisis happened, it forced an upgrade of many dependencies all at once which led to delays in a crisis situation.</p><p>This sort of thing may vary by company, for instance if you have tooling to periodically test your code with updated dependencies, or if you have a strong culture around dependency updates.</p><p>In the context of machine learning, the model artifact may depend on certain installed libraries. Scikit-learn models can be sensitive to the version of scikit-learn and joblib, for example. They may just not load in a different version. So the version of those dependencies needs to be pinned in the serving code. You just can’t take a chance with another version. And if you have automated testing of new version, it’ll just fail unless you code it to retrain on certain dependency updates.</p><p>I also want to mention that saving your models with ONNX and other library-independent formats may fix this problem altogether for you, so long as you don’t also have any preprocessing code that needs to be released to the service.</p><h4>Use dependencies, not too many, not too few</h4><p>It’s generally good to use well-tested, publicly-available code instead of writing new code. For example, using PyTorch will be better than writing your own neural network library from scratch because it’s highly tested and optimized.</p><p>On the other hand, I’ve seen code that goes overboard with dependencies that aren’t strictly needed. Unfortunately, each dependency is an opportunity for a performance bug or security vulnerability. I found this was a problem in the Javascript ecosystem. As a result, projects which depended on Javascript would often trigger security scan warnings. At 98point6 I experienced this because of CDK in Javascript — we’d go to deploy a minor update to an old service only to find that the Javascript dependencies of CDK had tripped the security scanner. Then we’d have to go figure out the update process.</p><p>In contrast, Swype and Nuance were on the extreme minimal side of dependencies. In my first two months I learned that we couldn’t use standard template library (STL) in C++ because some of our customers required compilers without STL. So instead I wrote my own data structures which were certainly less tested, documented, and performant than STL. If I could do it again I’d explore other options.</p><p>There’s another cost to dependencies — it’s more for new developers to learn. When you’re adding more dependencies and complexity, it’s good to double-check that the benefit will be worthwhile even for new teammates.</p><h3>What’s next?</h3><p>Thanks for reading!</p><p><a href="https://medium.com/@keith.trnka/mlops-repo-walkthrough-90c7bd275f53">In the next post I walk through an example repo that shows MLOps for web services on AWS</a>. After explaining the repo I’ll also audit it.</p><h3>Appendix: Types of deployments</h3><p>There are many different kinds of deployments and they affect MLOps differently. I’ll provide a brief summary of how they differ here:</p><ul><li><strong>Web services</strong>: Latency is a major factor to consider, and that leads to things like auto-scaling or geographic distribution. And don’t forget that you’re paying for that compute too!</li><li><strong>Code packages</strong>: Releasing your model and code as an importable package frees you from thinking so much about the compute environment. But your models may be integrated much slower than you’d like. Also, you may not get crash reporting.</li><li><strong>Mobile apps</strong>: Mobile devices vary widely in terms of compute and memory, which affects the kinds of models you can ship. You also don’t have precise control over getting your update to everyone’s phone, especially on iOS.</li><li><strong>Analytics data warehouse / ETL</strong>: If you update a model, should you re-run predictions on all old data? Or just new? How will you communicate that to your users? Software dependencies can be a challenge depending on your platform too.</li><li><strong>Web frontends</strong>: The available compute and memory varies widely across users. You also don’t have full control over when they refresh and get updates by default.</li></ul><p>I’ve worked with most of these except deploying models into web frontends. I’m sure there are other types of deployments with unique challenges as well.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e30cc40442a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Machine translation for medical chat, checkpoint #4]]></title>
            <link>https://medium.com/@keith.trnka/machine-translation-for-medical-chat-checkpoint-4-d5c449400f6f?source=rss-3e4d2400adbe------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5c449400f6f</guid>
            <category><![CDATA[healthcare-technology]]></category>
            <category><![CDATA[user-experience]]></category>
            <category><![CDATA[machine-translation]]></category>
            <dc:creator><![CDATA[Keith Trnka]]></dc:creator>
            <pubDate>Tue, 07 Feb 2023 08:32:28 GMT</pubDate>
            <atom:updated>2023-02-07T08:32:28.445Z</atom:updated>
            <content:encoded><![CDATA[<p>If this is your first time reading this series, welcome!</p><p>This series of posts is about building trustworthy machine translation for medical chat. Multilingual doctors are rare and not all patients in the US speak English. However, just using machine translation isn’t enough; physicians often have concerns with safety and trust.</p><p><a href="https://medium.com/@keith.trnka/machine-translation-for-medical-chat-checkpoint-3-9a00ef1e9a11">My previous article</a> was a literature review of user experience for machine translation in chat. I found that there were some promising directions in safety and trust, but the field hasn’t discovered a definitive solution yet.</p><p>In this post, I’ll describe my efforts so far to build trust by allowing users to inspect the way the words and phrases are “aligned” by the translation algorithm. In contrast with <a href="https://medium.com/@keith.trnka/machine-translation-for-medical-chat-checkpoint-2-32bb8d77ca8b">a previous prototype</a>, I’m optimistic about it for a few reasons:</p><ul><li>I previously integrated dictionary definitions but found that bilingual dictionaries don’t work well for multi-word expressions. Internally, the translation algorithms support this better than dictionarys so I’m optimistic.</li><li>I’ve also been searching for a way to teach users verb conjugation, because existing approaches don’t help with that. I’m optimistic that alignment may work.</li></ul><p>I started out by building a prototype of the user interface. That helps me to understand whether the idea is plausible or not before spending significant time into the technical details.</p><p>Initially I sought to extract attention weights from HuggingFace machine translation models but found that it’s tougher than expected. So I decided to approximate it with a word alignment package. Keep in mind that alignment algorithms are built for training, not to explain a translation. So it’s only a rough prototype.</p><p>Let’s start with a brief demo:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/298/1*FKBpjguMzSKwBOQnpjwKIg.gif" /></figure><p>Users can click words in either language and it’ll highlight the word and the aligned words in the other language. It’ll also group words into phrases based on alignment, such as grouping “help you” with “ayudarte”. Likewise “puedo” maps to “can I” though it’s a little hard to see the highlighting on “I”.</p><h3>How it works</h3><p>I’ll give a brief rundown:</p><ol><li>Translate “Hi, how can I help you today?” from English to Spanish. I used <a href="https://github.com/neuml/txtai">NeuML’s txtai wrapper</a> around <a href="https://huggingface.co/">HuggingFace</a> for this.</li><li>Align the translations using <a href="https://github.com/cisnlp/simalign">SimAlign</a>. This gives us a list of pairs of aligned words in the source and target text. Note that it needs to be tokenized, so I used <a href="https://spacy.io/">spacy</a> for tokenization.</li><li>Find all the groups of connected words using a graph algorithm. That’s needed so that I can highlight both “ayudarte” and “you” when clicking on “help”.</li><li>CSS &amp; Javascript for the user interface in a Colab notebook.</li></ol><p>If you’d like the code, <a href="https://colab.research.google.com/drive/1ALLux9evKf_-gh-Rpi8o6dDWxkdTp--E?usp=sharing">it’s available here</a>!</p><h3>When it fails</h3><p>Let’s review some examples where it doesn’t do as well:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*eE_pfv_zqKt-5NFO-YzQzA.gif" /></figure><p>In this case, “lower back” should’ve aligned to “parte baja de la espalda”. It <em>almost</em> worked, but I don’t want “almost” when dealing with potential medical safety issues.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*LsJn3RHdOeDeDR8v_T6Hwg.gif" /></figure><p>“I’m sorry” should align to “Lamento” and “to hear” should align to “oír” so that’s not great. And “hear” definitely doesn’t mean “que”! The rest is pretty good though.</p><p>I also tried a basic Japanese example to get another perspective. I’d suggest to pause a moment after seeing the example and ask yourself if you could assess the quality of the translation before reading further.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/246/1*qkX1Dsk8fpfDjUmihLG0Cw.gif" /></figure><p>The alignment should be:</p><ul><li>one: not translated</li><li>coffee: コーヒー (kōhī)</li><li>please: お願いします (onegaishimasu)</li></ul><p>What SimAlign provides:</p><ul><li>one: aligned to お (o-) which is a part of onegaishimasu (please)</li><li>coffee: not aligned</li><li>please: aligned to 願い (negai), which is the core of the word for please</li></ul><p>Although the SimAlign alignment component has some problems, I feel good about the user interface. When it works, it helps for showing verb conjugation and phrase translation. And it feels easier to use than many of the examples I saw in the literature review.</p><p>That said, even if the alignment problem were fixed, it’d still be an improvement to also show the dictionary definitions of each highlighted word.</p><h3>Alternative: BertViz</h3><p><a href="https://github.com/jessevig/bertviz">BertViz</a> is a project to help visualize attention weights in transformers. They even provide an example of attention in machine translation.</p><p>Here’s a recording of BertViz for a translation of the English “She sees the small elephant.” into the German “Sie sieht den kleinen Elefanten.” with the HuggingFace Helsinki-NLP/opus-mt-en-de model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*-FK8vgeycHnbpiQ24OpLvA.gif" /></figure><p>This machine translation model is a 6-layer transformer and the 8 color-coded columns are attention heads.</p><p>There’s just too much information for me here! I’d been going into this naively thinking of classic attention, where there’s only one layer and only one attention head. But I forgot that modern neural machine translation isn’t nearly as simple. There <em>might</em> be good alignment information in certain layers or heads, but I don’t know of a systematic way to find the right layers or heads (yet).</p><p>I also tried to get it to work with the HuggingFace MarianMTModel models but it didn’t work. Those models use a different setup that isn’t compatible with BertViz. So I’ll need to dive more into HuggingFace and PyTorch to do it myself.</p><h3>When in doubt, lit review!</h3><p>At this point, I wasn’t sure if what I wanted was possible but also it seems like the sort of thing that a researcher might publish. So I did some searching and read a few of the results so far.</p><p><strong>Koehn, P., &amp; Knowles, R. (2017). <em>Six Challenges for Neural Machine Translation</em>. 28–39. </strong><a href="https://doi.org/10.48550/arxiv.1706.03872"><strong>https://doi.org/10.48550/arxiv.1706.03872</strong></a></p><p>On page 1 we have a key quote:</p><blockquote>The attention model for [neural machine translation] does not always fulfill the role of a word alignment model, but may in fact dramatically diverge.</blockquote><p>In most language pairs, they found that attention weights were similar to word alignment. However, in one language pair, attention weights were all offset by 1 word and they didn’t find any good explanation.</p><p><strong>Munz, T., Ath, D. V., Kuznecov, P., Thang Vu, N., &amp; Weiskopf, D. (2021). Visual-Interactive Neural Machine Translation. <em>Graphics Interface 2021 Conference Second Cycle</em>. </strong><a href="https://github.com/MunzT/NMTVis"><strong>https://github.com/MunzT/NMTVis</strong></a></p><p>This paper has some wonderful graphics of what I’d like to build!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/1*KQwJapjJ1mLkSL67MBx-vw.png" /></figure><p>It looks so nice! Though it’s a little tough to tell from the lines alone if <em>verarbeiten</em> only means <em>process</em> or if it means <em>easy to process</em>. Here’s what it looks like if I run it through my demo and inspect those words:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*xVAVOK4ewRdWr67odN2-pQ.gif" /></figure><p>So <em>verarbeiten</em> probably just means <em>process</em>. To be fair, if I could click their user interface in their paper I would likely find the same.</p><p>Here’s another example of showing the full alignment:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yr_wkd-LuMCPjq-52scNDA.png" /></figure><p>There’s a big section in the top example that doesn’t line up to anything. It wasn’t translated at all! So even zoomed out this type of visual can help to detect certain translation errors without knowing the target language.</p><p>Unfortunately, most of their examples are with an LSTM and a simple attention mechanism. They tried working with Transformer architectures in some examples but just averaged attention heads. In the picture above, it’s connecting words to too many others, not just the aligned one.</p><p>This paper gave me a great example of what I’d like to build but didn’t show how to use Transformer attention weights.</p><p>I also want to note that I’ve only discussed a piece of the paper — it’s a larger system to help professional translators and I enjoyed reading it.</p><p><strong>Bibal, A., Cardon, R., Alfter, D., Wilkens, R., Wang, X., François, T., &amp; Watrin, P. (2022). Is Attention Explanation? An Introduction to the Debate. <em>ACL</em>, <em>1</em>, 3889–3900. </strong><a href="https://doi.org/10.18653/V1/2022.ACL-LONG.269"><strong>https://doi.org/10.18653/V1/2022.ACL-LONG.269</strong></a></p><p>This is another great read!</p><blockquote>Explanations can be <strong>faithful</strong> (how close the explanation is to the inner workings of the model) or <strong>plausible</strong> (does the user consider the explanation of the model plausible?)</blockquote><p>This early note helps me describe what went wrong with SimAlign: The alignments were sometimes plausible but not faithful.</p><p>I found the section “Is Attention Explanation on Different Tasks?” also very relevant. Although attention in general may not be good for explainability, there have been more successes in natural language processing.</p><p>This quote leaves me optimistic about attention for explanation of machine translation:</p><blockquote>… however does not hold true for self-attention networks nor for tasks depending on an additional text sequence, as for example in neural machine translation or natural language inference (pair-wise tasks and text generation tasks). In such cases, altering learned attention weights significantly degrades performance and attention appears to be an explanation of the model and to correlate with feature importance measures.</blockquote><p>They also have citations that investigate how to deal with multi-head, multi-layer attention!</p><h3>So where does that leave us?</h3><p>I feel good about the simplicity of the user interface, and I’m sure it could be a good interface with more work. (Though of course I should test that!)</p><p>SimAlign isn’t sufficient for alignment but I think it’ll be possible to get more faithful alignments by extracting them from cross-attention in the txtai/HuggingFace machine translation models. But to do it, I need to first learn 1) more about PyTorch 2) how to flatten multi layer multi head attention.</p><p>The one major downside is that this means I won’t be able to use Google/Microsoft/Amazon Translate APIs if I’m showing alignment this way. That’s a bummer because the Microsoft APIs look nice for building a domain-adapted model.</p><p>So that’s where I’m at in the project! Sorry I didn’t get to the point of a satisfying conclusion yet. The next step is to learn more about PyTorch and HuggingFace.</p><p>Also if you spot any errors or have ideas, let me know!</p><h3>Appendix/notes</h3><ul><li>I made a mistake in the first version of this post with Japanese, because the tokenization is a little tricky. Originally I used spacy’s tokenizer but the alignment was poor. Then I read up about SimAlign and the multilingual BERT model under the hood, finding a note that they split Japanese text at the character level not word level. So I redid it with character tokenization which was a slightly improvement.</li><li>SimAlign has three different alignment algorithms. I tried all three and settled with <em>itermax</em>. The different approaches seem generally similar in their publication so that probably doesn’t invalidate my results but if you know more about them let me know.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5c449400f6f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lessons learned in 2022]]></title>
            <link>https://medium.com/@keith.trnka/lessons-learned-in-2022-b67b68e19035?source=rss-3e4d2400adbe------2</link>
            <guid isPermaLink="false">https://medium.com/p/b67b68e19035</guid>
            <dc:creator><![CDATA[Keith Trnka]]></dc:creator>
            <pubDate>Fri, 30 Dec 2022 08:32:44 GMT</pubDate>
            <atom:updated>2022-12-30T08:32:44.550Z</atom:updated>
            <content:encoded><![CDATA[<p>At the end of each year, I like to reflect on my career and life. This post is meant to celebrate learning and growth, whether learning something new, or changing my mind as I gain more experience. I hope you’ll also take time to notice and celebrate your own growth this year!</p><p>As I was listing things out, I didn’t want anyone to feel like this is in any way a competition about how much you learned. So the list is just an assorted survey of topics that this audience may find interesting.</p><h3>Machine learning</h3><p>Genetic algorithms still have uses, even in the age of neural networks. I found them useful in an optimization problem that was difficult to represent as constraint programming and also difficult to represent as gradient descent. Using a genetic algorithm drastically shortened the time it took to get an algorithm functional enough to demonstrate.</p><p>Early in the year, I’d dismissed GPT3 and other large language models as hype and not interesting. I was wrong — they’re quite interesting and useful, even if they’re <em>sometimes</em> overhyped. I’ve found them useful for writing and summarizing, and sometimes as an alternative for Google search. I find it helpful to think of them as “super duper fill-in-the-blanks algorithms”. And related to that, prompt engineering is an interesting field. If you’d like to learn more, see <a href="https://learnprompting.org/">Learn Prompting</a>.</p><h3>Data science</h3><p>Over the years I’ve used machine learning tools to do data analysis that can adjust for confounding variables. This year I also explored statistical methods for the same in the form of generalized linear models (GLM). I mostly used those methods to analyze whether a new product feature was having an effect on efficiency while controlling for confounders such as the practicing doctor, how busy the clinic was, the complexity of the patient’s issue, other features, and so on.</p><p>I found that both machine learning methods in scikit-learn and GLM in statsmodels were valuable but have slightly different advantages. GLM methods will tell you things like “feature ABC changes visit duration by +0.1 to -0.4 minutes.” Machine learning toolkits like scikit-learn on the other hand have advantages in preprocessing your data and dealing with messy data, even text inputs.</p><p>Regardless of the approach, I still haven’t found a satisfying way to explain the results of either approach to a general audience, even after reaching out to more experienced folks for advice. For now I do two types of analysis: one that’s more technical for myself and I use it to guide a more interpretable analysis for a general audience. Hopefully I’ll learn a better way in the future.</p><h3>Software engineering</h3><p>When designing a software system, the ease of local testing has a large effect on the amount of bugs and also the team’s happiness. I had an inkling of this before but feel more strongly about it after reviewing 50-100 code bases for deployment safety.</p><p><a href="https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern">Pub-sub</a> is more complicated than I previously thought. This year I saw two challenges in testing: 1) the order in which events are normally triggered can be critical 2) some pieces such as retries may be implemented by AWS and are harder to test. In the cases I saw, the order of events was not well understood and it led to bugs. Now that I’ve experienced the pub-sub pattern I’m better equipped to look out for reliability risks.</p><p>Healthy on-call alarms and notifications can be designed by asking questions such as: When would you want to be woken up at night? When could a notification wait until business hours? When would you prefer to periodically check dashboards, with full awareness that you will forget sometimes? What would the business impact be if all alarms had been disabled for the last 6 months?</p><h3>Leadership</h3><p>Previously I thought that teams would be able to autonomously fix chaotic on-call rotations if only they have skill, time, and agency. This year I learned that teams also need a little nudge even if they have all those things.</p><p>Speaking with a small group that knows you is VERY different than speaking with a large group that doesn’t know you. Your immediate team knows you and will give you the benefit of the doubt. In a large organization, many people do not know you and you may not have earned the benefit of the doubt yet. I felt that push me towards more “manager speak” when talking about company policy or roadmap. I suspect that many of the leadership flops I’ve witnessed in the past were the result of talking to a large audience the same as a small, high-trust audience.</p><h3>Baking</h3><p>This year a friend asked me about making bread from 100% whole wheat flour to reduce glucose spikes. I’d tried it once or twice before and it came out awful. This fall I took the time to read up more and practice, so now I see that it’s possible to make good-tasting 100% whole wheat bread. The lessons are 1) use a lot more water than the equivalent white bread, and going by the dough texture is ok 2) add a hint of sweetness to balance it, such as cranberries 3) allow more proofing time than white bread. Hopefully the cranberries don’t spike glucose too much.</p><p>I’d tried making bagels before with unsatisfying results. I’m not sure what I changed other than the recipe but I practiced a lot more this time and they came out very satisfying. As before, one key was to do a little more reading, and then practice every day until it’s good. There’s still more improvement to make but I found some ideas to try on /r/breadit.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b67b68e19035" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Machine translation for medical chat, checkpoint #3]]></title>
            <link>https://medium.com/@keith.trnka/machine-translation-for-medical-chat-checkpoint-3-9a00ef1e9a11?source=rss-3e4d2400adbe------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a00ef1e9a11</guid>
            <category><![CDATA[healthcare]]></category>
            <category><![CDATA[user-experience]]></category>
            <category><![CDATA[machine-translation]]></category>
            <dc:creator><![CDATA[Keith Trnka]]></dc:creator>
            <pubDate>Thu, 15 Dec 2022 13:01:49 GMT</pubDate>
            <atom:updated>2022-12-15T13:01:49.446Z</atom:updated>
            <content:encoded><![CDATA[<p>This is another literature review, but this time with more papers and more user interface pictures.</p><p><a href="https://medium.com/@keith.trnka/machine-translation-for-medical-chat-checkpoint-2-32bb8d77ca8b">Last time I posted</a>, I was prototyping different user interfaces for machine translation-mediated chat and hit a wall. Since then I’ve been reading papers to get ideas. I read papers already in my queue, explored the citation graph around those papers, and I also tried <a href="https://elicit.org/">Elicit</a> to expand my search more.</p><p>I was mainly looking to read about user interfaces for machine translation but included other areas as they came up:</p><ol><li>User interfaces to improve understanding of MT-mediated communication</li><li>User studies of MT-mediated communication</li><li>Computer-Aided Translation (CAT) tools — This is a field just for tools to support translators, and I read a few papers about interactive machine translation (IMT) that might be useful for writing</li><li>Healthcare machine translation — I found more to read about MT in healthcare too!</li></ol><p>I’ll go through papers in chronological order within each category. Sometimes I read them out of order, and I apologize if that makes the reading more difficult. I’ll include as many user interface screenshots and complete citations as I can. And also, I’m trying ChatGPT to help convert my raw notes into readable summaries.</p><p>I’ll share my thoughts as I go, and afterwards summarize what I think are the most promising directions for the future.</p><p>I hope this article will be helpful to others that are looking to improve machine translation for healthcare.</p><h3>User interface design for comprehension</h3><p>This grouping largely has self-contained user interface experiments.</p><h4>Leveraging uncertainty visualization to enhance multilingual chat</h4><p>Collins, C., &amp; Penn, G. (2006). <em>Leveraging uncertainty visualization to enhance multilingual chat. </em>Proceedings of the CSCW</p><p>The researchers presented a visual representation of the most probable parts of the lattice of a statistical machine translation system. The weight of each arc in the lattice is proportional to the probability of its corresponding translation. Initially, the visual representation may be confusing to interpret, but once the idea is understood, it is fairly easy to read and provides insight into the ambiguity of the translation process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KWWg4RFn7iBzA_SLagsRrA.png" /></figure><p>In addition, the researchers propose a novel approach for dealing with out-of-vocabulary (OOV) words. Rather than simply leaving these words untranslated, they suggest searching for images of the OOV words on Flickr and displaying the images alongside the untranslated words. This approach offers a unique way to handle OOVs and provides additional context for the reader.</p><p>The visual is too complex for the chat interface in my project. I haven’t seen many challenges with OOVs, but the idea of linking to a secondary database for complex words might have potential if OOVs are a problem.</p><h4>Automatic Prediction of Misconceptions in Multilingual Computer-Mediated Communication</h4><p>Yamashita, N., &amp; Ishida, T. (2006). <em>Automatic Prediction of Misconceptions in Multilingual Computer-Mediated Communication</em>. Proceedings of the 11th international conference on Intelligent user interfaces</p><p>This paper focuses on the role of machine translation in facilitating communication between people who speak different languages. The study found that misunderstandings are common in such interactions, and that both parties may think they have successfully communicated when in fact they have not.</p><p>The researchers make a distinction between stated misconceptions, which are related to mistranslations, and unstated misconceptions, which arise from assumptions made by one or both parties. They also discuss the potential use of lexical chains, which are sequences of words that are related in meaning, to help identify misunderstandings.</p><p>I didn’t understand all of the paper. In particular, it is unclear how the researchers are annotating misconceptions and measuring the success of their methods. The core idea seems to be that people often switch topics when they do not understand each other, and it can be detected using lexical chains.</p><p>Overall, the study raises the possibility that misconceptions caused by machine translation can be automatically detected in certain kinds of chat.</p><p>In doctor-patient communication, typically the doctor leads the conversation and the patient follows. I don’t think the method of lexical chains would help identify situations in which the patient misunderstands the doctor, but may identify situations in which the doctor misses some information from the patient. Unfortunately that would be a special-case solution for only one type of miscommunication; I’d prefer to find a more general-purpose solution.</p><h4>Evaluation and Usability of Back Translation for Intercultural Communication</h4><p>Shigenobu, T. (2007). <em>Evaluation and Usability of Back Translation for Intercultural Communication. </em>International Conference on Usability and Internationalization</p><p>The researchers in this study explore the use of back-translation as a feedback mechanism to improve machine translation. They argue that simply providing back-translation is not enough, and that the user interface (UI) must also be designed carefully to enable users to easily identify and correct mistakes. (I agree!)</p><p>In their experiment, the researchers used back-translation in a non-native speaker (NNS) machine translation (MT) scenario, where the back-translation was used as a feedback loop to help the author revise their original input. They found that the quality of the back-translation was highly correlated with the quality of the forward translation, although the back-translation was on average 20% worse.</p><p>The researchers also developed a real-time translation system that attempts to identify parts of the input that are “translation unstable” and highlight them to the user. However, they do not provide much detail on how this is done. They found that the approach worked well for Japanese-English translation, but not for Chinese or Korean.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*MyFalyFcmA9cKObQ8jS32w.png" /></figure><p>In my project, it may be possible to use multiple back-translations with different pivot languages to help identify “translation unstable” parts of the input.</p><h4>picoTrans: An Icon-driven User Interface for Machine Translation on Mobile Devices</h4><p>Song, W., Tanaka-Ishii, K., Finch, A., &amp; Sumita, E. (2011). <em>picoTrans: An Icon-driven User Interface for Machine Translation on Mobile Devices</em>. Proceedings of the 16th international conference on Intelligent user interfaces</p><p>The researchers present a novel approach to machine translation using icons and hierarchical categorization. The system is designed for non-native speakers of Japanese, and allows users to select from a range of pre-defined icons to communicate their intended meaning. The icons are organized into a hierarchy of categories, making it easier for users to find the appropriate icons for their needs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hvkHJxKn51nNqM0ebfEvGQ.png" /></figure><p>While the idea of using icons for communication has potential, there are some challenges with the approach. For example, the hierarchical categorization of icons may be difficult for users to navigate. Additionally, it may assume the user has awareness of Japanese verb conjugation.</p><p>Overall I found it interesting but didn’t take away implications for my work.</p><h4>Can Indicating Translation Accuracy Encourage People to Rectify Inaccurate Translations?</h4><p>Miyabe, M., &amp; Yoshino, T. (2011). <em>Can Indicating Translation Accuracy Encourage People to Rectify Inaccurate Translations?</em> International Conference on Human-Computer Interaction</p><p>The researchers in this study conduct user testing to evaluate the quality of automated machine translation. They use BLEU scores on back-translations to assess the accuracy of the translations.</p><p>The researchers tested three different indicators of translation accuracy: percentage, a 5-point scale, and a 3-point scale. However, the scales were presented in words rather than visual aids, which may have affected the results. The study focused on Japanese translation.</p><p>The researchers also had users attempt to repair inaccurate translations. They found that the 5-point scale was the preferred indicator of translation accuracy, but that the indicators did not significantly affect users’ judgments of the accuracy of the translations.</p><p>(Rapp, 2009) found that BLEU wasn’t good at measuring back-translation quality, so this isn’t entirely surprising. It’s also possible that the translators would’ve been thorough regardless of the user interface.</p><h4>Same Translation but Different Experience: The Effects of Highlighting on Machine-Translated Conversations.</h4><p>Gao, G., Wang, H.-C., Cosley, D., &amp; Fussell, S. R. (2013). <em>Same Translation but Different Experience: The Effects of Highlighting on Machine-Translated Conversations</em>. Proceedings of the SIGCHI conference on human factors in computing systems</p><p>The researchers in this study explore the use of highlighting to improve the user experience of machine translation. Their hypothesis is that highlighting certain words in the translated text can make it easier to understand and increase trust in the translation. For example, in the case of the poorly-translated sentence “Was in Beijing on a six point document send out,” highlighting the keywords “Beijing” and “six o’clock” might make it easier to infer the intended meaning, which was “Need to send this document out by six o’clock Beijing time.”</p><p>To test their hypothesis, the researchers conducted a user study comparing no highlighting, human-selected keyword highlighting, and random highlighting. The study involved Chinese-English machine translation (presumably using Google Translate) and had users engage in MT-mediated chat to complete brainstorming tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*9kJi2yS8k-k94yL0zNPDqA.png" /></figure><p>The researchers found that keyword highlighting was rated as the most clear, while random highlighting was less clear than no highlighting. They also found that participants had a slightly higher impression of their conversational partner when keyword highlighting was used.</p><p>Overall, this study provides some evidence that highlighting can improve the user experience of machine translation.</p><p>The examples show nearly-unintelligible English translations. Would it still be helpful with better quality translations from modern MT models?</p><h4>Agent Metaphor for Machine Translation Mediated Communication</h4><p>Shi, C., Lin, D., &amp; Ishida, T. (2013). <em>Agent Metaphor for Machine Translation Mediated Communication</em>. Proceedings of the 2013 international conference on Intelligent user interfaces</p><p>The researchers in this study explore the use of machine translation in a conversational agent scenario. I wasn’t able to understand the paper fully.</p><p>They propose a system in which the agent uses BLEU scores on back-translations to determine when to intervene and suggest that the author repair the message. One finding of the study is that “using machine translation almost doubles the participants’ effort” which is worth pondering.</p><h4>BBN TransTalk: Robust multilingual two-way speech-to-speech translation for mobile platforms.</h4><p>Prasad, R., Natarajan, P., Stallard, D., Saleem, S., Ananthakrishnan, S., Tsakalidis, S., … Challenner, A. (2013). BBN TransTalk: Robust multilingual two-way speech-to-speech translation for mobile platforms. <em>Computer Speech &amp; Language</em>, <em>27</em>, 475–491. doi:10.1016/J.CSL.2011.10.003</p><p>The researchers in this study developed a machine translation system for use in military communications, specifically in the context of the Pashto language. The system is designed to be used in a star trek communicator type of device, and incorporates a number of features to minimize errors and improve the user experience.</p><p>One key aspect of the system is the use of confirmation strategies, such as requiring the user to confirm the output of the automatic speech recognition (ASR) before it is sent to the machine translation (MT) and text-to-speech (TTS) components. The researchers also incorporate a number of other techniques to improve the quality of the ASR, including a large vocabulary and the use of a high-quality grapheme-to-phoneme (g2p) dictionary.</p><p>The user experience was designed to be simple and intuitive, and meant to support eyes-free communication. Press YOU for push-to-talk for yourself, HIM for the other person. There’s a way to review what it heard, and also it’ll start speaking the translation after a delay. If you don’t like it you can just push YOU to start over.</p><p>The researchers explored the use of back-translation and quality estimation (which they call confidence estimation) to improve the MT component of the system. They found that back-translation with METEOR scoring was not as effective as a confidence measure based on translation consistency, but that both approaches were useful. I think they set a threshold on the score for the system to ask the user to repeat themselves.</p><p>I enjoyed this paper — It presents a complete system with a range of research. In addition to the research I’ve summarized, they also dealt with challenges in speech recognition and machine translation as well.</p><p>I don’t think the details are applicable to MT-mediated chat in healthcare though. At a high level though I’m inspired by how simple their system is.</p><h4>Improving machine translation by showing two outputs</h4><p>Xu, B., Gao, G., Fussell, S. R., &amp; Cosley, D. (2014). <em>Improving machine translation by showing two outputs</em>. Proceedings of the SIGCHI Conference on Human Factors in Computing Systems</p><p>The researchers in this study conducted a user evaluation of a machine translation interface that provides both the original and translated sentences. The study involved a Mandarin-English translation task, and included a number of quotes from users to provide insight into their experiences with the system.</p><p>One quote mentioned that the dual translations were not useful when they were too similar. Another quote mentioned the potential usefulness of the system when the machine translation is not of high quality, such as in Russian-English translation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*K7bWK-i2i0My0vACkrxIOQ.png" /></figure><p>My notes on this paper are very limited; I read (Gao et al., 2015) first, which is a very similar paper. (Xu et al., 2014) focuses more on summarizing feedback from users.</p><h4>Enhancing machine translation with crowdsourced keyword highlighting</h4><p>Pan, M. H., &amp; Wang, H. C. (2014). <em>Enhancing machine translation with crowdsourced keyword highlighting</em>. Proceedings of the 5th ACM international conference on Collaboration across boundaries: culture, distance &amp; technology</p><p>Pan and Wang (2014) examine the use of crowdsourced keyword highlighting to improve machine translation quality in the user interface. The authors find that while highlighting can be beneficial, it only has a significant impact on difficult sentences when the highlighters are bilingual.</p><p>These results suggest that highlighting may not be a reliable method for improving machine translation in healthcare settings. I had been considering having doctors underline important words and propagate those underlines in the translation. However, that’s similar to the failed monolingual tests so I’m less confident it would work.</p><h4>Designing User Experience for Machine Translated Conversations</h4><p>Surti, T. (2015). <em>Designing User Experience for Machine Translated Conversations</em>. Proceedings of Machine Translation Summit XV: User Track</p><p>The researchers in this study conducted a user evaluation of a speech-to-speech translation system integrated into Skype. The system was developed around 2014 and involved two people speaking in different languages, with the system providing real-time translations for both participants.</p><p>The researchers were surprised to find that user complaints about the system were focused more on the user interface than on the translation quality. Users found the experience chaotic and overwhelming, with four voices (two people and two translations) often speaking simultaneously. The authors suggest using audio ducking, which adjusts the volume of the less relevant audio stream, to improve the user experience in these cases.</p><p>Additionally, users reported frustration with the perceived slowness of the system. The authors explain that this was due to the system only starting the translation once the full utterance had been received, rather than providing partial translations as the user spoke. They suggest adjusting the settings for pause duration and partial translation to improve the speed of the system.</p><p>Overall, this study provides some interesting insights into the challenges and user experience of speech-to-speech translation systems. I don’t think there’s applicability to my work though.</p><h4>Two is better than one: Improving multilingual collaboration by giving two machine translation outputs</h4><p>Gao, G., Xu, B., Hau, D., Yao, Z., Cosley, D., &amp; Fussell, S. R. (2015). <em>Two is better than one: Improving multilingual collaboration by giving two machine translation outputs</em>. Proceedings of the 18th ACM Conference on Computer Supported Cooperative Work &amp; Social Computing</p><p>The researchers in this study explored the use of multiple machine translation outputs in MT-mediated chat. They used two different MT systems (Google and Bing) for Mandarin-English translation, and compared the results to using English on both sides and using only one MT system.</p><p>The researchers conducted a user study with a task-based scenario involving navigating a map. They found that using two MT systems was better than using one or using English on both sides. In some cases, the use of two MT systems was nearly equivalent to using English.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A-4U9NSK3ZQM432pshNrQg.png" /></figure><p>One surprising finding was that participants did not report a higher workload when using two MT systems, and in fact reported a lower workload compared to using one MT system. However, the workload was still higher than using English on both sides.</p><p>One limitation of the study is that the two MT systems used in the experiment did not produce particularly high-quality translations, which may have contributed to the effectiveness of the approach.</p><p>In my work, I explored showing multiple translations in the user interface from different translation systems. Unfortunately, the translations from modern MT systems were often very similar so there may not be as much benefit. I also found it challenging to design user interfaces that could work for both the reading and writing side of communication, and having multiple translations plus back-translations on the writing side took up too much screen space.</p><h4>Beyond translation: Design and evaluation of an emotional and contextual knowledge interface for foreign language social media posts</h4><p>Lim, H., Cosley, D., &amp; Fussell, S. R. (2018). <em>Beyond translation: Design and evaluation of an emotional and contextual knowledge interface for foreign language social media posts</em>. Proceedings of the 2018 CHI Conference on Human Factors in Computing Systems</p><p>The researchers in this study explored the use of multiple techniques to enhance the translation of social media posts. They used named entity recognition to identify words that could be linked to Wikipedia, added a display showing the sentiment of the translated post, and extracted sentiment themes from the posts. The study focused on Facebook profiles in other languages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*7VdCiyzL9QKLYiS-XyQu2w.png" /></figure><p>The researchers conducted a user evaluation of the enhanced translation system and found that it was perceived positively by users. Users reported that they were able to comprehend posts better using the enhanced system, and were more willing to engage with the posts (e.g. liking them). However, there was no significant effect on the desire to socialize or make friends with the poster.</p><p>The researchers also found that the enhanced system slightly reduced cognitive load, compared to using only the translated text.</p><p>In my project, there could be benefits to integrating health information in this way, especially if it’s professionally translated in multiple languages. Doctors might perceive Wikipedia links as too risky, but there may be translations of Mayo Clinic or other trusted resources available.</p><h4>Three Directions for the Design of Human-Centered Machine Translation</h4><p>Robertson, S., Deng, W. H., Gebru, T., Mitchell, M., Liebling, D. J., Lahav, M., … Salehi, N. (2021). <em>Three Directions for the Design of Human-Centered Machine Translation</em>.</p><p>Robertson et al. (2021) discuss the challenges of machine translation and propose three directions for future research in human-centered machine translation. These include helping users craft good inputs, helping users understand translations, and expanding interactivity and adaptivity. They ran a social media survey and also ran a pilot test of TranslatorBot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*VQibePiSEWvUu7dSRMIxGQ.png" /></figure><p>One key idea is that translation tools should be able to identify messages that are difficult to translate and provide strategies to adjust the text. For example, TranslatorBot will warn users if their message is very long or if they use words that are unstable under backtranslation.</p><p>Another important direction is making it easier for users to understand the translations. This could include using quality estimation models to help users assess the accuracy of the translation, and providing easy access to backtranslation and bilingual dictionaries.</p><p>Finally, the authors suggest exploring ways to make machine translation more interactive and adaptable. This could include allowing users to prioritize the accuracy of certain words or phrases, and utilizing contextual information such as chat history to improve the quality of the translations. These ideas could be useful for designing the user interface of a healthcare chat system.</p><p>Overall it’s a good read! For my project, they suggest several ideas along the same direction I’m headed:</p><ul><li>Could we use back-translation to estimate stability? I need to read (Mehta et al., 2020)</li><li>Integrating a bilingual dictionary or Wiki links for sensemaking</li><li>Users in healthcare need adequacy more than fluency, could we tune a MT system for that?</li><li>Are there ways to integrate chat history?</li></ul><h4>Bridging Fluency Disparity between Native and Nonnative Speakers in Multilingual Multiparty Collaboration Using a Clarification Agent</h4><p>Duan, W., Yamashita, N., Shirai, Y., &amp; Fussell, S. R. (2021). Bridging Fluency Disparity between Native and Nonnative Speakers in Multilingual Multiparty Collaboration Using a Clarification Agent. <em>Proceedings of the ACM on Human-Computer Interaction</em>, <em>5</em>. doi:10.1145/3479579</p><p>In this study, researchers tested the effectiveness of a new automated speech recognition (ASR) and text-to-speech (TTS) bot designed to assist non-native speakers (NNS) in communication. The bot uses word frequency analysis to identify and interrupt the conversation to ask for clarification on words that NNS are unlikely to know.</p><p>Three conditions were tested in the study: the use of the ASR/TTS bot, a “dumb” baseline version of the bot, and no bot at all. The results of the study showed that the ASR/TTS bot was effective in helping NNS communicate more evenly with native speakers (NS), and that even the baseline version of the bot was useful at times.</p><p>Participants in the study reported several benefits of using the ASR/TTS bot, including that it allowed NNS to ask for clarification without feeling embarrassed or self-conscious, and that it helped to bridge the gap in understanding complex words. Additionally, the bot’s interruptions would sometimes “buy time” for NNS to try and understand the conversation before NS moved on.</p><p>Interestingly, the researchers also found that exposure to the ASR/TTS bot caused NS to change their behavior in subsequent sessions, making them more aware of their vocabulary choices and more likely to explain or avoid complex words.</p><p>In my project, the core idea of asking for clarification of complex words might make sense, similar to (Robertson et al., 2021)’s TranslatorBot.</p><p>Additionally, I like the study’s approach of placing the burden of clarification on the speaker rather than the listener (who is already struggling). I could imagine more focus on writing tools rather than just trying to support the reader. I also like how the authors were aware of social dynamics and wanted to alleviate stress from the non-native speakers because they were already stressed. In a healthcare chat setting it might be similar to place more burden on the doctors to have effective communication rather than just giving patients a way to look up definitions of words. Although my solutions are unrefined in this area, I agree with the perspective of unburdening the disadvantaged party.</p><h4>Backtranslation Feedback Improves User Confidence in MT, Not Quality</h4><p>Zouhar, V., Novák, M., Žilinec, M., Bojar, O., Obregón, M., Hill, R. L., … Yankovskaya, L. (2021). Backtranslation Feedback Improves User Confidence in MT, Not Quality. <em>NAACL-HLT 2021–2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Proceedings of the Conference</em></p><p>Zouhar et al. (2021) examines the effectiveness of using backtranslation to improve the quality of machine translation. The authors find that while backtranslation increases user confidence in the translation, it does not necessarily improve the quality of the translation itself.</p><p>The authors also experiment with paraphrasing and quality estimation to improve translation quality. They found that paraphrasing also increases user confidence in the translation, but it actually leads to decreased translation quality. They didn’t find a benefit from quality estimation, though it’s possible that the quality estimation method was too simple to be useful.</p><p>Overall, the paper shows that user confidence in a translation interface is not necessarily correlated with improved translation capabilities. This is an important finding for the design of future studies.</p><p>Although the paper raises doubts on several approaches, I remain optimistic that there may be a way to use backtranslation to improve user comprehension or to improve authoring for non-native speakers. I’m less optimistic about quality estimation after reading the paper though.</p><h4>Beyond General Purpose Machine Translation: The Need for Context-specific Empirical Research to Design for Appropriate User Trust</h4><p>Deng, W., Mehandru, N., Robertson, S., &amp; Salehi, N. (2022). <em>Beyond General Purpose Machine Translation: The Need for Context-specific Empirical Research to Design for Appropriate User Trust</em>. arXiv preprint arXiv:2205.06920</p><p>This paper was very similar to “Reliable and Safe User of Machine Translation in Medical Settings” (Mehandru et al., 2022). But it added many citations on user interfaces. This paragraph is worth quoting:</p><blockquote>Researchers have also designed and evaluated interfaces that provide additional information other than the back- translation, such as two different translations [15, 61], highlights of key words [14, 26], emotional and cultural context [26], and numerical indications of translation quality [34]. Lab studies suggest that additional information can improve message recipients’ perceived understanding without increasing the mental workload [14, 15, 26, 61], but it is not clear from these studies whether users’ perceived understanding aligns with their actual understanding of the intended meaning [43]. In other words, we do not know whether these interventions help users appropriately calibrate their trust in MT, or whether it promotes trust indeterminately even when translations are incorrect.</blockquote><p>It seems to argue against (Robertson and Diaz, 2022) to some extent, suggesting that seamful design for MT may not help users to identify poor translations.</p><p>The above quote seems to say that it’s a hopeless quest, but I disagree. The field has experimented with many approaches and had limited success in building a high quality human+computer system. I suspect we’re in need of a paradigm shift rather than more research of the same type, and I feel even more confident that a paradigm shift to language learning has a chance at being effective.</p><h3>Other user studies</h3><p>These papers didn’t explore user interface changes; they sought more to understand the challenges in MT-mediated communication.</p><h4>Machine translation vs. Common language: Effects on idea exchange in cross-lingual groups</h4><p>Wang, H. C., Fussell, S. R., &amp; Cosley, D. (2013). Machine translation vs. Common language: Effects on idea exchange in cross-lingual groups. <em>Proceedings of the ACM Conference on Computer Supported Cooperative Work, CSCW</em>, 935–944. doi:10.1145/2441776.2441882</p><p>In this study, researchers explored the impact of machine translation on communication productivity and comprehension, comparing brainstorming in English to brainstorming in native language with machine translation. The study found that while machine translation can improve productivity of ideas, it can also lower comprehension.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*Xjfxe-FIk7SdtvAm118LBA.png" /></figure><p>This trade-off may be acceptable for certain applications, but could be problematic in others where comprehension is critical like healthcare.</p><p>In my project, I’m aware of the challenge and I’ve been working to support better comprehension, whether through multiple translations or integrated bilingual dictionaries.</p><h4>Multilingual Chat through Machine Translation: A Case of English-Russian</h4><p>Şahin, M., &amp; Duman, D. (2013). Multilingual Chat through Machine Translation: A Case of English-Russian. <em>Meta</em>, <em>58</em>(2), 397–410. <a href="https://doi.org/10.7202/1024180ar">https://doi.org/10.7202/1024180ar</a></p><p>This paper explored the use of machine translation in English-Russian communication. The authors found that the MT-mediated conversation worked surprisingly well, with about half of the messages being translated perfectly and the majority being accurate and intelligible.</p><p>The authors remained positive and optimistic about the future of MT-mediated communication despite any challenges, though they did express some concern about using it in high-stakes situations like healthcare. Overall, their tone was much more positive than other works in the field.</p><h4>Multilingual Communication via Best-Balanced Machine Translation</h4><p>Pituxcoosuvarn, M., &amp; Ishida, T. (2018). Multilingual Communication via Best-Balanced Machine Translation. <em>New Generation Computing 2018 36:4</em>, <em>36</em>, 349–364. doi:10.1007/S00354–018–0041–7</p><p>This paper introduces the concept of “quality of message” (QoM), which considers not only the quality of the machine translation but also the writing proficiency of the author and the reading proficiency of the reader.</p><p>The authors used this concept to determine the best language for participants to read and write in, in three conditions: all English, all native language with machine translation, or a best-balanced approach. They found that the QoM of a message had a relationship with the likelihood of a conversation breakdown, and that generally, the less variation in QoM, the less variation in talkativeness.</p><p>The findings of this study suggest that the QoM concept could be useful in determining when a doctor should switch from writing in English to writing in the patient’s native language, or from reading in English to reading in the patient’s native language. It also suggests that patients with limited English proficiency may be more forthcoming with their doctors when chatting in their native language even with machine translation.</p><h4>Opportunities for Human-centered Evaluation of Machine Translation Systems</h4><p>Liebling, D. J., Robertson, S., Heller, K., &amp; Deng, W. H. (2022). <em>Opportunities for Human-centered Evaluation of Machine Translation Systems</em>. 229–240. doi:10.18653/V1/2022.FINDINGS-NAACL.17</p><p>This paper discusses the use of machine translation in healthcare and highlights the need for better metrics to evaluate its effectiveness. The authors emphasize that a machine translation system is more than simply the machine translation model. The success of a machine translation system includes not only the quality of the model but also the quality of the user interface for the goal it’s addressing.</p><p>They also emphasize the importance of adequacy in task success, despite the traditional focus on fluency in metrics like BLEU. METEOR and COMET are suggested as adequacy metrics.</p><blockquote>There is growing evidence that MT is widely used in high-stakes contexts such as healthcare (Vieira et al., 2020)</blockquote><p>That’s an interesting change of perspective — It’s not a question of whether we can make machine translation useful or not. It’s already being used, and our work could make it safer.</p><p>Overall this is a good summary paper to read.</p><h4>Understanding Cross-lingual Pragmatic Misunderstandings in Email Communication</h4><p>Lim, H., Cosley, D., &amp; Fussell, S. R. (2022). Understanding Cross-lingual Pragmatic Misunderstandings in Email Communication. <em>Proceedings of the ACM on Human-Computer Interaction</em>, <em>6</em>. doi:10.1145/3512976</p><p>This paper presents a detailed study on email miscommunication between native and non-native speakers of English. The findings showed that it is generally better for non-native speakers to use English instead of machine translation, as their messages are received more positively and their intentions are conveyed more accurately. The study also found that providing information about the speaker/writer can be helpful in improving communication, potentially due to a “humanizing” effect.</p><p>The results showed that length of time spent in an English-speaking country was relevant for the communication of politeness intentions but not for other factors. The non-native speakers in the study had relatively high TOEFL scores, at the 92nd percentile.</p><p>In my project, this has me wondering when NNS_EN &lt; NNS_TR. Below what TOEFL score would it be better to translate? Above what TOEFL score would it be better for patients to write in English with supporting technology?</p><p>The work on showing the name and background of the participants also got me thinking about ways to help the patient and doctor see one another as people more, even in a chat medium. Even simple things like clear photos of each might help. Or a quick introduction, which sadly is often skipped in a rush, but this study suggests that it might help the conversation make it through any challenges.</p><h3>Computer-Aided Translation (CAT) tools</h3><p>I found a number of papers meant to aid translators in writing translations, and they may be relevant in making user interfaces for text entry in healthcare chat.</p><h4>Target-Text Mediated Interactive Machine Translation</h4><p>Foster, G., Isabelle, P., &amp; Plamondon, P. (1997). Target-Text Mediated Interactive Machine Translation. <em>Machine Translation</em>, <em>12</em>, 175–194. doi:10.1023/a:1007999327580</p><p>This paper was an early exploration of the use of interactive machine translation (IMT), focusing on word completion using both the source sentence and partial translation. The authors faced some challenges in combining the probabilities correctly and in accessing the translation model probabilities. They also found that the translation model was effective for nouns, verbs, and open-domain words, but the regular language model was better for closed-domain words, making it difficult to combine the two effectively.</p><p>The authors proposed a method for preventing re-translation using an “anti-cache” and showed that IMT was possible with 1997 technology. They concluded that IMT was a better fit for the needs of skilled translators, as it allowed for more control and flexibility in the translation process.</p><h4>Using word alignments to assist computer-aided translation users by marking which target-side words to change or keep unedited</h4><p>Espla, M., Sánchez-Martínez, F., &amp; Forcada, M. L. (2011). <em>Using word alignments to assist computer-aided translation users by marking which target-side words to change or keep unedited</em>. Proceedings of the 15th Annual conference of the European Association for Machine Translation</p><p>Espla, Sánchez-Martínez, &amp; Forcada (2011) proposes using word alignments to assist computer-aided translation users by marking which target-side words to change or keep unedited. The authors used GIZA++ alignment to spot similarities and differences in the alignments and identify parts of the original text that may not have been translated.</p><p>The authors were positive about the results of their approach, but it is unclear from the paper how they evaluated the effectiveness of their method and whether it would be useful for real-world translation users.</p><p>I was hopeful about this paper because I was searching for publications that used machine translation attention weights to help show the inner workings of the system. Unfortunately this paper predates transformers by a lot, and I didn’t see much in the way of ideas to use.</p><h4>User Evaluation of Interactive Machine Translation Systems.</h4><p>Alabau, V., Leiva, L. A., Ortiz-Martínez, D., &amp; Casacuberta, F. (2012). <em>User Evaluation of Interactive Machine Translation Systems</em>. Proceedings of the 16th Annual conference of the European Association for Machine Translation</p><p>This paper presents a study on the design of an effective user interface for interactive machine translation (IMT), comparing it against a phrase-based baseline. The authors found that their initial system was not an improvement, but after addressing feedback, the second system performed much better. The findings suggest that it is important to avoid jostling the predictions too much, to not undo any conversions that the user is making, to keep the user interface simple, and to pay attention to details like capitalization and number formatting. Overall, the study emphasizes the importance of UI design in evaluating an IMT system.</p><h4>MT Quality Estimation for Computer-assisted Translation: Does it Really Help?</h4><p>Turchi, M., Negri, M., Federico, M., &amp; Kessler, F.-F. B. (2015). <em>MT Quality Estimation for Computer-assisted Translation: Does it Really Help?</em> Proceedings of the 53rd Annual Meeting of the Association for Computational Linguistics and the 7th International Joint Conference on Natural Language Processing (Volume 2: Short Papers)</p><p>Turchi et al. (2015) investigates the effectiveness of machine translation quality estimation (QE) for computer-assisted translation. The authors conducted a study with human translators using the Mate-Cat tool, comparing the performance of translators with and without QE indicators.</p><p>The study found that QE had a mild benefit for computer-assisted translation, with translators using QE indicators producing slightly better translations than those without.</p><p>Their QE model is using source-side complexity metrics and target-side language model probabilities to compute a score. I think it’s unlikely that a target-side language model probability would be useful in a modern QE model because neural machine translation is so good at fluency.</p><p>It’s also possible that the color indicators may have needed more time for users to get used to, and the randomization of the indicators may have dampened the potential benefits.</p><p>In my own work, I would be interested in using QE to inform authors about the quality of their text, rather than for translation tasks.</p><h4>INMT: Interactive Neural Machine Translation Prediction</h4><p>Santy, S., Dandapat, S., Choudhury, M., &amp; Bali, K. (2019). INMT: Interactive Neural Machine Translation Prediction. <em>EMNLP-IJCNLP 2019–2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing, Proceedings of System Demonstrations</em>, 103–108. doi:10.18653/V1/D19–3018</p><p>Santy et al. (2019) presents a system for interactive neural machine translation prediction (INMT), which uses a neural machine translation (NMT) model to suggest word and phrase completions in real-time as the user types. The authors demonstrate the system using a beam length of 2 to avoid diversity problems, but note that this can lead to challenges with partial words in the search.</p><p>The INMT system has a user interface that allows users to see which source words have been translated so far and provides BLEU scores for completion suggestions. However, the authors acknowledge that the completion user interface is not ideal and that the system only leads to a 30% reduction in keystrokes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SkNVxRxOYc0cSYob20ln6A.png" /></figure><p>This study presents an interesting approach to using NMT for real-time translation, but the limitations of the system suggest that it may not be suitable for all contexts. In particular, the system may be useful for providing a “training wheels” approach to translation for doctors who have some knowledge of a second language, but it is unlikely to be effective for patients who have little or no knowledge of the second language. Additionally, the alignment visualization provided by the INMT system could be useful for some applications, but it is unclear how it could be incorporated into a healthcare chat interface.</p><h3>Healthcare machine translation</h3><h4>Usability Issues in an Interactive Speech-to-Speech Translation System for Healthcare</h4><p>Seligman, M., &amp; Dillinger, M. (2006). <em>Usability Issues in an Interactive Speech-to-Speech Translation System for Healthcare</em>. Proceedings of the First International Workshop on Medical Speech Translation</p><p>Seligman &amp; Dillinger (2006) examines usability issues in an interactive speech-to-speech translation system for healthcare. The authors provide a useful introduction to the challenges of translation in healthcare and discuss some of the proprietary technology used in their system, including techniques for ensuring accurate lexical senses in back-translation and the use of meaning cues to improve translation quality.</p><p>One of the key features of the system described in the paper is the ability to gradually tune word-sense preferences, which the authors argue can improve translation quality. Additionally, the system includes a “save as shortcut” feature that allows users to save commonly used phrases for later use, which could be useful in a healthcare chat interface.</p><p>However, the paper is somewhat dated and does not include any usability testing, so it is unclear how effective the system described would be in a modern healthcare context. Additionally, the use of voice commands and voice enrollment for automatic speech recognition may not be ideal for all users, particularly those who are not experts in the technology.</p><p>Their description of Meaning Cues sounds similar to what I’m doing with bilingual dictionaries.</p><h4>Real-time Multi-media translation for healthcare: a usability study</h4><p>Seligman, M., &amp; Dillinger, M. (2011). <em>Real-time Multi-media translation for healthcare: a usability study</em>. Proceedings of Machine Translation Summit XIII: Papers</p><p>Seligman &amp; Dillinger (2011) presents a usability study of a real-time multi-media translation system for healthcare, called Converser. The authors describe the challenges of deploying the system, including issues with literacy, font size and style, language switching, text-to-speech speed, and security. They also discuss the challenges of training users on the system and the difficulties of using the system in a hospital environment, where space and ambient noise can be limiting factors.</p><p>Overall, this paper provides a useful overview of the challenges of deploying a real-time translation system in a healthcare setting. This paper may be useful for identifying potential challenges and limitations of using translation technology in healthcare, but it does not provide definitive answers about the effectiveness of such systems.</p><h4>Automatic Speech Translation for Healthcare: Some Internet and Interface Aspects</h4><p>Seligman, M., &amp; Dillinger, M. (2013). <em>Automatic Speech Translation for Healthcare: Some Internet and Interface Aspects</em>. Proceedings of the 10th International Conference on Terminology and Artificial Intelligence (TIA-13)</p><p>Seligman &amp; Dillinger (2013) presents an update on the development of their real-time multi-media translation system for healthcare, Converser 4.0. The authors describe some of the challenges of deploying the system, including issues with internet connectivity and the use of cloud-based automatic speech recognition.</p><p>The authors also discuss the use of meaning cues and other techniques to improve the quality of the machine translation, and describe some updates to the user interface, including a “feeling lucky” feature for the machine translation. In this paper they mention that WordNet is one of the sources for meaning cues.</p><p>Overall, this paper provides a brief update on the development of the Converser system, but it does not include much new information.</p><h4>Local Health Department Translation Processes: Potential of Machine Translation Technologies to Help Meet Needs</h4><p>Turner, A. M., Mandel, H., &amp; Capurro, D. (2013). Local Health Department Translation Processes: Potential of Machine Translation Technologies to Help Meet Needs. <em>AMIA Annual Symposium Proceedings</em>, <em>2013</em>, 1378.</p><p>Turner et al. (2013) survey the use of machine translation technologies in local health departments. The study, which was part of the TransPHorm project funded by the National Library of Medicine, aimed to identify potential ways that machine translation could help health departments better serve their communities.</p><p>Most health departments felt they were underserving their communities, regardless of the size or resources of the department. They also found that most departments used in-house bilingual staff for translation, and that there was a high level of awareness and interest in shared translation resources even though few departments contributed to shared translations.</p><p>Health professionals were optimistic about machine translation, especially if it were tailored to public health communication.</p><p>Overall, the paper felt more optimistic about machine translation compared to (Mandel and Turner, 2013), which I summarized in a prior post.</p><h4>Evaluation and revision of a speech translation system for healthcare</h4><p>Seligman, M., &amp; Dillinger, M. (2015). <em>Evaluation and revision of a speech translation system for healthcare</em>. Proceedings of the 12th International Workshop on Spoken Language Translation: Papers</p><p>Seligman &amp; Dillinger (2015) presents an evaluation and revision of the Converser for Healthcare speech translation system. The authors describe their use of off-the-shelf components for automatic speech recognition, machine translation, and text-to-speech, and discuss feedback from both patients and staff who used the system.</p><p>The authors found that the system was generally well-received by patients and staff, and that it was useful in a variety of medical scenarios. In particular, it was best received by technology-positive participants “in a pinch”. They also identified challenges in verification of translations. In response to these challenges, the authors revised the user interface to adopt a “check before sending” and “edit after sending” paradigm.</p><p>This quote resonates with my experience:</p><blockquote>While numerous staff members (and, separately, their managers) praised the ability to verify translations, others also stressed that verification consumed limited time.</blockquote><p>This could mean that staff who are very busy may skip verification at times, which could lead to miscommunications and medical risks.</p><p>This paper also included a picture of meaning cues, which could be relevant for my work:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0poYS1T-Mi6we6WWsjxa5w.png" /></figure><p>There are some differences in how meaning cues work in this system compared to what I’m working on. In my use case, I’m integrating the dictionary to help teach the user the secondary language rather than focusing on the meaning cues for the user’s primary language.</p><p>Overall, this paper provides valuable insights into the use of speech translation technology in a healthcare setting. The authors’ findings suggest that the system was useful and well-received, which was sorely needed in their previous publications.</p><p>This was also the most recent paper I found by this group of authors. I tried searching for Converser or Spoken Translation, but I didn’t find anything recent.</p><h4>Using Google Translate in the hospital: A case report</h4><p>Leite, F. O., Cochat, C., Salgado, H., Costa, M. P. D., Queirós, M., Campos, O., &amp; Carvalho, P. (1 2016). Using Google Translate^© in the hospital: A case report. <em>Technology and Health Care</em>, <em>24</em>, 965–968. doi:10.3233/THC-161241</p><p>Leite et al. (2016) present a case study of using Google Translate for Ukrainian-Portuguese translation in a hospital setting. One complication was that a family member was available for translation, but the patient thought the family member was trying to keep him hospitalized. The authors report that the translation was successful in the case study even though it concerned very complex mental health challenges.</p><h4>Workshop on Machine Translation (WMT) 2016, Biomedical Track</h4><p>The biomedical track mainly concerns biomedical titles and abstracts from scientific publications, predominantly using training data from the Scielo corpus. They also included a parallel corpus of MEDLINE titles.</p><p>Only Spanish-English and English-Spanish attracted multiple submissions. I took notes on two high-scoring teams, IXA and TALP. They both used Moses for their MT system. The IXA team focused on the challenge of out-of-vocabulary words (OOVs). They used SNOMED-CT to augment translation vocabulary and further augmented vocabulary using morphology and transliteration.</p><p>The TALP team also worked on OOVs, but used a bilingual embedding to expand their vocabulary. They also worked to improve the fluency of translations using a neural character-based language model.</p><h4>Babeldr vs Google Translate: A user study at Geneva university hospitals (HUG)</h4><p>Bouillon, P., Gerlach, J., Spechbach, H., Tsourakis, N., &amp; Mallem, H. (2017). <em>Babeldr vs Google Translate: A user study at Geneva university hospitals (HUG)</em>. 20th Annual Conference of the European Association for Machine Translation (EAMT)</p><p>Bouillon et al. (2017) study the effectiveness of BabelDr, their MT system, compared to Google Translate with hospital staff and patient actors.</p><p>BabelDr forces staff to search for predefined translations and structured questions such as yes-no questions. In contrast Google Translate will produce translations of any input.</p><p>Staff found BabelDr frustrating at times because they couldn’t say exactly what they wanted. However, they were more accurate in diagnosis than they were with Google Translate, and it’s wonderful to see researchers evaluate a critical healthcare task like diagnosis rather than just BLEU scores or subjective opinions on translation quality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bvu-Mu2wcTB99svk-O66og.png" /></figure><p>The evaluation didn’t feel like an entirely fair comparison, because when doctors could not find a translation in BabelDr they would have to rephrase and try again. In contrast, Google Translate didn’t reject any input. On the other hand, it’s a conclusive test of the user interface. Like other papers I’ve seen, it’s especially helpful to use closed-ended questions in a translation situation because it allows the system to rely on professional translations.</p><p>This is similar to what I would’ve done in telemedicine with chatbot translation.</p><h4>Comparison of the quality of two speech translators in emergency settings : A case study with standardized Arabic speaking patients with abdominal pain</h4><p>Spechbach, H., Mallem, I. S. H., Gerlach, J., Tsourakis, N., &amp; Bouillon, P. (2017). <em>Comparison of the quality of two speech translators in emergency settings : A case study with standardized Arabic speaking patients with abdominal pain</em>. European Congress of Emergency Medicine, (EUSEM 2017)</p><p>This is a highly abbreviated version of the previous paper on BabelDr.</p><h4>The MeSpEN Resource for English-Spanish Medical Machine Translation and Terminologies: Census of Parallel Corpora, Glossaries and Term Translations</h4><p>Villegas, M., Intxaurrondo, A., Gonzalez-Agirre, A., Marimon, M., &amp; Krallinger, M. (2018). <em>The MeSpEN Resource for English-Spanish Medical Machine Translation and Terminologies: Census of Parallel Corpora, Glossaries and Term Translations</em>. LREC MultilingualBIO: multilingual biomedical text processing</p><p>Villegas et al. (2018) presents the MeSpEN resource, a collection of parallel corpora, glossaries, and term translations for English-Spanish medical machine translation. The authors demonstrate the need for specialized medical data sets, citing previous work showing the inadequacy of general-purpose models for medical translation tasks. The MeSpEN resource includes data from a variety of sources, including academic publications and patient-facing resources like MedlinePlus. The authors also provide 46 bilingual glossaries and discuss the MDM-Portal, a database of translated questionnaires.</p><p>This paper provides a wealth of specialized data for English-Spanish medical machine translation. The MeSpEN resource, the EMEA corpus, and the MDM-Portal, in particular, may be potential sources of parallel data for medical chat translation systems.</p><h4>A Speech-Enabled Fixed-Phrase Translator for Emergency Settings: Crossover Study</h4><p>Spechbach, H., Gerlach, J., Karker, S. M., Tsourakis, N., Combescure, C., &amp; Bouillon, P. (2019). A Speech-Enabled Fixed-Phrase Translator for Emergency Settings: Crossover Study. <em>JMIR Med Inform 2019</em></p><p>Spechbach et al. (2019) presents a speech-enabled fixed-phrase translator called BabelDr, which is designed for use in emergency settings. The authors conducted a study with 12 French-speaking doctors and 2 Arabic-speaking patients, in which the doctors were asked to use BabelDr to diagnose the patients’ simulated symptoms. The study found that all doctors were able to reach the correct diagnosis using BabelDr, indicating that the tool is effective for facilitating communication in emergency settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XyYNZRmnmhnJJs1wqB38CQ.png" /></figure><p>However, the study also raises some questions about the efficiency of using a fixed-phrase translator in a healthcare setting. The time to diagnosis was relatively long compared to diagnosis of cystitis in telemedicine in my experience. Doctors also remained frustrated with being limited to a fixed bank of phrases.</p><p>I’m concerned that the authors needed to set the system category to “lower back pain” to allow the search to work. That suggests that the domain of medicine may be narrowed sufficiently even before the medical professional says their first sentence. I also had questions about the way they search for similar messages — I expect that the findings would be highly sensitive to the quality of the similarity algorithm, which is not described.</p><p>I’d like to see subsequent research explore a combination between a fixed-phrase translator and open-domain translator like Google Translate to address the limitations of the phrase bank.</p><h4>A Smart Chatbot Architecture based NLP and Machine Learning for Health Care Assistance</h4><p>Ayanouz, S., Abdelhakim, B. A., &amp; Benhmed, M. (2020). <em>A Smart Chatbot Architecture based NLP and Machine Learning for Health Care Assistance</em>. Proceedings of the 3rd International Conference on Networking, Information Systems &amp; Security</p><p>This paper presents a brief review of research on the use of multilingual chatbots in healthcare settings. The authors suggest that user satisfaction should be the primary measure of the effectiveness of these chatbots, but this will be problematic. In my experience, patient satisfaction is most correlated with short-term things like whether the patient got antibiotics, not long-term health benefits.</p><h4>Multilingual Healthcare Chatbot Using Machine Learning</h4><p>Badlani, S., Aditya, T., Dave, M., &amp; Chaudhari, S. (2021). <em>Multilingual Healthcare Chatbot Using Machine Learning</em>. 2021 2nd International Conference for Emerging Technology (INCET)</p><p>This paper surveys some ideas in multilingual chatbots, and it’s interesting to see that it’s similar in many ways to my experience in healthcare. However, it’s mainly an idea survey rather than a system evaluation so I didn’t take much away from it.</p><h4>Findings of the WMT 2021 Biomedical Translation Shared Task: Summaries of Animal Experiments as New Test Set</h4><p>Yeganova, L., Wiemann, D., Neves, M., Vezzani, F., Siu, A., Unanue, I. J., … Yepes, A. J. (2021). <em>Findings of the WMT 2021 Biomedical Translation Shared Task: Summaries of Animal Experiments as New Test Set</em>. Sixth Conference on Machine Translation</p><p>The authors note that the quality of machine translations has improved significantly in recent years, but also highlight some cases where translations were not entirely accurate. They provide some examples of recent challenges:</p><blockquote>There have been cases in which abbreviations were not translated correctly (e.g. HGS vs FPM for fuerza de prensión manual) and some times specific terms were not translated, e.g. receiver operating characteristic curve. Only in a few cases word gender was different to the article one. There are examples of words that are not translated properly for instance adnexal has been translated as adnexiales instead of anexas by one of the teams.</blockquote><p>I saw the abbreviation problem with “UTI” in a previous post. Also, all systems were neural machine translation despite some preference for phrase translations in healthcare. It’s plausible that evaluation has been too sensitive to fluency and not sensitive enough to adequacy, as a result of over-reliance on BLEU as the primary metric.</p><p>I was also disappointed that it’s a unified biomedical track which combines many different kinds of biomedical communication. In particular, I feel that doctor-patient communication is quite different than doctor-doctor communication or scientist-scientist communication, and that those types of communications may need separate translation models or at least that the translation models should be aware of the recipient of the communication.</p><h4>How well do real-time machine translation apps perform in practice? Insights from a literature review</h4><p>Pluymaekers, M. (2022). <em>How well do real-time machine translation apps perform in practice? Insights from a literature review</em>. Proceedings of the 23rd Annual Conference of the European Association for Machine Translation</p><p>Pluymaekers (2022) is a literature review of the performance of real-time machine translation apps in practice. The review focuses on studies of the use of machine translation in communication apps, particularly in the healthcare domain. The author focuses on “fitness for purpose” as a key factor in evaluation — Machine translation is being applied in the context of a large system, and should be evaluated by how well it allows users to achieve their goals. This is aligned with the frequent statement in healthcare that adequacy is more important than fluency for medicine. The review includes a number of studies that evaluate the ability of machine translation to facilitate accurate diagnosis, which is a good example of fitness for purpose.</p><p>However, many of the papers included in the review are relatively old, with the most recent study being from 2019. There is a need for more recent research on the performance of machine translation in healthcare contexts, as the field of neural machine translation has advanced significantly since many of the studies were published.</p><h3>Course-correcting my project</h3><p>I most recently read the “three directions” paper and I’ll organize my thoughts in a similar way.</p><h4>Directions that may help understand translations</h4><ul><li>Showing multiple translations — There’s some evidence that this helps, and I’m sure it’s best when the MT systems are unreliable and make different errors. That’s not the case with the MT systems I have right now, but could become the case in the future if I train one especially for doctor-patient communication.</li><li>Linking words to external knowledge sources — There’s some evidence that this can help, whether bilingual dictionaries or Wikipedia. In the healthcare space, linking to Mayo Clinic or another translated resource may be a good option too. One downside is that it places more burden on the reader, who may already be struggling.</li></ul><p>I’m not optimistic about:</p><ul><li>Quality estimation for understanding — There are mixed results of using this in systems, and it’s very hard to have reliable QE models especially with good NMT models.</li></ul><h4>Directions that may help to write for MT</h4><ul><li>Back-translation for review — I’m optimistic about back-translation because it’s so widely used even in healthcare. That said, it needs more work to ensure that it actually helps people assess translation quality rather than increasing trust without increasing quality.</li><li>Flag “unstable” phrases — This seems worth exploring. It might be hard to keep latency low if I’m using web APIs though.</li><li>Redirect towards pre-translated databases — I’ve read about multiple successes from pretranslated content. I’m not sure if I want to build such a database for this project, but I might consider using an already-existing database if one is available. In a company, this would be a great option — It’s simple and reliable. Moreover, there’s already pressure to standardize physician content anyway so the database may exist depending on your company.</li><li>Automatically ask for clarification on rare words — The paper that did this in a speech system was quite effective. There might be a way to use click data on definitions to bootstrap data on word familiarity in secondary languages.</li></ul><p>These directions may help for writing in a secondary language, once the writer knows enough:</p><ul><li>Word completion, possibly with the Google Docs interface — Once the doctor is learning Spanish, I bet ideas from CAT like word completion would help a lot. The big questions I have are 1) What’s the best way to use the other person’s chat as context into the language model? 2) How can we make sure that the user double-checks the content, even when rushed?</li></ul><p>I’m not optimistic about:</p><ul><li>Suggesting revision based on quality estimation</li><li>Detecting misunderstandings with lexical chains</li></ul><h4>Other directions</h4><p>The quality of message (QoM) paper was interesting, and the papers showing that ESL communication was often better than relying on MT. I wonder if the chat could start by helping the doctor and patient decide the best communication strategy based on their language proficiencies, MT quality, and any medical risk factors in the case? For instance something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*afhllOf-GtOrgDAs4-N9Eg.png" /></figure><p>The one thing I missed was how to analyze the patient’s case — the medical severity and urgency of the case should be considered in deciding the best option.</p><p>I have a hunch that rapport is even more important in MT-mediated chat. The literature had hints that it may be critical to weathering all the communication challenges. I bet there’s a way to give physicians more of an opportunity to establish rapport with one or two automated questions.</p><h3>Assorted other observations</h3><p>BBN TransTalk would’ve been a good fit for hospitals, in contrast with Converser. The Converser papers often mentioned challenges like needing to cart around a laptop or users struggling with the interface. TransTalk was much simpler and more portable so I think it would’ve worked well.</p><p>I’m optimistic about some changes in research direction of the field:</p><ul><li>I’d love to see medical machine translation corpora split up more, for instance patient-doctor communication (chat, pamphlets, informational websites), doctor-doctor communication (clinical notes), scientist-scientist (academic papers).</li><li>It’s worth replicating some older experiments from before the advent of high quality neural machine translation.</li><li>I’d love to see machine translation competitions emphasize adequacy or fitness for task. For instance in the medical field measuring diagnostic accuracy, triage accuracy, or treatment accuracy.</li><li>I find myself pondering the differences between the fields of human-computer interaction (HCI) and user experience (UX). It’s often hard to articulate the differences between the fields, but I found while reading so many HCI papers that there’s often a lack of attention to detail in the user interface, ranging from the readability of fonts to layout to clutter. Papers often focus on one main change, but that change is being evaluated in the context of all the little details of the user interface.</li></ul><h3>What’s next? (Short term)</h3><p>I’m headed on travel starting next week so I’ll be quiet for a little while.</p><p>I’m most interested in these directions:</p><ul><li>Visualize NMT attention to enable users to explore definitions easier. I thought for sure I’d discover a research paper on this, but I haven’t yet.</li><li>Use multiple back-translations for translation instability and feedback to the writer</li><li>Improve my user interface for definitions; it’s too verbose</li><li>Build a MT model that’s more focused on adequacy for patient-doctor communications. That <em>might</em> make different kinds of mistakes as modern NMT systems and therefore it might be useful to include in a “two translations” type of interface</li></ul><h3>What’s next? (Long term)</h3><ul><li>I’ve got a lot more papers to read but I want to find a better balance between reading and building. That’s tough to do while also traveling!</li><li>I’ve got a long list of things to follow up on from this review, such as potential corpora or CAT tools to check out.</li><li>The papers on public health brochures had somewhat different needs than patient-doctor chat. I wonder how hard it would be to build a system for them? If I build a web system that people can use for chat as a demo, it might be worthwhile to include a page for pamphlet translation.</li><li>I’d love to do a user study and actually publish if possible, but I’m not sure if I’ll have the time or money for it when I get that far. I’d particularly like to develop an adequacy aka “is it good enough” metric for diagnosis and treatment, because my experience in healthcare is that diagnosis and treatment are often inexact.</li></ul><h3>Appendix: Notes on using ChatGPT</h3><p>I had taken notes on all the papers, but those aren’t suitable for distribution. I thought it might be good to try using ChatGPT to convert those notes into narrative form; my experience is that it can’t really generate true information aside from general knowledge, but it can generate content that’s consistent with the input, so if the information is in the input it should be able to do it. (At least that’s my interpretation of it)</p><p>I got a lot of value out of <a href="https://learnprompting.org/">learning more about prompt engineering</a>.</p><p>Things that worked:</p><ul><li>Setting expectations of the answer type by using a format like “Notes: … Narrative:”</li><li>Giving examples of how I like to convert notes to narratives. This helped make sure it mostly sounded like me.</li></ul><p>Things that didn’t work:</p><ul><li>Just asking for a summary</li><li>Trying to group the papers into sections — I couldn’t figure out how to do this, but some of the posts I’ve read suggest it should be possible with the right prompting</li></ul><p>Challenges:</p><ul><li>Sometimes it didn’t include information that’s valuable either to the project or readers and I had to add that</li><li>It often misrepresented my opinions from the notes as the opinions of the paper authors (very bad!)</li><li>It often had lots of nice-sounding but meaningless sentences so I found myself deleting around 10% of the sentences</li><li>It’s nice to include quotes when possible but ChatGPT usually wouldn’t do that</li><li>ChatGPT’s input length was a challenge at times. I’m not sure the best way to go about that</li></ul><p>Successes:</p><ul><li>I find it’s tough to start a narrative but much easier to edit once I have something started</li><li>If my notes about a paper were very negative, ChatGPT found a much more polite way to say that</li></ul><p>If you made it to the end, I truly appreciate it! If you saw any issues, or would like to discuss further, feel free to reach out.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a00ef1e9a11" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>