Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarification on the use of hard-written output field prompt in TextToSQLAnswer Signature #1178

Closed
backslash112 opened this issue Jun 19, 2024 · 1 comment

Comments

@backslash112
Copy link

I am reading the text-to-sql example from the examples/ folder, and I have a question regarding the TextToSQLAnswer class. I noticed that the sql output field uses a hard-written prompt in its description:

sql:str = dspy.OutputField(desc="Generate syntactically correct sqlite query with correct column names using suitable tables(s) and its rows.\n Don't forget to add distinct.\n Please rename the returned columns into suitable names.\n DON'T OUTPUT anything else other than the sqlite query")

My question is: Does the content of the desc parameter matter in this case? Is it used as a prompt for the model to generate the SQL query, or is it just a human-readable description?

Thanks!

@backslash112 backslash112 changed the title Clarification on the use of hard-written output field prompt in TextToSQLAnswer module Clarification on the use of hard-written output field prompt in TextToSQLAnswer Signature Jun 19, 2024
@arnavsinghvi11
Copy link
Collaborator

Hi @backslash112 , the description is attached with the field within the prompt.

For instance, in the intro.ipynb notebook, the signature BasicQA is defined as

class BasicQA(dspy.Signature):
    """Answer questions with short factoid answers."""

    question = dspy.InputField()
    answer = dspy.OutputField(desc="often between 1 and 5 words")

which turns into the prompt:

Answer questions with short factoid answers.

---

Follow the following format.

Question: ${question}
Answer: often between 1 and 5 words

---

Question: What is the nationality of the chef and restaurateur featured in Restaurant: Impossible?
Answer:

The description is certainly not necessary if the signature instruction covers your task requirements, but can often help in guiding the model on how to treat the corresponding Input and OutputFields.

@okhat okhat closed this as completed Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants