Prompts are what we input to a large language model, and prompt engineering is the art of optimizing prompts to produce effective output.
Guidelines for effective prompting include:
Hallucination is when an AI model generates outputs that are not based on real data but rather are fabricated by the model itself.
For example, an AI model might generate code using syntax that doesn’t actually exist.
As human beings, we are psychologically prone to believing new things that confirm our existing beliefs, known as confirmation bias. If we run code provided by an AI and it produces a result that “makes sense”, we are less likely to catch errors in the AI code.
We need to be very stringent with ourselves when using AI generated code, double-checking everything the AI has done for validity. Note that we can’t use AI to do these checks, as that is using the same flawed system to check itself.
The data we feed into an AI model may be used to train future iterations of the model, or stored in some other way, which can result in data leaks where our information becomes part of the publicly available large language model. This poses privacy and security risks if the data is sensitive or confidential.
Instead of writing one large detailed prompt, it is often more effective to interact with an AI system using a conversational approach, adding details as necessary and asking for refinements to build our analytics step by step.
By using a conversational approach, we:
Here are some different types of prompts we might write during a conversation:
I’m working on an analytics report about electric vehicles
)I have three tables with the following names
)Write a query to determine the most efficient vehicle
) Can you explain this piece of the query you generated:
) That’s great, what other types of statistics should I look into for this report?
)Instead of including every detail in our prompt, we can often get away with telling the AI the final output structure we want, and letting the AI infer how to structure the prompt.
For example:
I have three database tables: models, manufacturers, and fuels. they join using the columns fuel_id and manufacturer_id
I want a SQL query that produces a table structured as follows:
| manufacturers.manufacturer | fuels.fuel | number_of_models |
Notice how
AI has many uses in SQL, including: