使用开源服务为 Vue JS 机器人添加智能

Adding intelligence to Vue JS bot using open source services

我正在尝试使用 Vue JS 构建一个完全开源的机器人,我需要添加智能以使机器人按时间从用户输入中学习,我不想使用 Microsoft 或Google 或 IBM 或任何我想使用我可以自己托管并稍后改进的开源解决方案

我该怎么做?

下面是我现在显示 hello world 的方式:

var botui = new BotUI('hello-world');
botui.message.add({
  content: 'Hello World from bot!'
}).then(function () { // wait till previous message has been shown.
  botui.message.add({
    delay: 1000,
    human: true,
    content: 'Hello World from human!'
  });
});

这是我关注的 rn: https://www.cssscript.com/minimal-javascript-chat-bot-framework-botui/

AIML: 您可以使用人工智能标记语言 (AIML) 为您的机器人创建对话流。 AIML 非常容易学习,基本上是 XML.

的扩展

这是一个基本示例:

<category> defines beggining of category
<pattern>What the User Says</pattern>
<template>What the Bot Responds</template>
</category>

您可以在这里了解更多信息: Playground

AIML 开源平台:Pandorabots

Open AI 非常好,因为它是非营利性的,并且允许一切免费 https://openai.com/

嗨,如果您熟悉 Python,您可以查看 Spacy:

https://spacy.io/

https://github.com/explosion/spaCy

他们有预训练的 word2vec 模型,您可以使用这些模型并将其托管在您自己的服务器上。该库还提供了许多高级方法,可让您计算任意两个句子之间的相似度。这是一个很好的网络演示,说明它如何在他们的网站上工作:

https://explosion.ai/demos/similarity

https://spacy.io/usage/vectors-similarity

一旦找到句子之间的相似性,您所要做的就是将问题列表及其相应的答案存储在 list/database.

每当有人提出新问题时,您的程序将简单地计算存储在数据库中的每个问题的相似度分数。它将选择相似度得分最高的问题和 return 相应的答案。

请注意,整个库都是用 python 编写的,因此您必须自己托管它并在其上创建一个 API 层(可能使用 Flask 等)。然后您的网络应用程序可以使用 API 调用与它通信。

他们已经提供了对许多开箱即用的语言(包括英语)的支持,但您也可以训练自己的自定义模型。

这是从他们的网站上获取的示例代码示例:

import spacy
nlp = spacy.load('en_core_web_md')
doc1 = nlp(u"Hello how are you?")
doc2 = nlp(u"Hi! how are you doing?")
doc1.similarity(doc2)