Skip to content

Commit

Permalink
update zeroshot prompt format to 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Mel-iza committed Jun 26, 2024
1 parent 4083260 commit 68f02b5
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions bothub/api/v2/zeroshot/usecases/format_prompt.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
BASE_PROMPT = """<s>[INST] {context_description} {context}
BASE_PROMPT = """<|begin_of_text|><|start_header_id|>system<|end_header_id|>
{context_description} {context}
{reflection}
# {classes_title}
{all_classes}
{all_classes}<|eot_id|><|start_header_id|>user<|end_header_id|>
{input}<|eot_id|><|start_header_id|>assistant<|end_header_id|>
# {sentence_title} {input}
# {class_id_title} [/INST]"""
"""

class FormatPrompt:
const_prompt_data = {
"por": {
"context_description": "Você é muito especialista em classificar a frase do usuário em um chatbot sobre:",
"reflection": "Pare, pense bem e responda com APENAS UM ÚNICO `id` da classe que melhor represente a intenção para a frase do usuário de acordo com a análise de seu contexto, responda APENAS com o `id` da classe só se você tiver muita certeza e não explique o motivo. Na ausência, falta de informações ou caso a frase do usuário não se enquadre em nenhuma classe, classifique como \"-1\".",
"classes_title": "Essas são as Classes com seus Id e Contexto:",
"sentence_title": "Frase do usuário:",
"class_id_title": "Id da Classe:"
"classes_title": "Essas são as Classes com seus Id e Contexto:"
},
"eng": {
"context_description": "You are very expert in classifying the user sentence in a chatbot about:",
"reflection": "Stop, think carefully, and respond with ONLY ONE SINGLE `id` of the class that best represents the intention for the user's sentence according to the analysis of its context, respond ONLY with the `id` of the class if you are very sure and do not explain the reason. In the absence, lack of information, or if the user's sentence does not fit into any class, classify as \"-1\".",
"classes_title": "These are the Classes and its Context:",
"sentence_title": "User's sentence:",
"class_id_title": "Class Id:"
"classes_title": "These are the Classes and its Context:"
},
"spa": {
"context_description": "Eres muy experto en clasificar la frase del usuario en un chatbot sobre:",
"reflection": "Deténgase, piense bien y responda con SOLO UN ÚNICO `id` de la clase que mejor represente la intención para la frase del usuario de acuerdo con el análisis de su contexto, responda SOLO con el `id` de la clase si está muy seguro y no explique el motivo. En ausencia, falta de información o en caso de que la frase del usuario no se ajuste a ninguna clase, clasifique como \"-1\".",
"classes_title": "Estas son las Clases con sus Id y Contexto:",
"sentence_title": "Frase del usuario:",
"class_id_title": "Id de la Clase:"
"classes_title": "Estas son las Clases con sus Id y Contexto:"
}
}

Expand All @@ -41,11 +39,10 @@ def generate_prompt(self, language: str, zeroshot_data: dict):
prompt = BASE_PROMPT.format(context_description=translated_text.get("context_description"),
reflection=translated_text.get("reflection"),
classes_title=translated_text.get("classes_title"),
sentence_title=translated_text.get("sentence_title"),
class_id_title=translated_text.get("class_id_title"),
context=context,
all_classes=all_classes,
input=input)
print(f"prompt: {prompt}")

return prompt

Expand Down

0 comments on commit 68f02b5

Please sign in to comment.