반응형

How to Make a Chatbot - Intro to Deep Learning #12



Code + Challenge for this video:
https://github.com/llSourcell/How_to_...

Nemanja's Winning Code:
https://github.com/Nemzy/language-tra...

Vishal's Runner up code:
https://github.com/erilyth/DeepLearni...

Web app to run the code yourself:
https://ethancaballero.pythonanywhere...

Please subscribe! And like. And comment. That's what keeps me going. 

More Learning resources:
https://www.youtube.com/watch?v=FCtpH...
https://www.youtube.com/watch?v=Qf0Bq...
https://yerevann.github.io/2016/02/05...
https://www.youtube.com/watch?v=2A5DK...
http://www.wildml.com/2016/01/attenti...
https://github.com/domluna/memn2n




...

반응형
반응형

[R] R 교육 블로그 http://blog.naver.com/tjdudwo93


http://blog.naver.com/tjdudwo93/220978385006 취지가 좋아요~ 



통계분석, 랜덤 포레스트


R 프로그래밍 언어(줄여서 R)는 통계 계산과 그래픽을 위한 프로그래밍 언어이자 소프트웨어 환경이다. 뉴질랜드 오클랜드 대학의 로버트 젠틀맨(Robert Gentleman)과 로스 이하카(Ross Ihaka)에 의해 시작되어 현재는 R 코어 팀이 개발하고 있다. R은 GPL 하에 배포되는 S 프로그래밍 언어의 구현으로 GNU S라고도 한다. R은 통계 소프트웨어 개발과 자료 분석에 널리 사용되고 있으며, 패키지 개발이 용이하여 통계학자들 사이에서 통계 소프트웨어 개발에 많이 쓰이고 있다.




R 프로젝트 페이지 : https://www.r-project.org/




...

반응형
반응형

[ChatBot] ChatScript 설명.




챗봇 데모 : http://ec2-54-215-197-164.us-west-1.compute.amazonaws.com/speech.php


Github chatscript manual : https://github.com/bwilcox-1234/ChatScript/blob/master/WIKI/ChatScript-Basic-User-Manual.md


ChatScript (CS)는 사용자 텍스트 입력을 받아들이고 텍스트 응답을 생성하도록 설계된 스크립팅 언어입니다.

채팅은 테니스처럼 발리슛으로 진행됩니다 프로그램 은 사용자로부터 하나 이상의 문장 을 입력하고 하나 이상의 문장을 다시 출력합니다.

가장 일반적으로 사용하는 방법은 사용자 가 입력을 받아 응답을 출력하는 프로그램 인 대화 표시 입니다. 그것은 당신과 대화합니다. 그러나 나는 문서 를 읽는 데에만 전념하는 챠트 봇 (chatbot)을 만들었다 이 경우 입력은 전체 문서입니다.

생성되는 출력은 프로그램에 달려 있습니다. 내 프로그램은 목차, 각 장 경계 및 뒤의 색인이있는 위치를 찾도록 설계되었습니다.

그래서, 더 광범위하게, ChatScript는 chatbot을 만드는 것뿐만 아니라 자연어를 조작하기위한 시스템입니다 .

이 문서는 스크립트를 작성하는 방법에 대한 것입니다. 문서에서 Writing a Chatbot 문서에서 봇을 저작하는 것에 대해 생각하는 방법에 대한 좀 더 일반적인 논의 가 있습니다.

반응형
반응형

[ChatScript] ChatScript 에제 따라하기 삽질 중 . 


K-POP 소재로 챗봇 개발하기    다라하는데 오류발생. 삽질 중 . 구글링에도 잘 안나옴. 

그런데, 굉장히 단순한 문제였음. 

 

unknown top-level declaration tablemacro~~~~ 였는데,  구글링에도 답이 없음. 


하다하다 궁극의 코딩 정리를 다시 해보니.

Tablemacro:^NounPlusPP(~~~) 였는데, 

Tablemacro: ^NounPlusPP(~~~) 이렇게 바꾸니 오류 발생 안함. 이건 뭐냐고...?!


