Contribute Media
A thank you to everyone who makes this possible: Read More

Creating AI chat bot with Python 3 and TensorFlow

Description

발표자: 신정규 ( Jeongkyu Shin ) 슬라이드: https://speakerdeck.com/inureyes/building-ai-chat-bot-using-python-3-and-tensorflow

Recently, chat bot has become the center of public attention as a new mobile user interface since 2015. Chat bots are widely used to reduce human-to-human interaction, from consultation to online shopping and negotiation, and still expanding the application coverage. Also, chat bot is the basic of conversational interface and non-physical input interface with combination of voice recognition.

Traditional chat bots were developed based on the natural language processing (NLP) and bayesian statistics for user intention recognition and template-based response. However, since 2012, accelerated advance in deep-learning technology and NLPs using deep-learning opened the possibilities to create chat bots with machine learning. Machine learning (ML)-based chat bot development has advantages, for instance, ML-based bots can generate (somewhat non-sense but acceptable) responses to random asks that has no connection with the context once the model is constructed with appropriate learning level.

In this talk, I will introduce the garage chat bot creation process step-by-step. First, get the data and preprocess it with Python 3 and pandas. Also, data is modified to more trainable form. With preprocessed data, design the deep learning model with TensorFlow which is suitable for sentence-type input / output and train it. After training, serve the model with messenger interface created by using telegram API and Python 3, and demonstrate the result.

In the process, we have to solve several problems. First is the preprocessing the Korean sentences with natural language processors, and tokenizing the sentences with proper length and types. Also, we have to solve the ‘josa (postpositions in Korean) hell” and conjunction problems to construct TensorFlow model. In addition to preprocessing, model architecture to recognize the conversational context is also needed. To serve bot with Python HTTP server and telegram API, some points demand deliberation. I’ll share my multi-modal bot model idea, implementation and tips to solve these problems.

(Korean)

chat bot은 2015년부터 모바일을 중심으로 새로운 사용자 UI로 주목받고 있다. 챗 봇은 상담시 인간-인간 인터랙션을 줄이는 용도부터 온라인 쇼핑 구매에 이르기까지 다양한 분야에 활용되고 있으며 그 범위를 넓혀 나가고 있다. 챗 봇은 대화형 인터페이스의 기초이면서 동시에 (음성 인식과 결합을 통한) 무입력 방식 인터페이스의 기반 기술이기도 하다.

기존의 챗 봇들은 자연어 분석과 베이지안 통계에 기반한 사용자 의도 패턴 인식과 그에 따른 템플릿 응답을 기본 원리로 하여 개발되었다. 그러나 2012년 이후 급속도로 발전한 딥러닝 및 그에 기초한 자연어 인식 기술은 기계 학습을 이용해 챗 봇을 만들 수 있는 가능성을 열었다. 기계학습을 통해 챗 봇을 개발할 경우, 충분한 학습도의 모델을 구축한 후에는 학습 데이터에 따라 컨텍스트에서 벗어난 임의의 문장 입력에 대해서도 적당한 답을 생성할 수 있다는 장점이 있다.

이 발표에서는 Python 3 를 이용하여 실제 사용할 수 있는 챗 봇을 만드는 과정을 단계별로 진행한다. 우선 데이터를 구한 후 Python 3 와 Pandas를 사용하여 데이터를 전처리한다. 이렇게 전처리한 데이터를 학습에 적당한 형태로 재가공한다. 그 후 컴퓨터에 TensorFlow의 python 3 패키지를 설치한다. 이후 TensorFlow 를 이용하여 문장형 입출력에 적절한 딥러닝 모델을 설계한 후, 앞에서 전처리한 데이터를 이용하여 학습시킨 모델을 만든다. 이렇게 만든 모델을 telegram API 를 이용해 인터페이스를 만든 후, telegram에 봇을 친구로 등록하여 대화를 시연한다.

이 과정에서 여러 문제들을 해결해야 한다. 우선 한국어 자연어 처리를 위해 데이터를 적절히 전처리하는 과정과, 모델 학습을 위해 문장의 길이 및 형태를 적절히 토크나이징하는 과정이 필요하다. 그 다음 Tensorflow 로 모델을 설계하고 딥러닝 모델로 학습하는 단계에서 장애가 되는 조사 및 접속사 처리, 오타 처리등의 문제를 해결해야 한다. 또한 연속 대화 구현을 위하여 문장 단위의 입출력이 아니라 컨텍스트를 인식하기 위한 모델 설계 또한 필요하다. 학습한 결과를 파이썬 HTTP 서버 및 telegram API를 이용해 서빙하는 부분에서 몇가지 고려할 부분들도 있다. 이러한 부분들에 대한 아이디어 및 구현과 팁을 공유하고자 한다.

Improve this page