I have a blog post, here on this blog called "Find song by lyrics". It's very popular and has, over the years, 28k approved comments posted.
Now, I've built an AI tool that attempts to edit these comments by correcting spelling and punctuation, without changing the meaning. It looks like this:
When I'm moderating, every. single. comment, this is more or less what I myself do, if I can be bothered. I don't want to take away the message, but I think it looks and reads a lot of better if I correct the spelling and punctuations. It's super common that people write sentences like this:
im looking for a song.a lady with a lowe voice that sound happy,and i cant find anywhere
I correct that to:
I'm looking for a song. A lady with a low voice that sound happy, and I can't find anywhere.
It's just spelling and punctuation. The sentence structure isn't changed. It's still written by a human, but we can assume a human that didn't have time to correct the little details. Also, a lot of blog post comments are written by people where English is not their native language so it's less expected to be perfect.
The implementation
The way I implemented this was using the OpenAI API, in Python, using litellm, and because they take quite long to compute, they run in an asynchronous message queue. The prompts I wrote to implement it are as follows:
- "You are a helpful editor that reads blog post comments and corrects grammar and punctuations."
- "You have to look for common spelling mistakes, lack of spaces after full stops, incorrect capitalization."
- "Your job is to rewrite the comment without changing the meaning, but correcting any grammar and punctuation mistakes. Only return the rewritten comment and nothing else. Avoid using Unicode quotation marks, use regular ASCII quotes instead."
- "Here is the comment:\n\n```{comment_escaped}```"
I'm not an expert at prompt engineering and first to admit that I have a lot to learn. Because I don't really trust it yet fully, I'm manually skimming all comments first before I allow AI to attempt the rewrite.

Comments