xjlulu commited on
Commit
a5b6307
1 Parent(s): 9045e66
Files changed (3) hide show
  1. app.py +2 -1
  2. cache/intent/intent2idx.json +148 -148
  3. cache/intent/vocab.pkl +2 -2
app.py CHANGED
@@ -7,6 +7,7 @@ import pickle
7
  from pathlib import Path
8
  from utils import Vocab
9
  from model import SeqClassifier
 
10
 
11
  # Set model parameters
12
  max_len = 128
@@ -57,7 +58,7 @@ best_model.eval()
57
 
58
  # Processing function to convert text to embedding indices
59
  def collate_fn(texts: str) -> torch.tensor:
60
- texts = texts.split()
61
  encoded_texts = vocab.encode_batch([[text for text in texts]], to_len=max_len)[0]
62
  encoded_text = torch.tensor(encoded_texts)
63
  return encoded_text
 
7
  from pathlib import Path
8
  from utils import Vocab
9
  from model import SeqClassifier
10
+ import re
11
 
12
  # Set model parameters
13
  max_len = 128
 
58
 
59
  # Processing function to convert text to embedding indices
60
  def collate_fn(texts: str) -> torch.tensor:
61
+ texts = re.findall(r"\w+|[^\w\s]", texts)
62
  encoded_texts = vocab.encode_batch([[text for text in texts]], to_len=max_len)[0]
63
  encoded_text = torch.tensor(encoded_texts)
64
  return encoded_text
cache/intent/intent2idx.json CHANGED
@@ -1,152 +1,152 @@
1
  {
2
- "last_maintenance": 0,
3
- "car_rental": 1,
4
- "transactions": 2,
5
- "user_name": 3,
6
- "credit_limit": 4,
7
- "date": 5,
8
- "greeting": 6,
9
- "international_fees": 7,
10
- "gas": 8,
11
- "calculator": 9,
12
- "redeem_rewards": 10,
13
- "change_ai_name": 11,
14
- "alarm": 12,
15
- "pin_change": 13,
16
- "update_playlist": 14,
17
- "what_can_i_ask_you": 15,
18
- "translate": 16,
19
- "change_accent": 17,
20
- "text": 18,
21
- "thank_you": 19,
22
- "where_are_you_from": 20,
23
- "goodbye": 21,
24
- "recipe": 22,
25
- "interest_rate": 23,
26
- "ingredients_list": 24,
27
- "tire_pressure": 25,
28
- "definition": 26,
29
- "who_do_you_work_for": 27,
30
- "todo_list": 28,
31
- "improve_credit_score": 29,
32
- "meaning_of_life": 30,
33
- "change_speed": 31,
34
- "exchange_rate": 32,
35
- "next_holiday": 33,
36
- "make_call": 34,
37
- "insurance_change": 35,
38
- "spending_history": 36,
39
- "meal_suggestion": 37,
40
- "fun_fact": 38,
41
- "restaurant_suggestion": 39,
42
- "tire_change": 40,
43
- "calendar_update": 41,
44
- "confirm_reservation": 42,
45
- "next_song": 43,
46
- "are_you_a_bot": 44,
47
- "yes": 45,
48
- "find_phone": 46,
49
- "cancel_reservation": 47,
50
- "what_is_your_name": 48,
51
- "bill_balance": 49,
52
- "direct_deposit": 50,
53
- "flight_status": 51,
54
- "order_status": 52,
55
- "maybe": 53,
56
- "transfer": 54,
57
- "freeze_account": 55,
58
- "cancel": 56,
59
- "shopping_list": 57,
60
- "measurement_conversion": 58,
61
- "jump_start": 59,
62
- "international_visa": 60,
63
- "travel_alert": 61,
64
- "oil_change_when": 62,
65
- "accept_reservations": 63,
66
- "report_lost_card": 64,
67
- "pto_request_status": 65,
68
- "repeat": 66,
69
- "directions": 67,
70
- "payday": 68,
71
- "smart_home": 69,
72
- "damaged_card": 70,
73
- "lost_luggage": 71,
74
- "carry_on": 72,
75
- "insurance": 73,
76
- "what_song": 74,
77
- "current_location": 75,
78
- "ingredient_substitution": 76,
79
- "order": 77,
80
- "todo_list_update": 78,
81
- "reset_settings": 79,
82
- "replacement_card_duration": 80,
83
- "order_checks": 81,
84
- "roll_dice": 82,
85
- "new_card": 83,
86
- "vaccines": 84,
87
- "pto_used": 85,
88
- "time": 86,
89
- "how_old_are_you": 87,
90
- "account_blocked": 88,
91
  "card_declined": 89,
92
- "who_made_you": 90,
93
- "shopping_list_update": 91,
94
- "rewards_balance": 92,
95
- "restaurant_reviews": 93,
96
- "change_user_name": 94,
97
- "spelling": 95,
98
- "nutrition_info": 96,
99
- "restaurant_reservation": 97,
100
- "timer": 98,
101
- "cook_time": 99,
102
- "whisper_mode": 100,
103
- "travel_notification": 101,
104
- "routing": 102,
105
- "book_hotel": 103,
106
- "apr": 104,
107
- "w2": 105,
108
- "gas_type": 106,
109
- "schedule_meeting": 107,
110
- "meeting_schedule": 108,
111
- "reminder": 109,
112
- "income": 110,
113
- "plug_type": 111,
114
- "what_are_your_hobbies": 112,
115
- "schedule_maintenance": 113,
116
- "report_fraud": 114,
117
- "food_last": 115,
118
- "traffic": 116,
119
- "no": 117,
120
- "reminder_update": 118,
121
- "book_flight": 119,
122
- "mpg": 120,
123
- "pto_balance": 121,
124
- "tell_joke": 122,
125
  "calories": 123,
126
- "balance": 124,
127
- "rollover_401k": 125,
128
- "weather": 126,
129
- "change_language": 127,
130
- "distance": 128,
131
- "play_music": 129,
132
- "min_payment": 130,
133
- "sync_device": 131,
134
- "pay_bill": 132,
135
- "taxes": 133,
136
- "share_location": 134,
137
- "bill_due": 135,
138
- "pto_request": 136,
139
- "calendar": 137,
140
- "uber": 138,
141
- "do_you_have_pets": 139,
142
- "change_volume": 140,
143
- "timezone": 141,
144
- "application_status": 142,
145
- "flip_coin": 143,
146
- "credit_score": 144,
147
- "oil_change_how": 145,
148
- "expiration_date": 146,
149
- "credit_limit_change": 147,
150
- "how_busy": 148,
151
- "travel_suggestion": 149
152
  }
 
