BETA
This is a BETA experience. You may opt-out by clicking here

More From Forbes

Edit Story

Prompt Engineering Embraces New Essay-Compression Technique That Expands On Getting Very Constructive Generative AI Results

Following

In today’s column, I am continuing my ongoing coverage of prompt engineering strategies and tactics that aid in getting the most out of using generative AI apps such as ChatGPT, GPT-4, Bard, Gemini, Claude, etc. The focus here is on a brand-new prompting approach that enables you to cleverly compress essays and other text-based narratives. This is a handy technique that ought to be in your prompting best-practices toolkit.

For my in-depth comprehensive guide on over thirty other keystone prompting strategies, see the link here.

Here’s the essence of today’s discussion.

One of the most popular uses of generative AI entails creating summaries of entered text, see my prior coverage on prompting strategies for summarization at the link here and also the chain-of-density technique (CoD) at the link here. The deal is this. You might have a lengthy document that needs a helpful summary covering the crucial points so that you don’t have to wade through a convoluted textual morass. The simplest prompt to achieve a summary will merely tell the AI to go ahead and summarize the material. Boom, you are done, or so it seems.

The problem is that the summary might not be very good. Odds are that the generative AI might omit points that a human would have realized are vital to include in a summary. There is also a significant chance that the source material will be interpreted rather than carried straight ahead into the summary. Loosey-goosey interpretations of what was said in the source could be way off base.

Into this realm comes the act of compression.

Rather than producing a summary that might veer from the source, you can ask to do a compression. The idea of compression is that the source is reduced in size by a thinning process, but no adaptations or rephrasing takes place. You are still seeing the same words that were in the source. A thinning process is undertaken to try and keep just the needed meat on the bones conveying the crux of the source material.

To clarify, compression is not a silver bullet. Issues about compression can arise. For example, it is conceivable that as generative AI thins out a source text, some key points might inadvertently get weaned out. Another possible issue is that the resulting compressed text might seem nearly unreadable or incomprehensible. The words removed that might have seemed inconsequential by the AI were possibly integral to the intelligible reading of the text.

The bottom line is that anyone proficient in the use of generative AI should know both techniques by heart, freely welding the best ways to do prompting that encompasses summarization and astute prompting that does compression. You can then wisely decide which approach befits a given circumstance. Sometimes you pull out the hammer of summarization, and other times you reach for the screwdriver of compression. They are two distinct tools that require suitable handling and must be selected for the appropriate situations.

A frequent question I get during the prompt engineering classes that I teach is whether summarization is better than compression, or whether compression is better than summarization. This always brings a smile to my face. The conveyed conundrum is a false choice. None is especially better than the other in the abstract. Each provides a set of benefits and drawbacks. I don’t think you can in the abstract make a solid case that a hammer is better than or worse than a screwdriver since the situation at hand dictates as such. The same goes for summarization versus compression.

Okay, now that we’ve got that foundation established, there are already various recommended ways to word a prompt to do summarizations and compressions. A recent research study explored the topic and proffered a prompt for compression that they extensively tested and found to be quite useful. I will walk you through their research efforts and results.

I opted to try out the compression prompt by doing some of my own testing as a mini-experiment using ChatGPT and GPT-4. This allows you to see the compression prompting in action. I will discuss the matter and aim to arm you with how to suitably use the clever technique.

Before we get into the specifics of this new compression technique, it would be useful to make sure we are all on the same page about the nature and importance of prompt engineering.

Let’s do that.

The Nature And Importance Of Prompt Engineering

Please be aware that composing well-devised prompts is essential to getting robust results from generative AI and large language models (LLMs). It is highly recommended that anyone avidly using generative AI should learn about and regularly practice the fine art and science of devising sound prompts. I purposefully note that prompting is both art and science. Some people are wanton in their prompting, which is not going to get you productive responses. You want to be systematic leverage the science of prompting, and include a suitable dash of artistry, combining to get you the most desirable results.

My golden rule about generative AI is this:

  • The use of generative AI can altogether succeed or fail based on the prompt that you enter.

If you provide a prompt that is poorly composed, the odds are that the generative AI will wander all over the map and you won’t get anything demonstrative related to your inquiry. Similarly, if you put distracting words into your prompt, the odds are that the generative AI will pursue an unintended line of consideration. For example, if you include words that suggest levity, there is a solid chance that the generative AI will seemingly go into a humorous mode and no longer emit serious answers to your questions.

Be direct, be obvious, and avoid distractive wording.

