Skip to content

Commit f8a7564

Browse files
committed
feat: update evolution class
1 parent ebed7de commit f8a7564

File tree

6 files changed

+146
-30
lines changed

6 files changed

+146
-30
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
- role: user
2+
content: |
3+
{base_instruction}
4+
1. Rewrite the utterance in a more formal tone.
5+
2. Use polite and professional language while maintaining clarity.
6+
3. The rewritten utterance should be grammatically correct and complete.
7+
4. Keep the rewritten utterance within 15 words.
8+
9+
Intent Class:
10+
Reserve Restaurant
11+
12+
Utterance:
13+
I want to reserve a table for 4 persons at 9 pm.
14+
- role: assistant
15+
content: |
16+
I would like to make a reservation for four guests at 9 pm.
17+
- role: user
18+
content: |
19+
Intent Class:
20+
requesting technical support
21+
22+
Utterance:
23+
My Lenovo laptop is constantly rebooting and overheating.
24+
- role: assistant
25+
content: |
26+
My Lenovo laptop frequently restarts and experiences overheating issues. Kindly assist.
27+
- role: user
28+
content: |
29+
Intent Class:
30+
{intent_name}
31+
32+
Utterance:
33+
{utterance}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
- role: user
2+
content: |
3+
{base_instruction}
4+
1. Rewrite the utterance in a humorous way while maintaining its original meaning.
5+
2. Use wordplay, exaggeration, or lighthearted phrasing.
6+
3. The rewritten utterance should still be understandable and relevant.
7+
4. Keep it within 15 words.
8+
9+
Intent Class:
10+
Reserve Restaurant
11+
12+
Utterance:
13+
I want to reserve a table for 4 persons at 9 pm.
14+
- role: assistant
15+
content: |
16+
Gotta feed my squad at 9 pm. Got a table for us?
17+
- role: user
18+
content: |
19+
Intent Class:
20+
requesting technical support
21+
22+
Utterance:
23+
My Lenovo laptop is constantly rebooting and overheating.
24+
- role: assistant
25+
content: |
26+
My Lenovo thinks it's a phoenix—keeps dying and rising in flames.
27+
- role: user
28+
content: |
29+
Intent Class:
30+
{intent_name}
31+
32+
Utterance:
33+
{utterance}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
- role: user
2+
content: |
3+
{base_instruction}
4+
1. Rewrite the utterance in a silly, exaggerated, or nonsensical way while keeping the intent clear.
5+
2. Use playful words, randomness, or exaggeration.
6+
3. The rewritten utterance should still be answerable.
7+
4. Keep it under 15 words.
8+
9+
Intent Class:
10+
Reserve Restaurant
11+
12+
Utterance:
13+
I want to reserve a table for 4 persons at 9 pm.
14+
- role: assistant
15+
content: |
16+
Need a feast for my hungry goblins at 9. Got room?
17+
- role: user
18+
content: |
19+
Intent Class:
20+
requesting technical support
21+
22+
Utterance:
23+
My Lenovo laptop is constantly rebooting and overheating.
24+
- role: assistant
25+
content: |
26+
My laptop's having an existential crisis—keeps rebooting and melting. Help!
27+
- role: user
28+
content: |
29+
Intent Class:
30+
{intent_name}
31+
32+
Utterance:
33+
{utterance}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
- role: user
2+
content: |
3+
{base_instruction}
4+
1. Rewrite the utterance in a more casual and relaxed tone.
5+
2. Use contractions, friendly language, and a conversational style.
6+
3. The rewritten utterance should feel natural in an informal conversation.
7+
4. Keep it under 15 words.
8+
9+
Intent Class:
10+
Reserve Restaurant
11+
12+
Utterance:
13+
I want to reserve a table for 4 persons at 9 pm.
14+
- role: assistant
15+
content: |
16+
Hey, can I book a table for 4 at 9?
17+
- role: user
18+
content: |
19+
Intent Class:
20+
requesting technical support
21+
22+
Utterance:
23+
My Lenovo laptop is constantly rebooting and overheating.
24+
- role: assistant
25+
content: |
26+
My Lenovo keeps crashing and getting super hot. Any ideas?
27+
- role: user
28+
content: |
29+
Intent Class:
30+
{intent_name}
31+
32+
Utterance:
33+
{utterance}

