Skip to main content

AI and Human-Computer Communication

Chatbot virtual assistant

Chatbot virtual assistant (LuckyStep48, iStockphoto)

Chatbot virtual assistant

Chatbot virtual assistant (LuckyStep48, iStockphoto)

Let's Talk Science
5.87

How does this align with my curriculum?

Share on:

Learn about how artificial intelligence and machine learning help us communicate with computers.

Does Artificial Intelligence (AI) make you think of a robot takeover movie? If so, you might think of AI as a future technology. But it’s actually used in many areas of your life right now. In this backgrounder, we will explore some of the tools that AI has made possible. But, before you go further, you need to know what machine learning (ML) is. If you have not read the machine learning backgrounder, you will want to do it now. Most of the applications (apps) we will discuss involve machine learning.

Natural Language Processing

Have you ever used a search engine? Or used autocorrect to catch your spelling mistakes? If so, you have used an app that involved Natural Language Processing (NLP). Natural language is the speech and text humans use to communicate with each other.

But humans and computers do not speak the same language. This is one of the biggest problems in human-computer communication. NLP is a way of trying to solve this problem.

As people, we use text, voice and gestures to communicate. Machines do not immediately recognize a lot of this.To help bridge this gap, NLP follows a number of steps.

Let’s look at an example of text analysis.

Shown is a colour illustration of 22 coloured squares on a white background.
Assortment of text represented by coloured squares (©2023 Let’s Talk Science).
Image - Text Version

Shown is a colour illustration of 22 coloured squares on a white background. The squares are scattered randomly across the image and are in the same orientation. There are two or three squares of each colour: orange, pink, light blue, dark blue, light purple, dark purple, yellow, light green, dark green, red and dark red.

Preprocessing

This is the first, and often most important step of NPL. Many of the choices people make in this step affect the accuracy of models that are built.

In preprocessing, people ask computers to prepare a text for machine reading. This involves:

  1. Tokenization, which is splitting the text into individual words, called tokens, or small phrases, called ngrams
  2. Removing punctuation
  3. Making all text lowercase
  4. Removing stopwords, which are common words like 'the', 'is', 'in', etc.
Shown are 16 squares, some of which are the same as in the previous image.
Preprocessing involves removing (squares removed) and changing text (squared recoloured) (©2023 Let’s Talk Science)
Image - Text Version

Shown are 16 squares, some of which are the same as in the previous image. The dark green squares have changed to light green. The dark blue squares have changed to light blue. The dark purple squares changed to light purple. These represent making words into lower case. The yellow, red and pink squares were removed. This represents removing punctuation and stopwords.

Here is an example of text before preprocessing:

The sunny day filled us with joy, and we played games in the park. Even the dark clouds did not dampen the fun. It was a day we'll always remember with big smiles on our faces!

Example text after preprocessing:

"sunny day filled us joy played games park even dark clouds dampen fun day always remember big smiles faces"

Text Analysis

In this step, a person gets the machine to change the tokens and ngrams into meaningful data for a computer to use. There are a number of ways this can be done. Two common ways are semantics analysis and sentiment analysis.

Semantics analysis looks at the meaning of words in context, like the way they're used in sentences. Sentiment analysis uses a special kind of dictionary. The dictionary is a separate dataset where words are assigned scores based on their emotional impact.

Shown is a colour illustration of the 16 squares from the previous image, in labelled groups or four.
Words categorized by how they are used in context (©2023 Let’s Talk Science)
Image - Text Version

Shown is a colour illustration of the 16 squares from the previous image, in labelled groups or four. Starting on the top left, the orange squares are labelled “Nouns.” On the top right, the light blue squares are labelled “Verbs.” On the lower left, the light green squares are labelled “Adverbs.” On the lower right, the light purple squares are labelled “Adjectives.”

Most sentiment dictionaries score words based on how positive or negative they are.

For example, if we apply a sentiment analysis dictionary to our previous set of tokens:

"sunny day filled us joy played games park even dark clouds dampen fun day always remember big smiles faces"

It will provide a set of words and their scores. Below are the scores from our example paragraph. Any word not listed in the table has a sentiment score of 0. 

Word Negative Positive
Sunny   1
Joy   1
Dark 1  
Clouds 1  
Dampen 1  
Fun   1
Smiles   1

This paragraph would have a positive score of 4 and a negative score of 3. NLP typically uses large amounts of text in its analysis, and this would be one chunk of data in a large set. The machine would use this paragraph as an example of a fairly neutral paragraph.

Did you know?

Other dictionaries break sentiment analysis down further. One example is the Canadian NRC Word-Emotion Association Lexicon, which uses eight emotion groupings.

Feature Extraction 

The goal of text analysis is to turn our human-written text into structured data. A machine usually expresses this data as a table or spreadsheet. This is often called a Document-Feature Matrix, or DFM.

Documents form the rows of the table. A document is a collection of tokens. These can be the individual tokens themselves. But often they are paragraphs, chapters, or whole reports.

Features are the columns in the table. These are the things we want the machine to consider. In this example, the positive and negative scores would be the features.

