Let us create a dictionary called transitions and name its initial state as start:
#1: transitions is a .
Add transitions to conduct a single-turn dialogue:
#3: the system begins the dialogue by saying, "Hello. How are you?".
#4: the system matches the user input with 'good'.
All keys and values must be in the type, where literals need to be surrounded by reversed primes (e.g., '`Hello. How are you?`').
There are two ways to create a string in Python, using single quotes (e.g., 'Hello') and double quotes (e.g., "Hello"). When you use single quotes, any single quote inside the string needs to be escaped by a backslash (e.g., 'I\'m "good"!'). Similarly, when you use double quotes, any double quote needs to be escaped (e.g., "I'm \"good\"!").
Create the dialogue flow df that expects the initial state start and the final state end, which must match the names of the initial and final states in transitions:
#1: the import statement should be on top of the source code (see ).
#2:
Load the transitions to the dialogue flow df:
Finally, run the dialogue flow:
#1:
Enter inputs such as "good", "Good", or "Good!" (separately) and see how the system responds. Does the system respond differently?
How does the system respond to inputs like "fantastic" or "bad"?
Branching
Let us add a transition such that it can also handle the input 'bad':
#7-9: a new transition for the 'bad' condition.
When you load the new transitions and run the dialogue flow, it now gives proper responses to both 'good' and 'bad':
Error Handling
Even with branching, it still throws errors for other inputs. Let us add an error transition to set the default statement for all the other inputs:
#10-12: an error transition to generate the default response.
Make sure to put a default error statement for every branching; otherwise, it will throw an exception during runtime, which can be detrimental.
Code Snippet
#3: although Python is a dynamically-typed language, it allows you to indicate the type of a variable or a function using (since Python 3.5).
2.5. Quiz
Quiz 2: Dialogue Graph
Overview
You run a hair salon and recently adopted a dialogue system to take a call from a customer and book a service for the customer:
Your salon provides three services: haircut, hair coloring, and perms. Your system should reject any other service request from the customer:
Your system should understand the following dates:
. The time is always followed by the date with the following format:
<number><space><AM|PM>
:
Only the following times and dates are available for the specific services:
Haircut:
Monday 10 AM, 1 PM, 2 PM
Tuesday: 2 PM
Hair coloring:
Wednesday: 10 AM, 11 AM, 1 PM
Thursday: 10 AM, 11 AM
Perms
Friday: 10 AM, 11 AM, 1 PM, 2 PM
Saturday: 10 AM, 2 PM
Thus, your system should not schedule an appointment for any other slots:
Make sure your system does not throw an exception in any situation.
Task 1
Create a python file quiz2.py under the quiz package and copy the code.
Update the transitions to design a dialogue flow for the above dialogue system.
Task 2
Create a PDF file quiz2.pdf that describes the limitations of your system.
Submission
Commit and push quiz2.py to your GitHub repository.
Submit quiz2.pdf to Canvas.
transitions = {
'state': 'start',
'`Hello. How are you?`': {
'good': {
'`Glad to hear that you are doing well :)`': 'end'
}
}
}
from emora_stdm import DialogueFlow
df = DialogueFlow('start', end_state='end')
df.load_transitions(transitions)
if __name__ == '__main__':
df.run()
transitions = {
'state': 'start',
'`Hello. How are you?`': {
'good': {
'`Glad to hear that you are doing well :)`': 'end'
},
'bad': {
'`I hope your day gets better soon :(`': 'end'
}
}
}
S: Hello. How are you?
U: Good
S: Glad to hear that you are doing well :)
S: Hello. How are you?
U: Bad
S: I hope your day gets better soon :(
transitions = {
'state': 'start',
'`Hello. How are you?`': {
'good': {
'`Glad to hear that you are doing well :)`': 'end'
},
'bad': {
'`I hope your day gets better soon :(`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
}
}
}
S: Hello. How are you?
U: It could be better.
S: Sorry, I didn't understand you.
from emora_stdm import DialogueFlow
def state_transition() -> DialogueFlow:
transitions = {
'state': 'start',
'`Hello. How are you?`': {
'good': {
'`Glad to hear that you are doing well :)`': 'end'
},
'bad': {
'`I hope your day gets better soon :(`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
}
}
}
df = DialogueFlow('start', end_state='end')
df.load_transitions(transitions)
return df
if __name__ == '__main__':
state_transition().run()
S: Hello, how can I help you?
U: Hi, I'd like to book a haircut.
S: Sure. What date and time are you looking for?
U: Tuesday at 2 PM.
S: Your appointment is set. See you!
S: Hello, how can I help you?
U: Can I make an appointment for waxing?
S: Sorry, we do not provide that service.
U: OK then.
S: Goodbye.
S: Hello, how can I help you?
U: Can I make an appointment for a perm?
S: Sure. What date and time are you looking for?
U: Saturday 10 AM.
S: Your appointment is set. See you!
S: Hello, how can I help you?
U: Hi, I'd like to book a haircut.
S: Sure. What date and time are you looking for?
U: Saturday 10 AM.
S: Sorry, that slot is not available for a haircut.
U: OK.
S: Goodbye.
2.4. Multi-turn Dialogue
Create a multi-turn dialogue flow.
All examples in the previous session are single-turn dialogues, where users get to interact with the system only once. Let us design a multi-turn dialogue:
#5: after the system says "Glad to ...", it matches the input with those conditions.
#6: if the condition in #5 is true, the system responds with "I feel superb ...".
The condition in #6 does not come with the default action indicated by an error transition. Let us create an error transition for it:
#10: prompts the error statement for any other inputs.
3. Contextual Understanding
This chapter explains how to improve contextual understanding using Natex.
Besides #ONT for checking an ontology, STDM provides several macros useful for dialogue design.
#LEM
The following example shows a use case of the macro #LEM that uses the to match lemmas of "raining tacos":
#5: maches the input with the lemma of "rain" or "rainy", then the lemma of "taco".
#UNX
The #UNX macro can be used as an alternative to the 'error' transition, which prepends a short acknowledgment phrase (e.g., "yeah", "sure") to the error statement:
#8: prepends an acknowledgment phrase to the error statement, "Thanks for sharing" in #8.
#3,5: add acknowledgment phrases given the user inputs.
#7: does not add an acknowledgment phrase when the user input is short.
When the user input contains fewer than three tokens, #UNK does not add any acknowledgment.
Seldomly, #UNKgets selected even when conditions in other transitions match the input (due to an STDM bug). If you notice this during testing, assign a very slow to the #UNK state to ensure it gets the lowest priority among other branches.
#SET & #IF
Let us update the above transitions so that it sometimes refuses to sing the same song:
#6: can be picked if the variable $RAINING_TACOS equals to the string 'True'.
#7: sets $RAINING_TACOS to 'True' after prompting the system output.
Once $RAINING_TACOS is set to 'True', STDM randomly picks a statement in #6 or #7 as the system output.
Notice that the #SET macro only assigns a string value to the variable. It is possible to write a macro to set any variable to an actual boolean value (e.g., True, False):
#3-4: checks if there are two arguments.
#6-8: retrieves the variable name.
#10-12
Given MacroSetBool, the above transitions can be updated as follow:
#6: is selected if $RAINING_TACOS is True.
#0: sets the variable $RAINING_TACOS to the boolean value True.
Currently, STDM randomly chooses the statements in #6 and #7 once $RAINING_TACOS becomes True. We can write another macro that prompts #7 only for the first time:
#3: the method in returns the value corresponding to the key, RAINING_TACOS if exists; otherwise, False.
Given MacroPlayRainingTacos, the transitions can be updated as follow:
#7: is selected if the macro #PLAY_RAINING_TACOS returns True.
#17: adds #PLAY_RAINING_TACOS to the macro dictionary.
Music
It is possible to make our system actually sings instead of prompting the lyric. Let us first install the package:
Then, import the package and update the MacroPlayRainingTacos macro to play the MP3 file, :
#1: imports the VLC package.
#6: creates a VLC media player and plays the specified MP3 file.
When you run the above dialogue flow, it now plays the MP3 file and prompts the lyric.
Time
The transitions in prompt the same time (3PM) upon every request. Let us create a new macro that checks the current (system) time:
#1: imports the package.
#5: retrieves the current time in the specified format using the method.
#6
The macro MacroTime can be called to generate the system output:
#11: calls the TIME macro to generate the system output displaying the current time.
#22: adds #TIME to the macro dictionary.
Weather
The transitions in prompt the same weather (sunny) upon every request. Let us retrieve the latitude and the longitude of the system using :
Then, use a web API provided by the to retrieve the grid correlates to the coordinate:
Look for the forecast field under properties:
Write a macro that retrieves the current weather for the grid using another web API:
#1: imports the package.
#2: imports the package.
#6
Finally, update the transitions with the weather macro:
#15: calls the WEATHER macro to generate the system output displaying today's weather.
#22: adds #WEATHER to the macro dictionary.
The time and the weather retrieved by the above macros are oriented to the system, not the user. It is possible to anticipate the users' location if one's IP address is provided; however, this is not possible unless the user uses a specific device (e.g., Amazon Echo, smartphone) and agrees to send one's private information to our system.
: checks if the argument is a proper boolean value.
#14: stores the boolean value to the variable.
: returns the current time using the
method.
: specifies the forecast URL.
#7: retrieves the content from the URL in JSON.
#8: saves the JSON content to a dictionary.
#9: retrieves forecasts for all supported periods.
#10: retrieves the forecast for today.
#11: returns today's forecast.
S: What can I do for you?
U: Play raining tacos
S: It's raining tacos. From out of the sky ... What can I do for you?
U: Play raining taco
S: It's raining tacos. From out of the sky ... What can I do for you?
U: Play rain taco
S: It's raining tacos. From out of the sky ... What can I do for you?
U: Play rainy taco
S: It's raining tacos. From out of the sky ... What can I do for you?
U: Bye
S: Sorry, I didn't understand you.
Mathematics and Science Center at Emory University (400 Dowman Dr, Atlanta, GA, 30322)
transitions = {
'state': 'start',
'`What can I do for you?`': {
'[play, [!{#LEM(rain), rainy}, #LEM(taco)]]': {
'state': 'play_raining_tacos',
'`It\'s raining tacos. From out of the sky ...`': 'start'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
},
}
}
transitions = {
'state': 'start',
'`What can I do for you?`': {
'[play, [!{#LEM(rain), rainy}, #LEM(taco)]]': {
'state': 'play_raining_tacos',
'`It\'s raining tacos. From out of the sky ...`': 'start'
},
'#UNX': {
'`Thanks for sharing.`': 'end'
},
}
}
S: What can I do for you?
U: My name is Jinho
S: Right. Thanks for sharing. What can I do for you?
U: I am a professor
S: Yeah. Thanks for sharing. What can I do for you?
U: Hello world
S: Thanks for sharing. What can I do for you?
U: Play raining tacos
S: It's raining tacos. From out of the sky ...
transitions = {
'state': 'start',
'`What can I do for you?`': {
'[play, [!{#LEM(rain), rainy}, #LEM(taco)]]': {
'state': 'play_raining_tacos',
'#IF($RAINING_TACOS=True) `Don\'t make me sing this again!`': 'start',
'`It\'s raining tacos. From out of the sky ...` #SET($RAINING_TACOS=True)': 'start',
},
'#UNX': {
'`Thanks for sharing.`': 'start'
},
}
}
S: What can I do for you?
U: Play raining tacos
S: It's raining tacos. From out of the sky ... What can I do for you?
U: Play raining tacos
S: Don't make me sing this again! What can I do for you?
...
class MacroSetBool(Macro):
def run(self, ngrams: Ngrams, vars: Dict[str, Any], args: List[str]):
if len(args) != 2:
return False
variable = args[0]
if variable[0] == '$':
variable = variable[1:]
boolean = args[1].lower()
if boolean not in {'true', 'false'}:
return False
vars[variable] = bool(boolean)
return True
transitions = {
'state': 'start',
'`What can I do for you?`': {
'[play, [!{#LEM(rain), rainy}, #LEM(taco)]]': {
'state': 'play_raining_tacos',
'#IF($RAINING_TACOS) `Don\'t make me sing this again!`': 'start',
'`It\'s raining tacos. From out of the sky ...` #SETBOOL(RAINING_TACOS, True)': 'start',
},
'#UNX': {
'`Thanks for sharing.`': 'start'
},
}
}
macros = {
'SETBOOL': MacroSetBool()
}
class MacroPlayRainingTacos(Macro):
def run(self, ngrams: Ngrams, vars: Dict[str, Any], args: List[str]):
return not vars.get('RAINING_TACOS', False)
transitions = {
'state': 'start',
'`What can I do for you?`': {
'[play, [!{#LEM(rain), rainy}, #LEM(taco)]]': {
'state': 'play_raining_tacos',
'#IF($RAINING_TACOS) `Don\'t make me sing this again!`': 'start',
'#IF(#PLAY_RAINING_TACOS) `It\'s raining tacos. From out of the sky ...` #SETBOOL(RAINING_TACOS, True)': 'start',
},
'#UNX': {
'`Thanks for sharing.`': 'start'
},
}
}
macros = {
'SETBOOL': MacroSetBool(),
'PLAY_RAINING_TACOS': MacroPlayRainingTacos()
}
df = DialogueFlow('start', end_state='end')
df.load_transitions(transitions)
df.add_macros(macros)
df.run()
S: What can I do for you?
U: Play raining tacos
S: It's raining tacos. From out of the sky ... What can I do for you?
U: Play raining tacos
S: Don't make me sing this again! What can I do for you?
U: Play raining tacos
S: Don't make me sing this again! What can I do for you?
...
pip install python-vlc
import vlc
class MacroPlayRainingTacos(Macro):
def run(self, ngrams: Ngrams, vars: Dict[str, Any], args: List[str]):
if not vars.get('RAINING_TACOS', False):
vlc.MediaPlayer("resources/raining_tacos.mp3").play()
return True
return False
import time
class MacroTime(Macro):
def run(self, ngrams: Ngrams, vars: Dict[str, Any], args: List[str]):
current_time = time.strftime("%H:%M")
return "It's currently {}.".format(current_time)
transitions = {
'state': 'start',
'`What can I do for you?`': {
'[play, [!{#LEM(rain), rainy}, #LEM(taco)]]': {
'state': 'play_raining_tacos',
'#IF($RAINING_TACOS) `Don\'t make me sing this again!`': 'start',
'#IF(#PLAY_RAINING_TACOS) `It\'s raining tacos. From out of the sky ...` #SETBOOL(RAINING_TACOS, True)': 'start',
},
'[{time, clock}]': {
'state': 'time',
'#TIME': 'end'
},
'#UNX': {
'`Thanks for sharing.`': 'start'
},
}
}
macros = {
'SETBOOL': MacroSetBool(),
'PLAY_RAINING_TACOS': MacroPlayRainingTacos(),
'TIME': MacroTime()
}
S: What can I do for you?
U: What time is it now?
S: It's currently 05:27.
import json
import requests
class MacroWeather(Macro):
def run(self, ngrams: Ngrams, vars: Dict[str, Any], args: List[Any]):
url = 'https://api.weather.gov/gridpoints/FFC/52,88/forecast'
r = requests.get(url)
d = json.loads(r.text)
periods = d['properties']['periods']
today = periods[0]
return today['detailedForecast']
transitions = {
'state': 'start',
'`What can I do for you?`': {
'[play, [!{#LEM(rain), rainy}, #LEM(taco)]]': {
'state': 'play_raining_tacos',
'#IF($RAINING_TACOS) `Don\'t make me sing this again!`': 'start',
'#IF(#PLAY_RAINING_TACOS) `It\'s raining tacos. From out of the sky ...` #SETBOOL(RAINING_TACOS, True)': 'start',
},
'[{time, clock}]': {
'state': 'time',
'#TIME': 'end'
},
'[{weather, forecast}]': {
'state': 'weather',
'#WEATHER': 'end'
},
'#UNX': {
'`Thanks for sharing.`': 'start'
},
}
}
macros = {
'SETBOOL': MacroSetBool(),
'PLAY_RAINING_TACOS': MacroPlayRainingTacos(),
'TIME': MacroTime(),
'WEATHER': MacroWeather()
}
S: What can I do for you?
U: How is the weather today?
S: A chance of rain showers. Cloudy, with a high near 68. South wind 0 to 5 mph. Chance of precipitation is 30%.
English Premier League Chatbot: Guide to the World’s Most Exciting Football League (Team 1)
: Cholyeon Cho, Hasong Cho, Changhyun Kim, Melinda Zhang
: proposal (slides, comments: 7), final (slides, comments: 8)
SpeakEasy (Team 2)
: Max Bagga, Yella Diekmann, Harry Jeon, Victoria Ploerer, Rhea Ramachandran
: (, : 18), (, , : 33)
KINDRED: Be the kindness you want to see (Team 3)
: Microl Chen, Steve Li, Eugene Lim, Abbey Yuan
: (, : 11), (, , : 16)
Becca: Your Personal Stylist (Team 4)
: Rebecca Gerber, Cole Katz, Amya Moore, Yousef Rajeh, Andy Sun
: (, : 10), (, : 5)
LEANNA: A Startup Business Model Chatbot (Team 5)
: Yifei Gao, Yijun Liu, James Song, Jessie Wang, Eric Xue
: (, : 17), (, , : 11)
LorelAI: A Music Recommendation Chatbot (Team 6)
: Hazel Cho, Claire Fenton, Safia Read, Christopher Roebuck, Dani Royburg
: (, : 24), (, : 16)
The proposal should be 6 - 8 pages, including figures and tables (excluding references). Your proposal must include the following:
Write an abstract summarizing your proposal.
What is the team vision of your dialogue system? What makes your system interesting and important? Is a dialogue system the best practice to pursue your vision?
Who is your primary target audience? If your target audience is narrow, what is your strategy to engage the general audience in your system?
Describe a high-level dialogue flow of your system. Additionally, provide sample dialogues that you expect your system to conduct.
Describe your scientific approach in detail. What techniques and/or datasets will you use, and how do you plan to integrate them into your system?
How will you evaluate your system? Be specific about what aspects you plan to assess and how you will conduct such evaluation in terms of metrics and demographics.
What is novel about your system? Survey similar existing systems and compare them to show the uniqueness of your system.
Provide a weekly timeline specifying which members will work on which parts.
Submissions
Submit your presentation slides and the report in PDF to Canvas.
Artificial Intelligence (AI) has advanced to the point that it starts interacting with humans in natural language. This communication ability makes AI an integral part of human society as a collaborator and companion. Thus, it is essential to understand how AI can (and should) be designed to conduct meaningful conversations with humans. The main objectives of this course are:
To discover technical approaches to dialogue systems.
To conceive manifold use cases of dialogue systems.
To study effective ways of Human-Computer Interaction.
To develop a dialogue system using methods in Computational Linguistics.
To comprehend the limitations of your dialogue system through Statistical Analysis.
Students will have individual assignments and work in groups to build end-to-end dialogue systems of their choice. Toward the end of the semester, all teams will present the dialogue systems with live demonstrations.
LINC Course
For Spring 2023, this is selected as a course. Thus, it will include collaborative work with students taking .
0.2. Quiz
Quiz 0: Getting Started
Task
1. Create a package called under the conversational-ai directory.
1.2. Project Ideas
Discuss project ideas in groups.
Before Discussion
Prepare your ideas about the questions in .
1.1. Overview
Explain components, properties, scopes, techniques, and assessments of dialogue systems.
Components
Genre
1.3. Quiz
Quiz 1: Exploration
Task 1
Create a PDF file quiz1.pdf that includes your ideas about the following questions:
2.1. Emora STDM
Introduce Emora State Transition Dialogue Manager.
Emora State Transition Dialogue Manager (STDM) is a dialogue system development framework that seamlessly integrates intent classification, pattern recognition, state machine, and information state approaches to dialogue management and natural language understanding. It supports rapid prototyping and long-term team-based development workflows, catering to a wide range of developer expertise.
Make sure you have the emora_stdm package installed from the .
3.2. Ontology
How to use ontologies for matching in Natex.
Ontology
Let us create a dialogue flow to talk about animals:
3.4. Regular Expression
How to use regular expressions for matching in Natex.
Regular expressions provide powerful ways to match strings and beyond:
, Chapter 2.1, Speech and Language Processing (3rd ed.), Jurafsky and Martin.
, Python Documentation
4.1. State Referencing
Start State
Let us create transitions for a virtual agent that handles time, weather, and playing music:
#5: shows the current time (although it is correct only twice a day at the moment).
4.3. Compound States
Multiple Topics
A dialogue flow can be complex when you start adding multiple topics. In this case, you can create a separate transition dictionary for each topic.
Let us create transitions talking about music and movies:
5.1. Language Models
Statistical
, Jurafsky and Martin, Chapter 3 in Speech and Language Processing (3rd ed.), 2023.
5.4. Quiz
Revisit your and improve its language understanding capability using the large language model such as GPT.
Use to figure out the right prompts.
Use your trial credits from OpenAI to test the APIs.
5.3. Information Extraction
Consider that you want to extract someone's call name(s) during a dialogue in real time:
Design a prompt that extracts all call names provided by the user.
In "My friends call me Pete, my students call me Dr. Parker, and my parents call me Peter.", how does the speaker want to be called? Respond in the following JSON format: {"call_names": ["Mike", "Michael"]}
Let us write a function that takes the user input and returns the GPT output in the JSON format:
5.2. Quickstart with GPT
API Key
Create an account for and log in to your account.
Click your icon on the top-right corner and select "View API keys":
Click the "+ Create new secret key" button and copy the API key:
6.1. H2H vs. H2M
Overview
What is a conversational analysis, and why is it important?
Conversational Analysis is the study of how people communicate in everyday interactions.
6.3. Quiz
Task
Your task is to evaluate your team chatbot given the following instructions:
This is an individual assignment. Each member must evaluate the team chatbot separately.
Final Report Guidelines
Presentation
The presentation should include only the proposed project, not the LINC movie discussion:
Every team is expected to give a 12 mins presentation.
Syllabus
Spring 2023
General
Book:
0. Getting Started
This chapter helps you set up the development environment for this course.
Content
2.3. Matching Strategy
A taste of matching strategies provided in Emora STDM.
Multiple Matching
There is more than one way of expressing "good" or "bad". Let us use a to match multiple expressions per condition by surrounding them with curly brackets:
3.5. Macro
How to use macro functions for matching in Natex.
The most powerful aspect of Natex is its ability to integrate pattern matching with arbitrary code. This allows you to integrate regular expressions, NLP models, or custom algorithms into Natex.
Creation
A macro can be defined by creating a class inheriting the Macro in STDM and the run method:
3.1. Natex
Several matching strategies built in Natex.
Emora STDM supports several ways for interpreting the contexts of user inputs through Natex (Natural Langauge Expression), some of which you already experienced in .
Literal
A literal is what you intend the system to say. A literal is represented by reversed primes (`..`):
3.5. Quiz
Quiz 3: Contextual Understanding
Overview
Your goal is to create a chatbot that talks about movies. Here is a sample dialogue:
Your chatbot aims to collect user information by asking the following:
4.4. Global Transition
Exercise
Draw a diagram describing the following dialogue flow.
4.6. Quiz
Overview
You aim to create a chatbot that makes a movie or a song recommendation. Your system should conduct dialogue including the following aspects:
Greet with respect to the current time and/or weather.
4.5. Saving and Loading
Saving
Let us create a simple transition that counts how many times the user visits:
#4: calls the macro #VISITS
6.2. Team Evaluation
Criteria
Effective
Page 1
Give me 10 unique ways of me asking to make an appointment with professors for general purposes. Write as I would speak to the professor's secretary. Use "Prof.", "Dr.", or "Professor" to indicate professors.
Hi there, could you please help me schedule a meeting with Prof. Smith?
LINC Course
Spring 2023
IDS 385W - Translation: Who, What, How
This seminar examines the realities of translation in multiple settings and contexts. Translation is embedded into our everyday lives, central to newsfeeds, religious texts, politics, Netflix and literature. Often, however, the phenomenon is unremarked, rendered invisible. Yet embedded within it are decisions with cultural, ethical and political ramifications. This course aims to make visible the people, issues and products involved: translators, subtitlers and interpreters; theories, strategies and methodologies; and the written and visual texts they produce. To that end, we will examine the history of translation via the Bible; study current issues in the field; and read work by several translators. Topics to include: translation and gender; bible translation; translation and race; LGBTQ issues in translation; subtitling; translators as social and political actors. Readings span fiction, memoir, theory, methodology, history, and journalism. Classes are discussion and workshop based and include numerous translation activities: comparing multiple versions of the same work, imitation pieces, translating genre and style, editing, and Oulipo activities. The course is taught in English, with no foreign language proficiency required.
What kind of a dialogue system do you want to develop for your team project?
Who will benefit from your dialogue system in what way?
What is the novelty of your dialogue system?
What are the expected challenges in developing your dialogue system?
How do you plan to evaluate your dialogue system?
Provide your ideas in detail, about 100 words (or more) per question.
Task 2
Group a team of 3-4 members for your project.
Submission
Submit quiz1.pdfto Canvas.
Go to [People → Team Projects] in Canvas and assign your team members to the same group.
You need to evaluate at least 5 categories (e.g., team evaluation). Give a clear description of each category. You are welcome to discuss them with your team; however, your description must be original.
Create a static form to evaluate your chatbot. Your form should include a metric (e.g., Likert scale of 1 - 3) to evaluate each category and ask for reasons for the assessment.
Find a group of 10 people suitable to interact with your chatbot. Each interactor will evaluate your chatbot after one or more conversations using the static form.
Submission
Submit quiz6.pdf summarizing your evaluation results, including:
Your evaluation categories and their descriptions.
Quantitative analysis of your chatbot using the metric.
Qualitative analysis of your chatbot using assessment reasoning.
Based on the analyses, potential improvements can (or should) be made.
Your presentation must include key contents from each section in the report (see below).
Report
The proposal writing must be created in LaTex using this template.
The report should be 8 - 10 pages, including figures and tables (excluding references). Your proposal must include the following:
Abstract: Summarize the report, including the motivation, approach, and results.
Vision: Explain what this project aims to accomplish and why that is beneficial to society.
Challenges: Describe the main challenges of your project. Describe how your vision, approach, evaluation, etc. may have changed due to the challenges.
Dialogue Flow: Describe the overall dialogue flow of your system. Additionally, provide sample dialogues that your system can conduct.
Methodology: Illustrate specific methods used in your chatbot (other than the ones built-in STDM), including external APIs, datasets, macros, etc.
Evaluation: Describe the demographics and statistics of the users who participated in assessing your chatbot. Explain in detail how you evaluate your chatbot.
Novelty: Point out the main novelty of your chatbot against competitors. Survey on related systems similar to yours.
Contributions: Depict the contribution of each team member throughout the course of the project and estimate the percentages of individual contributions so that they sum up to 100%.
Submissions
Submit your presentation slides and the report in PDF to Canvas.
Create a python file quiz5.py under the quiz package and copy the code.
Update the code to design a dialogue flow for the assigned dialogue system.
Create a PDF file quiz5.pdf that describes the approach (e.g., prompt engineering) and how the large language model improved over the limitations you described in Quiz 2.
Task 2
Answer the following questions in quiz5.py:
What are the limitations of the Bag-of-Words representation?
Describe the Chain Rule and Markov Assumption and how they are used to estimate the probability of a word sequence.
Explain how the Word2Vec approach uses feed-forward neural networks to generate word embeddings. What are the advantages of the Word2Vec representation over the Bag-of-Words representation?
Explain what patterns are learned in the multi-head attentions of a Transformer. What are the advantages of the Transformer embeddings over the Word2Vec embeddings?
The degree to which the chatbot is able to achieve its intended goals and produce desirable outcomes for users.
Whether the advice provided helps the user feel more confident in their conversational abilities.
How well it provides mental health support to individuals with varying levels of stress.
Whether the user found the previous interaction helpful.
Whether the chatbot was able to successfully complete her goal with the help of the chatbot.
The user's rating of how much the chatbot helped them in their career path.
How users feel about its ability to prepare them for real interviews.
Satisfactory
The degree to which the chatbot meets users' expectations and provides a satisfactory experience.
Whether the insights, questions, and communication are well-balanced and whether the users feel comfortable with the ideal proportion.
How comfortable the user felt during the conversation.
Whether it understood the user's needs and provided personalization based on their style and preferences.
Whether the user felt a bit better after the interaction.
The pleasantness of the system persona and whether it meets users' expectations.
Correctness
The degree to which the chatbot provides accurate and correct information or recommendations to users.
How accurately it identifies the presence of stress and changes response style accordingly.
Whether the bot's suggestions were relevant to the user's personal taste, style, and preferences, and whether the user would wear everything suggested by the bot.
The accuracy of its performance metrics, such as the accuracy of style recommendations.
Whether it is successful in making accurate recommendations for the user.
The quality and specificity of the feedback users received from the system, and whether the feedback provided accurate and correct information.
Interpretability
The degree to which the chatbot's responses and actions can be understood and interpreted by users.
Whether users can understand what the chatbot is saying.
Whether users experience instances of missed messages, misunderstandings, or abrupt exits, and whether the chatbot's responses can be interpreted clearly by users.
Its ability to understand the context of users' inquiries and provide relevant responses that can be understood and interpreted by users.
Whether the chatbot can assess the user's level of knowledge and adjust its responses accordingly, whether it uses language that the user can understand, and whether the user feels engaged with the chatbot's insights.
Coherent
The degree to which the chatbot's responses and actions are logically consistent and connected with each other, and with the context of the conversation.
Whether it can recognize the topics mentioned by the user and provide relevant information that is logically connected with those topics.
Whether its responses are self-explanatory and related to each other in a logical and coherent manner.
Its level of consistency with actual interviews, i.e., whether its responses are logically consistent with the expectations and norms of real-life interviews.
Whether its suggestions are relevant and helpful for the given topic, and whether they are logically consistent with the context of the conversation.
Natural
The degree to which the chatbot's responses and actions resemble those of a human being, and are perceived as natural, fluent, and realistic by users.
How closely its responses resemble those of a human being, i.e., whether they are naturalistic in terms of language, syntax, grammar, tone, and other linguistic aspects.
Ethical
The degree to which the chatbot's responses and actions adhere to ethical principles and standards, and avoid causing harm or offense to users or other stakeholders.
Whether it contains any content or responses that are offensive or inappropriate, such as hate speech, discrimination, or harassment.
Empathetic
The degree to understand and respond to the emotions and feelings of users in a compassionate and sensitive manner, and to provide emotional support or encouragement when appropriate.
Whether it demonstrates an understanding of the user's emotions and concerns, and responds in a way that is supportive and validating.
Using appropriate language and tone, acknowledging the user's perspective, and offering words of encouragement or empathy.
Informative
The degree to provide accurate and useful information to users in response to their queries or requests for assistance.
Its ability to provide factual information about fitness, such as exercise techniques, workout routines, or nutrition advice.
Assessing the accuracy and relevance of the information provided, as well as the chatbot's ability to understand and respond appropriately to the user's specific needs and goals.
Engaging
The degree to capture and hold the user's attention, as well as to create a positive and enjoyable user experience.
The user's level of interest and involvement during the conversation.
Assessing the chatbot's ability to generate interesting and relevant topics of conversation, to respond in a timely and personalized manner, and to use engaging language and visual elements to create a more immersive and interactive experience.
Personalization
The degree to tailor its responses and recommendations to the individual user's preferences, needs, and past interactions.
Evaluate the chatbot's ability to personalize advice based on the user's preferences and past interactions.
Whether the chatbot can effectively use data about the user, such as their history, feedback, and stated preferences, to provide personalized responses and recommendations. The following example illustrates this concept:
Evaluation Criteria, Team Projects, Spring 2023
The latest movie that the user watched (#3-4).
A contextualized question regarding the latest movie (#5-6).
A question regarding the genre of the latest movie (#7-10).
Your chatbot should give an appropriate response to every user response. For this assignment, you must use all of the following:
An ontology covering common movie genres and a branch of movies that you target,
Update them to design a dialogue flow for the chatbot.
Task 2
Create a PDF file quiz3.pdf that describes the following:
Sample dialogues that your chatbot can conduct.
Explanations of how the ontology, macro(s), and regular expression(s) are used for contextual understanding in your chatbot.
Submission
Commit and push quiz3.py to your GitHub repository.
Submit quiz3.pdf to Canvas.
For each type of animal, however, the list can be indefinitely long (e.g., there are over 5,400 mammal species). In this case, it is better to use an ontology (e.g., WordNet, FrameNet).
Let us create a JSON file, ontology_animal.json, containing an ontology of animals:
#2: the key ontology is paired with a dictionary as a value.
#3: the key animal represents the category, and its subcategories are indicated in the list.
#4-6: each subcategory, mammal, reptile, and amphibian, has its own subcategory.
#7: the ontology hierarchy: animal -> mammal -> dog.
Given the ontology, the above transitions can be rewritten as follow:
#4: matches the key "mammal" as well as its subcategories: "dog", "ape", and "rat".
#5: matches the key "reptile" as well as its subcategories: "snake" and "lizard".
#6: matches the key "amphibian" as well as its subcategories: "frog" and "salamander".
Unlike set matching, ontology matching handles plurals (e.g., "frogs").
Although there is no condition specified for the category dog that includes "golden retriever", there is a condition for its supercategory mammal (#4), to which it backs off.
Currently, ontology matching does not handle plurals for compound nouns (e.g., "golden retrievers"), which will be fixed in the following version.
Expression
It is possible that a category is mentioned in a non-canonical way; the above conditions do not match "puppy" because it is not introduced as a category in the ontology. In this case, we can specify the aliases as "expressions":
#10: the key expressions is paired with a dictionary as a value.
#4: allows matching "canine" and "puppy" for the dog category.
Once you load the updated JSON file, it now understands "puppy" as an expression of "dog":
It is possible to match "puppy" by adding the term as a category of "dog" (#7). However, it would not be a good practice as "puppy" should not be considered a subcategory of "dog".
Variable
Values matched by the ontology can also be stored in variables:
#4,7,10: the matched term gets stored in the variable FAVORITE_ANIMAL.
#5,8,11: the system uses the value of FAVORITE_ANIMAL to generate the response.
Loading
The custom ontology must be loaded to the knowledge base of the dialogue flow before it runs:
#1: loads the ontology in ontology_animal.json to the knowledge base of df.
#14: print the error message and references to the start state.
Notice that when the user input does not match any of the conditions, it prints the error message and loops back to the start state.
Custom States
It is possible to name any transition you create as a state:
#6: names the state as time.
#9: names the state as weather.
#13: names the state as play_raining_tacos.
#17: references to the play_raining_tacos state.
Exit State
State referencing can be abused to create transitions that never end (infinite loop). It is important to design an exit state so you can terminate the conversation without throwing errors:
#6,10,14,17: loops back to the start state.
#19-21: creates an exit state to terminate the dialogue.
What is the main difference between an error transition and an exit state?
An error transition defines a default action for uninterpretable user input, whereas an exit state terminates the current session of the dialogue.
#4
: matches the input with either
'good'
or
'fantastic'
.
#7: matches the input with either 'bad' or 'could be better'.
The above transitions can handle the following inputs (on top of the cases of good and bad):
A phrase can be used for matching, although it needs to match the entire input such that 'could be better' in #7 does not match an input like "It could be better".
Enter inputs such as "I'm good" or "Pretty bad" and see how the system responds.
It responds with the error statement because the string key (e.g., 'good', 'bad') does not match the entire input (e.g., "I'm good", "Pretty bad").
If you replace 'bad' in #7 with 'pretty bad', it matches the input "Pretty bad". However, it no longer matches the input "bad".
Currently, STDM does not allow you to insert a single quote (') in any condition such that if you replace 'good' in #4 with 'I\'m good', it will throw a runtime error. This bug will be fixed in the next version.
Partial Matching
Matching the entire input is often too restrictive. Let us use a list to allow partial matching:
#4: the keyword 'good' is surrounded by the square brackets (good -> [good]), and matched to any word in the input.
#7: the keyphrase 'could be better' is surrounded by the square brackets, and matched to any phrase in the input.
What are the differences between a set and a list in general data structures?
The above transitions yield the following dialogues:
Replace the condition in #4 with '[good, fantastic]'. Does it respond as expected?
All terms in a list must match some terms in the input sequentially. Thus, by replacing '[good]' with '[good, fantastic]', it no longer understands the inputs "good" or "fantastic":
Instead, it understands the input "good and fantastic" by matching "good" first, then "fantastic" later:
To allow partial matching of multiple expressions, a set can be put in a list:
#4: the keywords 'good' and 'fantastic' are first put in a set for multiple matching and then in a list for partial matching.
#7: the keyword 'bad' and the keyphrase 'could be better' are first put in a set for multiple matching, then in a list for partial matching.
What are the meanings of nesting a set inside a list vs. a list inside a set?
What happens if '[{good, fantastic}]' in #4 is replaced with '{[good, fantastic]}'; in other words, put the keywords in a list first, then in a set?
It behaves the same way as the one in Exercise 2.
Sequential Matching
Keywords or keyphrases delimited by commas in a list are matched sequentially:
#10: first matches 'how', then matches 'you' sequentially so that "how" must be followed by "you" in the input for this condition to be true.
All terms in the list must be matched sequentially such that the conditions are false for the following cases:
Let us replace 'how' with '{how, and}' and 'you' with '{you, going}' in #10:
#10: first matches ('how' or 'and'), then matches ('you' or 'going') sequentially.
What other inputs does the condition in #10 match? Is there any consequence of matching that many expressions?
How does the system respond when the input is "Good, how are you"?
Since both the conditions in #5 and #11 match the input, it randomly chooses one of the responses such that it can nondeterministically generate either of the followings:
#2: imports type hints from the typing package in Python.
#4: creates the MacroGetName class inheriting Macro.
#5: overrides the run method declared in Macro.
Currently, the run method returns True no matter what the input is.
Integration
Let us create transitions using this macro. A macro is represented by an alias preceded by the pound sign (#):
#4: calls the macro #GET_NAME that is an alias of MacroGetName.
#13: creates a dictionary defining aliases for macros.
#14: creates an object of MacroGetName and saves it to the alias GET_NAME.
To call the macro, we need to add the alias dictionary macros to the dialogue flow:
#3: adds all macros defined in macros to the dialogue flow df.
Parameters
The run method has three parameters:
ngrams: is a set of strings representing every n-gram of the input matched by the Natex.
vars: is the variable dictionary, maintained by a DialogueFlow object, where the keys and values are variable names and objects corresponding to their values.
args: is a list of strings representing arguments specified in the macro call.
Let us modify the run method to see what ngrams and vars give:
#2: prints the original string of the matched input span before preprocessing.
#3: prints the input span, preprocessed by STDM and matched by the Natex.
#4: prints a set of n-grams.
When you interact with the the dialogue flow by running it (df.run()), it prints the followings:
The raw_text method returns the original input:
The text method returns the preprocessed input used to match the Natex:
The ngrams gives a set of all possible n-grams in text():
Finally, the vars gives a dictionary consisting of both system-level and user-custom variables (no user-custom variables are saved at the moment):
Implementation
Let us update the run method that matches the title, first name, and last name in the input and saves them to the variables $TITLE, $FIRSTNAME, and $LASTNAME, respectively:
#2: creates a regular expression to match the title, first name and last name.
#3: searches for the span to match.
#4: returns False if no match is found.
#6-18 -> exercise.
#20-22: saves the recognized title, first name, and last name to the corresponding variables.
#24: returns True as the regular expression matches the input span.
Given the updated macro, the above transitions can be modified as follow:
#5: uses the variables $FIRSTNAME and $LASTNAME retrieved by the macro to generate the output.
The followings show outputs:
Although the last name is not recognized, and thus, it leaves a blank in the output, it is still considered "matched" because run() returns True for this case. Such output can be handled better by using the language generation capability in Natex.
#3: the system prompts the literal and ends the dialogue.
S: Hello. How are you?
Matching
Natex supports several ways of matching the input with key terms.
Term
The condition is true if the input exactly matches the term. A term is represented as a string and can have more than one token:
#4: matches the input with 'could be better'.
#7: error is a reserved term indicating the default condition of this conditional branching, similar to the wildcard condition (_) in a match statement.
Set
The condition is true if the input exactly matches any term in the set. A set is represented by curly brackets ({}):
#7: matches the input with either 'good' or 'not bad'.
Unordered List
The condition is true if some terms in the input match all terms in the unordered list, regardless of the order. An unordered list is represented by angle brackets (<>):
#10: matches the input with both 'very' and 'good' in any order.
Ordered List
The condition is true if some terms in the input match all terms in the ordered list, a.k.a. sequence, in the same order. An ordered list is represented by square brackets ([]):
#13: matches the input with both 'so' and 'good' in that order.
Currently, it matches the input "could be better" with the condition in #4, but does not match "it could be better" or "could be better for sure", where there are terms other than the ones indicated in the condition.
Update the condition such that it matches all three inputs.
How about matching inputs such as "could be much better" or "could be really better"?
'[could be better]'
'[could be, better]'
Rigid Sequence
The condition is true if all terms in the input exactly match all terms in the rigid sequence in the same order. A rigid sequence is represented by square brackets ([ ]), where the left bracket is followed by an exclamation mark (!):
#16: matches the input with both 'hello' and 'world' in that order.
There is no difference between matching a term (e.g., 'hello world') and matching a rigid sequence (e.g., '[!hello, world]'). The rigid sequence is designed specifically for negation, which will be deprecated in the next version.
Negation
The condition is true if all terms in the input exactly match all terms in the rigid sequence except for ones that are negated. A negation is represented by a hyphen (-):
#19: matches the input with 'aweful' and zero to many terms prior to it that are not 'not'.
Nesting
It is possible to nest conditions for more advanced matching. Let us create a term condition that matches both "so good" and "very good" using a nested set:
#4: uses a set inside a term.
Does this condition match "good"?
No, because the outer condition uses term matching that requires the whole input to be the same as the condition.
However, it does not match when other terms are included in the input (e.g., "It's so good to be here"). To broaden the matching scope, you can put the condition inside a sequence:
#4: the term condition is inside the sequence.
What if we want the condition to match the above inputs as well as "fantastic"? You can put the condition under a set and add fantastic as another term:
#4: the sequence condition and the new term fantastic is inside the set.
The above transitions match "Fantastic" but not "It's fantastic". Update the condition such that it can match both inputs.
Put fantastic under a sequence such that '{[{so, very} good], [fantastic]}'.
Variable
Saving user content can be useful in many ways. Let us consider the following transitions:
Users may feel more engaged if the system says, "I like dogs too" instead of "them". Natex allows you to create a variable to store the matched term. A variable is represented by a string preceded (without spaces) by a dollar sign $:
#4: creates a variable FAVORITE_ANIMAL storing the matched term from the user content.
#5: uses the value of the variable to generate the follow-up system utterance.
In #5, two literals, `I like` and `too!` surround the variable $FAVORITE_ANIMAL. If a variable were indicated inside a literal, STDM would throw an error.
It is often the case that the user says something out of the topic that the system expects. One way of handling such occasions is by using global transitions that anticipate common cases:
#1-8: creates global transitions.
#10: adds the global transitions to the dialogue flow.
Notice that after prompting an output in the global transitions, it will direct to the good state defined in the regular transitions.
The global transitions are fired whenever the user content matches their conditions, which can cause multiple matching conditions as follow:
#5: matches the condition in the movie state.
#5: matches the condition in the global transition.
Thus, it is recommended to put lower scores on the conditions in global transitions such that local transitions are prioritized over them:
Ask about the user's name (with a different way of asking each time the user logins).
If it is the first time the system sees the name, then prompt the first-time greeting. Otherwise, greet by asking about its previous recommendation.
Recommend a movie or a song, depending on the user's request. Do not make the same recommendation more than once for each genre.
If the user requests a different recommendation, make another suggestion.
Provide more information about the recommendation upon request.
Here is an example dialogue for a user talking to this chatbot for the first time:
Here is an example dialogue for a user coming back for the second time:
Your chatbot should give an appropriate response to every user response.
Task 1
Create a Python file quiz4.py under the quiz package.
Update it to design a dialogue flow for the chatbot.
Task 2
Create a PDF file quiz4.pdf that describes the following:
Sample dialogues that your chatbot can conduct.
Explanations of your approach.
Submission
Commit and push quiz4.py to your GitHub repository.
Submit quiz4.pdf to Canvas.
Good morning, I was hoping to set up a time to speak with Dr. Brown. Could you assist me with that?
Hello, I'm interested in scheduling a general appointment with Professor Green. Would it be possible for you to arrange that for me?
Greetings, I would like to schedule a meeting with Prof. Garcia. Is there a convenient time we could arrange?
Hi, I would appreciate your help setting up a time to meet with Dr. Patel. Could you let me know his availability?
Good day, I would like to request a meeting with Professor Jones for general purposes. Can you assist me in scheduling that?
Hello, I need to speak with Dr. Kim and was hoping to schedule an appointment. Could you please let me know when she is available?
Good morning, I would like to set up a meeting with Prof. Nguyen. Could you please help me arrange that?
Hi, I am interested in speaking with Dr. Lee and was hoping to schedule a time to meet. Could you assist me with that?
Good day, I would like to request a general appointment with Professor Chen. Could you please help me schedule a time to meet with her?
Give me 10 unique ways of me asking to make an appointment with professors regarding coursework. Write as I would speak to the professor's secretary. Use "Prof.", "Dr.", or "Professor" to indicate professors. Add specific times.
Hi there, could I please schedule an appointment with Prof. Johnson to discuss coursework? I'm available next Tuesday from 2-3pm if that works for him.
Hello, may I request an appointment with Dr. Lee to go over some coursework? I'm free on Thursday mornings before 11am, would that be possible?
Good morning, could I schedule a meeting with Professor Green to talk about our coursework? I'm available on Wednesday afternoons after 1pm, is that a good time for her?
Hi, I was wondering if it would be possible to set up a time to meet with Dr. Patel about coursework? I have availability on Monday and Wednesday evenings after 6pm, would either of those work for her?
Hello, I would like to make an appointment with Professor Hernandez to discuss our coursework. I'm free on Friday mornings between 9am and 11am, could we schedule something then?
Good afternoon, could I request a meeting with Dr. Kim to go over some coursework? I have availability on Tuesday afternoons from 3-4pm, would that work for her?
Hi there, I was hoping to schedule a time to talk with Professor Chen about our coursework. I'm available on Thursday evenings after 5pm, would that be a good time for him?
Hello, may I schedule a meeting with Dr. Jones to discuss some coursework? I'm free on Monday mornings before noon, would that work for her?
Good morning, could I please set up an appointment with Professor Nguyen to go over our coursework? I have availability on Wednesday afternoons from 2-3pm, would that be convenient for her?
Hi, I would like to make an appointment with Dr. Smith to discuss some coursework. I'm available on Friday afternoons after 1pm, would that be a good time for him?
Replace all professors with their full names.
Hi there, could I please schedule an appointment with Professor Elizabeth Johnson to discuss coursework? I'm available next Tuesday from 2-3pm if that works for her.
Hello, may I request an appointment with Dr. Amanda Lee to go over some coursework? I'm free on Thursday mornings before 11am, would that be possible?
Good morning, could I schedule a meeting with Professor Emily Green to talk about our coursework? I'm available on Wednesday afternoons after 1pm, is that a good time for her?
Hi, I was wondering if it would be possible to set up a time to meet with Dr. Rahul Patel about coursework? I have availability on Monday and Wednesday evenings after 6pm, would either of those work for her?
Hello, I would like to make an appointment with Professor Sofia Hernandez to discuss our coursework. I'm free on Friday mornings between 9am and 11am, could we schedule something then?
Good afternoon, could I request a meeting with Dr. Ji-Young Kim to go over some coursework? I have availability on Tuesday afternoons from 3-4pm, would that work for her?
Hi there, I was hoping to schedule a time to talk with Professor Yen-Ling Chen about our coursework. I'm available on Thursday evenings after 5pm, would that be a good time for him?
Hello, may I schedule a meeting with Dr. Lauren Jones to discuss some coursework? I'm free on Monday mornings before noon, would that work for her?
Good morning, could I please set up an appointment with Professor Thu-Huong Nguyen to go over our coursework? I have availability on Wednesday afternoons from 2-3pm, would that be convenient for her?
Hi, I would like to make an appointment with Dr. James Smith to discuss some coursework. I'm available on Friday afternoons after 1pm, would that be a good time for him?
Give me 10 unique ways of me asking to make an appointment with professors regarding research. Write as I would speak to the professor's secretary. Use only first names to indicate professors without "Prof.", "Dr.", or "Professor". Add specific times where multiple options are allowed.
Hi there! Could I schedule a meeting with Sarah sometime this week to discuss research? I'm available on Tuesday at 2 pm, Wednesday at 10 am, or Thursday at 3 pm.
Hello! I was wondering if I could set up a time to chat with David about some research I'm working on. Is he available next Monday at 11 am, Wednesday at 1 pm, or Friday at 3 pm?
Good morning! Can I schedule a meeting with Jessica to talk about research opportunities? I'm free on Tuesday at 11 am, Thursday at 2 pm, or Friday at 10 am.
Hey there! Could I arrange a time to meet with John to discuss a research project I'm working on? I'm available on Monday at 1 pm, Wednesday at 3 pm, or Friday at 11 am.
Hi! I would love to schedule a meeting with Lisa to talk about some research ideas I have. Would next Wednesday at 10 am, Thursday at 2 pm, or Friday at 11 am work for her?
Good afternoon! I was hoping to schedule a meeting with Michael to discuss a potential research collaboration. Is he available on Tuesday at 3 pm, Wednesday at 10 am, or Friday at 2 pm?
Hello there! Can I arrange a time to meet with Rachel to discuss research opportunities in her department? I'm free on Monday at 11 am, Wednesday at 1 pm, or Friday at 3 pm.
Hey! Could I schedule a meeting with Sam to talk about a research project I'm working on? I'm available on Tuesday at 2 pm, Thursday at 11 am, or Friday at 10 am.
Hi, I'd like to schedule a meeting with Tom to discuss a research proposal I'm developing. Would next Monday at 2 pm, Wednesday at 10 am, or Thursday at 3 pm work for him?
Good morning! I was hoping to set up a time to meet with Victoria to discuss some research ideas I have. Is she available on Tuesday at 1 pm, Thursday at 3 pm, or Friday at 10 am?
Give me 10 unique ways of me asking to make an appointment with professors regarding specific course issues (e.g., homework, quiz, midterm, final, exam). Write as I would speak to the professor's secretary. Use "Prof.", "Dr.", or "Professor" to indicate professors. Add specific time for the appointment.
Hello, may I schedule a meeting with Prof. Smith to discuss some issues with the upcoming midterm? How about next Tuesday at 3 PM?
Good morning, could I make an appointment with Dr. Johnson to talk about the final exam? Would next Wednesday at 1 PM work for you?
Excuse me, can I schedule a meeting with Professor Brown to go over some questions I had on the last quiz? What about this Thursday at 10 AM?
Hi, I was wondering if I could meet with Prof. Garcia to discuss a specific homework problem. Is there any availability next Friday at 2 PM?
Good afternoon, can I make an appointment with Dr. Kim to talk about some course material I am struggling with? How about next Monday at 11 AM?
Hello, may I schedule a meeting with Professor Patel to discuss an issue with the midterm grades? Would next Wednesday at 4 PM be possible?
Excuse me, I would like to make an appointment with Prof. Jones to review some final exam questions. What about this Friday at 9 AM?
Hi, I was hoping to schedule a meeting with Dr. Davis to discuss some study strategies for the upcoming final exam. Is there any availability next Thursday at 2 PM?
Good morning, can I make an appointment with Professor Lee to discuss some questions I have about the course syllabus? How about next Tuesday at 1 PM?
Hello, I would like to schedule a meeting with Dr. Hernandez to discuss some exam review material. Is there any availability next Monday at 3 PM?
Specify when the homework, quiz, midterm, final, exam was.
Hi, could I schedule a meeting with Prof. Johnson to discuss some issues with the homework we turned in last Friday? How about next Tuesday at 3 PM?
Good morning, I was wondering if I could make an appointment with Dr. Williams to go over some questions I had on the quiz we took last week. Would next Wednesday at 1 PM work for you?
Excuse me, may I schedule a meeting with Professor Brown to talk about the midterm we took two weeks ago? What about this Thursday at 10 AM?
Hi, I would like to make an appointment with Prof. Garcia to discuss a specific problem on the final exam we took last month. Is there any availability next Friday at 2 PM?
Good afternoon, could I make an appointment with Dr. Kim to talk about some course material we covered in class yesterday? How about next Monday at 11 AM?
Hello, I was wondering if I could schedule a meeting with Professor Patel to discuss an issue with the midterm grades that were posted last week. Would next Wednesday at 4 PM be possible?
Excuse me, may I schedule a meeting with Prof. Jones to review some final exam questions that we went over in class last week? What about this Friday at 9 AM?
Hi, I would like to schedule a meeting with Dr. Davis to discuss some study strategies for the upcoming final exam that is in two weeks. Is there any availability next Thursday at 2 PM?
Good morning, could I make an appointment with Professor Lee to discuss some questions I have about the course syllabus and the midterm that we took three weeks ago? How about next Tuesday at 1 PM?
Hello, may I schedule a meeting with Dr. Hernandez to discuss some exam review material that was covered in class yesterday? Is there any availability next Monday at 3 PM?
Give me 10 unique ways of me asking to make an appointment with professors regarding research issues (e.g., progress, deadline, result). Write as I would speak to the professor's secretary. Use "Prof.", "Dr.", or "Professor" to indicate professors.
Hi, may I please schedule a meeting with Prof. Smith to discuss my research progress and set some deadlines?
Good morning, I was hoping to arrange a meeting with Dr. Johnson to review the results of my research project.
Hello, could you help me schedule an appointment with Professor Garcia to discuss some issues related to my research?
Hi, I need to meet with Prof. Lee to discuss the results of my research and get some feedback on next steps. Can you help me schedule a meeting?
Good afternoon, I'd like to schedule a meeting with Dr. Patel to discuss the progress of my research and any areas where I need to improve.
Hello, I'd like to set up a meeting with Professor Kim to discuss my research project and ask for advice on how to proceed.
Hi, could you help me schedule a meeting with Prof. Brown to talk about my research progress and any issues I'm encountering?
Good morning, I need to meet with Dr. Davis to discuss the results of my research and get some guidance on next steps. Can you help me schedule a meeting?
Hello, I'd like to arrange a meeting with Professor Nguyen to discuss my research and get some feedback on how I can improve it.
Hi, may I please schedule a meeting with Prof. Taylor to review the progress of my research and discuss any concerns or questions I have?
Replace all professors with their full names. Indicate another person who also wants to come to this appointment.
Hi there, could I please schedule an appointment with Professor Jane Smith and my research partner, John Doe, to discuss the progress of our research project?
Good morning, I was hoping to schedule a meeting with Dr. Emily Johnson and my lab assistant, Sarah Lee, to talk about the results of our latest experiment.
Hello, I would like to request a meeting with Professor William Brown and my co-author, Karen Chen, to discuss the deadlines for our research paper.
Hi, could you help me schedule a time to meet with Professor Sungsoo Kim and my graduate student, Michael Park, to go over the progress of our thesis?
Good afternoon, I need to speak with Dr. Maya Patel and my research assistant, David Rodriguez, regarding the results of our research study. Could you assist me in scheduling a meeting?
Hello, I was hoping to schedule a meeting with Professor Youngjin Lee and my fellow lab member, Jiyeon Kim, to discuss the next steps for our research project.
Good morning, I need to speak with Dr. Carlos Garcia and my co-researcher, Maria Torres, about our research proposal. Could you please help me schedule a meeting?
Hi, I'd like to request a meeting with Professor Rachel Davis and my research partner, Steven Nguyen, to talk about the progress of our research project and any feedback they may have.
Hello, I would like to schedule a time to meet with Dr. Adam Adams and my co-investigator, Laura Nguyen, to discuss the results of our latest research experiment and any potential implications.
Good afternoon, I need to speak with Professor Lingling Chen and my research collaborator, Wei Zhang, regarding the deadlines for our research paper. Could you please assist me in scheduling a meeting with them?
G: General
C: Coursework
R: Research
CI: Course Issues
RI: Research Issues
1. Is the following about making an appointment? Respond with "yes" or "no". 2. Who does the speaker want to meet? Respond with the name. 3. What are the suggested times? Respond with bullet points 4. What is it about? Save the answer to a JSON format such as {"Q1": "yes", "Q2": [{"first_name": "John", "last_name": "Doe"}], "Q3": ["Monday at 1 pm"], "Q4": "Regarding the deadlines for their research paper."}:
Now is 2023-03-10 12:05. Convert "Tomorrow at 3:30pm" to the absolute date and time. Respond in the following JSON format: {"from": "%Y-%m-%d %H:%M", "to": "%Y-%m-%d %H:%M"}.
"Thursday evenings after 5pm"
"Thursday between 3:30 - 5pm"
S: Hello, may I have your name?
U: Call me Jinho.
S: It's nice to meet you, Jinho. What was the latest movie you watched?
U: That'd be Spider Man No Way Home.
S: I love Marvel movies. Who is your favorite avenger?
U: Captain America.
S: Captain is my man. So I guess you are a big fan of Sci-Fi movies?
U: Yes, I am.
S: Excellent. Why do you like them so much?
U: They make me feel like living in the future.
S: I'm with you. Thanks for sharing.
S: What is your favorite animal?
U: I love frogs
S: Amphibians can be cute :)
S: What is your favorite animal?
U: I love my golden retriever
S: I love mammals!
S: What is your favorite animal?
U: I cannot live without my puppy!
S: I've never heard of that animal.
S: What is your favorite animal?
U: I cannot live without my puppy!
S: I love mammals!
S: What is your favorite animal?
U: I love frogs
S: frogs can be cute :)
S: What is your favorite animal?
U: I can't live without my puppy!
S: I love puppy !
transitions = {
'state': 'start',
'`What is your favorite animal?`': {
'[{dog, ape, rat}]': {
'`I love mammals!`': 'end'
},
'[{snake, lizard}]': {
'`Reptiles are slick, haha`': 'end'
},
'[{frog, salamander}]': {
'`Amphibians can be cute :)`': 'end'
},
'error': {
'`I\'ve never heard of that animal.`': 'end'
}
}
}
S: What is your favorite animal?
U: I love frog
S: Amphibians can be cute :)
S: What is your favorite animal?
U: Cat
S: I've never heard of that animal.
S: What is your favorite animal?
U: Dogs
S: I've never heard of that animal.
def natex_ontology() -> DialogueFlow:
transitions = {
'state': 'start',
'`What is your favorite animal?`': {
'[$FAVORITE_ANIMAL=#ONT(mammal)]': {
'`I love` $FAVORITE_ANIMAL `!`': 'end'
},
'[$FAVORITE_ANIMAL=#ONT(reptile)]': {
'$FAVORITE_ANIMAL `are slick, haha`': 'end'
},
'[$FAVORITE_ANIMAL=#ONT(amphibian)]': {
'$FAVORITE_ANIMAL `can be cute :)`': 'end'
},
'error': {
'`I\'ve never heard of that animal.`': 'end'
}
}
}
df = DialogueFlow('start', end_state='end')
df.knowledge_base().load_json_file('resources/ontology_animal.json')
df.load_transitions(transitions)
return df
if __name__ == '__main__':
natex_ontology().run()
S: What can I do for you?
U: What time is it now?
S: It's 3PM.
S: What can I do for you?
U: What's the weather like?
S: It's sunny outside
S: What can I do for you?
U: Play rainy taco
S: Sorry, I didn't understand you. What can I do for you?
U: Play raining tacos
S: It's raining tacos. From out of the sky ...
S: What can I do for you?
U: Play rainy taco
S: Sorry, I didn't understand you. It's raining tacos. From out of the sky ...
S: What can I do for you?
U: time
S: It's 3PM. What can I do for you?
U: weather
S: It's sunny outside What can I do for you?
U: play raining tacos
S: It's raining tacos. From out of the sky ... What can I do for you?
U: exit
S: Goodbye!
transitions = {
'state': 'start',
'`What can I do for you?`': {
'[{time, clock}]': {
'`It\'s 3PM.`': 'end'
},
'[{weather, forecast}]': {
'`It\'s sunny outside`': 'end'
},
'[play, raining tacos]': {
'`It\'s raining tacos. From out of the sky ...`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'start'
}
}
}
transitions = {
'state': 'start',
'`What can I do for you?`': {
'[{time, clock}]': {
'state': 'time',
'`It\'s 3PM.`': 'end'
},
'[{weather, forecast}]': {
'state': 'weather',
'`It\'s sunny outside`': 'end'
},
'[play, raining tacos]': {
'state': 'play_raining_tacos',
'`It\'s raining tacos. From out of the sky ...`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'play_raining_tacos'
}
}
}
transitions = {
'state': 'start',
'`What can I do for you?`': {
'[{time, clock}]': {
'state': 'time',
'`It\'s 3PM.`': 'start'
},
'[{weather, forecast}]': {
'state': 'weather',
'`It\'s sunny outside`': 'start'
},
'[play, raining tacos]': {
'state': 'play_raining_tacos',
'`It\'s raining tacos. From out of the sky ...`': 'start'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'start'
},
'[exit]': {
'state': 'exit',
'`Goodbye!`': 'end'
}
}
}
S: Hello. How are you?
U: Fantastic!!
S: Glad to hear that you are doing well :)
S: Hello. How are you?
U: Could be better..
S: I hope your day gets better soon :(
S: Hello. How are you?
U: I'm good!!
S: Glad to hear that you are doing well :)
S: Hello. How are you?
U: It could be better..
S: I hope your day gets better soon :(
S: Hello. How are you?
U: good
S: Sorry, I didn't understand you.
S: Hello. How are you?
U: fantastic
S: Sorry, I didn't understand you.
S: Hello. How are you?
U: good and fantastic!
S: Glad to hear that you are doing well :)
S: Hello. How are you?
U: I'm so good!
S: Glad to hear that you are doing well :)
S: Hello. How are you?
U: It's fantastic!!
S: Glad to hear that you are doing well :)
S: Hello. How are you?
U: Pretty bad..
S: I hope your day gets better soon :(
S: Hello. How are you?
U: It could be better.
S: I hope your day gets better soon :(
S: Hello. How are you?
U: Fine. How are you doing?
S: I feel superb. Thank you!
S: Hello. How are you?
U: Fine. How is it going?
S: Sorry, I didn't understand you.
S: Hello. How are you?
U: Fine, and you?
S: Sorry, I didn't understand you.
S: Hello. How are you?
U: Fine. How is it going?
S: I feel superb. Thank you!
S: Hello. How are you?
U: Fine, and you?
S: I feel superb. Thank you!
S: Hello. How are you?
U: Good, how are you?
S: Glad to hear that you are doing well :)
S: Hello. How are you?
U: Good, how are you?
S: I feel superb. Thank you!
transitions = {
'state': 'start',
'`Hello. How are you?`': {
'{good, fantastic}': {
'`Glad to hear that you are doing well :)`': 'end'
},
'{bad, could be better}': {
'`I hope your day gets better soon :(`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
}
}
}
transitions = {
'state': 'start',
'`Hello. How are you?`': {
'[good]': {
'`Glad to hear that you are doing well :)`': 'end'
},
'[could be better]': {
'`I hope your day gets better soon :(`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
},
}
}
transitions = {
'state': 'start',
'`Hello. How are you?`': {
'[{good, fantastic}]': {
'`Glad to hear that you are doing well :)`': 'end'
},
'[{bad, could be better}]': {
'`I hope your day gets better soon :(`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
},
}
}
transitions = {
'state': 'start',
'`Hello. How are you?`': {
'[{good, fantastic}]': {
'`Glad to hear that you are doing well :)`': 'end'
},
'[{bad, could be better}]': {
'`I hope your day gets better soon :(`': 'end'
},
'[how, you]': {
'`I feel superb. Thank you!`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
},
}
}
transitions = {
'state': 'start',
'`Hello. How are you?`': {
'[{good, fantastic}]': {
'`Glad to hear that you are doing well :)`': 'end'
},
'[{bad, could be better}]': {
'`I hope your day gets better soon :(`': 'end'
},
'[{how, and}, {you, going}]': {
'`I feel superb. Thank you!`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
},
}
}
def matching_strategy() -> DialogueFlow:
transitions = {
'state': 'start',
'`Hello. How are you?`': {
'[{good, fantastic}]': {
'`Glad to hear that you are doing well :)`': 'end'
},
'[{bad, could be better}]': {
'`I hope your day gets better soon :(`': 'end'
},
'[{how, and}, {you, going}]': {
'`I feel superb. Thank you!`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
},
}
}
df = DialogueFlow('start', end_state='end')
df.load_transitions(transitions)
return df
if __name__ == '__main__':
matching_strategy().run()
S: Hello. What should I call you?
U: Dr. Jinho Choi
S: It's nice to meet you.
S: Hello. What should I call you?
U: Dr. Jinho Choi
S: It's nice to meet you, jinho . choi is my favorite name.
S: Hello. What should I call you?
U: Jinho Choi
S: It's nice to meet you, jinho . choi is my favorite name.
S: Hello. What should I call you?
U: Dr. Choi
S: It's nice to meet you, dr choi . choi is my favorite name.
S: Hello. What should I call you?
U: Jinho
S: It's nice to meet you, jinho . is my favorite name.
from emora_stdm import Macro, Ngrams
from typing import Dict, Any, List
class MacroGetName(Macro):
def run(self, ngrams: Ngrams, vars: Dict[str, Any], args: List[Any]):
return True
transitions = {
'state': 'start',
'`Hello. What should I call you?`': {
'#GET_NAME': {
'`It\'s nice to meet you.`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
}
}
}
macros = {
'GET_NAME': MacroGetName()
}
{
'__state__': '0',
'__system_state__': 'start',
'__stack__': [],
'__user_utterance__': 'dr jinho choi',
'__goal_return_state__': 'None',
'__selected_response__': 'Hello. What should I call you?',
'__raw_user_utterance__': 'Dr. Jinho Choi',
'__converged__': 'True'
}
def run(self, ngrams: Ngrams, vars: Dict[str, Any], args: List[Any]):
r = re.compile(r"(mr|mrs|ms|dr)?(?:^|\s)([a-z']+)(?:\s([a-z']+))?")
m = r.search(ngrams.text())
if m is None: return False
title, firstname, lastname = None, None, None
if m.group(1):
title = m.group(1)
if m.group(3):
firstname = m.group(2)
lastname = m.group(3)
else:
firstname = m.group()
lastname = m.group(2)
else:
firstname = m.group(2)
lastname = m.group(3)
vars['TITLE'] = title
vars['FIRSTNAME'] = firstname
vars['LASTNAME'] = lastname
return True
transitions = {
'state': 'start',
'`Hello. What should I call you?`': {
'#GET_NAME': {
'`It\'s nice to meet you,` $FIRSTNAME `.` $LASTNAME `is my favorite name.`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
}
}
}?
S: Hello. How are you?
U: Could be better..
S: I hope your day gets better soon :(
S: Hello. How are you?
U: It could be better
S: Sorry, I didn't understand you.
S: Hello. How are you?
U: Good!!
S: Glad to hear that you are doing well :)
S: Hello. How are you?
U: Not bad..
S: Glad to hear that you are doing well :)
S: Hello. How are you?
U: I'm good
S: Sorry, I didn't understand you.
S: Hello. How are you?
U: Not so bad
S: Sorry, I didn't understand you.
S: Hello. How are you?
U: Very good!
S: So glad that you are having a great day!
S: Hello. How are you?
U: I'm very well and good
S: So glad that you are having a great day!
S: Hello. How are you?
U: Good, things are going very well!
S: So glad that you are having a great day!
S: Hello. How are you?
U: Good
S: Glad to hear that you are doing well :)
S: Hello. How are you?
U: So good!
S: Things are just getting better for you!
S: Hello. How are you?
U: It's so wonderfully good!
S: Things are just getting better for you!
S: Hello. How are you?
U: It's good
S: Sorry, I didn't understand you.
S: Hello. How are you?
U: It's good so far
S: Sorry, I didn't understand you.
S: Hello. How are you?
U: Hello World
S: You're a programmer!
S: Hello. How are you?
U: hello world to you
S: Sorry, I didn't understand you.
S: Hello. How are you?
U: It's hello world
S: Sorry, I didn't understand you.
S: Hello. How are you?
U: Aweful!
S: Sorry to hear that :(
S: Hello. How are you?
U: It's so aweful..
S: Sorry to hear that :(
S: Hello. How are you?
U: Not aweful
S: Sorry, I didn't understand you.
S: Hello. How are you?
U: Not so aweful
S: Sorry to hear that :(
S: Hello. How are you?
U: Aweful and terrible
S: Sorry, I didn't understand you.
S: Hello. How are you?
U: I'm very good, thank you!
S: Things are just getting better for you!
S: Hello. How are you?
U: It's so good to be here :)
S: Things are just getting better for you!
S: Hello. How are you?
U: Fantastic!!!
S: Things are just getting better for you!
S: Hello. How are you?
U: Good
S: Sorry, I didn't understand you.
S: Hello. How are you?
U: It's fantastic
S: Sorry, I didn't understand you.
S: What is your favorite animal?
U: I like dogs
S: I like them too!
S: What is your favorite animal?
U: I like dogs!!
S: I like dogs too!
S: What is your favorite animal?
U: Hamsters are my favorite!
S: I like hamsters too!
transitions = {
'state': 'start',
'`Hello. How are you?`': 'end' # literal
}
transitions = {
'state': 'start',
'`Hello. How are you?`': { # literal
'could be better': { # term
'`I hope your day gets better soon :(`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
}
}
}
transitions = {
'state': 'start',
'`Hello. How are you?`': { # literal
'could be better': { # term
'`I hope your day gets better soon :(`': 'end'
},
'{good, not bad}': { # set
'`Glad to hear that you are doing well :)`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
}
}
}
transitions = {
'state': 'start',
'`Hello. How are you?`': { # literal
'could be better': { # term
'`I hope your day gets better soon :(`': 'end'
},
'{good, not bad}': { # set
'`Glad to hear that you are doing well :)`': 'end'
},
'<very, good>': { # unordered list
'`So glad that you are having a great day!`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
}
}
}
transitions = {
'state': 'start',
'`Hello. How are you?`': { # literal
'could be better': { # term
'`I hope your day gets better soon :(`': 'end'
},
'{good, not bad}': { # set
'`Glad to hear that you are doing well :)`': 'end'
},
'<very, good>': { # unordered list
'`So glad that you are having a great day!`': 'end'
},
'[so, good]': { # ordered list (sequence)
'`Things are just getting better for you!`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
}
}
transitions = {
'state': 'start',
'`Hello. How are you?`': { # literal
'could be better': { # term
'`I hope your day gets better soon :(`': 'end'
},
'{good, not bad}': { # set
'`Glad to hear that you are doing well :)`': 'end'
},
'<very, good>': { # unordered list
'`So glad that you are having a great day!`': 'end'
},
'[so, good]': { # ordered list (sequence)
'`Things are just getting better for you!`': 'end'
},
'[!hello, world]': { # rigid sequence
'`You\'re a programmer!`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
}
}
}
}
transitions = {
'state': 'start',
'`Hello. How are you?`': { # literal
'could be better': { # term
'`I hope your day gets better soon :(`': 'end'
},
'{good, not bad}': { # set
'`Glad to hear that you are doing well :)`': 'end'
},
'<very, good>': { # unordered list
'`So glad that you are having a great day!`': 'end'
},
'[so, good]': { # ordered list (sequence)
'`Things are just getting better for you!`': 'end'
},
'[!hello, world]': { # rigid sequence
'`You\'re a programmer!`': 'end'
},
'[!-not, aweful]': { # negation
'`Sorry to hear that :(`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
}
}
}
transitions = {
'state': 'start',
'`Hello. How are you?`': {
'{so, very} good': {
'`Things are just getting better for you!`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
}
}
}
transitions = {
'state': 'start',
'`Hello. How are you?`': {
'[{so, very} good]': {
'`Things are just getting better for you!`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
}
}
}
transitions = {
'state': 'start',
'`Hello. How are you?`': {
'{[{so, very} good], fantastic}': {
'`Things are just getting better for you!`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
}
}
}
transitions = {
'state': 'start',
'`What is your favorite animal?`': {
'[{dogs, cats, hamsters}]': {
'`I like them too!`': 'end'
},
'error': {
'`I\'ve never heard of that animal.`': 'end'
}
}
}
transitions = {
'state': 'start',
'`What is your favorite animal?`': {
'[$FAVORITE_ANIMAL={dogs, cats, hamsters}]': {
'`I like` $FAVORITE_ANIMAL `too!`': 'end'
},
'error': {
'`I\'ve never heard of that animal.`': 'end'
}
}
}
S: Hi there, how are you doing today?
U: Fantastic!
S: Glad to hear that. What do you want to talk about?
U: Let's talk about movies
S: My favorite movie is "Spider-Man: Homecoming"! What's yours?
U: The Sound of Music
S: Glad to hear that. What else do you want to talk about?
U: How about music?
S: My favorite song is "Raining Tacos"! What's yours?
U: Amazing Grace
S: Glad to hear that. What else do you want to talk about?
U: That's it..
S: Goodbye!
S: Hi there, how are you doing today?
U: Good
S: Glad to hear that. What do you want to talk about?
U: Music
S: My favorite song is "Raining Tacos"! What's yours?
U: I got vaccinated for COVID
S: I hope you are OK. Glad to hear that. What else do you want to talk about?
U: It's my birthday
S: Happy birthday to you! Glad to hear that. What else do you want to talk about?
U: I'm done
S: Goodbye!
S: Hi there, how are you doing today?
U: Good
S: Glad to hear that. What do you want to talk about?
U: Let's talk about virus movies
S: My favorite movie is "Spider-Man: Homecoming"! What's yours?
S: Hi there, how are you doing today?
U: Good!
S: Glad to hear that. What do you want to talk about?
U: Let's talk about virus movies
S: I hope you are OK. Glad to hear that. What else do you want to talk about?
transitions = {
'state': 'start',
'`Hi there, how are you doing today?`': {
'[{good, fantastic}]': {
'state': 'good',
'`Glad to hear that.` #WHAT_ELSE': {
'[#LEM(movie)]': 'movie',
'[music]': 'music',
'error': {
'state': 'goodbye',
'`Goodbye!`': 'end'
}
}
},
'error': 'goodbye'
}
}
music_transitions = {
'state': 'music',
'`My favorite song is "Raining Tacos"! What\'s yours?`': {
'error': 'good'
}
}
movie_transitions = {
'state': 'movie',
'`My favorite movie is "Spider-Man: Homecoming"! What\'s yours?`': {
'error': 'good'
}
}
macros = {
'WHAT_ELSE': MacroWhatElse()
}
class MacroWhatElse(Macro):
def run(self, ngrams: Ngrams, vars: Dict[str, Any], args: List[Any]):
vn = 'HAVE_TALK'
if vn in vars and vars[vn]:
return 'What else do you want to talk about?'
else:
vars[vn] = True
return 'What do you want to talk about?'
df = DialogueFlow('start', end_state='end')
df.load_transitions(transitions)
df.load_transitions(music_transitions)
df.load_transitions(movie_transitions)
df.add_macros(macros)
gloabl_transitions = {
'[{covid, corona, virus}]': {
'`I hope you are OK.`': 'good'
},
'[{birthday}]': {
'`Happy birthday to you!`': 'good'
}
}
df.load_global_nlu(gloabl_transitions)
gloabl_transitions = {
'[{covid, corona, virus}]': {
'score': 0.5,
'`I hope you are OK.`': 'good'
},
'[{birthday}]': {
'score': 0.5,
'`Happy birthday to you!`': 'good'
}
}
S: Good afternoon; it's sunny today. What should I call you?
U: Call me Jinho.
S: Hi, Jinho. Nice to meet you. What do you want me to recommend?
U: A movie, please.
S: How about "Spider-Man: Homecoming"? It's my personal favorite.
U: I've already seen that.
S: Got ya. How about "The Sound of Music"? It's classic.
U: Sure, I'll watch that one. Thanks.
S: Don't mention.
S: Good morning; it's cloudy today. What's your name?
U: I'm Jinho.
S: Welcome back, Jinho. Did you get to watch "The Sound of Music"?
U: Yes, I did. I loved it.
S: Wonderful. What else do you want me to recommend?
U: Maybe, a song?
S: How about "Raining Tacos"?
U: What is it about?
S: It's a fun children's song by Parry Gripp.
U: Sure, I'll listen to that.
S: Enjoy!
S: Hello, Jinho. Should I call you Jinho or something else?
U:
PyCharm may automatically create the __init__.py file under src, which is required for Python to treat the directory as a package, so leave the file as it is.
3. Create a python file called quiz0.py under the quiz package and copy the code:
If PyCharm prompts you to add quiz0.py to git, press [Add].
4. Run quiz0 by clicking [Run] - [Run 'quiz0']. An alternative way of running the program is to click the green triangle by the line #26 and select Run 'quiz0':
5. Conduct the following two dialogues with the chatbot you just created (S: system, U: user):
This is what your directory structure may look like in PyCharm after finishing this assignment:
Submission
1. Create the .gitignore file under the conversational-ai directory and copy the content:
2. Add the following files to git by right-clicking on them and selecting [Git] - [Add]:
quiz0.py
.gitignore
Once the files are added to git, they should turn green. If not, restart PyCharm and try to add them again.
3. Commit and push your changes to GitHub:
Right-click on conversational-ai.
Select [Git] - [Commit Directory].
Enter a commit message (e.g., Submit Quiz 0).
Press the [Commit and Push] button.
Make sure you both commit and push, not just commit.
4. Check if the above files are properly pushed to your GitHub repository.
5. Submit the address of your repository to Canvas.
Conversation: interactive communication between two or more people.
Dialogue: a conversation, often between two people, with a specific goal in mind.
Dialog: a window that appears on a screen in computing contexts (e.g., dialog box).
Application
Dialogue System: a computer system that interacts with humans in natural language.
Conversational Agent: a dialogue system that interprets and responds to user statements.
Virtual Assistant: a dialogue system that performs tasks or services for user requests.
Chatbot: a dialogue system that simulates and processes human conversation.
Chatbots are typically understood to follow pre-defined dialogue flows for open-domain conversations without using sophisticated artificial intelligence technology.
Intelligence
Dialogue Management: a process of controlling the state and flow of the dialogue to conduct contextual communications.
Conversational AI: a type of Artificial Intelligence (AI) for a dialogue system to understand user inputs and respond properly to them, often processed by machine learning models.
What are examples of dialogue systems currently used in practical applications?
Are there applications that would greatly benefit from adopting dialogue systems?
Properties
Unit
Turn: a single contribution from one speaker to the dialogue.
Utterance: a natural unit of speech bounded by breaths or pauses.
For a text-based conversation, each turn is often considered an utterance.
Context
Speech Act: the action, either explicitly or implicitly, expressed by an utterance (e.g., answering, advising, greeting; see Switchboard Dialog Act Corpus).
Intent: the user's goal expressed by an utterance within the context of a conversation (e.g., making an appointment, requesting information).
Topic: the matter dealt with in an utterance (e.g., movie, family, midterm).
It is possible that one utterance expresses multiple speech acts and intents and also deals with various topics.
What kind of tasks are presented in the above task-oriented datasets?
Try the demos of BlenderBot and ChatGPT. What are their limitations?
What are the challenges in building task-oriented vs. open-domain dialogue systems?
Techniques
State Machine
A dialogue flow can be designed into a fine-state machine. Most commercial dialogue systems take this approach because it gives greater control over how the systems behave. Several platforms are available to facilitate the development of state machine-based dialogue systems:
Three of the open-domain dialogue systems above, Meta BlenderBot, OpenAI ChatGPT, and Google LaMDA, are end-to-end systems based on S2S models.
Implementing an end-to-end system is beyond the scope of this course. Thus, we will use the state machine approach to develop dialogue systems, starting from Chapter 2.
Assessments
The primary objective of both task-oriented and open-domain dialogue systems is to satisfy users by communicating with them. For task-oriented, users are generally satisfied if the tasks are accomplished efficiently. For open-domain, however, user satisfaction is often highly subjective, so proper conversational analysis may need to be involved.
What are the differences between a list and a tuple in Python?
It is possible to group specific patterns using parentheses:
#1: there are two groups in this regular expression, (M[rs]) and (\.).
#3: returns a tuple of matched substrings ('Ms', '.') for the two groups in #1.
#4,5: return the entire match "Ms.".
#6: returns "Ms" matched by the first group (M[rs]).
#7: returns "." matched by the second group (\.).
The above RE_MR matches "Mr." and "Ms." but not "Mrs." Modify it to match all of them (Hint: use a non-capturing group and |).
The non-capturing group (?:[rs]|rs) matches "r", "s", or "rs" such that the first group matches "Mr", "Ms", and "Mrs", respectively.
Since we use the non-capturing group, the following code still prints a tuple of two strings:
What if we use a capturing group instead?
Now, the nested group ([rs]|rs) is considered the second group such that the match returns a tuple of three strings as follows:
search()
Let us match the following strings with RE_MR:
#4: matches "Mr." but not "Ms."
#5: matches neither "Mr." nor "Mrs."
For s1, only "Mr." is matched because match() stops matching after finding the first pattern. For s2 on the other hand, even "Mr." is not matched because match() requires the pattern to be at the beginning of the string.
To match a pattern anywhere in the string, we need to search for the pattern instead:
search() returns a match object as match() does.
findall()
search() still does not return the second substrings, "Ms." and "Mrs.". The following shows how to find all substrings that match the pattern:
findall() returns a list of tuples where each tuple represents a group of matched results.
finditer()
Since findall() returns a list of tuples instead of match objects, there is no definite way of locating the matched results in the original string. To return match objects instead, we need to interactively find the pattern:
#1: finditer() returns an iterator that keeps matching the pattern until it no longer finds.
The nesting example in Section 3.1 has a condition as follows (#4):
Write a regular expression that matches the above condition.
It is possible to use regular expressions for matching in Natex. A regular expression is represented by forward slashes (/../):
#4: true if the entire input matches the regular expression.
You can put the expression in a sequence to allow it a partial match:
#4: the regular expression is put in a sequence [].
When used in Natex, all literals in the regular expression (e.g., "so", "good" in #4) must be lowercase because Natex matches everything in lowercase. The design choice is made because users tend not to follow typical capitalization in a chat interface, whether it is text- or audio-based.
Variable
It is possible to store the matched results of a regular expression to variables. A variable in a regular expression is represented by angle brackets (<..>) inside a capturing group ((?..)).
The following transitions take the user name and respond with the stored first and last name:
#4: matches the first name and the last name in order and stores them in the variables FIRSTNAME and LASTNAME.
The music and movie states can be defined in separate transition dictionaries:
#5: directs to the start state.
#8: directs to the movie state.
#5: directs to the start state.
#8: directs to the music state.
Finally, all three transition dictionaries can be loaded to the same dialogue flow:
Overview of the above transitions combining three transition dictionaries.
When the dialogue flow runs, it randomly selects one of the 3 states, music, movie, and end:
#1: randomly selects the music state.
#3: switches to the movie state when it does not understand the user input.
#5: switches to the music state when it does not understand the user input.
#7: goes back to the start state when it understands the user input, and randomly selects the movie state.
#9: goes back to the start state when it understands the user input, and randomly selects the music state.
#11: goes back to the start state when it understands the user input, and randomly selects the end state.
#1: randomly selects the end state and terminates the dialogue.
Gating
The randomness in the above transitions can be quite annoying because it may end the dialogue immediately after it runs or repeats the same topic over and over. This can be alleviated by using the #GATE built-in macro:
#3: puts the music topic to an open gate.
#4: puts the movie topic to an open gate.
#4: has no gate to open (so it can be selected at any time).
Once an output is selected, #GATE closes the door for that output such that it will never be selected again.
It is important to have at least one output with no gate; otherwise, the system will crash unless one of the outputs leads to the end state.
Scoring
The gating prevents the system from repeating the same topic, but the end state can still be selected at any time without consuming all the other topics. To ensure that the end state gets selected last, we use scoring:
#6: indicates that this is the end state.
#7: assigns the score of this state to 0.1.
By default, all states receive a score of 1; thus, assigning a score below 1 would make that state not selected at all unless there are dynamic scoring changes through macros such as #GATE.
#2-6: uses the ChatCompletition model to retrieve the GPT output.
#8-10: uses the regular expression (if provided) to extract the output in the specific format.
Let us create a macro that calls MacroGPTJSON:
#3: the task to be requested regarding the user input (e.g., How does the speaker want to be called?).
#4: the example output where all values are filled (e.g., {"call_names": ["Mike", "Michael"]}).
#5: the example output where all collections are empty (e.g., {"call_names": []}).
#6: the to check the information.
#7: it is a function that takes the STDM variable dictionary and the JSON output dictionary and sets necessary variables.
Override the run method in MacroGPTJSON:
#2-3: creates a input prompt to the GPT API.
#4-5: retreives the GPT output using the prompt.
#7-11: checks if the output is in a proper JSON format.
#13-14: updates the variable table using the custom function.
#15-16: updates the variable table using the same keys as in the JSON output.
Let us create another macro called MacroNLG:
#3: is a function that takes a variable table and returns a string output.
Finally, we use the macros in a dialogue flow:
The helper methods can be as follow:
How does the speaker want to be called? Respond in the one-line JSON format such as {"call_names": ["Mike", "Michael"]}: My friends call me Pete, my students call me Dr. Parker, and my parents call me Peter.
OpenAI API key generator.
Make sure to save this key in a local file. If you close the dialog without saving, you cannot retrieve the key again, in which case, you have to create a new one.
Create a file openai_api.txt under the resources directory and paste the API key to the file such that it contains only one line showing the key.
Communication is a fundamental part of human interaction, and studying it can help us better understand social dynamics and cultural norms.
It involves analyzing the structure of conversations, including turn-taking, topic initiation and maintenance, and repair strategies.
By examining these elements, researchers can gain insight into the social dynamics of a particular interaction and the underlying cultural norms that guide communication.
Can the study of Human-to-Human Conversational Analysis be applied to analyze Huaman-to-Machine conversations?
-> It helps you understand the social context of the conversation.
-> It helps you understand the patterns of communication between speakers.
-> It helps you understand how speakers introduce and develop discussion topics.
-> It helps you understand how speakers handle communication breakdowns and errors.
-> It helps you understand how cultural norms, values, and beliefs influence communication.
Recording/Transcribing
If your conversations are based on an audio or video interface, recording and transcribing them enables you to go back and analyze the conversation to gain a deeper understanding.
There are several automatic transcribers available:
Category
OpenAI Whisper
Microsoft Azure
Rev AI
Website
Pricing
Free
$1 / hour
$0.02 / minute
Interface
Identifying Participants
When analyzing a conversation, it is important to consider the gender, age, social status, and other relevant characteristics of the speakers. These factors can influence communication and provide important context for understanding the conversation.
Diversity: Including a diverse range of participants can provide insights into how different groups communicate and interact. It can include age, gender, race, ethnicity, socioeconomic status, and cultural background.
Context: Conversations in different settings, such as workplaces or social gatherings, may involve different communication styles and norms.
Purpose: Conversations focused on a specific topic or goal may involve different communication strategies than casual conversations.
Power Dynamics: Conversations that involve power imbalances, such as a boss and an employee, may involve different communication patterns than conversations between peers.
Relationship: Conversations between strangers may involve different communication patterns than conversations between friends or family members.
Identify ideal participants for testing your chatbot and discuss your strategy to gather such participants for the final project.
Turn-taking
Turn-taking refers to the way that speakers take turns participating in the interaction. It includes both the decision to speak and the transition between speakers. Turn-taking can reveal:
Power imbalances between speakers, with some individuals dominating the conversation and others having less opportunity to speak.
How speakers collaborate and negotiate with each other to move the conversation forward.
Analysis aspects:
Message Length: The length of messages can indicate a speaker's intention to take a turn or signal that they have finished speaking.
Response Time: The time it takes for a speaker to respond to a message can indicate their intention to take a turn or signal that they are finished speaking.
Use of Markers: Speakers may use markers such as ellipses, dashes, or quotation marks to signal that they are taking a turn or indicate that they are listening to another speaker.
Emojis / Emoticons: The use of emojis or emoticons can indicate a speaker's attitude, emotion, or intention to take a turn.
Repetition: Speakers may repeat words or phrases to indicate their intention to take a turn or emphasize a point.
What are your strategies to balance the lengths between the chatbot and the users? Can you use any of the above cues to improve the overall quality of the conversations?
Topic Analysis
Topic initiation refers to how speakers introduce a new topic of conversation, while topic maintenance refers to how they keep the conversation focused on that topic. Through this analysis, we:
Gain insights into the participants' interests, goals, and social context.
Understand how speakers collaborate to build shared understanding and mutual goals.
Learn effective communication techniques for keeping conversations focused and productive.
Analysis aspects:
Topic Introduction: Speakers may introduce a new topic of discussion explicitly by using phrases such as "By the way," "Speaking of," or "Have you heard about". Such phrases indicate the speaker intends to change the topic or introduce something new.
Topic Development: Speakers may develop a topic by providing additional information or asking related questions. They may use open-ended, follow-up, or clarifying questions to maintain the topic.
Topic Shift: Speakers may shift the topic of discussion by changing the subject or introducing a new topic. Such shifts may be explicit or implicit and can be signaled by phrases such as "Anyway," "Moving on," or "So, as I was saying".
Topic Re-introduction: Speakers may re-introduce a topic discussed earlier by referring to it or bringing it up again. Such references can indicate that the speaker wants to continue discussing or bring attention to the topic.
Nonverbal Cues: Speakers may use punctuation or capitalization for emphasis or tone to indicate their intention to initiate or maintain a topic.
Does your chatbot allow users to introduce or switch topics? How does your chatbot proceed when users intend to do so?
Repair Strategies
Repair strategies refer to techniques used by speakers to correct misunderstandings, clarify meaning, or resolve problems in communication. It allows us to:
Identify areas where communication breakdowns are more likely to occur, such as when speakers have different cultural backgrounds, use different languages, or have varying knowledge about the discussed topic.
Identify communication patterns that may be hindering effective communication. For example, a speaker consistently interrupts others or fails to listen actively can lead to more frequent communication breakdowns.
Several aspects need to be analyzed to understand repair strategies:
Self-repair: Speakers may self-correct errors or repair communication breakdowns in real time by repeating or rephrasing their previous statement.
Other-repair: Speakers may ask their conversational partner to repeat or clarify what they said to repair communication breakdowns. They may also offer suggestions or provide information to help resolve the problem.
Repair Initiation: Speakers may initiate repair by indicating a problem or error in communication, such as saying, "I didn't understand what you said," or "Can you repeat that?".
Repair Resolution: Speakers may resolve the problem by clarifying, repeating, or rephrasing their previous statement or using other strategies to ensure successful communication.
Lexical Choice: The words speakers choose to use can impact the success of the repair. They may use more straightforward language to clarify their message or help their conversational partner understand.
Does your chatbot have any repair strategies? What are effective ways of catching them in STDM?
Cultural Analysis
Cultural context refers to the social norms, values, and beliefs that influence communication. They can vary between different cultures and can impact how people interact with each other:
In some cultures, interrupting someone may be seen as assertive and confident, while in others, it may be seen as rude or disrespectful.
Some cultures may place a high value on politeness and indirect communication, while others may value directness and assertiveness.
Culture shapes how individuals perceive and interpret the world around them. By analyzing the cultural context, we can:
Gain insights into how communication is influenced by cultural factors such as social status, gender roles, power dynamics, and language proficiency.
Recognize and address potential biases or assumptions we may bring to the interaction.
Avoid misunderstandings and communicate more respectfully and effectively with people from different cultural backgrounds.
Analysis aspects:
Social Norms: Different cultures may have different social norms that dictate appropriate behavior in conversation, such as turn-taking, interruptions, and politeness strategies.
Language Use: Language use may vary based on cultural context, including vocabulary, grammar, and pronunciation. For example, some languages may have different words or expressions for the same concept, or different cultures may have different levels of formality in their language use.
Worldviews: Cultural differences can impact how people perceive and interpret events and actions. These differences can manifest in conversation through differences in humor, storytelling, and nonverbal communication.
Values and Beliefs: Different cultures may have different values and beliefs, influencing how people communicate and what topics they discuss. For example, some cultures may prioritize directness and honesty, while others prioritize harmony and social relationships.
Contextual Factors: Cultural context is also influenced by contextual factors such as the purpose of the conversation, the setting, and the relationship between speakers.
Benjamin Ascoli
Ph.D. student of Computer Science and Informatics
Office Hours → MW 11:30AM - 1PM, MSC W302B
Ph.D. student of Computer Science and Informatics
Office Hours → MW 1PM - 2:30PM, MSC W302B
Grading
1 + 7 topical quizzes: 55%
3 LINC discussions: 10%
Project proposal: 15%
Final project: 20%
Your work is governed by the . Honor code violations (e.g., copies from any source, including colleagues and internet sites) will be referred to the .
Excuses for exam absence/rescheduling and other serious personal events (health, family, personal related, etc.) that affect course performance must be accompanied by a letter from the .
Topical Quizzes
For every topic, one quiz will be assigned to check if you keep up with the materials.
Quizzes must be submitted individually. Discussions are allowed; however, your work must be original.
Late submissions within a week will be accepted with a grading penalty of 15% and will not be accepted once the solutions are discussed in class.
#10-13: uses the match statements to return the appropriate literal.
The challenge is that we must save the number of visits to make this macro effective (and correct). This can be achieved by saving the variable dictionary into a binary file using the built-in Python object serialization called pickle:
#1: takes a dialogue flow df and a file path varfile for saving the variable dictionary to.
#3: creates a dictionary by copying only user-generated variables.
#4: a writable (w) and binary (b) file and dumps the dictionry object into the file.
After running this code, you will see the visits.pkl file saved under the resources directory.
Loading
The following code shows how to load the saved dictionary to a new dialogue flow:
#1: takes a dialogue flow df and a file path varfile for loading the variable dictionary from.
#2: opens a readable (r) and binary (b) file and loads the object as a dictionary.
#3: adds all variables in the loaded dictioinary to the variable dictionary of df.
#5: saves the new variable dictionary to the same file.
Please watch the movie Babel before coming to this meeting. You can watch it at Emory's Swank Streaming: link.
from emora_stdm import DialogueFlow
transitions = {
'state': 'start',
'`Hello. How are you?`': {
'[{good, fantastic}]': {
'`Glad to hear that you are doing well :)`': {
'error': {
'`See you later!`': 'end'
}
}
},
'error': {
'`I hope your day gets better soon :(`': {
'error': {
'`Take care!`': 'end'
}
}
}
}
}
df = DialogueFlow('start', end_state='end')
df.load_transitions(transitions)
if __name__ == '__main__':
df.run()
S: Hello. How are you?
U: I'm good
S: Glad to hear that you are doing well :)
U: Thanks
S: See you later!
==========================================
S: Hello. How are you?
U: It's not going well
S: I hope your day gets better soon :(
U: Hopefully
S: Take care!
.idea/
venv/
<re.Match object; span=(0, 3), match='Mr.'>
Mr. 0 3
s1 = 'Mr. and Ms. Wayne are here'
s2 = 'Here are Mr. and Mrs. Wayne'
print(RE_MR.match(s1))
print(RE_MR.match(s2))
print(RE_MR.search(s1))
print(RE_MR.search(s2))
print(RE_MR.findall(s1))
print(RE_MR.findall(s2))
for m in RE_MR.finditer(s1):
print(m)
for m in RE_MR.finditer(s2):
print(m)
ms = [m for m in RE_MR.finditer(s1)]
print(ms)
'{[{so, very} good], fantastic}'
transitions = {
'state': 'start',
'`Hello. How are you?`': {
'/((?:so|very) good|fantastic)/': {
'`Things are just getting better for you!`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
}
}
}
transitions = {
'state': 'start',
'`Hello. How are you?`': {
'[/((?:so|very) good|fantastic)/]': {
'`Things are just getting better for you!`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
}
}
}
transitions = {
'state': 'start',
'`Hello. What should I call you?`': {
'[/(?<FIRSTNAME>[a-z]+) (?<LASTNAME>[a-z]+)/]': {
'`It\'s nice to meet you,` $FIRSTNAME `. I know several people with the last name,` $LASTNAME': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
}
}
}
transitions_music = {
'state': 'music',
'`What is your favorite song?`': {
'[[!{#LEM(rain), rainy}, #LEM(taco)]]': {
'`I love children\'s songs by Parry Gripp.`': 'start',
},
'error': {
'`Sorry, I don\'t know that song.`': 'movie'
}
}
}
transitions_movie = {
'state': 'movie',
'`What is your favorite movie?`': {
'[{#LEM(avenger), iron man, hulk}]': {
'`I love the Marvel Cinematic Universe.`': 'start',
},
'error': {
'`Sorry, I don\'t know that movie.`': 'music'
}
}
}
S: Let's talk about music. What is your favorite song?
U: Doremi Song
S: Sorry, I don't know that song. What is your favorite movie?
U: Superman
S: Sorry, I don't know that movie. What is your favorite song?
U: Raining Tacos
S: I love children's songs by Parry Gripp. Let's talk about movies. What is your favorite movie?
U: Iron man
S: I love the Marvel Cinematic Universe. Let's talk about music. What is your favorite song?
U: It's raining tacos
S: I love children's songs by Parry Gripp. That\'s all I can talk about.
S: Let's talk about music. What is your favorite song?
U: Raining Tacos
S: I love children's songs by Parry Gripp. Let's talk about movies. What is your favorite movie?
U: Iron Man
S: I love the Marvel Cinematic Universe. That's all I can talk about.
transitions = {
'state': 'start',
'#GATE `Let\'s talk about music.`': 'music',
'#GATE `Let\'s talk about movies.`': 'movie',
'`That\'s all I can talk about.`': 'end',
}
transitions = {
'state': 'start',
'`Let\'s talk about music.`': 'music',
'`Let\'s talk about movies.`': 'movie',
'`That\'s all I can talk about.`': 'end'
}
transitions = {
'state': 'start',
'#GATE `Let\'s talk about music.`': 'music',
'#GATE `Let\'s talk about movies.`': 'movie',
'`That\'s all I can talk about.`': 'end',
}
transitions = {
'state': 'start',
'#GATE `Let\'s talk about music.`': 'music',
'#GATE `Let\'s talk about movies.`': 'movie',
'`That\'s all I can talk about.`': {
'state': 'end',
'score': 0.1
}
}
S: Hi, how should I call you?
U: My friends call me Jin, but you can call me Jinho. Some students call me Dr. Choi as well.
def gpt_completion(input: str, regex: Pattern = None) -> str:
response = openai.ChatCompletion.create(
model='gpt-3.5-turbo',
messages=[{'role': 'user', 'content': input}]
)
output = response['choices'][0]['message']['content'].strip()
if regex is not None:
m = regex.search(output)
output = m.group().strip() if m else None
return output
transitions = {
'state': 'start',
'`Hi, how should I call you?`': {
'#SET_CALL_NAMES': {
'`Nice to meet you,` #GET_CALL_NAME `. Can you tell me where your office is and when your general office hours are?`': {
'#SET_OFFICE_LOCATION_HOURS': {
'`Can you confirm if the following office infos are correct?` #GET_OFFICE_LOCATION_HOURS': {
}
}
}
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
}
}
}
macros = {
'GET_CALL_NAME': MacroNLG(get_call_name),
'GET_OFFICE_LOCATION_HOURS': MacroNLG(get_office_location_hours),
'SET_CALL_NAMES': MacroGPTJSON(
'How does the speaker want to be called?',
{V.call_names.name: ["Mike", "Michael"]}),
'SET_OFFICE_LOCATION_HOURS': MacroGPTJSON(
'Where is the speaker\'s office and when are the office hours?',
{V.office_location.name: "White Hall E305", V.office_hours.name: [{"day": "Monday", "begin": "14:00", "end": "15:00"}, {"day": "Friday", "begin": "11:00", "end": "12:30"}]},
{V.office_location.name: "N/A", V.office_hours.name: []},
set_office_location_hours
),
}
def get_call_name(vars: Dict[str, Any]):
ls = vars[V.call_names.name]
return ls[random.randrange(len(ls))]
def get_office_location_hours(vars: Dict[str, Any]):
return '\n- Location: {}\n- Hours: {}'.format(vars[V.office_location.name], vars[V.office_hours.name])
def set_office_location_hours(vars: Dict[str, Any], user: Dict[str, Any]):
vars[V.office_location.name] = user[V.office_location.name]
vars[V.office_hours.name] = {d['day']: [d['begin'], d['end']] for d in user[V.office_hours.name]}
<class 'openai.openai_object.OpenAIObject'>
{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "\n\n\"Believe in yourself and all that you are. Know that there is something inside you that is greater than any obstacle.\"",
"role": "assistant"
}
}
],
"created": 1678893623,
"id": "chatcmpl-6uNDL6Qfh7MjxpLxH3NW7UPJXS3tN",
"model": "gpt-3.5-turbo-0301",
"object": "chat.completion",
"usage": {
"completion_tokens": 26,
"prompt_tokens": 10,
"total_tokens": 36
}
}
"Believe in yourself and all that you are. Know that there is something inside you that is greater than any obstacle."
class MacroVisits(Macro):
def run(self, ngrams: Ngrams, vars: Dict[str, Any], args: List[Any]):
vn = 'VISITS'
if vn not in vars:
vars[vn] = 1
return 'first'
else:
count = vars[vn] + 1
vars[vn] = count
match count:
case 2: return 'second'
case 3: return 'third'
case default: return '{}th'.format(count)
def save(df: DialogueFlow, varfile: str):
df.run()
d = {k: v for k, v in df.vars().items() if not k.startswith('_')}
pickle.dump(d, open(varfile, 'wb'))
save(visits(), 'resources/visits.pkl')