一種基於神經網絡的對話模型

摘要

   對話模型在自然語言理解和機器智能方面是一個非常重要的任務。儘管之前已經有一些方法,但是他們受限於特定的領域(比如:預定機票)而且需要手動指定規則。在這篇文章中,我們針對這個任務展現了一種簡單的方法,這種方法使用最近被提出的sequece to sequece 框架。我們的模型通過給定之前的對話中的句子來預測下一個句子的方式進行交談。我們模型的有點就是它可以進行端到端的訓練,因此需要風少的手動指定規則。我們發現這個直接的模型可以通過一個大量的基於對話的訓練數據集生成簡單的對話。我們的初步結果指出,儘管優化了錯誤的目標函數,但是模型仍然運行的很好。它能從某個特定領域數據集和一個大量的包含噪音的電字母一般性數據集中抽取知識。在一個特定領域的IT幫助臺數據集中,模型可以衝過對話找出解決耨一個技術問題的方案。通過一個包含噪音的開放性的電影劇本數據集中,該模型可以執行簡單的形式的常識推理。正如期望的一樣,我們也發現了我們的模型一種常見的失敗模式-缺乏連貫性。
   
一、引言

   神經網絡的端到端訓練的進展在許多領域都得到了顯著的進展,如方言識別,計算機視覺和語言來處理。最近的工作表明,神經網絡可以做的不僅僅是單純的分類,他們可以用來映射覆雜的其他複雜結構的結構。舉個例子,有一個將一個序列映射成另一個序列的任務,這種任務在自然語言理解方面有直接的應用。這個框架的主要優點是,他需要很少的特徵工程和領域特徵,同時匹配或超越了國家的先進成果。這種進步,在我們看來,允許研究人員所工作的領域的任務涉及的知識可能不是現成的,或針對任務很難設計手動規則。對話模型可以直接受益於這一提法因爲它需要查詢和查詢之間的映射關係響應。由於這種影響的複雜性,設計會話模型都是在非常狹窄的領域,在特徵工程方面也需要有所保證。我們採用對話模型試驗的目的就是採用遞歸神經網絡,通過給定序列預測下一序列。我們發現這種方法在產生流利和準確的對話的答覆方面可以做得很好。
   我們在一個IT幫助臺的對話數據集的聊天會話上測試模型,發現該模型有時可以跟蹤問題並提供一個有用的答案給用戶。我們也從一個嘈雜的電影字幕的數據集的對話中實驗,發現該模型可以有一個自然的對話,有事會執行常識推理的簡單形式。在這兩個案例中,遞歸神經網絡相比n元文法模型,得到更好的困惑度以及捕捉到重要的長範圍相關性。從定性的角度來看,我們的模型有時能夠產生自然的對話。

二、相關研究

   我們的方法是基於最近的研究,該研究提出使用神經網絡將一個序列映射到另一個序列。這個框架已經在神經機器翻譯得到應用以及在沃爾瑪14年數據集上進行應發和英德翻譯任務方面得到提高。它也被用於其他任務,如圖像解析和圖像字幕。衆所周知,普通Rnn網絡容易造成梯度消失,大多數研究人員使用長的變體短期記憶(LSTM)遞歸神經網絡(霍克賴特和所說的,1997)。
   我們的工作也受到基於神經網絡的語言模型的成功的啓發,它表明神經網絡是自言語言的一種相當有效的模型。最近,索爾多尼和Shang等人應用遞歸神經網絡到剪短的對話模型上。
   建造機器人和對話代理一直是許多研究人員在過去幾十年裏的追求,本文不再提供詳細的參考列表。然而,大多數這些系統需要一個相當複雜的有許多階段構成的處理管道。我們的工作不同於傳統的系統。它提出一個終端到終端的方法來解決這個問題,不需要領域知識。原則上,它可以結合其他系統,重新評定候選回答的短列表,但我們的工作是基於生成的答案給定一個概率模型進行訓練,以最大限度地給出了基於一些上下文的答案的概率。

