Earlier this evening, I had an idea: what if I could use OpenAI's GPT-3 model to generate an appropriate emoji for a commit message? I have seen emojis used in commit messages and I am curious about the visual representation of the information with which they are associated.
I wrote this short script that calls the OpenAI
text-davinci-003 model and returns a relevant emoji:
import openai message = input("Commit message: ") result = openai.Completion.create( engine="text-davinci-003", prompt="Given the below commit message, generate a relevant emoji. Provide a unicode emoji. Provide only one emoji. Do not provide actual unicode text. Provide in format [emoji] - [description]. Don't elaborate on commit message. Explain your decision. \n" + message ) output = result.choices.text emoji = output.split(" - ").strip() print(message + " " + emoji)
Most of the work on writing this script went into the prompt engineering; figuring out what words would result in the output that I wanted. I read somewhere on Hacker News earlier today that "prompt engineering" is essentially "natural language programming."
The result of the above script is contingent less on my written code than it is about the language I use in my prompt. I needed to be specific as to what I wanted. With a generic prompt asking for an emoji, I found that sometimes an emoji in the format
:emoji: would be returned, or a series of characters representing the Unicode for the emoji. I thus narrowed my prompt. I asked for a specific format, so as to ensure the prompt was easy to parse.
Natural language programming indeed.
I have not played around too much with prompt engineering, but suffice to say I am intrigued. Feel free to tinker with the above script (you will need to have an OpenAI account, add your API key to your local programming environment, and you should be aware of the pricing of GPT-3).
Comment on this post
Respond to this post by sending a Webmention.
Have a comment? Email me at email@example.com.