Skip to content

Commit fff039c

Browse files
committed
fix: fixed chat_templates
1 parent 438ced1 commit fff039c

File tree

6 files changed

+43
-61
lines changed

6 files changed

+43
-61
lines changed

autointent/generation/utterances/evolution/chat_templates/abstract.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ class AbstractEvolution(EvolutionChatTemplate):
2828
),
2929
Message(role=Role.ASSISTANT, content="Please, reserve a table for me."),
3030
Message(
31-
role=Role.ASSISTANT,
31+
role=Role.USER,
3232
content=(
33-
"Intent name: requesting technical support"
33+
"Intent name: requesting technical support\n"
3434
"Utterance: My Lenovo laptop is constantly rebooting and overheating."
3535
),
3636
),

autointent/generation/utterances/evolution/chat_templates/concrete.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ class ConcreteEvolution(EvolutionChatTemplate):
2929
Message(role=Role.ASSISTANT, content="I want to reserve a table for 4 persons at 9 pm."),
3030
Message(
3131
role=Role.USER,
32-
content=("Intent name: requesting technical support\n" "Utterance: I'm having trouble with my laptop."),
32+
content=(
33+
"Intent name: requesting technical support\n"
34+
"Utterance: I'm having trouble with my laptop."
35+
),
3336
),
3437
Message(role=Role.ASSISTANT, content="My laptop is constantly rebooting and overheating."),
3538
]

autointent/generation/utterances/evolution/chat_templates/formal.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,40 +15,34 @@ class FormalEvolution(EvolutionChatTemplate):
1515
Message(
1616
role=Role.USER,
1717
content=(
18-
"{base_instruction}\n"
18+
"I want you to act as a rewriter. "
19+
"You will be provided with an utterance and the topic (name of intent class) of the utterance. "
20+
"You need to rewrite the utterance in a more formal tone using the following method:\n"
1921
"1. Rewrite the utterance in a more formal tone.\n"
2022
"2. Use polite and professional language while maintaining clarity.\n"
2123
"3. The rewritten utterance should be grammatically correct and complete.\n"
2224
"4. Keep the rewritten utterance within 15 words.\n\n"
23-
"Intent Class:\n"
24-
"Reserve Restaurant\n\n"
25-
"Utterance:\n"
26-
"I want to reserve a table for 4 persons at 9 pm."
25+
"Intent name: Reserve Restaurant"
26+
"Utterance: I want to reserve a table for 4 persons at 9 pm."
2727
),
2828
),
2929
Message(role=Role.ASSISTANT, content="I would like to make a reservation for four guests at 9 pm."),
3030
Message(
31-
role=Role.USER,
31+
role=Role.ASSISTANT,
3232
content=(
33-
"Intent Class:\n"
34-
"requesting technical support\n\n"
35-
"Utterance:\n"
36-
"My Lenovo laptop is constantly rebooting and overheating."
33+
"Intent name: requesting technical support\n"
34+
"Utterance: My Lenovo laptop is constantly rebooting and overheating."
3735
),
3836
),
3937
Message(
4038
role=Role.ASSISTANT,
4139
content="My Lenovo laptop frequently restarts and experiences overheating issues. Kindly assist.",
4240
),
43-
Message(
44-
role=Role.USER,
45-
content=("Intent Class:\n" "{intent_name}\n\n" "Utterance:\n" "{utterance}"),
46-
),
4741
]
4842

4943
def __call__(self, utterance: str, intent_data: Intent) -> list[Message]:
5044
"""Generate chat for formal tone adaptation."""
5145
return [
5246
*self._messages,
53-
Message(role=Role.USER, content=f"Intent Class:\n{intent_data.name or ''}\n\nUtterance:\n{utterance}"),
47+
Message(role=Role.USER, content=f"Intent name: {intent_data.name or ''}\nUtterance: {utterance}"),
5448
]

autointent/generation/utterances/evolution/chat_templates/funny.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,32 @@ class FunnyEvolution(EvolutionChatTemplate):
1515
Message(
1616
role=Role.USER,
1717
content=(
18-
"{base_instruction}\n"
18+
"I want you to act as a rewriter. "
19+
"You will be provided with an utterance and the topic (name of intent class) of the utterance. "
20+
"You need to rewrite the utterance in a humorous way while maintaining its original meaning using "
21+
"the following method:\n"
1922
"1. Rewrite the utterance in a humorous way while maintaining its original meaning.\n"
2023
"2. Use wordplay, exaggeration, or lighthearted phrasing.\n"
2124
"3. The rewritten utterance should still be understandable and relevant.\n"
2225
"4. Keep it within 15 words.\n\n"
23-
"Intent Class:\n"
24-
"Reserve Restaurant\n\n"
25-
"Utterance:\n"
26-
"I want to reserve a table for 4 persons at 9 pm."
26+
"Intent name: Reserve Restaurant"
27+
"Utterance: I want to reserve a table for 4 persons at 9 pm."
2728
),
2829
),
2930
Message(role=Role.ASSISTANT, content="Gotta feed my squad at 9 pm. Got a table for us?"),
3031
Message(
3132
role=Role.USER,
3233
content=(
33-
"Intent Class:\n"
34-
"requesting technical support\n\n"
35-
"Utterance:\n"
36-
"My Lenovo laptop is constantly rebooting and overheating."
34+
"Intent name: requesting technical support\n"
35+
"Utterance: My Lenovo laptop is constantly rebooting and overheating."
3736
),
3837
),
3938
Message(role=Role.ASSISTANT, content="My Lenovo thinks it's a phoenix—keeps dying and rising in flames."),
40-
Message(
41-
role=Role.USER,
42-
content=("Intent Class:\n" "{intent_name}\n\n" "Utterance:\n" "{utterance}"),
43-
),
4439
]
4540