autointent/generation/utterances/evolution/cli.py

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
"""CLI for evolutionary augmenter."""
22

33
from argparse import ArgumentParser
4-
from typing import TYPE_CHECKING
4+
from typing import get_args
55

66
from autointent import load_dataset
77
from autointent.generation.utterances.evolution.evolver import UtteranceEvolver
88
from autointent.generation.utterances.generator import Generator
99

10-
if TYPE_CHECKING:
11-
from .evolver import EvolutionType
10+
from .evolver import EvolutionType
11+
12+
EVOLUTION_TYPES: list[EvolutionType] = list(get_args(EvolutionType))
1213

1314

1415
def main() -> None:
@@ -34,32 +35,13 @@ def main() -> None:
3435
)
3536
parser.add_argument("--private", action="store_true", help="Publish privately if --output-repo option is used")
3637
parser.add_argument("--n-evolutions", type=int, default=1, help="Number of utterances to generate for each intent")
37-
parser.add_argument("--reasoning", action="store_true", help="Whether to use `Reasoning` evolution")
38-
parser.add_argument("--concretizing", action="store_true", help="Whether to use `Concretizing` evolution")
39-
parser.add_argument("--abstract", action="store_true", help="Whether to use `Abstract` evolution")
40-
parser.add_argument("--formal", action="store_true", help="Whether to use `Formal` evolution")
41-
parser.add_argument("--informal", action="store_true", help="Whether to use `Informal` evolution")
42-
parser.add_argument("--funny", action="store_true", help="Whether to use `Funny` evolution")
43-
parser.add_argument("--goofy", action="store_true", help="Whether to use `Goofy` evolution")
4438
parser.add_argument("--seed", type=int, default=0)
39+
parser.add_argument(
40+
"--evolutions", nargs="+", choices=EVOLUTION_TYPES, required=True, help="Evolution types to apply."
41+
)
4542
args = parser.parse_args()
4643

47-
evolutions: list[EvolutionType] = []
48-
if args.reasoning:
49-
evolutions.append("reasoning")
50-
if args.concretizing:
51-
evolutions.append("concretizing")
52-
if args.abstract:
53-
evolutions.append("abstract")
54-
if args.formal:
55-
evolutions.append("formal")
56-
if args.informal:
57-
evolutions.append("informal")
58-
if args.funny:
59-
evolutions.append("funny")
60-
if args.goofy:
61-
evolutions.append("goofy")
62-
44+
evolutions: list[EvolutionType] = args.evolutions
6345
dataset = load_dataset(args.input_path)
6446

6547
generator = UtteranceEvolver(Generator(), evolutions, args.seed)

autointent/generation/utterances/evolution/evolver.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,12 @@ def augment(
8383

8484
def _load_prompts() -> dict[str, str]:
8585
files = ires.files("autointent.generation.utterances.evolution.chat_templates")
86-
8786
res = {}
88-
for file_name in ["reasoning.yaml", "concretizing.yaml", "abstract.yaml", "base_instruction.txt"]:
89-
with files.joinpath(file_name).open() as file:
90-
res[file_name.split(".")[0]] = file.read()
87+
88+
for file_path in files.iterdir():
89+
if (file_path.suffix == ".yaml" and file_path.is_file()) or (file_path.name == "base_instruction.txt"):
90+
key = file_path.stem
91+
with file_path.open() as file:
92+
res[key] = file.read()
9193

9294
return res

0 commit comments

Comments
 (0)