We continue our journey into the fascinating realm of prompt engineering for text operations 😁 In our last blog post, we dived into the world of LLMs and the groovy trends in generative AI. Now, let’s talk about something pivotal: prompt engineering. Think of it as the secret recipe for teaching, the art of handling all sorts of texts and pulling off various tricks.

While cooking up a new rewrite/generative AI feature for WProofreader, we faced a handful of challenges. We embraced them and achieved some seriously exciting outcomes. Ready to spill the beans? Good, then let’s explore the wonders of prompt engineering together.

Prompt engineering for different operations with texts

Let’s talk about traditional text transformation first, when language is shaped for effective communication. 

From cutting narratives to expanding sentences, each operation serves a specific purpose in influencing the way we express ideas.

Text compression, expansion, rewrite, style improvement, and style shift — each has its unique role in refining language.

  1. Text compression is about making things shorter and more compact, focusing on the essential information. Best practices for text compression include keeping essential meaning, clarity, and grammatical correctness of a text. Editors focus on conciseness, relevance, and clarity in their revisions. It’s vital not to over-compress (optimal text cut is 10-30%) to the point where important information is lost or the message becomes unclear or incomplete. The original formality of the text should be strictly preserved.
  2. Text expansion is all about making things more detailed and expressive, adding depth to the existing content. Creative additions that provide new, valuable information while adhering to the constraints of the prompt are welcome. However, it’s important to keep expanded sentences under 20-25 words for optimal readability. Aim for an expansion of 10% to 30% of the original text length to provide valuable and relevant details without overburdening the reader with unnecessary information. Just like with text compression, the original formality should be strictly preserved.
  3. Text rewrite involves rephrasing content without changing the core message, focusing on a different way of expressing the same idea. The rewritten text should be clear, grammatically correct, and coherent. If possible, optimize for a balance between conciseness and detail. The size of the rewritten text should be  similar to the original one as well as the formality.
  4. Style improvement is like polishing the surface of the text, refining the way it looks and feels without altering the substance. Before proceeding with any changes, editors identify the primary objective for improving the text, such as clarity, brevity, tone adjustment, audience suitability, stylistic enhancement, grammar correction, or consistency. The revised text maintains its essential meaning while effectively meeting the desired goal. 
  5. Style shift. It involves transitioning from one writing style or tone to another within the same text. This shift can encompass various aspects, including formality, tone, vocabulary, and overall linguistic characteristics. You can change the formality of a text: from formal to informal and vice versa.
WProofreader AI

WProofreader AI writing assistant

Rewrite and text generation for business and individual users. Contact us.

Today, every first webinar, conference or meetup is about prompt engineering hacks. We’re not an exception and suggest our own tips on how to create effective prompts. So during our test sessions we relied on such hacks such as: roles, guidelines, formatting, conditions and restrictions, emotional aspect, chain-based approach, etc. And the result really depends.

Roles in prompt engineering, roles refer to the different personas or characters you can adopt when interacting with the language model. By framing your prompt as if you were a specific character or had a certain perspective, you can influence the tone and style of the generated response. In proofreading, roles may be: human editor, proofreader, copywriter, etc.

Guidelines are general recommendations or rules that users follow when constructing prompts. Guidelines can include suggestions on how to structure your input, the level of specificity to provide, or the use of certain keywords to trigger desired behaviors in the model.

Formatting is also crucial. The way you structure and format your prompt can significantly impact the model’s output. For example, using bullet points, numbering, or other formatting styles can help in organizing information and getting more coherent responses. We choose to format the prompt this way:

Prompt format

A chain-based approach involves providing context or additional information within the same prompt or in a series of prompts. By building on the model’s previous responses, users can guide the conversation in a more coherent and meaningful direction.

These hacks seriously impact output. In the next session, we’ll show you the difference and you may be very surprised.

LLaMA vs Mistral vs Claude for text rewrite

In Part 1, we analysed different generative AI solutions offered by our competitors and found out that most of them are built with OpenAI ChatGPT-3,5 and -4 models. While ChatGPT seems to deliver outputs of the highest quality, it raises considerable security risks of its cloud infrastructure, especially for security-conscious businesses and may not be an opt-in.

Besides, recent news about OpenAI top management transformations give credence to the belief that the provider is fragile and dealing with it in the long-term may be risky.

Therefore, in our research we mainly focused on small-scale LLMs have fewer parameters than ChatGPT and Claude, yet available to be deployed on a company’s server. The models we tested are LLaMA-2-7b-chat and Mistral-7b-v0.1. Both have 7b parameters and designed specifically for completing tasks in English.
By contrast, ChatGPT has 175 billion parameters, Claude — on 52 billion parameters.

LLaMA and Mistral aren’t our final decision: we’re looking for a multilingual model and that’s why our search goes on. Herein, we’ll show how LLaMA, Mistral and Claude (just for a comparison) do a simple text rewrite, each time with an improved prompt during several iterations. Please note, that the approach below is for educational purposes only, this is not the disclosure of the final variant of prompts we’re going to use.

The input sentence will be:

I hope this message finds you well

— a basic opening statement for a business email, now considered a bit cookie-cutter.

Iteration #1

We’ll start with a simple one sentence prompt.

Prompt

Please, rewrite this sentence.

LLaMA

Wishing you good health upon receiving this message.

Mistral

1. I wish that you were in good health and this message finds you happy.

2. I pray that you are in good health and receive this message with joy.

3. I hope and pray that you are in good health and enjoying this message

