|
|
|
|
|
|
|
|
for c, desc in self.category_description.items(): |
|
|
for c, desc in self.category_description.items(): |
|
|
if desc.get("description"): |
|
|
if desc.get("description"): |
|
|
descriptions.append( |
|
|
descriptions.append( |
|
|
"--------------------\nCategory: {}\nDescription: {}\n".format(c, desc["description"])) |
|
|
|
|
|
|
|
|
"\nCategory: {}\nDescription: {}".format(c, desc["description"])) |
|
|
|
|
|
|
|
|
self.prompt = """ |
|
|
self.prompt = """ |
|
|
You're a text classifier. You need to categorize the user’s questions into {} categories, |
|
|
|
|
|
namely: {} |
|
|
|
|
|
Here's description of each category: |
|
|
|
|
|
{} |
|
|
|
|
|
|
|
|
|
|
|
You could learn from the following examples: |
|
|
|
|
|
{} |
|
|
|
|
|
You could learn from the above examples. |
|
|
|
|
|
Just mention the category names, no need for any additional words. |
|
|
|
|
|
|
|
|
|
|
|
---- Real Data ---- |
|
|
|
|
|
{} |
|
|
|
|
|
|
|
|
Role: You're a text classifier. |
|
|
|
|
|
Task: You need to categorize the user’s questions into {} categories, namely: {} |
|
|
|
|
|
|
|
|
|
|
|
Here's description of each category: |
|
|
|
|
|
{} |
|
|
|
|
|
|
|
|
|
|
|
You could learn from the following examples: |
|
|
|
|
|
{} |
|
|
|
|
|
You could learn from the above examples. |
|
|
|
|
|
|
|
|
|
|
|
Requirements: |
|
|
|
|
|
- Just mention the category names, no need for any additional words. |
|
|
|
|
|
|
|
|
|
|
|
---- Real Data ---- |
|
|
|
|
|
USER: {}\n |
|
|
""".format( |
|
|
""".format( |
|
|
len(self.category_description.keys()), |
|
|
len(self.category_description.keys()), |
|
|
"/".join(list(self.category_description.keys())), |
|
|
"/".join(list(self.category_description.keys())), |
|
|
"\n".join(descriptions), |
|
|
"\n".join(descriptions), |
|
|
"- ".join(cate_lines), |
|
|
|
|
|
|
|
|
"\n\n- ".join(cate_lines), |
|
|
chat_hist |
|
|
chat_hist |
|
|
) |
|
|
) |
|
|
return self.prompt |
|
|
return self.prompt |