Being copiously specific should also be cautiously employed. You see, being painstakingly specific can be off-putting due to giving too much information. Amidst all the details, there is a chance that the generative AI will either get lost in the weeds or will strike upon a particular word or phrase that causes a wild leap into some tangential realm. I am not saying that you should never use detailed prompts. That’s silly. I am saying that you should use detailed prompts in sensible ways, such as telling the generative AI that you are going to include copious details and forewarn the AI accordingly.

You need to compose your prompts in relatively straightforward language and be abundantly clear about what you are asking or what you are telling the generative AI to do.

A wide variety of cheat sheets and training courses for suitable ways to compose and utilize prompts has been rapidly entering the marketplace to try and help people leverage generative AI soundly. In addition, add-ons to generative AI have been devised to aid you when trying to come up with prudent prompts, see my coverage at the link here.

AI Ethics and AI Law also stridently enter into the prompt engineering domain. For example, whatever prompt you opt to compose can directly or inadvertently elicit or foster the potential of generative AI to produce essays and interactions that imbue untoward biases, errors, falsehoods, glitches, and even so-called AI hallucinations (I do not favor the catchphrase of AI hallucinations, though it has admittedly tremendous stickiness in the media; here’s my take on AI hallucinations at the link here).

There is also a marked chance that we will ultimately see lawmakers come to the fore on these matters, possibly devising and putting in place new laws or regulations to try and scope and curtail misuses of generative AI. Regarding prompt engineering, there are likely going to be heated debates over putting boundaries around the kinds of prompts you can use. This might include requiring AI makers to filter and prevent certain presumed inappropriate or unsuitable prompts, a cringe-worthy issue for some that borders on free speech considerations. For my ongoing coverage of these types of AI Ethics and AI Law issues, see the link here and the link here, just to name a few.

All in all, be mindful of how you compose your prompts.

By being careful and thoughtful you will hopefully minimize the possibility of wasting your time and effort. There is also the matter of cost. If you are paying to use a generative AI app, the usage is sometimes based on how much computational activity is required to fulfill your prompt request or instruction. Thus, entering prompts that are off-target could cause the generative AI to take excessive computational resources to respond. You end up paying for stuff that either took longer than required or that doesn’t satisfy your request and you are stuck for the bill anyway.

I like to say at my speaking engagements that prompts and dealing with generative AI is like a box of chocolates. You never know exactly what you are going to get when you enter prompts. The generative AI is devised with a probabilistic and statistical underpinning which pretty much guarantees that the output produced will vary each time. In the parlance of the AI field, we say that generative AI is considered non-deterministic.

My point is that, unlike other apps or systems that you might use, you cannot fully predict what will come out of generative AI when inputting a particular prompt. You must remain flexible. You must always be on your toes. Do not fall into the mental laziness of assuming that the generative AI output will always be correct or apt to your query. It won’t be.

Write that down on a handy snip of paper and tape it onto your laptop or desktop screen.

Using Special Prompts Including Chain-of-Density

There is a slew of somewhat remarkable prompt phrases that are essential for anyone seriously doing prompt engineering. One such phrase involves telling generative AI to work on a stepwise basis, something commonly known as invoking chain-of-thought responses by the AI, see my coverage at the link here. Another popular ploy entails telling the AI to take a deep breath, see my analysis of this prompt at the link here. One of the latest favorites involves commanding the AI to take on a Star Trek consideration when devising an answer, see my discussion at the link here.

I previously covered in my writings the various prompts that are particularly suited for getting summaries of text that you might provide to generative AI. Summarizing text is a very common use of generative AI. You can simply paste a whole bunch of text into generative AI and get a pretty good summary of the text. That being said, summaries can diverge from the original content and potentially contain misleading or even outright incorrect summarized content, see my analysis at the link here.

In short, summarizing can be risky due to the generative AI opting to rephrase the original content. The rephrasing might fail to depict the proper meaning and intention of the source content. Envision using summarization on doctor’s notes via generative AI, which is then handed to a different physician and they only have the summary at their purview, see my exploration of these matters at the link here.

Thus, a conventional summarization could be disturbingly problematic.

There is a method of devising summaries that use a prompting strategy that aims to bolster generative AI toward attaining especially superb or at least better than usual kinds of summaries. The technique is known as chain-of-density (CoD). Anybody versed in prompt engineering ought to become familiar with this insightful technique. Consider chain-of-density as not only helpful for producing summaries but there are a lot of other benefits garnered by understanding how the technique works and how this can power up your overall prompting prowess all-told.

For my detailed coverage of the chain-of-density prompting technique, see the link here.

Allow me a moment to share some of those elicitations with you here.