1
  {
2
+ "do_you_have_pets": 0,
3
+ "confirm_reservation": 1,
4
+ "new_card": 2,
5
+ "lost_luggage": 3,
6
+ "bill_due": 4,
7
+ "calendar": 5,
8
+ "text": 6,
9
+ "date": 7,
10
+ "insurance_change": 8,
11
+ "user_name": 9,
12
+ "min_payment": 10,
13
+ "reminder_update": 11,
14
+ "pto_request": 12,
15
+ "cancel": 13,
16
+ "change_speed": 14,
17
+ "change_accent": 15,
18
+ "cancel_reservation": 16,
19
+ "gas_type": 17,
20
+ "goodbye": 18,
21
+ "accept_reservations": 19,
22
+ "uber": 20,
23
+ "apr": 21,
24
+ "repeat": 22,
25
+ "directions": 23,
26
+ "tell_joke": 24,
27
+ "car_rental": 25,
28
+ "make_call": 26,
29
+ "taxes": 27,
30
+ "gas": 28,
31
+ "carry_on": 29,
32
+ "improve_credit_score": 30,
33
+ "what_song": 31,
34
+ "pto_used": 32,
35
+ "rewards_balance": 33,
36
+ "roll_dice": 34,
37
+ "weather": 35,
38
+ "flight_status": 36,
39
+ "spelling": 37,
40
+ "calculator": 38,
41
+ "rollover_401k": 39,
42
+ "what_can_i_ask_you": 40,
43
+ "report_fraud": 41,
44
+ "update_playlist": 42,
45
+ "travel_suggestion": 43,
46
+ "tire_change": 44,
47
+ "international_fees": 45,
48
+ "transactions": 46,
49
+ "change_ai_name": 47,
50
+ "order_status": 48,
51
+ "restaurant_reservation": 49,
52
+ "what_is_your_name": 50,
53
+ "measurement_conversion": 51,
54
+ "fun_fact": 52,
55
+ "tire_pressure": 53,
56
+ "todo_list_update": 54,
57
+ "order": 55,
58
+ "report_lost_card": 56,
59
+ "time": 57,
60
+ "travel_alert": 58,
61
+ "pay_bill": 59,
62
+ "todo_list": 60,
63
+ "pin_change": 61,
64
+ "thank_you": 62,
65
+ "change_language": 63,
66
+ "who_made_you": 64,
67
+ "shopping_list": 65,
68
+ "ingredients_list": 66,
69
+ "international_visa": 67,
70
+ "interest_rate": 68,
71
+ "book_hotel": 69,
72
+ "nutrition_info": 70,
73
+ "schedule_meeting": 71,
74
+ "are_you_a_bot": 72,
75
+ "payday": 73,
76
+ "insurance": 74,
77
+ "application_status": 75,
78
+ "restaurant_reviews": 76,
79
+ "what_are_your_hobbies": 77,
80
+ "whisper_mode": 78,
81
+ "w2": 79,
82
+ "pto_balance": 80,
83
+ "maybe": 81,
84
+ "exchange_rate": 82,
85
+ "account_blocked": 83,
86
+ "sync_device": 84,
87
+ "where_are_you_from": 85,
88
+ "income": 86,
89
+ "plug_type": 87,
90
+ "current_location": 88,
91
  "card_declined": 89,
92
+ "no": 90,
93
+ "reminder": 91,
94
+ "freeze_account": 92,
95
+ "timezone": 93,
96
+ "jump_start": 94,
97
+ "book_flight": 95,
98
+ "meaning_of_life": 96,
99
+ "play_music": 97,
100
+ "spending_history": 98,
101
+ "routing": 99,
102
+ "yes": 100,
103
+ "change_volume": 101,
104
+ "timer": 102,
105
+ "next_song": 103,
106
+ "expiration_date": 104,
107
+ "bill_balance": 105,
108
+ "restaurant_suggestion": 106,
109
+ "mpg": 107,
110
+ "greeting": 108,
111
+ "vaccines": 109,
112
+ "credit_limit": 110,
113
+ "find_phone": 111,
114
+ "shopping_list_update": 112,
115
+ "change_user_name": 113,
116
+ "credit_limit_change": 114,
117
+ "share_location": 115,
118
+ "distance": 116,
119
+ "how_old_are_you": 117,
120
+ "reset_settings": 118,
121
+ "direct_deposit": 119,
122
+ "transfer": 120,
123
+ "travel_notification": 121,
124
+ "redeem_rewards": 122,
125
  "calories": 123,
126
+ "recipe": 124,
127
+ "who_do_you_work_for": 125,
128
+ "pto_request_status": 126,
129
+ "last_maintenance": 127,
130
+ "translate": 128,
131
+ "alarm": 129,
132
+ "damaged_card": 130,
133
+ "meal_suggestion": 131,
134
+ "order_checks": 132,
135
+ "definition": 133,
136
+ "meeting_schedule": 134,
137
+ "balance": 135,
138
+ "how_busy": 136,
139
+ "schedule_maintenance": 137,
140
+ "credit_score": 138,
141
+ "oil_change_how": 139,
142
+ "replacement_card_duration": 140,
143
+ "flip_coin": 141,
144
+ "food_last": 142,
145
+ "oil_change_when": 143,
146
+ "ingredient_substitution": 144,
147
+ "calendar_update": 145,
148
+ "cook_time": 146,
149
+ "next_holiday": 147,
150
+ "traffic": 148,
151
+ "smart_home": 149
152
  }
cache/intent/vocab.pkl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:9d4fa520420cf60655dd67114826cef0f8be23bc7ca07cdb3c072f2a400e242b
3
- size 78973
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c98fcf18cd7d789236b4f28803c90bb00f8ecd3a0b13eb647bdb14a6d173fdb3
3
+ size 68005