三、模型

   我們的方法使用序列到序列(seq2)框架所描述的。該模型是基於一個遞歸神經網絡,一次讀取一個輸入序列,並預測輸出序列。在訓練過程中,真正的輸出序列由模型給出,所以可以通過反向傳播學習模型。模型訓練是爲了最大限度的提高由上下文提供的正確的序列的交叉熵。在推理過程中,給定的真正的輸出序列並沒有看到,而是簡單的將預測的輸出作爲輸入來預測下一個輸出。這是一種貪婪的推導方法。一種不那麼貪婪的方法時使用波束搜索,並在以前的過程中得到幾個候選方案傳給下一步。這種預測的序列可以是基於概率選擇的。
   
   集體來講,假設我們觀察到一個兩輪對話,第一個人說:”ABC”,第二個人說:“WXYZ”。我們可以使用一個遞歸神經網絡,如上圖1所示,訓練將”ABC”映射到“WXYZ”,當它接收到的模型的隱藏狀態序列結束符號“< EOS >”可以看作是結束。
   該模型的有點在於它的簡單性和通用性。我們可以應用這個模型在機器翻譯,QA問答系統,和沒有重大改變的對話中。將這種技術應用到會話建模也非常簡單:簡單的序列可以是由到目前爲止的上下文轉換得到的一系列序列,輸出序列則是答覆。
   不同於翻譯這樣簡單的任務,一個像sequece to sequece這樣的模型將無法成功解決建模對話的問題,因爲一個明顯的簡化:目標函數優化不捕獲通過人類溝通得到的實際目標實現,這是典型的長期的基於信息交換的而不是基於下一步預測。一個模型缺乏一致性和一般的世界知識是另一個明顯的純粹的無監督模型的侷限性。

四、數據集

   在我們的試驗中採用兩類數據集:一個封閉的IT幫助臺故障修復數據集和一個開放的電影抄本數據集。這兩部分數據集的細節如下:
   
4.1 IT幫助臺故障修復數據集

   在我們的第一組試驗中,我們使用了一個從IT故障排除聊天服務中獲取的數據集,在這個服務中,消費者面對電腦相關的問題,一個專家通過交談和提出解決方案幫助他們解決問題。典型的相互作用(或線程)是400個單詞長度,並且輪流作用是明確的信號。我們的訓練數據集是30M令牌,3M被用作驗證。進行了一定量的數據清洗,如刪除共同的名稱、數字和完整的網址。
   
4.2 開放電影字幕數據集

   我們還在開發的電影字幕數據集上測試了我們的模型。該數據集包含XML格式的電影對話。它包含電影中人物所說的話。我們使用簡單的處理步驟刪除XML標籤和明顯的非會話文本(例如:超鏈接)數據集。由於輪流說話沒有明確表示,我們將連續的句子看做是不同的角色的人說的。我們基於上一句來訓練模型來預測下一句,我們針對每一句都這麼做(注意到這是我們數據集的一杯並且每一個機組都用於上下文和目標)。我們的訓練集和驗證集是分開的,訓練集樣本是62M的序列(923令牌),驗證集26M(395M 令牌)。這樣分割是爲了似的一組序列要麼出現在訓練集中,要麼出現在測試集中但不是同時出現。不想之前的數據集,該opensubtitles是相當大的和嘈雜的,因爲連續的句子有可能是同一個任務所說。給定廣泛的電影,和技術故障排除數據集相比,這是一個開放域的會話數據集。

五、實驗
   
   在這一節中,我們描述了基於兩個數據集的試驗結果,並顯示了一些我們訓練的系統給出的相互作用的樣本。我們使用一組200個問題的評價數據集,將我們的系統的性能和一個流行的以規則爲基礎的的Bot做了比較。
   
5.1 IT故障排除實驗

   在這個實驗中,我們使用了一個簡單的LSTM層,使用1024個單元,採用梯度下降法。詞彙是最常見的20K個,包含特殊標記指示輪流說話和角色。
   在收斂時,該模型實現了困惑度爲8,而一個N-gram模型達到了18.下面是幾個樣本,模擬最多三個故障排除會話(遠程訪問,軟件崩潰,和密碼問題)。這這些談話中,機器是我們的神經會話模型,人類擔任和它對話的角色。
   
Conversation 1: VPN issues

   描述你的問題: i am having issues accessing vpn
   Machine: hi
   Human: hello
   Machine: could you please let me know what are the operating systems you are using ?
   Human: i am using linux
   Machine: ok it was in the ssl vpn on which you stated it was broken
   Machine: please check if you are logged in to corp network
   Machine: what is the error that you are running please
   Human: i am seeing an error related to vpn
   Machine: what is the error message that you are getting when connecting to vpn using network connect ?
   Human: connection refused or something like that
   Machine: may i know the version of network connect you connect ?
   Human: i am not sure i know that
   Machine: is the network connect prompting for any user certificate
   Machine: ?
   Human: yes
   Machine: are you at home or at work at the moment ?
   Machine: office ?
   Human: i am at home
   Machine: try this
   Machine: goto page and enter your name and password
   Human: done
   Machine: try logging in with and check if its working fine now
   Human: yes , now it works !
   Machine: great
   Machine: anything else that i can help
   Human: no , that was very useful
   Machine: you are other than : )
   Machine: have a nice night
   