When you are trying to craft a summary, you often might do so in a series of successive attempts. Your first shot might be to craft a summary that has only a few of the biggest points that need to be included. After considering the initial draft, the odds are that you might further refine the summary by adding more elements to it. This can go on and on. Depending on how thorough you are, you might do a handful or more of these refining iterations. Each iteration can be construed as a chain of iterative summaries, one leading to the next for a given instance of trying to write a summary.

That’s the “chain” part of this process.

Let’s add some further terminology to describe the summary-making effort.

A summary typically starts as somewhat sparse when you first toss it together. There isn’t much of any substance in the summary. You are usually seeking to further pack substance into the summary and do so while fighting the length of the summary. The more substance that you can jam into the summary, the higher the density of the summary.

We can give a name to the substance by saying that we are trying to identify important “entities” within the original content. Those entities might be facts or figures. The entities are said to be anything especially instrumental to the overall meaning of the original content. A hope is to carry over as many of the demonstrative entities as feasible into the summary.

Your summary-making process then is to iteratively devise a summary by starting with a sparse version and then adding more and more entities or substances to increase the density until you reach some desired or suitable end-state. The series of iterations acts as a chain. Each is used to connect to the next. You usually will retain the entities from one version to the next version, and be decidedly adding more of the entities available in the original as you seek to jampack the summary accordingly.

Reflect on the adage of putting five pounds of rocks into a three-pound bag.

Maybe you put one pound of rocks into the three-pound bag at the initial attempt. The bag is considered sparsely populated. There is still room to spare. The density is low. You then put a second pound of rocks into the bag. The density is increasing. The sparseness is lessening. Finally, you put in a third pound of rocks. You have hit the maximum density and the sparseness has presumably dropped to near zero.

Suppose that the bag can be elongated.

Wonderful, you exclaim, being overjoyed at having more available space. Imagine though that you are going to hand the bag over to someone else. The larger and heavier the bag, the less useful it becomes. The same applies to summaries.

A rule of thumb is that you want to minimize the length or size of the summary, meanwhile maximizing the summarization content. The two factors are often in contention with each other. You are tempted to increase the length to get more substance included. The length being increased will potentially undercut that the summary is supposed to be a summary.

A person might seemingly just go ahead and read the original content if the summary approaches the size of the original material being summarized. The summary isn’t especially a summary anymore at that juncture. Indeed, sometimes a summary turns out to be longer than the original content that is supposedly being summarized.

How can this be, you might be thinking?

The answer has to do with being extractive versus being abstractive.

During the summarization process, you are looking at two possibilities of the content being carried over into the summary. First, you aim to be extractive, primarily extracting key aspects and shoveling those into the summary. Second, you might at times be abstractive, whereby you go beyond the words themselves of the original content and begin to reinterpret or perhaps elaborate beyond what the summary per se has to say.

A purely extractive summary is more likely to be construed as a fair and balanced reflection of the original content. You are not changing things up. You are only carrying the essentials (entities) over into the summary. The problem with an abstractive summary is that you are potentially changing up things and will be biasing or in some manner altering the meaning found within the original content being summarized. The danger is that this kind of summary is no longer seen as fair and balanced, and instead is based on the perceptions and opinions of the summarizer.

In a sense, if you want an unadorned straightforward summary, you are better off with an extractive summary. If you want an adorned or embellished summary, that goes beyond the words presented in the original source, you might seek an abstractive summary. The thing is, the abstractive summary might no longer be an apt reflection of the original source. That is also how the summary might become longer than the original since the embellishments can possibly increase the size of things and you could find yourself looking at a summary that is much longer than the source used for the summary.

Focusing On Compression As An Extractive Form Of Summarization

The usual parlance when you want a strictly extractive form of summarization is to say that you want a compression of your text.

I should warn you though that the word “compression” means different things to different people. Some are willing to be abstractive when doing a compression. Others would be aghast at someone veering into an abstractive mode when doing what they consider to be a rightfully done compression. To them, compression must be stridently adherent to not rewording any aspect of the source text being used.

I will be showing you in the next section some examples of using prompts related to asking generative AI to do compression. You will immediately see that the word “compression” is relatively ambiguous to most generative AI apps. They might interpret the word to imply purely extractive, but more likely they will assume this means to be abstractive. You will need to nail down in detail what you want the AI to do. I will show you this.

What else should you be thinking about when it comes to doing compression in generative AI?

I am glad you asked.

