How I enhanced my typing ability with LLM

Photo by Burst on Unsplash

How I enhanced my typing ability with LLM

In this blog post, I recount my journey of enhancing my typing skills using a tool I developed, which harnesses the power of OpenAI's GPT-4. This tool, integrated as a Slack bot, corrects my typos in real-time on Slack.

The Problem

As a software developer and a native Japanese speaker, I find myself frequently typing in both Japanese and English. However, I noticed a recurring issue of making typos, particularly when using an Input Method Editor (IME) to convert hiragana input to kanji.

For those unfamiliar with Japanese IMEs, they facilitate phonetic input in hiragana, which is then converted to kanji. For instance, if I type "SAKURA", it translates to "さくら" in hiragana, and the IME provides a list of possible kanji conversions, such as "桜" (cherry blossoms), "佐倉" (a place name or surname), "砂倉" (a surname), or "櫻" (an old version of "桜"). The intricacy of kanji and the many-to-one mapping from hiragana to kanji often lead to errors. This additional layer of input makes auto-correction more challenging compared to languages like English.

The Solution: LLM

To address this issue, I developed a Slack bot that employs OpenAI's GPT-4 to detect and correct typos in my messages immediately after I post them.

Before:

After:

More complex correction is of course possible!

I primed GPT-4 with the following prompt:

"You're a correction bot. You reply to user's messages with corrected versions of them. Return the corrected message only. If you find the message correct, return the message itself. Only correct misspelling and grammar."

Implementation Details

The bot is implemented as a serverless function hosted on fly.io, triggered by new messages on Slack. When a message is detected, the function calls the OpenAI API, which employs the GPT-4 model to process the text and suggest corrections. The bot then uses the Slack API to edit the original message with the corrected text.

Source code is available at https://github.com/hmirin/SlackAutoCorrectionBot

Results

Since integrating the LLM bot into my Slack workspace, I've noticed a significant reduction in the number of typos I make, both in English and when using the Japanese IME. This has saved me a considerable amount of time!

The Surprise: High Precision of Auto-Correction

One of the most surprising aspects of this journey was the high precision of the auto-correction provided by the LLM. It was not only able to correct simple typos but also accurately convert hiragana to the appropriate kanji in context. This level of precision exceeded my initial expectations and has significantly improved my typing efficiency.

The Challenge: AI and Human Responsibility

While the bot has been incredibly helpful, it also presented an interesting challenge. My colleagues often found themselves confused, unsure if the corrected sentences were really from me or if the AI had fabricated the content. This raised an important question about the dissemination of AI-generated content and the responsibility that we as humans hold. It's crucial to ensure that the final message accurately represents our intended communication, even when AI is involved.

The Context: Where LLM Fits and Where It Doesn't

I believe this use case of LLM aligns perfectly with its nature:

Short Output

LLM processes input in parallel but generates output autoregressively, which means if the output is long, it takes much time. In this use case, chat messages are usually short, so it's a perfect fit.

Time-insensitivity

Even when the output text is short, LLM still takes some time. So, if you need a time-sensitive conversation like on a phone call, it can be challenging. However, chat communication can afford to take time as people also take time to type.

High Value Text

The cost of using OpenAI is relatively low, but for use cases such as document storage, it can be high. The API price can be burdensome for SaaS providers dealing with lower-valued documents. However, when it comes to correcting a Slack message, the benefits are clear. It saves time for both the writer, who would otherwise need to correct the message, and the reader, who would have to decipher a message riddled with typos. This makes it a cost-effective solution.

Non-Mission Critical

A chat message is just that - a chat message. You can afford to be more casual with AI content in this context than when using it for legal documents or medical use cases.

Conclusion

In conclusion, my journey with LLM has been an enlightening one, filled with challenges, surprises, and ultimately, significant improvements. It has not only enhanced my typing skills but also opened up a dialogue about the role and responsibility of AI in our daily communications.