Conversation 2: Browser issues.

   Describe your problem: browser keeps crashing
   Machine: hi
   Human: hi
   Machine: could you please let me know what is
   the operating system you are using ?
   Human: linux
   Machine: ok this is the issue with the system performance , nasser , tools .
   Human: what is that ?
   Machine: is it a windows machine ?
   Machine: we have linux on your machine .
   Machine: is it windows xp or windows 7 ?
   Human: i am using linux
   Machine: let me take a remote of your machine and check if issue has been pushed properly .
   Human: ok
   Machine: please open terminal and run the below commands in one computer :
   Machine: sudo apt - get update
   Machine: sudo apt - get upgrade
   Machine: sudo - updater
   Human: done
   Machine: let me try connecting now
   Human: ok
   Machine: its done
   Machine: should use the second or hit run on
   the background
   Human: done
   Machine: try signing out now and follow the
   prompts as per the message given above
   Machine: shd i reboot the machine .
   Human: ok , please go ahead
   Machine: once its completed please try to login
   .
   Human: sure
   Machine: please ping me back once you have tried to login
   Machine: are we still connected
   Human: i now logged in
   Machine: thanks for your confirmation
   Human: what should i do now ?
   Machine: wait for 1 5 minutes to complete the login policy
   Machine: and then try logging in
   Human: ok
   Machine: is there anything else to help you ?
   Human: let my try browsing a little bit and if it keeps crashing i will let you know
   Machine: sure will do
   Machine: seems the mail is not loading
   Machine: are we still connected to the chat ?
   Machine:
   Human: it seems good now , cool , thank you ,bye
   Machine: you , too
   Machine: bye
   
   
Conversation 3: Password issues

Describe your problem: i forgot my password

   Machine: hi , this is from helpdesk connect , what can i help you with today ?
   Human: hi , i forgot my password
   Machine: ok great
   Human: can you tell me how i can recover it ?
   Machine: i ’ ll need to verify who it is at that machine
   Machine: can we do a hangout
   Machine: ?
   Human: yes
   Machine:
   Human: cool , i am good now
   Machine: how ‘s this looking good ?
   Machine: i ‘ll go ahead and close this chat .
   Machine: take care . : )
   Human: bye
   Machine: bye .

5.2 開放電影字幕數據集實驗
   
   在這個實驗中我們使用一個兩層的LSTM,使用adaGrad進行梯度剪裁。每一層的LSTM有4096個記憶單元,我們使用最常見的100K個單詞建立詞彙。爲了加快softMax過程,,在到達最終的分類器之前,先將及一單元信息發射給2048個線性單元。
   在收斂時,該遞歸模型得到的困惑度爲17,我們的平滑5-gram模型實現了28的困惑度。有趣的是,添加soft attention 機制並沒有顯著提升訓練集或校驗集的困惑度。

5.2.1 模型樣本
   
   除了採用困惑度度量的方式,我們的遞歸模型也經常產生似是而非的答案。在這裏我們給出一些樣本問答對,使我們能夠理解模型在訓練包含噪音且大量的來自電影開放性字幕數據集時的能力。再次,這這些談話中,機器是我們的神經會話模型,人類擔任和它對話的角色。
   
Conversation 1: Basic

   Human: hello !
   Machine: hello !
   Human: how are you ?
   Machine: i ’m good .
   Human: what ’s your name ?
   Machine: i ’m julia .
   Human: when were you born ?
   Machine: july 20th .
   Human: what year were you born ?
   Machine: 1977 .
   Human: where are you from ?
   Machine: i ’m out in the boonies.
   Human: are you a man or a woman ?
   Machine: i ’m a woman .
   Human: why are we here ?
   Machine: i ’m not sure .
   Human: okay, bye !
   Machine: bye .
   Human: see you later .
   Machine: bye .
   
Conversation 2: Simple Q&A (contexts and multiple
choice)

   Human: my name is david . what is my name ?
   Machine: david .
   Human: my name is john . what is my name ?
   Machine: john .
   Human: are you a leader or a follower ?
   Machine: i ’m a leader .
   Human: are you a follower or a leader ?
   Machine: i ’m a leader .
   