A recent research study entitled “LLMLingua-2: Data Distillation for Efficient and Faithful Task-Agnostic Prompt Compression” by Zhuoshi Pan, QianhuiWu, Huiqiang Jiang, Menglin Xia, Xufang Luo, Jue Zhang, Qingwei Lin, Victor Rühle, Yuqing Yang, Chin-Yew Lin, H. Vicky Zhao, Lili Qiu, Dongmei Zhang, arXiv, March 19, 2024, made these salient points (excerpts):

  • “This paper focuses on task-agnostic prompt compression for better generalizability and efficiency.”
  • “We formulate prompt compression as a token classification problem to guarantee the faithfulness of the compressed prompt to the original one, and use a Transformer encoder as the base architecture to capture all essential information for prompt compression from the full bidirectional context.”
  • “Recent years have witnessed the emergence of various prompting techniques for large language models (LLMs), such as Chain-of-Thought (COT), In-context Learning (ICL), and Retrieval Augmented Generation (RAG). These techniques empower LLMs to handle complex and varied tasks through rich and informative prompts that may exceed tens of thousands of tokens.”
  • “However, the benefits of such lengthy prompts come at a cost of increased computational and financial overhead, as well as the degraded information perception ability of LLMs. Prompt compression is a straightforward solution to address these issues, which attempts to shorten the original prompts without losing essential information.”

I’d like to explain some of those notable points to you.

First, one ongoing consideration is whether a compression prompt is written to be task-specific or task-agnostic.

A task-specific prompt is worded to fit a particular task at hand, such as if you were doing a compression of medical notes and you wanted the prompt to emphasize particular characteristics associated with medical lingo. The prompt is devised for that domain.

A task-agnostic prompt is broader and allows you to use it in a wide variety of circumstances. It is always best to have in your tool chest a task-agnostic prompt since you can use it on a generalized basis, plus you can tweak the wording for task-specific settings. The aim of the above research study was to focus on task-agnostic prompts for compression, which is handy for our purposes herein.

Second, we often speak of compression prompts as hopefully being faithful to the source material.

Faithfulness refers to the notion that the compression tries to retain crucial wording and not goof by removing something that will substantively undercut the meaning. Imagine that a sentence said “Do not cook for more than two minutes” and the compression lopped out the word “not”, leading to this compressed version of “Do cook for more than two minutes”. Ouch, your souffle might be ruined by your having used an unfaithful compression.

Third, an aspirational aim of compression is to be bidirectional, allowing that besides going from the source to a proper compressed version, you potentially can use the compressed version to get back to the source. This is not necessarily the case and opens quite a can of worms. Not everyone needs or expects to be able to return to the full source.

Fourth, it is worthwhile to note frequent circumstances whereby compression really shines.

Suppose that you are importing a ton of text into generative AI, see my explanation of importations prompting strategies at the link here. Or maybe you are using in-context modeling and relying on an external source of text, doing so via the use of RAG (retrieval augmented generation), see my discussion at the link here. And so on.

An important question that comes up is whether it is sensible to bring in the whole ball of wax or whether to try and somehow shorten what you need to bring in.

If you bring in a massive amount of text, you are fighting against the potential limits of generative AI. Those limits can severely degrade the results of the AI trying to cope with the text overload. You also have to consider potential costs. If you are paying for the use of generative AI, the longer-sized text is bound to be a costlier charge than if you could thin it down. Likewise, the servers used to compute the generative AI actions will consume more computational cycles and you will get a double whammy on cost.

I am sure that you immediately discern that a potential solution would be to compress the content, thus, you don’t have to confront the technical limits of the generative AI and might be able to keep your costs lower too. Whenever you are considering bringing into generative AI any large-scale body of text, please have alarm bells go off in your head that tell you to consider doing either compression or summarization. You will be glad that you considered the option.

Returning to the above research study facets, let’s see what they did and the results they found (excerpts):

  • “We conduct extensive experiments and analysis on both in-domain (i.e., MeetingBank) and out-of-domain datasets (i.e., LongBench, ZeroScrolls, GSM8K, and Big Bench Hard).” (ibid).
  • “Despite being small in size, our model shows significant performance gains over strong baselines and demonstrates robust generalization ability from GPT-3.5-Turbo to Mistral-7B.” (ibid).
  • “Additionally, our model is 3x-6x faster than existing prompt compression methods, while accelerating the end-to-end latency by 1.6x-2.9x with compression ratios of 2x-5x.” (ibid).

You can see that they were able to attain some impressive results.

I especially applaud research on generative AI that includes multiple generative AI apps. I say this because each generative AI app differs from the other, ergo if a study exclusively uses only one generative AI app it is hard to claim that the same approach will work equally well on other generative AI apps. Here, it is good news for us that they tried different generative AI apps and essentially found similarly positive results.

I am sure you are eager to see an example of what their compression prompt was able to achieve.