그렇게 투애니원의 안부를 chatscript에게 물어볼수 있었다. 









...

반응형
반응형

[ChatScript] ChatScript 에서 Harry를 Dorothy로 바꾸고, 한글인사하기 - 웹으로


로컬에 APM 설치하고, 127.0.0.1/testbot.php 를 실행해보았다. 

그런데, chatscript에 보니까 이미 서버를 구현하는게 있던걸. 이런...



ChatScript port=1024 userlog  이렇게 하면 된다는걸~ 


서버측을 실행히켰는데 어떤 입력도 CMD에선 적용이 안됨. 


"I don't know what to say." 만 난발하고. 


암튼 어떻게 할지 모르다가, 웹 대화창에 입력한데로 챗봇이 실행되는걸 보고 입력창에 빌드명령어 다시 넣고.  빌드 한번 더 해보니 한글 답변을 볼 수 있었음. 


이제 첫번째 콘솔창에서 :build Dorothy reset을 실행하고, 컴파일이 끝나면 수정한 내용을 반영할 수 있도록 CS서버를 새로 기동시킨다. CS서버를 새로 기동시키기 위해서는 웹브라우저의 메시지 창에 :restart를 입력하고 send 함으로써 가능하다.

여기서 메시지 창을 통해 명령어를 전송할 수 있다는 점에 의아해 할 수 있는데, 이는 테스트 하는 동안의 편의를 위한 것이고 테스트가 끝난 후에는 메시지 창을 통한 명령어의 전송을  차단하거나 미리 등록한 사용자만 가능하도록 바꿀 수 있다. 현재는 모두에게 허락되어 있는데 등록한 사용자에게만 가능하도록 하겠다면 다음과 같이 수정하면 된다.

 

l  수정할 파일 : chatscript/authorizedIP.txt

l  현재 내용 : all

l  수정할 내용 : L_t8e3s7t8

 

수정할 내용에는 대문자 L_로 시작하여 뒤에 사용자 이름을 적으면 되는데, 쉽게 추측할 수 없는 사용자 이름을 쓰는 것이 좋을 것이다. 위와 같이 적었다면 브라우저로 로그인하는 ID가 t8e3s7t8일 경우에만 메시지 창의 명령어를 서버에 전송할 수 있다. 이제 다시 돌아와서 시스템이 restart를 하면, 곧이어 :reset 명령을 준다.



반응형
반응형

랜덤 포레스트



기계 학습에서의 랜덤 포레스트(영어: random forest)는 분류회귀 분석 등에 사용되는 앙상블 학습 방법의 일종으로, 훈련 과정에서 구성한 다수의 결정 트리로부터 부류(분류) 또는 평균 예측치(회귀 분석)를 출력함으로써 동작한다.



정의

랜덤 포레스트는 여러 개의 결정 트리들을 임의적으로 학습하는 방식의 앙상블 방법이다. 랜덤 포레스트 방법은 크게 다수의 결정 트리를 구성하는 학습 단계와 입력 벡터가 들어왔을 때, 분류하거나 예측하는 테스트 단계로 구성되어있다. 랜덤 포레스트는 검출, 분류, 그리고 회귀 등 다양한 애플리케이션으로 활용되고 있다.

역사

랜덤 포레스트의 초기 발전은 단일 트리를 확장하는 맥락에서 이용 가능한 결정(available decisions)에 대한 임의의 부분집합(random subset)에 대해 검색하는 아이디어를 도입한 얄리 아미트(Yali Amit)와 도널드 게먼(Donald Geman)의 연구[1]에 영향을 받았다. 또한 임의의 부분공간(random subspace)을 선택하는 틴 캄 호(Tin Kam Ho)의 아이디어[2] 역시 랜덤 포레스트의 디자인에 영향을 미쳤다. 포레스트가 성장할 때, 각 트리를 맞추기(fitting) 전에 임의로 선택한 부분공간으로 훈련 데이터를 투영(projection) 시키는 과정에서 트리 사이에 변형이 일어난다.

