Prompts for editing text with GPT
In the past few posts, I’ve been playing around with the OpenAI API in RStudio. This will probably be a short post testing prompts for editing text.
Simple pre-fab prompt approaches
I wrote some addins for RStudio that send text back and forth to OpenAI from the RStudio editor.
One of the addins is called gpt_edit
. This one takes selected text as input, and then queries the user to select from a few different prompts related to editing.
Two of the prompt choices are:
You are an editorial writing assistant. Edit the text for spelling and grammar. Don’t change the meaning or the words.
You are an editorial writing assistant. Your task is to edit the content you receive for improved clarity, flow, and reduced word count. You should respect the original style of the input text and use an active voice.
And, one of the prompt choices is to write your own prompt.
I’ve found these prompts generally useful. It’s convenient to be able to select text and quickly get back an alternative phrasing for a sentence. However, I’m not always impressed with the outputs (currently using gpt-3.5-turbo).
Custom one-off prompts
Another tack I’ve taken is writing one-off prompts for particular sections of text. For example, if I have a sentence or two, I’ll copy a prompt like the ones from above, and then start a chat to refine a sentence. It might go something like this:
You are an editorial writing assistant. Your task is to edit the content you receive for improved clarity, flow, and reduced word count. You should respect the original style of the input text and use an active voice.
Understood! Please provide me with the content you would like me to edit.
Another tack I’ve taken is writing one-off prompts for particular sections of text. For example, if I have a sentence or two, I’ll copy a prompt like the ones from above, and then start a chat to refine a sentence.
One approach I’ve taken is to create specific prompts for each section of text I am working on. For instance, if I have a short paragraph, I will utilize one of the prompts mentioned earlier and initiate a chat to enhance the clarity and flow of the paragraph.
Reduce the word count and enhance clarity
To reduce the word count and enhance clarity, we can make the sentence more concise and eliminate any unnecessary phrasing. Here is a possible edit:
“I create specific prompts for each section of text, such as a short paragraph, to refine it. I utilize the prompts mentioned earlier and initiate a chat to improve clarity and flow.”
Rephrase and describe this process without using the word I.
A process for refining text involves creating specific prompts for each section of the content to be edited. For example, when working on a short paragraph, appropriate prompts are employed to improve clarity and flow. The prompts are then utilized to initiate a chat aimed at enhancing the content.
Shorten
To refine text, specific prompts are created for each section. For instance, when focusing on a short paragraph, suitable prompts improve clarity and flow before initiating a chat for enhancement.
Writing analysis and rephrasing prompts
As an aside, in my experience writing is a thinking process. I don’t necessarily know what I’m thinking until I attempt to write down the ideas. The process of writing is inextricably intertwined with the process of idea formation and communication. Certainly, even when it feels like I have a clear thought ready to pump out into a series of words, the pumping process invariably finds a way to show me the thought was less well-formed than I thought it was. Editing plays an important role in this process. At a conceptual level I’m going back and forth questioning whether what is being said is what I want to say, and whether what I want to say is being said. Reworking sentences word-by-word over a series of revisions helps clarify my thinking process.
Now that I’ve spent some time writing with language assistance from an LLM, one background concern is how these tools may impact my thinking process. Am I concerned? Not particularly at this point. So far I haven’t tried using the models for any serious thinking and writing, and given the current state of the technology I’m not seeing a use case for having the model produce “thoughtful” analysis of conceptual ideas (e.g., theories of cognitive processes and their relation to patterns of evidence in the literature).
I also haven’t been overwhelmingly impressed with editorial suggestions for improving my own writing, but I have found usable results occasionally. I suspect the quality of editorial suggestions can be improved with different prompts and with different models. Nevertheless, one of the outcomes I’ve noticed, even with low-quality editorial suggestions, is that the process of generating alternative versions of a paragraph and then comparing them to my own is itself a useful revision exercise. Even if I don’t take any of the suggestions, the act of comparison has helped me focus on problems in my own writing that I was glossing over.
This morning I was testing out a longer prompt involving a to-be-edited sentence, a critical analysis of the sentence structure, and a suggested rephrasing. It is possible to provide a series of examples to “tune” the model. Here’s an example prompt:
You are an AI writing assistant. You receive a sentence, and then you provide a conceptual analysis of the properties of the sentence, and an alternative phrasing that addresses the criticisms in the analysis. Follow the examples between the ***.
Sentence: Although there is considerable evidence suggesting that self-referencing can improve memorability, the cognitive processes responsible are not as well understood.
Analysis: This sentence expresses two important ideas using an irrelevant contrast that makes the sentences nonsensical. The two big ideas are that there is substantial evidence for the self-reference effect, and that there are few explanations of the effect. The sentence contrasts differences in volume or amount between two kinds of things that are not the same, rendering the contrast meaningless. One kind of thing is the large amount of evidence, another kind of thing is the small amount of theoretical explanation. The ideas in the sentence can be rewritten to express both ideas without using a phrase that implies a meaningful contrast on a meaningless dimension.
Rephrase: There is considerable evidence showing that self-referencing can improve memorability. Cognitive process theories of the self-reference effect primarily explain the phenomenon in terms of encoding processes.
Sentence: Evidence for the self-reference effect on memorability is plentiful, but the cognitive processes that contribute to it remain uncertain.
Analysis: This sentence expresses two related ideas, but fails to connect them sufficiently. There appears to be evidence for the self-reference effect, and there are some theories as to the reasons why, but the implied connection between evidence and cognitive processes is misleading. The implied connection is a contrast between abundance of evidence and uncertainty of explanation, which are different concepts that should not be contrasted. A better phrasing would express both ideas about evidence and cognitive process explanations directly, without implying a contrast.
Rephrase: Evidence for the self-reference effect on memories is abundant and cognitive processes theories point to encoding processes for explanation.
Sentence: So, although research into cognition has been ongoing across centuries and much knowledge has been generated, there are many perspectives and unresolved issues that prevent widely agreed upon answers to questions about what cognition is and how it works.
Analysis: This sentence is made up of run-on, Compound, and incomplete sentences adjoined together. While the ideas expressed are accurate, the phrasing does not communicate them efficiently. Furthermore, the use of “So” in this sentence implies a sequence of events, as if the extensive research into cognition has been abruptly followed by the unresolved issues presented in the sentence, when in fact both have been ongoing across centuries. To communicate the ideas more effectively, the sentences need to be split into two simple sentences forming a logical sequence and the “So” omitted.
Rephrase: Research into cognition has been ongoing for centuries and has generated much knowledge. However, there are still many perspectives and unresolved issues preventing widely agreed upon answers to questions about what cognition is and how it works.
I generated the first example and the davinci model generated the last two (with some further editing by me). When I send the prompt I package all of the above examples together, and then append a sentence at the end. The model responds with an analysis and a rephrased sentence.
I’m not sure yet if this kind of prompting will result in tangibly improved sentences. However, this prompt format keeps me focused on my goals for the sentence, and whether the sentence is accomplishing them not. And that seems good.