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

Your email will never ever be published.

Previous:
Hosting your static web site with Firebase Hosting November 3, 2025 Firebase, Bun
Related by category:
A Python dict that can report which keys you did not use June 12, 2025 Python
In Python, you have to specify the type and not rely on inference October 10, 2025 Python
Native connection pooling in Django 5 with PostgreSQL June 25, 2025 Python
Combining Django signals with in-memory LRU cache August 9, 2025 Python