I include YASnippet in the prompt generation
pipeline to enable programmatic manipulation
within a prompt using
emacs functions and
In essence, this gives you the ability to make language agnostic prompts.
This is using
GPT-J by EleutherAI, via the
The following is the prompting output. The comment was dynamically generated by YASnippet and the LM generated the line after the comment, which contained a valid regex.
Explanation of problem and solution
The problem with many prompts you will find
online is that they are static and a comment
in the prompt, for example
will be tailored for a specific language, so
the prompt is over-specified.
The solution, using YASnippet
emacs has many editing functions, which are
language agnostic and these can be used to
generate more powerful, dynamic prompting.
In this example,
emacs detects the current
major mode (i.e. language) before the prompt
is run and then when the prompt template
expands, an interactive function
comment- line is run to put the correct comment syntax
into the prompt.
Why it’s important
Custom tailorded comments are important for code generation from comments, however we may want to generate code from a description where no such comment yet exists.
The dynamic prompt
end-yas: onmeans that the YASnippet will expand the prompt just before it is evaluated.
start-yaswas used, this would happen towards the start of prompt generation.
`(comment-line 1)`is an elisp function embedded in the prompt via YASnippet.
If this article appears incomplete, it may be intentional. Try prompting for a continuation.