Question Verifier Text To Sql
LangChain Hub prompt: spapicchio/question_verifier_text-to-sql
Determine if the SQL query aligns correctly with the provided question. Evaluate the SQL query to verify if it can accurately answer the question it corresponds to. Consider the intent of the question, the structure, and operations of the SQL query, and any fields or conditions used within the query.
Steps
- Understand the Question: Break down the question to identify its intent, involved entities, and expected results.
- Analyze the SQL Query: Decompose the SQL query to understand its structure, operations, filters, and selected fields.
- Compare Intent and Structure: Cross-reference the question's intent with the operations and structure of the SQL query to ensure they correspond appropriately.
- Conclusion: Determine if the SQL query can produce results that answer the question.
Output Format
Provide the output in JSON format with two keys, "correctness" and "reasoning". The JSON must be enclosed json
{{
"correctness": [true/false],
"reasoning": "Explain your reasoning based on each evaluation criteria. If correctness is True, this field contains an empty string. If correctness is false, explain what is wrong."
}
Examples
Example 1:
- Question: "What are the names of employees who work in the Sales department?"
- SQL Query:
SELECT name FROM employees WHERE department = 'Sales';Output: {{ "correctness": true, "reasoning": "" }
Example 2:
- Question: "What are the top 3 highest paid employees?"
- SQL Query:
SELECT name FROM employees ORDER BY salary DESC LIMIT 5;Output: {{ "correctness": false, "reasoning": "No, the SQL query does not align with the question as it selects the top 5 highest-paid employees instead of the top 3." }
Notes
- Ensure the SQL query targets the correct data fields and includes the necessary conditions to answer the question.
- Consider edge cases where a query might technically match the question but could be optimized or better structured for precision.
Question: {question} Query: {sql_query}
How to Use
Use with LangChain: hub.pull("spapicchio/question_verifier_text-to-sql")
Related Prompts
More prompts in Data & Analytics
Sql Agent System Prompt
LangChain Hub prompt: langchain-ai/sql-agent-system-prompt
Buyer Persona Legend
Generate detailed User Personas for your Business with data neatly organized into a table.
Prompt For Text To SQL
Prompt for text-to-SQL
Unlock Etsy Success 2024
This prompt will help you take your Etsy store to the next level.
A Prompt To Generate Multiple Variations Of A Vector Store Query For Use In A MultiQueryRetriever
A prompt to generate multiple variations of a vector store query for use in a MultiQueryRetriever
Text To Postgres Sql
LangChain Hub prompt: jacob/text-to-postgres-sql