현재의 랜덤 포레스트의 개념은 레오 브레이먼(Leo Breiman)의 논문[3]에서 만들어졌다. 이 논문에서는 임의 노드 최적화(randomized node optimization, RNO)와 배깅(bootstrap aggregating, bagging)을 결합한 방법과 같은 CART(classification and regression tree)를 사용해 상관관계가 없는 트리들로 포레스트를 구성하는 방법을 제시하였다.

동기

일반적으로 결정 트리를 이용한 방법의 경우, 그 결과 또는 성능의 변동 폭이 크다는 결점을 가지고 있다. 특히 학습 데이터에 따라 생성되는 결정 트리가 매우 달라지기 때문에 일반화하여 사용하기에 매우 어려움이 따른다. 특히, 결정 트리는 계층적 접근방식이기 때문에 만약 중간에 에러가 발생한다면 다음 단계로 에러가 계속 전파되는 특성을 가진다. 배깅(Bagging) 또는 임의 노드 최적화(Randomized node optimization)와 같은 임의화 기술은 결정 트리가 가진 이러한 단점을 극복하고 좋은 일반화 성능을 갖도록 한다.

기여

  • 월등히 높은 정확성
  • 간편하고 빠른 학습 및 테스트 알고리즘
  • 변수소거 없이 수천 개의 입력 변수들을 다루는 것이 가능
  • 임의화를 통한 좋은 일반화 성능
  • 다중 클래스 알고리즘 특성


반응형
반응형

[ChatScript] ChatScript 에서 Harry를 Dorothy로 바꾸고, 한글인사하기 


참고 : http://exagen.tistory.com/45


맥에선 설치가 안되고, 윈도우에서 잘되네. 이런. ComEmu는 원래 써오던거라 최신으로 업데이트 한번.


참고 글에서의 설명과 달리 버전이 변경되었는지 일단 느낌적으로 해봄. 


/RAWDATA/에 도로시를 Harry 카피해서 만든다. 

그리고, RAWDATA에 filesHarry.txt를 카피해서 filesDorothy.txt를 만든다. 

filesDorothy에서 RAWDATA/QUIBBLE/은 삭제. 삭제권고하셔서 삭제. 근데 build하면 왜 연결안하냐고 경고 나옴. 


CMD에서 >chatscript 실행. 

그리고, 빌드 >:build Dorothy

뭔가 안되서 보니 filesDorothy.txt 에  엉뚱한 내용이 있음. 


#underlying conversation system

RAWDATA/Dorothy/


위의 폴더 경로만 txt 파일에 들어있으면됨. 


다시 빌드하니 도로시가 인사를 한다. "Hi"  


"what is your name?" 이라고 하니까 "내 이름은  도로시에요." 라고 나온다. 

근데, 또 물어보면 딴 얘기함. 

그럴땐 리셋!!!


> :build Dorothy reset


introduction.top에서 영어를 국문으로 바꾸면 한국말 한다. ㅋㅋㅋ





...

반응형
반응형

[ChatScript] ChatScript - https://github.com/bwilcox-1234/ChatScript


Natural Language tool/dialog manager


ChatScript

Natural Language tool/dialog manager

ChatScript is the next generation chatbot engine that has won the Loebner's 4 times and is the basis for natural language company for a variety of tech startups.

ChatScript is a rule-based engine, where rules are created by humans writers in program scripts through a process called dialog flow scripting. These use a scripting metalanguage (simply called a "script") as their source code. Here what a ChatScript script file looks like:

#
# file: food.top
#
topic: ~food []

#! I like spinach
s: ( I like spinach ) Are you a fan of the Popeye cartoons?
	
	a: ( ~yes )  I used to watch him as a child. Did you lust after Olive Oyl?
    	    b: ( ~no ) Me neither. She was too skinny.
    	    b: ( yes ) You probably like skinny models.
	
	a: ( ~no ) What cartoons do you watch?
     		b: ( none ) You lead a deprived life.
     		b: ( Mickey Mouse ) The Disney icon.