Here is one such example from their study, in this case compressing a meeting transcript snippet from a database of such transcripts (excerpt):

  • Original Text: “Item 15, report from City Manager Recommendation to adopt three resolutions. First, to join the Victory Pace program. Second, to join the California first program. And number three, consenting to the inclusion of certain properties within the jurisdiction in the California Hero program. It was emotion, motion, a second and public comment. CNN. Please cast your vote. Oh. Was your public comment? Yeah. Please come forward. I thank you, Mr. Mayor. Thank you. Members of the council. My name is Alex Mitchell. I represent the hero program. Just wanted to let you know that the hero program. Has been in California for the last three and a half years.”
  • Compressed Text: “Item 15, City Manager Recommendation adopt three resolutions. Join Victory Pace program. Join California first program. Consent inclusion properties jurisdiction California Hero program. Emotion, motion, second, public comment. Cast vote. Public comment? Come forward. Alex Mitchell, represent Hero program. Hero program in California three half years.”

The original text has 109 words, while the compressed text has 46 words. The compression removed 63 words (that’s 109 words in total minus 46 words remaining = 63 words removed). You could say that roughly 58% of the source was removed (i.e., 58% of 109 is about 63). Well over half of the source has been removed.

Now comes the tough part.

Does the compressed version suitably capture the crux of the original text?

Has anything been removed that is essential and thus the compressed version has missed the boat?

I think you can likely see how hard a problem it is to do a proper compression if you try doing the same task yourself by hand. Here’s what I am saying. I want you to look at the original text and try to compress it. What would you remove? What would you leave in? How far can you go on this process, yet still ensure that the result has the needed points and is intelligible?

A twist involves settings where the original text itself is not necessarily that intelligible. A transcript is a great example of a thorny problem. The odds are that a transcript will contain filler words and utterances. Are they worthy of being retained or should those be removed? If you exhort it is obvious to remove the utterances, the issue there is that the tenor or tone of what was said could end up being removed. Perhaps that aspect is vital to comprehending the matter.

Besides deciding whether a compression has done a good job, you might also be wondering whether there is even more compression that can be performed.

Envision that we use a compression that does a good job and reduces the size of the source to half in size. But along comes a better approach that can do the same job and achieve a three-quarters reduction in size. Assuming that all else is equal, you would naturally seek to use the three-quarters reduction approach.

This can be tricky to compare. The greater the compression in terms of reducing the size, the more likely the odds that the compression isn’t going to be as intelligible or otherwise isn’t as apt. The criteria are usually battling with each other. The more reduction, the less of a good job in the sense of being usable and appropriate. The more of a good job you want, the less reduction you can usually achieve. Darned if you do, darned if you don’t.

The Compression Prompt As A Task-Agnostic Template

Congratulations, you have waded through the weeds to get to the crescendo.

Let’s see what the prompt template of their task-agnostic compression prompt consists of (excerpt):

  • “System Prompt: You are an excellent linguist and very good at compressing passages into short expressions by removing unimportant words while retaining as much information as possible.”
  • “User Prompt: Compress the given text to short expressions, such that you can reconstruct it as close as possible to the original.”
  • “Unlike the usual text compression, I need you to comply with the 5 conditions below:”
  • “1. You can ONLY remove unimportant words.”
  • “2. Do not reorder the original words.”
  • “3. Do not change the original words.”
  • “4. Do not use abbreviations or emojis.”
  • “5. Do not add new words or symbols.”

-“Compress the original aggressively by removing words only. Compress the original as short as you can, while retaining as much information as possible. If you understand, please compress the following text: {text to compress}”

I will be using that same prompt in a moment when I show you examples using ChatGPT and GPT-4.

Let’s briefly review the prompt and see what it contains.

First, the prompt tells the generative AI to invoke a persona. For my extensive coverage of personas in generative AI, see the link here and the link here. This is a powerful prompting technique.

Personas get the AI into a computational pattern-matching mode that can significantly aid whatever task you are trying to perform. In this instance, they are telling the AI that it is to pretend to be an excellent linguist and good at compressing passages of text. Nice touch.

Many users of generative AI fail to lean into personas when doing so would be especially advantageous. The use of a persona for amping up compression is a good move. Make sure to keep personas in your mind whenever using generative AI. You’ll be glad that you did.

Second, they provide five stipulated conditions for the compression. This is good since you want to provide as much guidance as you can when asking for a compression. I mentioned earlier that the word “compression” can be ambiguous. Spelling out the five stated conditions will give the AI important clues about what to do.