Shown is a colour illustration of the 16 squares from the previous image, arranged in a labelled grid.
Example Document-Feature Matrix (©2023 Let’s Talk Science)
Image - Text Version

Shown is a colour illustration of the 16 squares from the previous image, arranged in a labelled grid. The grid has four rows and four columns. The rows are labelled “Document 1” through “Document 4.” The columns are labelled “Feature 1” through “Feature 4.” The first column contains orange squares, the second light green squares, the third light blue squares, and the fourth light purple squares. Each row contains one square of each colour.

If we imagine our example paragraph as just one of many paragraphs in a story, our DFM might look like this:

Document Feature (Positive) Feature (Negative)
Paragraph 1 (our example from above) 4 3
Paragraph 2 2 8
Paragraph 3 6 1

In the structured set of data above, the positive column is one feature, and the negative column is a second feature. The individual scores, like the 4 in the positive column for paragraph 1 are called vectors.

An ML model for this set of data can then group the paragraphs by their features. A categorization model might create three groups. One is for strongly positive paragraphs, like paragraph 3. One is for strongly negative paragraphs, like paragraph 2. The third is for more neutral paragraphs, like paragraph 1.

A generative ML model, like ChatGPT, would then use these categories as examples. If it was asked to produce a positive text, it would use the strongly positive paragraphs as a guide on how to do it. Of course, an engine like GPT-3.5, which powers ChatGPT, uses many features to create text. But this gives you a simplified idea of how it works.

NLP is used for:

  • Text classification, like organizing survey responses into categories and detecting spam;
  • Text generation, like having chatbots build sentences by predicting what word will follow each generated word;
  • Translation, like the DeepL app, which use predictive ML models to translate text from one language to another; and
  • Summarization, like taking long pieces of text and creating short summaries, based on examining words in context.

Chatbots

Chatbots are one of the many apps that rely on NLP. The word "chatbot" comes from the words "chat" and "robot". But there are no mechanical robots here. Chatbots are software programs.

Chatbots are an app you can find on the web. Many companies use them for customer service. You may see them pop up when you go to a website. Chatbots are often the first point of contact with a company on their website or social media channels. They try to answer people’s questions without putting them on hold to talk to a human agent. This means they must be able to understand a customer’s question and respond with the best possible answer. Many basic chatbots have a predefined set of questions and answers. You often have to choose from a list of options when interacting with these chatbots. The ways they can help are limited. Some chatbots are more sophisticated though. They allow you to type in your question the way you would normally ask it. This is where natural language processing comes in.

Shown is a colour photograph of hands typing on a laptop, with speech bubbles floating above.
Person typing to a chatbot (Source: Blue Planet Studio via iStockphoto).
Image - Text Version

Shown is a colour photograph of hands typing on a laptop, with speech bubbles floating above. A cloud of translucent speech bubbles takes up the centre of the image. The largest one, in the centre, says “Hi.” Next to this is an image of a round face with two antennae, wearing headphones with a mouthpiece. The rest of the bubbles are different sizes and contain three dots, indicating responses in progress. A few orange dots are scattered among the bubbles. The person’s hands are on the keyboard. Their arms and chest are out of focus in the background.

Natural language processing allows chatbots to understand different ways of asking the same thing. That may sound easy to you, but it is tricky for a computer. Think of all the ways that someone might ask, “what is the weather going to be like today?” They might say: “Do I need an umbrella?” or “What’s the temperature outside?” or “Is it going to be hot today?” Natural language models can group questions by the customer’s intent. That way the company can teach a chatbot how to answer different intents, rather than specifically worded questions.

NLP can even help companies figure out how customers are feeling based on their chat transcripts. For example, if a person used words associated with anger, a chatbot could connect them directly to a human!

NLP can only understand a person's words. More complex systems also use other information from speech, like tone. A system that analyzes a person's tone of voice can identify if they sound angry, sad or happy. Combining NLP and speech recognition gets us much closer to having computers understand people.

ChatGPT

Probably the most famous NLP chatbot right now is ChatGPT. This was developed by OpenAI and based on their GPT 3.5 engine. ChatGPT is designed to generate text that looks, at first glance, like it was written by a person. Like all chatbots, it can engage in conversation with a human operator. The difference is that it can understand and respond to a much greater range of input than your typical chatbot. ChatGPT can generate idea prompts, help to modify language to fit a certain audience, or work with people to fix computer code. It was trained on an enormous amount of internet text. It can generate answers with the correct context and provide further detail if prompted.

Search Tools

NLP is an essential tool for web searches and recommendation enginesWeb search tools try to find the most relevant information based on what you are looking for. To do this, they need to understand what is contained in the many different web pages they can suggest. This involves analyzing text in news articles, blogs, and even the language in videos. NLP looks for specific keywords and phrases to help search engines find what you are looking for.

Spam Filters

NLP is also useful for email spam filters. NLP helps detect patterns commonly found in spam emails. This can make them better at catching and redirecting these emails.

Shown is a colour illustration of a laptop, a warning symbol, a magnifying glass and an email icon.
Spam filter (Source: axel2001 via iStockphoto).
Image - Text Version

