Practical Lessons on How To Work with LLM Prompting

Vedant Anil Joshi Avatar

Prompt engineering has become an important skill in modern AI development. Large Language Models (LLMs) can perform a wide range of tasks, but the quality, consistency, and format of their responses can depend significantly on how the instructions are written. As part of my internship at Valentius Kryptix, I worked on a hands-on Prompt Engineering task designed to understand how different prompting techniques affect LLM behavior.

For this task, I used Gemini 3.1 Pro Extended Thinking through Google AI Studio and conducted a series of controlled experiments. Instead of simply writing prompts and observing individual responses, I compared different prompting strategies using predefined test cases and measured their results.

Zero-Shot vs Few-Shot Prompting

The first experiment focused on sentiment classification. I tested two approaches: zero-shot prompting and few-shot prompting.

In the zero-shot approach, the model was given a task description without any examples. The model had to classify each sentence as Positive, Negative, or Neutral based only on the instructions.

For example, the prompt instructed the model to classify a sentence and return only one of the three sentiment labels.

The few-shot approach included several examples before presenting the test sentence. These examples demonstrated how positive, negative, and neutral sentences should be classified.

I tested both approaches using 10 sentiment classification examples. The zero-shot approach achieved an accuracy of 90%, while the few-shot approach also achieved 90%.

This result was particularly interesting because few-shot prompting did not automatically produce a higher accuracy on this dataset. One of the test cases involved a sentence describing a restaurant with “reasonable prices.” The model classified it as Positive in both approaches, while the predefined expected label was Neutral.

The experiment showed that examples are useful, but simply adding examples does not guarantee better results. The examples need to represent the important decision boundaries of the task.

Direct Prompting vs Reasoning-Oriented Prompting

The second experiment examined how prompting can influence the model’s reasoning behavior.

I created five mathematical and logical reasoning problems involving percentages, work rates, discounts, average speed, and ordering constraints.

The first version used a direct prompt that simply asked the model to solve the problem and provide the final answer.

The second version explicitly instructed the model to work through the problem step by step before providing the final answer.

Both approaches achieved 100% accuracy on the five selected problems.

However, there was a clear difference in the responses. The direct prompts generally produced concise final answers, while the reasoning-oriented prompts generated detailed intermediate calculations before presenting the final result.

For example, in the discount problem, the reasoning-oriented response explicitly calculated the first 15% discount, obtained the discounted price, calculated the additional 10% discount, and then produced the final price.

This experiment demonstrated that prompting can influence not only whether a model reaches the correct answer, but also how much explanation and intermediate reasoning it provides.

Structured JSON Output

The third experiment focused on one of the most important requirements when integrating LLMs into software applications: producing structured, machine-readable output.

I created a transaction extraction task where the model had to extract three fields:

  • Name
  • Date
  • Amount

The expected structure was:

{
  "name": "string",
  "date": "YYYY-MM-DD",
  "amount": 0
}

I tested the same 10 transaction inputs under three different conditions.

The first condition used a basic JSON prompt. The second used a stricter prompt containing explicit formatting and normalization rules. The third used Gemini’s native Structured Output capability with a defined schema.

All three approaches achieved 100% success on the selected 10 test cases.

The inputs intentionally included different formats such as currency symbols, INR/Rs., abbreviated amounts such as “12.5k”, written numbers, and different date formats.

For example, the model successfully converted:

12.5k

into:

12500

and normalized different date representations into the required YYYY-MM-DD format.

The native structured-output approach is particularly useful when building applications because the output format can be constrained by a schema rather than relying entirely on natural-language instructions.

What I Learned

These experiments gave me several practical insights into prompt engineering.

First, prompt complexity does not automatically mean better performance. A simple zero-shot prompt performed just as well as the few-shot prompt on my selected sentiment dataset.

Second, examples should be carefully selected. Few-shot prompting becomes more useful when examples demonstrate ambiguous cases and important decision boundaries rather than only obvious examples.

Third, prompting can control response behavior. Direct prompts encouraged concise answers, while reasoning-oriented prompts encouraged detailed explanations and intermediate calculations.

Finally, structured output is extremely valuable for LLM applications. When an LLM is integrated into a backend system, returning predictable JSON can make it much easier to pass model outputs into databases, APIs, workflows, and downstream applications.

Results at a Glance

ExperimentTechniqueTest CasesAccuracy
Sentiment ClassificationZero-Shot1090%
Sentiment ClassificationFew-Shot1090%
Problem SolvingDirect Prompt5100%
Problem SolvingReasoning-Oriented Prompt5100%
Structured ExtractionBasic JSON10100%
Structured ExtractionStrict JSON10100%
Structured ExtractionNative Structured Output10100%

These results represent the performance observed on the specific test cases used in the experiment and should not be interpreted as universal performance guarantees for the model.

Conclusion

This task helped me understand prompt engineering as an engineering discipline rather than simply a way of asking an AI model questions.

Effective prompt engineering involves defining clear instructions, selecting useful examples, controlling the desired response format, testing prompts systematically, and evaluating their behavior against predefined expectations.

The experiments also reinforced an important principle for building LLM-powered applications: a prompt should be designed around the requirements of the downstream system. Whether the goal is classification, reasoning, information extraction, or structured API integration, the prompt should clearly communicate the expected behavior and output.

I documented the complete experiments, prompts, raw model outputs, analysis, and results in my GitHub repository:

GitHub: https://github.com/Vedant-1724/prompt-engineering-mastery

This hands-on exercise has strengthened my understanding of LLM behavior and provided practical experience that I can apply to future Generative AI, RAG, and Agentic AI projects.

Vedant Anil Joshi Avatar

Leave a Reply

You May Love