Simple LLM Prompt Comparison Analysis

paras-madan-image
Paras Madan

3 min read

In the world of Language Learning Models (LLMs), prompt compression is a fascinating and crucial topic. It involves the process of reducing the size of the prompts that are fed into these models without losing the essential information they carry. This blog post will dive into the details of Simple LLM Prompt Compression Analysis with an example that reduced my costs upto 62%.

blog-thumbnail

What is Prompt Compression?

Prompt compression, in the context of LLMs, refers to the process of minimizing the length of the input prompts while maintaining the quality of the model’s output. The goal is to achieve the same or similar results with fewer input tokens. This is particularly important because many LLMs have a maximum token limit for their inputs.

Let's do a Practical Analysis

Here I am using a prompt to generate a blog. This prompt has 105 tokens. If we a cost analysis using costing of GPT-4 API, a single API call would cost me around 0.26 paise.

Actual Prompt: I want you to act as a blogger and write a blog post about the benefits of meditation for beginners, with a friendly and approachable tone that engages readers. Your target audience is individuals who are interested in improving their mental well-being. Write in a personal style using singular first-person pronouns only. Please include the keywords “mindfulness”, “relaxation”, and “stress reduction” throughout the article.Format your response using markdown. Use headings, subheadings, bullet points, and bold to organize the information.

Now, I am used Microsoft Bing in precise mode to reduce the size of the prompt. I just simply prompted it like this: I am giving you a prompt and your role is to reduce the prompt size by keeping the information intact. This should be a lossless compression and you need to be utmost sure that the same value is provided by this reduced prompt. The objectives is to reduce prompt size for reducing API cost.

Now the result reduced had 39 tokens and it will only cost us 0.098 paise/API call which is a 62% reduction in price.

Reduced Prompt: Write a beginner-friendly blog on meditation benefits, targeting individuals seeking mental well-being. Use “I”, include “mindfulness”, “relaxation”, “stress reduction”, and format with markdown.

Note: Words like Lossless Compression and Providing Consistent value is super important.

Now this technique may sound too simple but according to my experience its very effective when working with big human written prompts. Also a tip, before going to production with a reduced prompt try to do a A/B Test of both prompts.


If you like this blog you should also check out the videos I make on Instagram:https://www.instagram.com/parasmadan.in/


In case of any queries, feel free to reach out to me on parasmadan555@gmail.com

Llm

Langchain

Developer

Gpt

artificial intelligence

© 2024 Paras Madan