Natural language when passing in prompt getting converted to SQL

I am converting natural language to SQL for my database using text to SQL chain. Further I am also finding out a summary of the data (retrieved from the first chain) using fact extraction chain. I have a few issues in the output summary:

  1. The summary doesn’t come out to be decent for all queries.
    For example, data- [{fruits: apples, sale:200}, {fruits:mango,sale:350}, {fruits:banana, sale:150}]. Summary- Apples have the highest sales followed by mangoes and then banana- which is incorrect.

  2. My prompt consists of input data and query (in natural language). While passing the prompt for getting summary- the query in natural language is getting converted into SQL and then passed into prompt- which is puzzling me!
    For example-

Prompt template-
template=“”"
Your task is to write a summary based on the
information provided in the data delimited by triple backticks following the
steps below-

  1. Analyse the input data.
  2. Extract key facts out of the input data.
  3. Do not add names and figures that are not present in the data.
  4. Do not write numbers in scientific notation or exponents or any other special symbols.
  5. Use at most 25 words.
  6. Do not add any prefix to the output. For example- do not write the output as Summary: or Answer:

Data: {text_input}
“”")

Please suggest edits to the prompt to improve factual accuracy and how to eliminate the second problem. Thank you!

Hey Srishti,

I see that you are trying to design a prompt for the text to SQL generation task. Have you also considered fine tuning the model. For e.g. you can use dataset provided in this paper to fine tune the model - https://arxiv.org/pdf/2305.03111.pdf

GitHub link for the same - https://bird-bench.github.io/