LittleWhiteOne Basic Design
LittleWhite One A new LittleWhite implemented by heavily modifying the chatterbot framework~ Introduction core: core framework, a modded version of chatterbot corpus: English and Chinese training corpora nltk_data: nltk datasets that are needed Text similarity algorithms LevenshteinDistance SpacySimilarity JaccardSimilarity Levenshtein Distance algorithm Chinese name: Levenshtein dist
目录9 个章节
LittleWhite One
A new LittleWhite implemented by heavily modifying the chatterbot framework~
Introduction
- core: core framework, a modded version of chatterbot
- corpus: English and Chinese training corpora
- nltk_data: nltk datasets that are needed
Text Similarity Algorithms
- LevenshteinDistance
- SpacySimilarity
- JaccardSimilarity
Levenshtein Distance Algorithm
Chinese name: Levenshtein distance Reference: https://en.wikipedia.org/wiki/Levenshtein_distance
Levenshtein distance is a concept that characterizes or measures the degree of difference between two strings. Taking the words kitten and sitting as an example, three standard edit operations are defined: substitution, insertion (insert), and deletion (delete) to eliminate the differences between these two words. Each time a standard edit operation is applied, the Levenshtein distance is incremented by one. kitten requires 2 substitutions and 1 insertion of a new character to obtain the word sitting, so the so-called Levenshtein distance should be 3. By definition, this distance is proportional to the degree of difference between the strings.
Definition:
The Levenshtein distance between two strings a and b

Edit distance is a basic NLP algorithm for measuring text similarity. It can serve as one of the important features for text similarity tasks, and can be applied to spelling checking, paper plagiarism detection, gene sequence analysis, and many other areas. However, its shortcomings are also obvious: the algorithm computes based on the structure of the text itself and has no way to obtain information at the semantic level.
SpacySimilarity Algorithm
SpacySimilarity belongs to semantic similarity computation methods.
Reference: https://spacy.io/api/doc/#similarity
First average the word vectors of the sentence to obtain the sentence's semantic representation, then compute the cosine similarity of the two sentences' semantic representations.
JaccardSimilarity Algorithm
Reference: https://en.wikipedia.org/wiki/Jaccard_index
Given two sets A and B, the Jaccard coefficient is defined as the ratio of the size of the intersection of A and B to the size of the union of A and B, defined as follows:

When both sets A and B are empty, J(A,B) is defined as 1.
A related metric to the Jaccard coefficient is called the Jaccard distance, used to describe the dissimilarity between sets. The larger the Jaccard distance, the lower the sample similarity. The formula is defined as follows:

todo
Algorithm Optimization
- Try several other word-vector-based methods for computing text similarity:
- Compute similarity by averaging word vectors
- Compute similarity by tfidf-weighted averaging of word vectors
- Compute similarity with word-vector weighting-PCA
- Compute sentence semantic similarity based on deep learning
Training Optimization
- Train with a new large-capacity corpus
- Connect tai to extract chat corpus
- Combine with LittleWhite v3's dual engines to learn from user conversations
_EOF_
LittleWhiteOne Basic Design
- 本文作者:
- 程序设计实验室
- 版权声明:
- 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
相关文章
多个约束条件下的二维装箱问题——寻找《开罗拉面店》最优布局之代码解析(一)
介绍 本代码是用C#实现的。在开始代码解析之前,先把要用到的数据贴出来: | 店铺id | 店铺宽度 | 店铺高度 | 入口位置 | | ------ | -------- | -------- | -------- | | 1 | 9 | 6 | (5,6) | | 2 | 5 | 6 | (1,6) | | 3
2021-12-18 · 算法/机器学习 · 约 1 分钟
推荐系统开发实践:Surprise库基本用法
首先是构建数据集 这里我使用了随机生成用户和项目,以及用户对项目的评价,喜欢(1)与不喜欢(0) import random import pandas import numpy as np def build_dataframe() - pandas.DataFrame: datasets = { 'userID': [], 'itemID': [],
2021-12-18 · 算法/机器学习 · 约 1 分钟
多个约束条件下的二维装箱问题——寻找《开罗拉面店》最优布局之代码解析(五)遗传算法解析
前言 遗传算法的一些思路我在开篇有提到一些,这里给出具体过程: 1、生成两个种群,分别使用BL算法和BL_plus算法; 2、开始迭代 3、调用两个种群的update_max()函数更新最优个体 4、如果两个种群中有最优解(也就是12家店铺全部铺上去了),则跳出循环,返回该个体; 5、如果达到迭代次数,则跳出循环,返回两个种群的最优个体; 6、如果达到交换迭代次数,则: 假设种群P1的最优个体适应
2021-12-18 · 算法/机器学习 · 约 1 分钟
多个约束条件下的二维装箱问题——寻找《开罗拉面店》最优布局之代码解析(三)
种群类:Population 属性 种群类首先要储存的便是上一篇中提到的原始基因;其次为了应用精英保存策略、择伏分配等,需要记录最优个体的相关信息;同时在计算交叉变异概率的时候,需要用到求平均适应值的方法,所以为了简化计算,储存每个个体的适应值是很有必要的。 /// summary /// 个体列表 /// /summary public ListIndividual ind; /// summ
2021-12-18 · 算法/机器学习 · 约 1 分钟
讨论
共 0 条加载评论中…