Modern Neovim — AI Coding (Part 2)
In this article, we will deep dive into the OpenAI models and develop Neovim modules using Python and Lua for AI coding.
This article is part of the Modern Neovim series.
The Neovim configuration files are available in this repository.
The OpenAI API can be applied to virtually any task that involves understanding or generating natural language, code, or images. In this article, we will focus on using the APIs specifically for coding.
Before we deep dive into the details, let’s get started with the basics.
Prompt Design and Engineering
Designing a good prompt is essential to ensure good results with the OpenAI language models.
Designing the prompt is essentially how we “program” the model, usually by providing some instructions or a few examples.
Below are the basic guidelines extracted from the OpenAI documentation.
- Show and tell. Make it clear what you want either through instructions, examples, or a combination of the two. If you want the model to rank a list of items in alphabetical order or to classify a paragraph by sentiment, show it that’s what you want.
- Provide quality data. If you’re trying to build a classifier or get the model to follow a pattern, make sure that there are enough examples. Be sure to proofread your examples — the model is usually smart enough to see through basic spelling mistakes and give you a response, but it also might assume this is intentional and it can affect the response.
- Check your settings. The temperature and top_p settings control how deterministic the model is in generating a response. If you’re asking it for a response where there’s only one right answer, then you’d want to set these lower. If you’re looking for more diverse responses, then you might want to set them higher. The number one mistake people use with these settings is assuming that they’re “cleverness” or “creativity” controls.