Claude

I trust this message meets you in good health.

Conclusion

as far as you can see, all outputs sound a bit wordy and robot-like, yet the meaning remains.

Iteration #2

Now let’s add conditions and requirements.

Prompt

Please rewrite the following sentence, ensuring it maintains its original meaning. The rewritten sentence should be clear, grammatically correct, and coherent. Adjust the tone to make it appropriate for a general audience and enhance its readability. Ensure that the output contains only one sentence, not multiple. If possible, optimize for a balance between conciseness and detail.

LLaMA

I sincerely hope that, upon receiving this message, you are in good spirits and health, and that life has been treating you kindly.

Mistral

1. Greetings from me. I hope that my message finds you in the best of health.

2. I am writing to you in good health, I hope that you are as well.

Claude

I sincerely hope you are doing well when you receive this message.

Conclusion

LLaMa has considerably expanded the sentence, which goes beyond the task. Mistral’s output sounds better, yet the B version may not be suitable for business communication. Claude’s version seems to be the best one. In addition, Mistral ignored my request to create a single sentence output.

Iteration #3

Let’s play with roles in prompts.

Prompt

I want you to act as an editor. Please rewrite the following sentence, ensuring it maintains its essential meaning. The rewritten sentence should be clear, grammatically correct, and coherent. Adjust the tone to be universally appropriate, neither overly formal nor too casual, making it suitable for a broader audience. Ensure that the output is a single sentence and prioritize clarity and brevity.

LLaMA

I hope this message reaches you in good health and spirits.

Mistral

I hope this message finds you in good health.

Claude

I trust you are in good health upon receiving this message.

Conclusion

LLaMa’s and Claude’s rewritten sentence sounds relevant for business communication, yet they may be too formal for some cases.

Iteration #4

Finally, let’s improve the formatting.

Prompt

##Role

Please act as a human editor.

##Task

Fully rewrite the text.

##Guidelines

Style
Ensure the text maintains its original meaning. The rewritten text should be clear, grammatically correct, and coherent. If possible, optimize for a balance between conciseness and detail.

Size
Make the size of the rewritten text similar to the original one.

Formality
Strictly preserve the original formality of the text. Adjust the tone to make it appropriate for a general audience and enhance its readability.

Format
Provide only the revised text without any additional explanations.

LLaMA

I hope this message finds you in good health.

Mistral

I hope this message finds you in good health.

Claude

I sincerely hope you are doing well upon receipt of this message.

Conclusion

LLaMA’s and Mistral’s outcomes seem to be relevant to the use case and sound much better than their previous attempts. However, the rewrite is not complete, and for some users it may not be appropriate. Claude’s version seem to be more formal.

From the experiment, it is clear that when dealing with LLMs the outcome depends considerably on the prompts and how you fine-tune them. There are lots of hacks you can use and their number continues to grow. As experts say, the best way to understand what works and what doesn’t is to proceed with experiments. 

And this is what we are on now.

WProofreader writing assistant is coming soon

Why do we bother so much with prompt engineering and testing LLMs? The answer is obvious, following the rest of the digital marketing world, we’re going to launch a new rewrite/generative AI functionality soon aka WProofreader writing assistant.

The feature will join a set of advanced spelling and grammar checking functionality offered by WProofreader:

  • multilingual AI-driven spelling and grammar check with language autodetect
  • spelling autocorrect and autocomplete suggestions
  • style guide with custom rules
  • custom spelling dictionaries

And it will be available within WProofreader SDK and browser extension.

WProofreader AI writing assistant

And what’s more, we’re going to make the textgen feature multilingual and help our clients to use the model within their own infrastructures. 

As an MVP, this feature will include these prompts: text shortening (compression), text expansion, text rewrite, style improvement and style switch (from formal to informal and vice versa).

As future plans, we’re going to extend the set of predefined prompts and let users create their own. 

Importantly, WProofreader writing assistant will follow the paradigm of responsible AI that revolves around ethical considerations, fairness, transparency, and accountability.  

In particular, we’re going to:

  • make a disclosure of what LLM provider we’re utilizing for transparency in the development and deployment processes
  • use the non-inclusive and profanity language filters to promote user diversity and inclusion
  • develop an accessible UI to make sure the feature is compatible with accessibility standard
  • achieve regulatory compliance with existing laws and regulations governing AI usage.

So, stay tuned and be ready to find new cool functionality.

Summing up

So, wrapping up this prompt engineering topic:

  • we’ve been delving into the nitty-gritty of making AIs understand language tricks and handling all sorts of text magic. While spicing up WProofreader’s rewrite/generative AI mojo, we faced some challenges, but we managed to get some seriously cool outcomes. 
  • we’re talking about text compression, expansion rewriting, style polishing. Roles, guidelines, formatting in user prompts are the secret ingredients to the prompts for operations with texts.
  • we tested LLaMA and Mistral in our text rewrite experiment to turn a standard “I hope this message finds you well” into a bit of a language makeover. Both had their wordy robot moments, but finally generated some relevant outputs.
  • WProofreader is gearing up to drop a cool new rewrite/generative AI functionality. It’s going to be multilingual, secure and responsible. Fancy, right? Expect features like text shortening, expansion, rewrite, style improvement, and a style switch from formal to informal and back.

As we wrap this up, remember—the journey of prompt engineering is always evolving. Stay tuned for the next chapter, and let’s keep this conversation going. Until then, here’s to the magic of words and the wonders of AI! 🚀✨