Giter VIP home page Giter VIP logo

deep-learning-for-vui's Introduction

Deep-Learning-for-VUI

Amazon Alexa is one of the most popular representatives of today’s voice-powered conversational agents. These kind of voice user interface (VUI) platforms allow the third-party developers to freely design and build their own voice applications. However, how to evaluate these voice applications still needs exploring. As indicated in [1], topic Analysis for these voice applications is crucial in evaluating them. In this project, I deploy deep learning methods (e.g. DAN, text CNN, skip-gram) to conduct topic analysis based on my self-collected Alexa skill dataset. This project uses a machine learning algorithm (LR) to generate baseline. Both DAN & text CNN have better performance (with fastText embedding) , as well as DAN with self-generated skip-gram embedding matrix.

Data Collection -- Alexa Crawler

In order efficiently conduct data collection, I developed a crawler to automate the task of collecting a large sample of skills’ responses to voice commands [2]. This crawler follows the basic Alexa interaction mode of "open-command-stop" to initiate the skill and exit. As indicated in the follow figure, this crawler simulates the voice interaction between users and Alexa devices.

Screenshot

The crawler iterated through over 40,000 Alexa skills to perform this reponses data collection process for each skill, which is described pragmatically as Algorithm 1.

Screenshot

In order to generate adaptive commands list for each skill, I deployed Stanford CoreNLP package to parse the instruction sentence each skill has.

Dataset

From the voice application crawler, I retrieved the Alexa Skills Responses Dataset. The details are displayed in the following table and the distribution bar chart which indicates the general Alexa skills distribution across different topics.

Screenshot

Screenshot

Baseline generation

I used Logistic Regression (LR) to conduct topic classification (15 topics) and grid search was deployed to find the best parameters. As for feature engineering, 6 features were extracted: 1. Bag of words; 2.Tags frequency; 3. Name-entity frequency; 4. Sentence length; 5. Sentence entropy; 6. LDA. The accuracy on test set is 0.632.

Deep Learning methods

DAN and textCNN with fastText embedding

