When I first started working with language models, the frustration was real. I'd give it a prompt, and the AI would give me something generic, incomplete, or even totally off-topic. It felt like I was talking to a wall. But over time, I realized the problem wasn't the AI. The problem was how I was asking for things.
I started studying how big tech companies like OpenAI and Google get the most accurate results from these models. And what I learned, I want to share with you. These are prompt engineering techniques that completely changed the way I work.
5. Be as Specific as Possible
The first thing I understood is that clarity is everything. I stopped being so vague. Before, I'd ask for something like "tell me about JavaScript." The response would come back as a flood of information that wasn't useful to me.
Now, I think about what I really need. For example:
- Before: "Tell me about JavaScript."
-
Now: "I need a JavaScript code snippet that takes an array of objects, filters it to only include objects where the status property is '
active
', and then returns a new array with those filtered objects. Please include comments for each step of the code."
See the difference? I give the AI all the information it needs to give me exactly what I want. The result is always more accurate.
4. Use Delimiters to Organize Your Request
One of my favorite techniques is using delimiters. When I have a large block of text or multiple instructions, I use triple quotes (""")
or backticks to isolate the different parts. This keeps the AI from getting confused about what's an instruction and what's reference text.
Think about a scenario where I need the AI to analyze a text and answer a question.
Instruction: Based on the following text, identify the main challenge the development team faced and its impact on the project.
Text to be analyzed:
"""
The data migration project encountered an unexpected obstacle when the legacy database showed schema inconsistencies. This caused a three-week delay in the schedule, directly impacting the launch date.
"""
I used the delimiters to say, "hey, AI, this is the text you should analyze." It's that simple.
3. Break Down Complex Tasks into Smaller Parts
I stopped asking for everything at once. If my request is complex, I break it down into steps. This is especially useful when I need the AI to follow a logical sequence.
For example, if I need the AI to help me write API documentation, I don't ask for it all at once. I break it down:
- First, list all the API endpoints.
- Next, for each endpoint, describe its function.
- Then, create an example request and response for each endpoint.
By dividing the work, I ensure the AI doesn't skip any important part and delivers a more complete and well-structured result.
2. Provide Examples of the Expected Output
One of the most powerful techniques I use is few-shot prompting. I show the AI exactly what I want. I give it one or two examples of what the response should look like.
Let's say I need to classify the tone of a few sentences as "formal" or "informal."
Example:
Sentence: Please send me the report by the end of the day.
Tone: Formal
Sentence: Send the report to me when you can.
Tone: Informal
Sentence: I'd like to schedule our meeting for next Tuesday.
Tone:
By providing the examples, the AI "gets the hang of it" and can perfectly classify the last sentence. It's like I'm teaching it the rules of the game.
1. Ask the AI to Complete Your Work
I also learned to "start" the work and ask the AI to finish it. This is great for saving time and ensuring the AI understands the exact context.
If I'm writing a Python function to calculate an average, I can write the initial part and let the AI finish it.
def calculate_average(list_of_numbers):
#
I leave the line empty, and the AI, based on the function name and context, completes the code for me.
Try right now!
Conclusion
Mastering these techniques made me see the AI not as a black box, but as an incredibly powerful tool that, when used correctly, becomes an extension of my own reasoning.
Were you already familiar with these techniques? Which of them do you already use in your day-to-day work? Share in the comments!
Top comments (0)