https://github.com/shawnwun/RNNLG

数据集

给出了4个行业的语料,餐馆、酒店、电脑、电视,及其组合数据。

数据格式

任务

根据给定格式的命令,生成自然语言。

方法、模型、策略

作者给出了5种模型,2种训练(优化)策略、2种解码方式

* Model
- (knn) kNN generator:
k-nearest neighbor example-based generator, based on MR similarty.
- (ngram) Class-based Ngram generator [Oh & Rudnicky, 2000]:
Class-based language model generator by utterance class partitions.
- (hlstm) Heuristic Gated LSTM [Wen et al, 2015a]:
An MR-conditioned LSTM generator with heuristic gates.
- (sclstm) Semantically Conditioned LSTM [Wen et al, 2015b]:
An MR-conditioned LSTM generator with learned gates.
- (encdec) Attentive Encoder-Decoder LSTM [Wen et al, 2015c]:
An encoder-decoder LSTM with slot-value level attention. * Training Strategy
- (ml) Maximum Likehood Training, using token cross-entropy
- (dt) Discriminative Training (or Expected BLEU training) [Wen et al, 2016] * Decoding Strategy
- (beam) Beam search
- (sample) Random sampling

快速开始

需要python2环境,依赖:

* Theano 0.8.2 and accompanying packages such as numpy, scipy ...
* NLTK 3.0.0

创建虚机,Python2

virtualenv env
source env/bin/activate
pip install theano==0.8.2
pip install nltk==3.0.0

训练:python main.py -config config/sclstm.cfg -mode train

测试:python main.py -config config/sclstm.cfg -mode test

配置文件和参数

从上面的训练和测试的命令可以看出,参数在config目录下的文件配置,看看config/sclstm.cfg文件的内容

[learn] // parameters for training
lr = 0.1 : learning rate of SGD.
lr_decay = 0.5 : learning rate decay.
lr_divide = 3 : the maximum number of times when validation gets worse.
for early stopping.
beta = 0.0000001 : regularisation parameter.
random_seed = 5 : random seed.
min_impr = 1.003 : the relative minimal improvement allowed.
debug = True : debug flag
llogp = -100000000 : log prob in the last epoch [train_mode]
mode = all : training mode, currently only support 'all'
obj = ml : training objective, 'ml' or 'dt'
###################################
* Training Strategy
- (ml) Maximum Likehood Training, using token cross-entropy
- (dt) Discriminative Training (or Expected BLEU training) [Wen et al, 2016]
###################################
gamma = 5.0 : hyperparameter for DT training
batch = 1 : batch size [generator] // structure for generator
type = sclstm : the model type, [hlstm|sclstm|encdec]
hidden = 80 : hidden layer size [data] // data and model file
domain = restaurant 作者给出4种领域:餐馆、酒店、电脑、电视
train = data/original/restaurant/train.json
valid = data/original/restaurant/valid.json
test = data/original/restaurant/test.json
vocab = resource/vocab 词典
percentage = 100 : the percentage of train/valid considered
wvec = vec/vectors-80.txt : pretrained word vectors 预训练的词向量,有多个维度
model = model/sclstm-rest.model : the produced model path 生成的模型文件名称 [gen] // generation parameters, decode='beam' or 'sample'
topk = 5 : the N-best list returned
overgen = 20 : number of over-generation
beamwidth = 10 : the beam width used to decode utterances
detectpairs = resource/detect.pair : the mapping file for calculating the slot error rate 见下文
verbose = 1 : verbose level of the model, not supported yet
decode = beam : decoding strategy, 'beam' or 'sample' Below are knn/ngram specific parameters:
* [ngram]
- ngram : the N of ngram
- rho : number of slots considered to partition the dataset

结果

我在自己机器试了一下


inform(name=fresca;phone='4154472668')
Penalty TSER ASER Gen
0.0672 0 0 the phone number for fresca is 4154472668
0.1272 0 0 fresca s phone number is 4154472668
0.1694 0 0 the phone number of fresca is 4154472668
0.1781 0 0 the phone number for the fresca is 4154472668
0.2153 0 0 the phone number to fresca is 4154472668

文件resource/detect.pair

{
"general" : {
"address" : "SLOT_ADDRESS",
"area" : "SLOT_AREA",
"count" : "SLOT_COUNT",
"food" : "SLOT_FOOD",
"goodformeal": "SLOT_GOODFORMEAL",
"name" : "SLOT_NAME",
"near" : "SLOT_NEAR",
"phone" : "SLOT_PHONE",
"postcode" : "SLOT_POSTCODE",
"price" : "SLOT_PRICE",
"pricerange" : "SLOT_PRICERANGE",
"battery" : "SLOT_BATTERY",
"batteryrating" : "SLOT_BATTERYRATING",
"design" : "SLOT_DESIGN",
"dimension" : "SLOT_DIMENSION",
"drive" : "SLOT_DRIVE",
"driverange" : "SLOT_DRIVERANGE",
"family" : "SLOT_FAMILY",
"memory" : "SLOT_MEMORY",
"platform" : "SLOT_PLATFORM",
"utility" : "SLOT_UTILITY",
"warranty" : "SLOT_WARRANTY",
"weight" : "SLOT_WEIGHT",
"weightrange": "SLOT_WEIGHTRANGE",
"hdmiport" : "SLOT_HDMIPORT",
"ecorating" : "SLOT_ECORATING",
"audio" : "SLOT_AUDIO",
"accessories": "SLOT_ACCESSORIES",
"color" : "SLOT_COLOR",
"powerconsumption" : "SLOT_POWERCONSUMPTION",
"resolution" : "SLOT_RESOLUTION",
"screensize" : "SLOT_SCREENSIZE",
"screensizerange" : "SLOT_SCREENSIZERANGE"
},
"binary" : {
"kidsallowed":["child","kid","kids","children"],
"dogsallowed":["dog","dogs","puppy"],
"hasinternet":["internet","wifi"],
"acceptscreditcards":["card","cards"],
"isforbusinesscomputing":["business","nonbusiness","home","personal","general"],
"hasusbport" :["usb"]
}
}