#! I often eat chicken
u: ( ![ not never rarely ] I * ~ingest * ~meat ) You eat meat.

#! I really love chicken
u: ( !~negativeWords I * ~like * ~meat ) You like meat.

#! do you eat bacon?
?: ( do you eat _ [ ham eggs bacon] ) I eat '_0

#! do you like eggs or sushi?
?: ( do you like _* or _* ) I don't like '_0 so I guess that means I prefer '_1.

#! I adore kiwi.
s: ( ~like ~fruit ![~animal _bear] )  Vegan, you too...

#! do you eat steak?
?: ( do you eat _~meat ) No, I hate _0.

#! I eat fish.
s: ( I eat _*1 > ) 
  $food = '_0 
  I eat oysters.

Above example mentioned in article How to build your first chatbot using ChatScript.

Basic Features

  • Powerful pattern matching aimed at detecting meaning.
  • Simple rule layout combined with C-style general scripting.
  • Built-in WordNet dictionary for ontology and spell-checking.
  • Extensive extensible ontology of nouns, verbs, adjectives, adverbs.
  • Data as fact triples enables inferencing and supports JSON representation.
  • Rules can examine and alter engine and script behavior.
  • Planner capabilities allow a bot to act in real/virtual worlds.
  • Remembers user interactions across conversations.
  • Document mode allows you to scan documents for content.
  • Ability to control local machines via popen/tcpopen/jsonopen.
  • Ability to read structured JSON data from websites.
  • Postgres and Mongo databases support for big data or large-user-volume chatbots.

OS Features

  • Runs on Windows or Linux or Mac or iOS or Android
  • Fast server performance supports a thousand simultaneous users.
  • Multiple bots can cohabit on the same server.

Support Features

  • Mature technology in use by various parties around the world.
  • Integrated tools to support maintaining and testing large systems.
  • UTF8 support allows scripts written in any language
  • User support forum on chatbots.org
  • Issues or bugs on this repo

Getting started

Installation

Take this project and put it into some directory on your machine (typically we call the directory ChatScript, but you can name it whatever). That takes care of installation.

git clone https://github.com/bwilcox-1234/ChatScript

Standalone mode - run locally on a console (for developement/test)

From your ChatScript home directory, go to the BINARIES directory:

cd BINARIES

And run the ChatScript engine

Windows

ChatScript

Linux

./LinuxChatScript64 local

Note: to set the file executable: chmod a+x ./LinuxChatScript64

MacOS

./MacChatScript local

This will cause ChatScript to load and ask you for a username. Enter whatever you want. You are then talking to the default demo bot Harry.

Server Mode (for production)

From your ChatScript home directory, go to the BINARIES directory and run the ChatScript engine as server

Run the server on Windows

ChatScript port=1024

Run the server on Linux

./LinuxChatScript64

Run the server on MacOS

./MacChatScript

This will cause ChatScript to load as a server.
But you also need a client (to test client-server communication). You can run a separate command window and go to the BINARIES directory and type

Run a client (test) on Windows

ChatScript client=localhost:1024 

Run a client (test) on Linux

./LinuxChatScript64 client=localhost:1024

Run a client (test) on MacOS

./MacChatScript client=localhost:1024

This will cause ChatScript to load as a client and you can talk to the server.

How to build a bot

Run ChatScript locally. From the ChatScript command prompt, type

:build Harry

or whatever other preinstalled bot exists. If you have revised basic data, you can first:

:build 0

How to compile the engine.

On windows if you have Visual Studio installed, launch VS2010/chatscript.sln or VS2015/chatscript.sln and do a build. The result will go in the BINARIES directory.

On Linux, go stand in the SRC directory and type make server (assuming you have make and g++ installed). This creates BINARIES/ChatScript, which can run as a server or locally. There are other make choices for installing PostGres or Mongo.

Full Documentation

ChatScript Wiki (user guides, tutorials, papers)

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Last releases

changes.md

Author


반응형

+ Recent posts