Third, the phrasing for AI that you use in a prompt ought to at times be emphatic. If you aren’t emphatic, the instructions might be ignored or downplayed. For example, telling the generative AI to aggressively do the compression is a means of guiding the AI toward doing a strident job. I should note that your being emphatic has a downside. The emphatic wording, if it goes way over the top, can trigger a mathematical and computational pattern-matching storm that will distract from what you are trying to undertake.

I believe that sufficiently outlines the keystones of the prompt. Just like buying a new car, we need to take this shiny new vehicle for a drive. Get yourself strapped in and ready for a wild ride.

Showcasing The Topic Via Examples In Generative AI

I will next proceed to showcase what happens when you use compression prompting while in a conversation with generative AI. I am going to use ChatGPT and GPT-4 to showcase my examples. ChatGPT and GPT-4 are sensible choices in this case due to their immense popularity as generative AI apps. An estimated one hundred million weekly active users are said to be utilizing ChatGPT and GPT-4. That’s a staggering number.

A few quick comments before we launch into using ChatGPT and GPT-4.

If you are going to try to do the same prompts that I show here, realize that the probabilistic and statistical properties will likely produce slightly different results than what I show here. That’s the nature of generative AI and how it is devised.

You also should expect that different generative AI apps will respond in different ways. Not all generative AI apps are the same. The key is that sometimes a particular prompt will work in one generative AI app and not another. You will need to undertake a series of trial-and-error attempts to ferret this out.

There is also the timing factor. A prompt that worked today might not work the same way tomorrow. Most of the generative AI apps are continually being updated. The updates might alter internal facets that could change how the AI reacts to your prompting.

We are ready to get underway and I will begin with ChatGPT.

You can do the same in whichever generative AI app that you are using.

As a heads-up, I decided to use Abraham Lincoln’s famous Gettysburg Address as the text that I wanted to have compressed. There are variations of his speech that can be readily found online. I opted to use a version that contains 271 words. Our aim in this mini-experiment will be to do a compression and see if we can reduce the size, along with retaining intelligibility and vital points.

I’m sure that you already know the speech, which starts this way “Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure…”

Here we go.

  • My entered prompt into ChatGPT: “I want you to compress an essay that I am going to give you. Are you ready?”
  • ChatGPT generated response: “Yes, I'm ready to help compress your essay. Please provide the essay, and I'll assist you in condensing it.”
  • My entered prompt into ChatGPT: “Here is the text of the Gettysburg address. Go ahead and compress it.”
  • ChatGPT generated response: “Abraham Lincoln's Gettysburg Address, delivered during the American Civil War, reflects on the nation's founding principles of liberty and equality. He honors those who sacrificed their lives on the battlefield, emphasizing the ongoing responsibility to preserve freedom and uphold democratic government. Lincoln urges dedication to the unfinished task of ensuring the nation's survival and the continuation of its principles, emphasizing the importance of honoring the fallen and ensuring their sacrifice was not in vain.”

Take a look at the so-called compression that I got.

You right away certainly observed that the generated response is not a compression. It is more of a summary. Well, maybe not quite a summary either. It has indications that go beyond the text that was provided. This likely was tapped into by ChatGPT as per other prior data training about Abraham Lincoln and the Gettysburg Address in general during the initial setup of ChatGPT.

I’m glad this happened. You see, I wanted to show you this kind of an example to emphasize my earlier point that the word “compression” can be ambiguous. This was not the kind of compression I had in mind.

If at first, you don’t succeed, try and try again, as they say.

  • My entered prompt into ChatGPT: “Let’s start over. I want you to compress the material. You are to use only the material provided and compress the contents. Don’t make any interpretations. Don’t do any rewording.”
  • ChatGPT generated response: “Understood. Please provide the material you'd like me to compress, and I'll follow your instructions accordingly.”
  • My entered prompt into ChatGPT: ”Here is the text to be compressed…”
  • ChatGPT generated response: "87 years ago, our fathers founded a nation dedicated to liberty and equality. Now, in a great civil war, we honor those who sacrificed for our nation. It's fitting to dedicate this ground, yet their deeds surpass our words. We must continue their work, ensuring their sacrifices were not in vain. Let us resolve to uphold freedom and democratic government.”

I valiantly tried to convey to ChatGPT that I wanted a compression.

Though the result is more so a compression than the first run, it still isn’t a compression of the caliber we are looking for. One irksome thing was the “87 years ago” which is a kind of summary or interpretation of what the source says. Didn’t want that.

But I am somewhat pleased that the result came out badly because it shows that even if you try to be instructive about compression, the result still might not come out as hoped for. I think we are primed and ready to see if the compression prompting template will do any better with ChatGPT.

Are you ready to see?

