gramcheck
I think active practice is the most efficient way to learn something. It could be a musical instrument, a sport, a technical concept, or a language. Of course, some structure is required along with the practice. If “practicing” is the star of the show, a “structured plan” is its director.
This little tool is a text analysis tool. It checks the syntactic and semantic properties of a text, sentence by sentence, and returns comments about it. The idea came to me when I was practicing a language while writing. I think writing is especially helpful for learning a language, as it teaches you how to form sentences correctly in your head. Reading teaches you a lot of words, but without knowing how to form sentences, you can neither write nor speak well. While writing is helpful, it could reinforce incorrect phrases and grammar mistakes if not validated by an expert. In this context, an expert means someone with better language skills than you, someone who could check and correct your mistakes, and not necessarily a language “expert”, like a language professor. However, it could be hard to find such a person in day-to-day life. Therefore, I started to practice writing with an LLM as the language expert.
Idea for a tool
LLMs are probabilistic, and their responses are not always accurate. But they are almost always accessible and pretty much free, and actually even weaker models are quite capable for this task. You can paste your practice text, with a short prompt, and it will show most of the usual errors correctly. After fixing the errors shown by the LLM, I usually edited the text and repasted it, and the LLM showed more errors. While this process worked, it was manual and slow, and as I preferred to work from a terminal, I started wondering if I could write a simple tool for this task.
Naming and underlying technology
I called the V1 of this tool “gc”, standing for “gramcheck”, without knowing there was already a tool with this name, which is a garbage collector. Therefore, in the final version, I decided to use the full name. I have used duck.ai for manual corrections. My initial idea was to use it on my little tool as well, through some unofficial libraries, like duck_chat. Unfortunately, most of them were broken at the time of writing this, and I had no interest in finding a way to fix them. Therefore, I decided to use a direct API access method, and chose Google as they have a generous free tier. However, considering their free tier is used to improve their products, I am planning to implement a local LLM version of it in the future. I believe even a relatively small LLM could perform very well on this task, albeit slower.
Source and usage
You can see the source code here. It is on PyPI, and you can simply install it with pipx install gramcheck. You have to generate an API key and set it with gramcheck --set-api-key <YOUR-API-KEY-HERE>, though. It buffers and prints the entire response in full, so it can seem to hang a while after you send your text. The tool calls the LLM with a predefined seed, so responses for the same text will be the same.