Shown is a colour illustration of a laptop, a warning symbol, a magnifying glass and an email icon. In the lower left, in front of the keyboard, is a bright pink triangle with an exclamation point in the centre. The laptop screen is crowded with a pile of brightly coloured envelopes and paper. Floating above, one orange envelope is open, with a long scroll of paper stretching behind it. A magnifying glass over the message reveals the word “Spam.” Above, a pink dotted line leads from another part of the paper to a blue rectangle containing several lines of information.

Summarizing Text

NLP can also be useful for summarizing long or complicated documents. For example, scientific research is usually shared in scientific papers that are sometimes hard to read. NLP tools can create short summaries of these. This way, scientists can find and read the most relevant papers for their work. Law firms have also been using NLP tools to summarize legal documents. NLP tools can quickly find information like dates, names, and the outcome of a trial.

Speech Recognition

Speech recognition (SR) also uses NLP. This  involves turning audio files into text. Some examples of SR include talking to a chatbot on the phone, dictating a text message to your friend, or talking to a virtual assistant like Alexa or Siri. Web search tools also use speech recognition to transcribe videos and audio files like podcasts.

The most popular speech recognition apps are virtual assistants. These include Apple’s Siri, Microsoft’s Cortana, Amazon’s Alexa and Google’s Google Assistant. Virtual assistants are a sophisticated kind of chatbot. They have much better NLP and speech recognition skills. Virtual assistants can also do different types of tasks. They can play music, find a document or look up a location on a map.

Shown is a colour illustration of a large smart home speaker with people walking around it.
Smart virtual assistants use speech recognition (Source: ribkhan via iStockphoto).
Image - Text Version

Shown is a colour illustration of a large smart home speaker with people walking around it. The speaker is a grey cylinder with a rounded bottom and flat top. It has a grid of small holes and a white microphone symbol on the front. The people are about half the height of the speaker. Two are holding smartphones, one is typing on a laptop and another is reaching up toward the microphone symbol. Above the speaker, a light grey arch contains seven icons: a security checkmark, a SIM card, a wifi symbol, a padlock, two speech bubbles containing three dots, a location symbol and a telephone symbol. In the background, a few light grey clouds are scattered on a green sky.

Did you know?

Early virtual assistants had female voices. Based on feedback from users, some virtual assistants now offer voices of different genders. But the best solution might be a gender-neutral voice, such as that of Q, the virtual assistant. What do you think of this voice? Listen to it in the video below.

Meet Q: The First Genderless Voice (2019) by Meet Q (1:01 min.).

Having your own personal assistant sounds pretty useful, but it comes with a price. For them to be ready to answer you, they listen to you at all times. This is a privacy risk. But it can be managed by adjusting a few settings. So be smart with your smart devices, and what you say and do around them!

Translation

NLP has allowed breakthroughs in the world of multilingual communication. Automatic translators on the web are available to everyone with an internet connection. Together, speech recognition and NLP let people who speak different languages communicate in real time.

Accessibility

NLP also helps remove communication barriers for people with disabilities. People with hearing loss can have easier access to closed captioning of recorded and live video content. AI apps exist that allow Deaf people to “see” sounds.

Using Otter.ai to communicate with people who are Deaf or have hearing loss (2020) by Otter.ai (0:50 min.).

Combining this technology with computer vision, there is a system that can turn sign language into speech!

What the Future Might Bring

NLP is a technology that is moving very fast. In fact, we had to revise this article once already because of all the advances in AI. More and more companies are finding ways to use it.

Health care is one area where NLP can help. NLP can save doctors time by asking patients basic questions before their appointments. Tools like this could be very useful in remote areas where people do not always have access to doctors. Robots are also starting to be used to care for people, like senior citizens.. NLP could help these robots to better understand them. NLP is also a useful tool that could help assess someone's mental health.

So, the next time you search for something online, or talk to a chatbot, remember that it could not happen without AI and ML.

Let’s Talk Science appreciates the contributions of Melissa Valdez, Technology Consultant from AI & Quantum, for revisions to this backgrounder.

Teachable Machine
This tool by Google allows you to teach a machine how to recognize words by training it.

Chatterbot Facts for Kids
This webpage by Kiddle presents the history of how chatbots were developed and the different uses.

Small Bot, the Kids, and the Future (2017)
A true story about 8 to 12 year old girls and boys creating a Facebook chatbot in one month.

Natural Language Processing: Crash Course Computer Science #36 (2017)
This Crash Course video (11:49 min.) from PBS explains what NLP is and how it works.

References

Brownlee, J. (2019, Aug. 7). What Is Natural Language Processing? Machine Learning Mastery.

Joshi, N. (2018, Dec. 23). Yes, Chatbots And Virtual Assistants Are Different! Forbes.

Mahler, L. (2015, Feb. 13). What Is NLP and Why Should Lawyers Care? Lawpracticetoday.org

Mortada, D. (2019, Mar. 11). Meet Q, The Gender-Neutral Voice Assistant. npr.

Rouse, M. (2017, Oct.). Virtual assistant (AI assistant). TechTarget.