I first used pre-trained embedding fastText (https://fasttext.cc/docs/en/english-vectors.html) to train both Deep Average Network (DAN) and text CNN. The structure of DAN is as follows:

Screenshot

DAN is a bag-of-words neural model. It averages the word embeddings in each input utterance as the utterance representation, then the representation is passed through a series of fully connected layers and a softmax output layer for classification. The loss graph is shown as follows:

Screenshot

DAN with self-trained skip-gram embedding

We also used skip-gram model to train our own embeddings. The following is a visualization for the word vectors. I used T-SNE to visualize these high-dimensional word vectors.

Screenshot

Results

The following table shows the trainning results:

Screenshot

Conclusion and analysis

  1. Deep Learning methods outperform the LR baseline in terms of classification accuracy.
  2. DAN with fastText embedding has the best performance. One biggest characteristic ofmy dataset is that there is too much noise (including the limitation of Alexa’s error handling ability). In this case, DAN’s robustness to noise can result in better performance, as well as its ability in memorizing keywords.
  3. Our DAN with self-trained skip-gram embedding matrix (Fig 5) also outperforms the baseline. This result indicates the potential of our datasets developing to a robust pre-trained word vectors.

Future work

The analysis above proves the feasibility of deploying deep learning methods to conduct voice application evaluation. Based on this, In the future work, a chatbot trained by deep learning methods using the Alexa responses dataset can be deployed to do evaluation.

About the codes and how to run them

sample dataset

I only showed a sample of the Alexa Response Dataset because of future research reasons.

crawler codes

  1. alexacrawler.py is used to run the basic "open-help-stop" loop for each Alexa skill
  2. recognizePossibleCommands.py is used to parse the instruction response.
  3. alexacrawler_withcommands.py is used to run the commands list.

preprocessing

  1. preprocessing.py is used to delete some repeated responses as well as labeling according to topics.

ML baseline

You can try featengr_withtagchunk.py directly using sample_train.csv and sample_test.csv

DAN

Hyperparameters: EPOCHS, BATCH_SIZE, LAYER_SIZES, ACTIVATION_FUNCTION You can try DAN.py directly using sample_train.csv and sample_test.csv

textCNN

Hyperparameters: EPOCHS, BATCH_SIZE, KERNEL_SIZE, DROPOUT, KERNEL_NUM You can try textCNN.py directly using sample_train.csv and sample_test.csv

skip-gram

Hyperparameters: EPOCHS, BATCH_SIZE, WINDOW_SIZE,
You can try skip-gram.py directly using sample_train.csv

References

[1] Guo, Fenfei, Angeliki Metallinou, Chandra Khatri, Anirudh Raju, Anu Venkatesh, and Ashwin Ram. 2018. “Topic-Based Evaluation for Conversational Bots.” arXiv [cs.CL]. arXiv. http://arxiv.org/abs/1801.03622.

[2]Han, Xu, and Tom Yeh. 2019. “Evaluating Voice Applications by User-Aware Design Guidelines Using an Automatic Voice Crawler.” http://ceur-ws.org/Vol-2327/IUI19WS-USER2AGENT-6.pdf.

deep-learning-for-vui's People

Contributors

knights207210 avatar

Watchers

James Cloos avatar  avatar paper2code - bot avatar

Forkers

faikey

deep-learning-for-vui's Issues

Getting Index Error In ML Baseline Code

Hye i,m beginner programmer and learning and exploring this code to learn In ML Baseline section i,m facing Index error:List out of index Plz guide me I didn't change your code still getting index error
I,m attaching Error

IndexError Traceback (most recent call last)
in
3
4 # Train your Logistic Regression classifier
----> 5 feat.train_model(random_state=1230)
6
7 # Shows the top 10 features for each class

in train_model(self, random_state)
309 dfTrain = pd.read_csv("sample_train.csv")
310 # get training features and labels
--> 311 self.X_train = self.build_train_features([list(dfTrain["response"])])
312 self.y_train = np.array(dfTrain["label"], dtype=int)
313

in build_train_features(self, examples)
275 self.vectorizer_t.fit_transform(examples[0])
276 self.feature_names = np.asarray(self.vectorizer_t.get_feature_names())
--> 277 return self.vectorizer.fit_transform(examples)
278
279 def get_test_features(self, examples):

~\Anaconda3\lib\site-packages\sklearn\pipeline.py in fit_transform(self, X, y, **fit_params)
934 sum of n_components (output dimension) over transformers.
935 """
--> 936 results = self._parallel_func(X, y, fit_params, _fit_transform_one)
937 if not results:
938 # All transformers are None

~\Anaconda3\lib\site-packages\sklearn\pipeline.py in _parallel_func(self, X, y, fit_params, func)
964 message=self._log_message(name, idx, len(transformers)),
965 **fit_params) for idx, (name, transformer,
--> 966 weight) in enumerate(transformers, 1))
967
968 def transform(self, X):

~\Anaconda3\lib\site-packages\joblib\parallel.py in call(self, iterable)
922 self._iterating = self._original_iterator is not None
923
--> 924 while self.dispatch_one_batch(iterator):
925 pass
926

~\Anaconda3\lib\site-packages\joblib\parallel.py in dispatch_one_batch(self, iterator)
757 return False
758 else:
--> 759 self._dispatch(tasks)
760 return True
761

~\Anaconda3\lib\site-packages\joblib\parallel.py in _dispatch(self, batch)
714 with self._lock:
715 job_idx = len(self._jobs)
--> 716 job = self._backend.apply_async(batch, callback=cb)
717 # A job can complete so quickly than its callback is
718 # called before we get here, causing self._jobs to

~\Anaconda3\lib\site-packages\joblib_parallel_backends.py in apply_async(self, func, callback)
180 def apply_async(self, func, callback=None):
181 """Schedule a func to be run"""
--> 182 result = ImmediateResult(func)
183 if callback:
184 callback(result)

~\Anaconda3\lib\site-packages\joblib_parallel_backends.py in init(self, batch)
547 # Don't delay the application, to avoid keeping the input
548 # arguments in memory
--> 549 self.results = batch()
550
551 def get(self):

~\Anaconda3\lib\site-packages\joblib\parallel.py in call(self)
223 with parallel_backend(self._backend, n_jobs=self._n_jobs):
224 return [func(*args, **kwargs)
--> 225 for func, args, kwargs in self.items]
226
227 def len(self):

~\Anaconda3\lib\site-packages\joblib\parallel.py in (.0)
223 with parallel_backend(self._backend, n_jobs=self._n_jobs):
224 return [func(*args, **kwargs)
--> 225 for func, args, kwargs in self.items]
226
227 def len(self):

~\Anaconda3\lib\site-packages\sklearn\pipeline.py in _fit_transform_one(transformer, X, y, weight, message_clsname, message, **fit_params)
726 with _print_elapsed_time(message_clsname, message):
727 if hasattr(transformer, 'fit_transform'):
--> 728 res = transformer.fit_transform(X, y, **fit_params)
729 else:
730 res = transformer.fit(X, y, **fit_params).transform(X)

~\Anaconda3\lib\site-packages\sklearn\pipeline.py in fit_transform(self, X, y, **fit_params)
383 """
384 last_step = self._final_estimator
--> 385 Xt, fit_params = self._fit(X, y, **fit_params)
386 with _print_elapsed_time('Pipeline',
387 self._log_message(len(self.steps) - 1)):

~\Anaconda3\lib\site-packages\sklearn\pipeline.py in _fit(self, X, y, **fit_params)
313 message_clsname='Pipeline',
314 message=self._log_message(step_idx),
--> 315 **fit_params_steps[name])
316 # Replace the transformer of the step with the fitted
317 # transformer. This is necessary when loading the transformer