总结

将结构化的数据,转为非结构化的文本。整个任务的核心就是这个吧

学习笔记(11)- 文本生成RNNLG的更多相关文章

  1. Spring MVC 学习笔记11 —— 后端返回json格式数据

    Spring MVC 学习笔记11 -- 后端返回json格式数据 我们常常听说json数据,首先,什么是json数据,总结起来,有以下几点: 1. JSON的全称是"JavaScript ...

  2. 《C++ Primer Plus》学习笔记11

    <C++ Primer Plus>学习笔记11 第17章 输入.输出和文件 <<<<<<<<<<<<<< ...

  3. Spring 源码学习笔记11——Spring事务

    Spring 源码学习笔记11--Spring事务 Spring事务是基于Spring Aop的扩展 AOP的知识参见<Spring 源码学习笔记10--Spring AOP> 图片参考了 ...

  4. Ext.Net学习笔记11:Ext.Net GridPanel的用法

    Ext.Net学习笔记11:Ext.Net GridPanel的用法 GridPanel是用来显示数据的表格,与ASP.NET中的GridView类似. GridPanel用法 直接看代码: < ...

  5. SQL反模式学习笔记11 限定列的有效值

    目标:限定列的有效值,将一列的有效字段值约束在一个固定的集合中.类似于数据字典. 反模式:在列定义上指定可选值 1. 对某一列定义一个检查约束项,这个约束不允许往列中插入或者更新任何会导致约束失败的值 ...

  6. golang学习笔记11 golang要用jetbrain的golang这个IDE工具开发才好

    golang学习笔记11   golang要用jetbrain的golang这个IDE工具开发才好  jetbrain家的全套ide都很好用,一定要dark背景风格才装B   从File-->s ...

  7. ArcGIS案例学习笔记2_2_等高线生成DEM和三维景观动画

    ArcGIS案例学习笔记2_2_等高线生成DEM和三维景观动画 计划时间:第二天下午 教程:Pdf/405 数据:ch9/ex3 方法: 1. 创建DEM SA工具箱/插值分析/地形转栅格 2. 生成 ...

  8. Python3+Selenium3+webdriver学习笔记11(cookie处理)

    #!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记11(cookie处理)'''from selenium im ...

  9. 并发编程学习笔记(11)----FutureTask的使用及实现

    1. Future的使用 Future模式解决的问题是.在实际的运用场景中,可能某一个任务执行起来非常耗时,如果我们线程一直等着该任务执行完成再去执行其他的代码,就会损耗很大的性能,而Future接口 ...

  10. SpringMVC:学习笔记(11)——依赖注入与@Autowired

    SpringMVC:学习笔记(11)——依赖注入与@Autowired 使用@Autowired 从Spring2.5开始,它引入了一种全新的依赖注入方式,即通过@Autowired注解.这个注解允许 ...

随机推荐

  1. 算法刷题--回溯算法与N皇后

    所谓回溯算法,在笔者看来就是一种直接地思想----假设需要很多步操作才能求得最终的解,每一步操作又有很多种选择,那么我们就直接选择其中一种并依次深入下去.直到求得最终的结果,或是遇到明细的错误,回溯到 ...

  2. CF1208G Polygons 数论

    题目链接:https://codeforces.com/contest/1208/problem/G 题意:给定两个正整数\(n\)和\(k\),询问在一个圆上你最少需要几个点,才能在这些点上构造出\ ...

  3. AxureRP 9安装、激活、汉化

    AxureRP安装 AxureRP激活 AxureRP汉化

  4. Python3问题TypeError: object() takes no parameters

    1. Python中关键字变量和特殊函数,都是以__xxx__来表示的 初学Python的朋友,需要注意其中变量名中前后是有两个下划线(_)的,如果不注意,调用内部关键字变量和特殊函数时,将会出现错误 ...

  5. Go语言 二分查找算法的实现

    二分查找也称折半查找(Binary Search),它是一种效率较高的查找方法.但是,二分查找算法的前提是传入的序列是有序的(降序或升序),并且有一个目标值. 二分查找的核心思想是将 n 个元素分成大 ...

  6. 【Python协程的实现】

    " 补充:数据安全问题 进程: 多个进程操作同一个文件,会出现数据不安全 线程: 多个线程操作同一个全局变量,会出现数据不安全 对于共享的数据操作: 如果是 += *= /= -= 操作,都 ...

  7. Druid数据源SQL数据库与Spring监控

    Druid监控概要说明 为什么要监控? Druid是什么?德鲁伊 URL监控配置说明 配置步骤 步骤 配置 第一步 web.xml 配置 WebStatFilter 第二步 WebStatFilter ...

  8. 【代码审计】XDCMS 报错注入

    审计的都是之前很老的一些的CMS,把学习的过程分享出来,如果有正在和我一起学习的兄弟们,希望看到文章之后会有所收获 ------------------------------------------ ...

  9. scala基础API

    1.对象和json转换 1.1 json取值 val json:JSONObject = JSON.parseObject(jsonMsg:String)val message:String = js ...

  10. JQuery DOM操作:设置内容&属性&添加元素&插入元素&包裹&克隆&移除&替换

    JQuery text().html().val() $(elem).text(str):添加文本内容str到elem类型元素,返回jQuery对象 $(elem).text():返回第一个elem标 ...