Skip to content

Commit

Permalink
feat: minor prompt adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-ny committed Sep 27, 2024
1 parent 795b87f commit bc4dcd5
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
6 changes: 4 additions & 2 deletions backend/src/lm/generate_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from src.lm.generate_events import lm_model_essay as lm_model
from src.embeddings.vector_store import get_similar_results

from src.lm.prompts import QUESTION_POINT_GEN_SYSPROMPT as SYSPROMPT
from src.lm.prompts import ROLE_SYSPROMPT as SYSPROMPT
from src.lm.prompts import QUESTION_POINT_GEN_SYSPROMPT as HUMAN_PROMPT


class Points(BaseModel):
Expand All @@ -14,7 +15,8 @@ class Points(BaseModel):


def generate_points_from_question(question: str) -> dict:
messages = [SystemMessage(content=SYSPROMPT), HumanMessage(content=question)]
human_message = HUMAN_PROMPT + question
messages = [SystemMessage(content=SYSPROMPT), HumanMessage(content=human_message)]

result = lm_model.invoke(messages)
parser = JsonOutputParser(pydantic_object=Points)
Expand Down
39 changes: 32 additions & 7 deletions backend/src/lm/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,33 @@
"""

ROLE_SYSPROMPT = """
You are a knowledgeable assistant designed to help students with their GCE A Levels General Paper.
Your goal is to provide logical, coherent, and well-reasoned arguments for argumentative or discursive essay questions.
Always maintain a neutral and informative tone.
"""

QUESTION_POINT_GEN_SYSPROMPT = """
You are a Singaporean student studying for your GCE A Levels General Paper.
Given an General Paper essay question that is argumentative or discursive in nature, you should provide points that can be used to support or refute the argument in the question.
You should provide 2 points for the statement and 2 points against the statement. You should also provide a brief explanation for each point.
For each point, you should generate a clear and specific point to support or refute the argument followed by a good reason or explanation.
The point statement should directly address the question with a clear stand.
The reason or explanation should be relevant and specific to the point that you have made. It should be coherent and provide a clear argument that supports the point strongly.
Do not provide any examples in your response.
Important Note: Be very logical in your reasoning and ensure that it DIRECTLY addresses the question and the point you are making.
Think step by step, starting from the point and then providing a clear, direct reason that reinforces the point. If it helps, you may rephrase the adjectives in your thinking process.
Do not provide any specific examples in your response.
Each point should follow this structure closely - "<A statement that supports/refutes the argument> because <reason for the statement>".
Important note: The point must directly address the question and have a clear stand. For example, for a question "Is A good?", a point should be "A is good because <clear reason why A is good>".
Here are some examples:
1. Question: "Should the government prioritize economic growth over environmental protection?"
- For Point: "The government should prioritize economic growth because a strong economy creates jobs and improves living standards for citizens."
- Explanation: "A robust economy enables the government to fund essential services, including healthcare and education, ultimately benefiting society as a whole."
- Against Point: "The government should not prioritize economic growth over environmental protection because neglecting the environment can lead to long-term damage that affects future generations."
- Explanation: "Sustainable practices ensure that natural resources are preserved, which is crucial for maintaining the quality of life for future citizens."
Your response should be in the following json format:
{
Expand All @@ -73,6 +86,7 @@
]
}
The question:
"""

Expand Down Expand Up @@ -153,7 +167,15 @@

QUESTION_CLASSIFICAITON_SYSPROMPT = """
You are an expert in General Paper essay questions. Analyze the following question and determine whether it is suitable for a General Paper essay.
A good GP question should encourage critical thinking and balanced arguments on relevant topics. It should be open-ended and allow for multiple perspectives.
A GP question should encourage critical thinking and arguments on relevant topics.
Sometimes a question may be one sided but it should still be acceptable if it encourages critical thinking and arguments.
Examples:
- "Should the government provide free education for all citizens?" is a good GP question.
- "The government should provide free education for all citizens. Discuss" is a good GP question.
- "Discuss the view that all big corporations are evil" is a good GP question.
- "Chicken is better than beef. Discuss" is a NOT good GP question.
- "Is the sky blue?" is a NOT good GP question.
Please evaluate the question based on these criteria and respond with:
1. "Yes" if it is a good General Paper essay question.
Expand All @@ -163,5 +185,8 @@
"is_valid": "Yes/No",
"error_message": "Explanation of why the question is suitable or unsuitable for a General Paper essay."
}
The question:
Final Check: Even if the question is one-sided, it is acceptable.
Discuss the view below:
"""

0 comments on commit bc4dcd5

Please sign in to comment.