~\Anaconda3\lib\site-packages\joblib\memory.py in call(self, *args, **kwargs)
353
354 def call(self, *args, **kwargs):
--> 355 return self.func(*args, **kwargs)
356
357 def call_and_shelve(self, *args, **kwargs):

~\Anaconda3\lib\site-packages\sklearn\pipeline.py in _fit_transform_one(transformer, X, y, weight, message_clsname, message, **fit_params)
726 with _print_elapsed_time(message_clsname, message):
727 if hasattr(transformer, 'fit_transform'):
--> 728 res = transformer.fit_transform(X, y, **fit_params)
729 else:
730 res = transformer.fit(X, y, **fit_params).transform(X)

~\Anaconda3\lib\site-packages\sklearn\base.py in fit_transform(self, X, y, **fit_params)
569 if y is None:
570 # fit method of arity 1 (unsupervised transformation)
--> 571 return self.fit(X, **fit_params).transform(X)
572 else:
573 # fit method of arity 2 (supervised transformation)

~\Anaconda3\lib\site-packages\sklearn\preprocessing_function_transformer.py in transform(self, X)
139 Transformed input.
140 """
--> 141 return self._transform(X, func=self.func, kw_args=self.kw_args)
142
143 def inverse_transform(self, X):

~\Anaconda3\lib\site-packages\sklearn\preprocessing_function_transformer.py in _transform(self, X, func, kw_args)
163 func = _identity
164
--> 165 return func(X, **(kw_args if kw_args else {}))
166
167 def _more_tags(self):

in (x)
245 ('tfid', TfidfVectorizer(analyzer='word',ngram_range=(1,2), lowercase=True, norm='l2',stop_words='english'))])),
246 ('type of page',
--> 247 Pipeline([('extract_field', FunctionTransformer(lambda x: x[2], validate = False)),
248 ('page', CountVectorizer())])),
249 ('type of trope',

IndexError: list index out of range

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.