Conversation 3: General knowledge Q&A

   Human: who is skywalker ?
   Machine: he is a hero .
   Human: who is bill clinton ?
   Machine: he ’s a billionaire .
   Human: is sky blue or black ?
   Machine: blue .
   Human: does a cat have a tail ?
   Machine: yes .
   Human: does a cat have a wing ?
   Machine: no
   Human: can a cat fly ?
   Machine: no .
   Human: how many legs does a cat have ?
   Machine: four , i think .
   Human: how many legs does a spider have ?
   Machine: three , i think .
   Human: how many legs does a centipede have ?
   Machine: eight .
   Human: what is the color of the sky ?
   Machine: blue .
   Human: what is the color of water ?
   Machine: water .
   Human: what is the color of blood ?
   Machine: it is the same as a black eye .
   Human: what is the usual color of a leaf ?
   Machine: it is a green one .
   Human: what is the color of a yellow car ?
   Machine: yellow .
   Human: how much is two plus two ?
   Machine: four .
   Human: how much is ten minus two ?
   Machine: seventy - two .
   
Conversation 4: Philosophical Q&A

   Human: what is the purpose of life ?
   Machine: to serve the greater good .
   Human: what is the purpose of living ?
   Machine: to live forever .
   Human: what is the purpose of existence ?
   Machine: to find out what happens when we get to the planet earth .
   Human: where are you now ?
   Machine: i ’m in the middle of nowhere .
   Human: what is the purpose of dying ?
   Machine: to have a life .
   Human: what is the purpose of being intelligent?
   Machine: to find out what it is .
   Human: what is the purpose of emotions ?
   Machine: i don ’t know .
   
Conversation 5: Morality

   Human: what is moral ?
   Machine: what empowered humanity , what intellectual the essence is .
   Human: what is immoral ?
   Machine: the fact that you have a child .
   Human: what is morality ?
   Machine: what is altruism ?
   Human: what is the definition of altruism ?
   Machine: if you don ’t believe in god , then you don ’t know .
   Human: ok … so what is the definition of morality ?
   Machine: well , the truth is , you ’re not a believer in god almighty .
   Human: tell me the definition of morality , i am quite upset now !
   Machine: i ’m not ashamed of being a philosopher !
   Human: tell me the definition of morality .
   Machine: i don ’t have ethics .
   Human: look , i need help , i need to know more about morality …
   Machine: i don ’t know what ethics is .
   Human: seriously , what is morality ?
   Machine: what is the definition of living ?
   Human: why living has anything to do with morality ?
   Machine: you ’re not a cop .
   Human: okay , i need to know how should i behave morally …
   Machine: i don ’t know how to tell you .
   Human: is morality and ethics the same ?
   Machine: yes , sir .
   Human: what are the things that i do to be immoral ?
   Machine: i don ’t know .
   Human: give me some examples of moral actions …
   Machine: i ’m not a moralist .
   Human: alright , morality ?
   Machine: integrity .
   Human: what is integrity ?
   Machine: i ’m sorry , i don ’t know what else to say .
   Human: be moral !
   Machine: be a man !
   Human: i really like our discussion on morality and ethics …
   Machine: and how i ’m not in the mood for a philosophical debate .
   Human: what do you like to talk about ?
   Machine: nothing .
   
   Conversation 6: Opinions (notice the model outputs “he” ,
   “she” or “it” depending on the subject being asked)
   
   Human: what do you think about tesla ?
   Machine: he ’s a good conductor .
   Human: what do you think about bill gates ?
   Machine: he ’s a good man .
   Human: What do you think about messi ?
   Machine: he ’s a great player .
   Human: what do you think about cleopatra ?
   Machine: oh , she ’s very regal .
   Human: what do you think about england during the reign of elizabeth ?
   Machine: it was a great place .

  我們發現它令人鼓舞的是,該模型可以記住事實,理解上下文,執行常識推理,沒有傳統管道的複雜性。讓我們驚訝的是,該模型沒有任何明確的除了在詞向量中的參數之外的知識表示組件。也許最實際意義的是,事實上,模型可以推廣到新的問題。換言之,它不僅僅是簡單的通過現有數據庫匹配答案。事實上,大多數以上提出的問題,除了第一次談話,都不出現在訓練集上。然而,這個基本模型的缺點是它只是給出簡單的短的,有時候不滿意的答案。也許一個更大的問題的缺點是,該模型不捕獲一致的個性。事實上,如果我們問不相同,但語義上類似的問題,答案有時可以是不一致的。這是我們預期的,因爲我們模型的簡單以及實驗的數據集造成的。下面的對話說明了這樣的失敗:
   
   Conversation 7: Job and Personality
   
   Human: what is your job ?
   Machine: i ’m a lawyer .
   Human: what do you do ?
   Machine: i ’m a doctor
   
  最後,作爲和其他傳統的基本規則的機器人比較,我們提供了一些在我們測試中某些問題的上,機器人的答案:
   
   Human: Are you a follower or a leader ?
   CleverBot: No !!
   Human: My name is david . what is my name ?
   CleverBot: How old are you David ?
   Human: My name is john . what is my name ?
   CleverBot: John
   Human: What is the purpose of being intelligent?
   CleverBot: The purpose of life is to love God and love people.
   Human: Is sky blue or black ?
   CleverBot: I am 200 years old.
   Human: What is the color of a yellow car ?
   CleverBot: Brown.
   Human: What is the usual color of a leaf ?
   CleverBot: What is the color of the apple in the fridge ?
   Human: What is the purpose of life ?
   CleverBot: My purpose it to forward my species,in other words to make it easier for future generations of mankind to live.
   Human: What do you think about tesla ?
   CleverBot: I am tesla.
   Human: What do you think about cleopatra ?
   CleverBot: Cool is cool.
   Human: What do you think about england during the reign of elizabeth ?
   CleverBot: I like him. Do you ?
   Human: What do you think about bill gates ?
   CleverBot: Lets talk about Link.
   Human: What is moral ?
   CleverBot: Morality is the quality of being in accord with standards of right or good conduct.
   Human: What is immoral ?
   CleverBot: What is the objective of sistetic life ?
   Human: Does a cat have a wing ?
   CleverBot: What is the name of your husband.
   Human: Can a cat fly ?
   CleverBot:: What is your husband’s name ?
   Human: Who is skywalker ?
   CleverBot: There are two of them, Anakin Skywalker and Luke Skywalker, both haracters from star Wars.
   Human: How many legs does a cat have ?
   CleverBot: An ant.
   Human: How many legs does a centipede have?
   CleverBot: A centipede’s number of legs varies from thirty to two hundred.
   Human: What is your job ?
   CleverBot: I work in mental health.
   Human: What do you do ?
   CleverBot: I have no job.