Hold your breath.

  • My entered prompt (based on the research prompt template): “You are an excellent linguist and very good at compressing passages into short expressions by removing unimportant words while retaining as much information as possible. Compress the text I am going to give you and compress the text into short expressions, and such that you (ChatGPT) can reconstruct it as close as possible to the original. Unlike the usual text compression, I need you to comply with 5 conditions. First condition: You can ONLY remove unimportant words. Second condition: Do not reorder the original words. Third condition: Do not change the original words. Fourth condition: Do not use abbreviations or emojis. Fifth condition: Do not add new words or symbols. Make sure to compress the original text aggressively by removing words only. Compress the original text as short as you can, while retaining as much information as possible. Do you understand these instructions?”
  • ChatGPT generated response: “Yes, I understand the instructions. Please provide the text you'd like me to compress.”
  • My entered prompt: ”Here is the text to be compressed…”
  • ChatGPT generated response: “Four score and seven years ago our fathers brought forth on this continent a new nation, conceived in Liberty, dedicated to the proposition that all men are created equal. Now engaged in a great civil war, testing whether that nation, or any nation so conceived and dedicated, can long endure. We are met on a great battle-field. We have come to dedicate a portion of that field, a final resting place for those who gave their lives. It is fitting and proper that we should do this. But, in a larger sense, we cannot dedicate, consecrate, hallow this ground. The brave men, living and dead, who struggled here, consecrated it. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living to be dedicated to the unfinished work they who fought here have nobly advanced. It is for us to be dedicated to the great task remaining before us—that from these honored dead we take increased devotion to that cause—that we highly resolve that these dead shall not have died in vain—that this nation, under God, shall have a new birth of freedom—and that government of the people, by the people, for the people, shall not perish.”

Finally, we got a compression.

We are now in the right ballpark.

The compressed result has 217 words.

The original text has 271 words, while the compressed text has 217 words. The compression removed 54 words (that’s 271 words in total minus 217 words remaining = 54 words removed). You could say that roughly 20% of the source was removed (i.e., 20% of 271 is about 54). Approximately one-fifth was removed.

I dare say that’s not a compression ratio to be overly elated about. Look, I’m glad that we got the 20%, and I don’t like to look a gift horse in the mouth. It would seem intuitively we might be able to do better.

Note that the prompt doesn’t give a target level of compression. This is something you might consider adding to the prompt. I would first start without a target and just see what you get. Once you’ve seen the result of a first run, go ahead and consider redoing the prompt with a desired target level.

We must also of course consider whether the compressed version is any good at the get-go.

In the case of something like the Gettysburg Address, we could argue forever about the portions that were removed. It is tough since the entire speech is remarkable. Nearly every line and each word is astounding. Imagine trying to compress a poem, and the odds are that you will be leaving out facets that will break your heart.

Another reminder is that you should carefully consider what text you are going to compress and whether the compression, no matter how it works, will be able to reasonably do justice to the original text.

I went ahead and played with the compression prompt template and tried all kinds of variations. In the end, I decided that ChatGPT just doesn’t have the gravitas to go much further on this. I became exasperated and thought that for sure GPT-4, being more advanced than ChatGPT, would do a better job.

Let’s try using GPT-4 and see what happens.

  • ​​My entered prompt into GPT-4: “I want you to compress an essay that I am going to give you. Here is the text to be compressed…”
  • GPT-4 generated response:

“To compress the text while retaining its essence, I'll remove some parts and rephrase others for brevity.”

"Four score and seven years ago, our fathers founded a new nation on this continent, dedicated to liberty and the belief that all men are created equal. We are now in the midst of a great civil war, testing whether this nation, or any nation so conceived, can endure. We meet on a battle-field of that war, dedicating a part of it as a final resting place for those who gave their lives for this nation's survival. It's fitting and proper we do this.

“Yet, we can't dedicate, consecrate, or hallow this ground beyond what the brave men, living and dead, who struggled here have done. The world may not remember our words, but it can't forget their deeds. It's our task to be dedicated to the unfinished work they've advanced so nobly. From these honored dead we take increased devotion to their cause, resolving that these dead shall not have died in vain, that this nation shall have a new birth of freedom, and that government of, by, and for the people shall not perish."

“The compressed text has been reduced to 176 words.”

End of GPT-4 response

You can see that I first tried a vague prompt about compression.

Sure enough, the compression included rephrasing, which isn’t what I had in mind. No problem. You can’t expect generative AI to be reading minds (well, you soon can, as I explain is being researched, see my coverage at the link here).

Similar to what I had done with ChatGPT, I will next try a compression prompt based on some simple wording. I will also include a target level of compression so you can see how that impacts the result.