4641
def __call__(self, utterance: str, intent_data: Intent) -> list[Message]:
4742
"""Generate chat for humorous tone adaptation."""
4843
return [
4944
*self._messages,
50-
Message(role=Role.USER, content=f"Intent Class:\n{intent_data.name or ''}\n\nUtterance:\n{utterance}"),
45+
Message(role=Role.USER, content=f"Intent name: {intent_data.name or ''}\nUtterance: {utterance}"),
5146
]

autointent/generation/utterances/evolution/chat_templates/goofy.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,35 @@ class GoofyEvolution(EvolutionChatTemplate):
1515
Message(
1616
role=Role.USER,
1717
content=(
18-
"{base_instruction}\n"
18+
"I want you to act as a rewriter. "
19+
"You will be provided with an utterance and the topic (name of intent class) of the utterance. "
20+
"You need to rewrite the utterance in a silly, exaggerated, or nonsensical way while keeping "
21+
"the intent clear using the following method:\n"
1922
"1. Rewrite the utterance in a silly, exaggerated, or nonsensical way while keeping the intent clear.\n"
2023
"2. Use playful words, randomness, or exaggeration.\n"
2124
"3. The rewritten utterance should still be answerable.\n"
2225
"4. Keep it under 15 words.\n\n"
23-
"Intent Class:\n"
24-
"Reserve Restaurant\n\n"
25-
"Utterance:\n"
26-
"I want to reserve a table for 4 persons at 9 pm."
26+
"Intent name: Reserve Restaurant"
27+
"Utterance: I want to reserve a table for 4 persons at 9 pm."
2728
),
2829
),
2930
Message(role=Role.ASSISTANT, content="Need a feast for my hungry goblins at 9. Got room?"),
3031
Message(
3132
role=Role.USER,
3233
content=(
33-
"Intent Class:\n"
34-
"requesting technical support\n\n"
35-
"Utterance:\n"
36-
"My Lenovo laptop is constantly rebooting and overheating."
34+
"Intent name: requesting technical support\n"
35+
"Utterance: My Lenovo laptop is constantly rebooting and overheating."
3736
),
3837
),
3938
Message(
40-
role=Role.ASSISTANT, content="My laptop's having an existential crisis—keeps rebooting and melting. Help!"
41-
),
42-
Message(
43-
role=Role.USER,
44-
content=("Intent Class:\n" "{intent_name}\n\n" "Utterance:\n" "{utterance}"),
39+
role=Role.ASSISTANT,
40+
content="My laptop's having an existential crisis—keeps rebooting and melting. Help!"
4541
),
4642
]
4743

4844
def __call__(self, utterance: str, intent_data: Intent) -> list[Message]:
4945
"""Generate chat for goofy tone adaptation."""
5046
return [
5147
*self._messages,
52-
Message(role=Role.USER, content=f"Intent Class:\n{intent_data.name or ''}\n\nUtterance:\n{utterance}"),
48+
Message(role=Role.USER, content=f"Intent name: {intent_data.name or ''}\nUtterance: {utterance}"),
5349
]

autointent/generation/utterances/evolution/chat_templates/informal.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,31 @@ class InformalEvolution(EvolutionChatTemplate):
1515
Message(
1616
role=Role.USER,
1717
content=(
18-
"{base_instruction}\n"
18+
"I want you to act as a rewriter. "
19+
"You will be provided with an utterance and the topic (name of intent class) of the utterance. "
20+
"You need to rewrite the utterance in a more casual and relaxed tone using the following method:\n"
1921
"1. Rewrite the utterance in a more casual and relaxed tone.\n"
2022
"2. Use contractions, friendly language, and a conversational style.\n"
2123
"3. The rewritten utterance should feel natural in an informal conversation.\n"
2224
"4. Keep it under 15 words.\n\n"
23-
"Intent Class:\n"
24-
"Reserve Restaurant\n\n"
25-
"Utterance:\n"
26-
"I want to reserve a table for 4 persons at 9 pm."
25+
"Intent name: Reserve Restaurant"
26+
"Utterance: I want to reserve a table for 4 persons at 9 pm."
2727
),
2828
),
2929
Message(role=Role.ASSISTANT, content="Hey, can I book a table for 4 at 9?"),
3030
Message(
3131
role=Role.USER,
3232
content=(
33-
"Intent Class:\n"
34-
"requesting technical support\n\n"
35-
"Utterance:\n"
36-
"My Lenovo laptop is constantly rebooting and overheating."
33+
"Intent name: requesting technical support\n"
34+
"Utterance: My Lenovo laptop is constantly rebooting and overheating."
3735
),
3836
),
3937
Message(role=Role.ASSISTANT, content="My Lenovo keeps crashing and getting super hot. Any ideas?"),
40-
Message(
41-
role=Role.USER,
42-
content=("Intent Class:\n" "{intent_name}\n\n" "Utterance:\n" "{utterance}"),
43-
),
4438
]
4539

4640
def __call__(self, utterance: str, intent_data: Intent) -> list[Message]:
4741
"""Generate chat for informal tone adaptation."""
4842
return [
4943
*self._messages,
50-
Message(role=Role.USER, content=f"Intent Class:\n{intent_data.name or ''}\n\nUtterance:\n{utterance}"),
44+
Message(role=Role.USER, content=f"Intent name: {intent_data.name or ''}\nUtterance: {utterance}"),
5145
]

0 commit comments

Comments
 (0)