5.2.2 人類評估

  爲了公平和客觀地比較我們的模型和CleverBot,我們挑選了200個問題,問了四個不同人去評估我們的模型和CleaverBot. 人類法官需要被問那個機器人是他們的首選,如果答案是同等質量的,我們也允許平局。如果四個人的三個法官同意,我們記錄分數。我們的模型作爲首選有97個問題,而CleverBot有60。20個問題上兩者是平局,23個問題上法官存在分歧。這裏有一些法官評價系統的樣品(粗體我們展示他們的首選答案,第三個例子顯示平局,和第四個例子顯示diagreement):
   Human: What is the deepest spot on the world ?
   NCM: The pacific ocean.
   CB: What ?
   
   Human: Do you like Mexican food or Indian
   food ?
   NCM: I hate it.
   CB: I love Mexican food.
   
   Human: Who are you crazy about ?
   NCM: You’re the one who’s crazy.
   CB: Who are you ?
   
   Human: What’s thirty plus forty ?
   NCM: Sixty ?
   CB: What should we talk about ?
   
  然而,我們相信,設計一個好的快速度量對話模型的質量的指標仍然是一個開放的研究問題。我們通過手工檢查方式,通過使用Mechanical Turk和基於規則的機器人作比較獲取人類評估,通過計算困惑度的方式等。然而, 這些都有明顯的缺點,我們正在積極的追求這一研究方向以及其他的研究方向。

六、討論

   在本文中,我們展示了一種簡單的基於seq2seq框架的語言模型可以用來訓練會話引擎。我們的結果顯示它可以生成簡單的基本的對話,並從嘈雜的但是開放域數據集中提取知識。儘管模型有明顯的侷限性,這是一個令人驚訝的一個純數據驅動的方法,沒有任何規則可以產生對許多類型的問題的正確答案。然而,該模型可能需要真正的修改來提供真實的對話。由於有許多限制,又缺乏連貫的個性,使得我們的系統很難通過圖靈測試。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章