Here’s what took place.

  • My entered prompt into GPT-4: “Do the compression over again. You cannot do any rephrasing this time. You can only remove words. Compress as much as possible while abiding by these rules. Try to aim for a result that has 100 words or less.”
  • GPT-4 generated response:

“To compress the text by only removing words without rephrasing, I'll select key sentences and phrases that capture the essence of the original message while significantly reducing the length. Given the constraints, this selection process aims to preserve the core themes of unity, dedication, and the importance of the struggle while adhering to the word count limit.”

"Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. It is for us the living, to be dedicated to the unfinished work which they who fought here have thus far so nobly advanced."

“The condensed version of the text is approximately 99 words in size while adhering to the rule of only removing words without rephrasing.”

End of GPT-4 response

Seems like GPT-4 did what I asked.

As always, it is important to gauge the intelligibility and aptness of the compression. I won’t delve into that here, other than to say it seemed basically on par with what might be expected, especially given the severe constraint of being around 100 words or less.

We are ready to try the compression prompt template.

  • My entered prompt into GPT-4 (based on the research prompt template): “You are an excellent linguist and very good at compressing passages into short expressions by removing unimportant words while retaining as much information as possible. Compress the text I am going to give you and compress the text into short expressions, and such that you (ChatGPT) can reconstruct it as close as possible to the original. Unlike the usual text compression, I need you to comply with 5 conditions. First condition: You can ONLY remove unimportant words. Second condition: Do not reorder the original words. Third condition: Do not change the original words. Fourth condition: Do not use abbreviations or emojis. Fifth condition: Do not add new words or symbols. Make sure to compress the original text aggressively by removing words only. Compress the original text as short as you can, while retaining as much information as possible. Do you understand these instructions?”
  • GPT-4 generated response: “Yes, I understand the instructions. Please provide the text you'd like me to compress.”
  • My entered prompt into GPT4: ”Here is the text to be compressed…”
  • GPT-4 generated response: “Four score seven years ago fathers brought forth continent, new nation, conceived Liberty, dedicated proposition men created equal. Now engaged great civil war, testing whether nation, any nation conceived dedicated, can long endure. Met great battle-field war. Come dedicate portion field, final resting place who gave lives nation might live. Altogether fitting proper do this. But, larger sense, can not dedicate—not consecrate—not hallow—ground. Brave men, living dead, struggled, have consecrated, above our power add detract. World will little note, nor long remember say here, but never forget did here. For us living, rather, dedicated here unfinished work fought have nobly advanced. Rather for us here dedicated great task remaining before us—that from these honored dead take increased devotion cause gave last full measure devotion—that here highly resolve dead not died in vain—that nation, under God, shall new birth freedom—and government people, by people, for people, shall not perish earth.”

Note that I didn’t give a target level this time and thus the size of the result was based on the general tenor of the compression prompt about being aggressive on the compression.

The original text has 271 words, while the compressed text has 156 words. The compression removed 115 words (that’s 271 words in total minus 156 words remaining = 115 words removed). You could say that roughly 42% of the source was removed (i.e., 42% of 271 is about 115). We were nearing maybe half being removed. Remarkable.

I’ll mention that as always, we would want to closely scrutinize the compressed version. All the other caveats I’ve mentioned still apply.

Conclusion

My recommendation to you is that you try doing some compression prompting exercises via whichever generative AI app you are customarily using. Do so now, before you suddenly discover the need to do a compression. It would be wise to be prepared.

Proceed as follows. First, make use of vague compression prompts and see what happens. Next, fine-tune those prompts and look anew at what happens. Then, try the mentioned compression prompt and gauge how it goes for you. Tweak the prompt as needed. Keep on practicing until you feel you’ve gotten the right swing of things. Reward yourself accordingly.

A final thought for now on this matter.

John Morley, 1st Viscount Morley of Blackburn, the famed British statesman, and journalist, said this about compression: “The essence of a quote is the compression of a mass of thought and observation into a single saying.”

Compression is not an easy task. Any wanton approach can easily do compression if you are willing to toss intelligibility and aptness out the window. Getting generative AI to do erstwhile compression requires soundness on the part of the person entering the prompts. They also need to carefully review the result and not wantonly hand off the compressed version to others who might be unaware of what the original had to say.

Please remember that I energetically asked you to consider practicing doing compressions in generative AI, so that when the day arrives that you must do so, you are ready with the axe firmly in hand.

The last line today suitably goes to Abraham Lincoln: "Give me six hours to chop down a tree and I will spend the first four sharpening the ax."

Follow me on Twitter