这是一个快速搭建NLP、CV、推荐等DL方向的手脚架,包括基本的分类、回归、聚类、序列标注、双塔等常见模型的简洁实现。
-
python2.7
-
Go 1.14.2
由于go的优良并发性能,使用go做模型预测server部署。
-
Tensorflow 1.5.0
核心代码使用tf 1.5实现。
-
tf_metrics 0.0.1
tf官方的tf.metrics对precision/recall的统计依然停留在二分类上,无法支持多分类准召统计,所以采用第三方tf_metrics库。
-
Tqdm 4.46.0
比较酷的进度条打印库,方便展示训练进度,同时会自动显示剩余预估训练时间。
任务划分 | 模型 | 说明 | |
---|---|---|---|
NLP-分类器 | TextCNN | 适合短文本,训练较快: 1、底层多窗口多核CNN。 2、上层max_pooling 3、最后softmax |
|
BILSTM-Attention | 适合短文本,训练慢: 1、底层多层堆叠bilstm。 2、上层soft-attention 3、最后softmax |
||
Transformer | 适合短文本,训练慢: 1、底层复现Attention is All your need中encoder部分。 2、上层max_pooling 3、最后softmax |
||
LongShortMixture | 适合对新闻等长文本建模: 1、title经过bilstm-attention建模 2、content经过Hierarchical Attention Network建模 3、最后两者concat再softmax |
||
.
├── LICENSE
├── README.md
├── add_comments.py
├── add_comments_to_tree.sh
├── ci.sh
├── corpus # 语料
│ ├── README.md
├── demos # 执行
│ ├── __init__.py
│ ├── executes # 执行内核
│ │ ├── __init__.py
│ │ ├── executor.py # 执行器
│ │ ├── graph_processor.py # 构图处理器
│ │ ├── init_processor.py # 参数处理器
│ │ ├── pre_processor.py # 语料处理器
│ │ ├── session_processor.py # 会话处理器
│ ├── nlp_classifier.py # nlp分类器
│ ├── run_nlp_classifier.sh
│ └── test.py
├── layers # 高级层
│ ├── README.md
│ ├── __init__.py
│ ├── tf_base_layer.py
│ ├── tf_bilstm_att_layer.py
│ ├── tf_classifier_layer.py
│ ├── tf_embedding_layer.py
│ ├── tf_feedforward_layer.py
│ ├── tf_hierarchical_att_layer.py
│ ├── tf_ln_layer.py
│ ├── tf_multihead_att_layer.py
│ ├── tf_pos_encoding_layer.py
│ ├── tf_soft_att_layer.py
│ ├── tf_textcnn_layer.py
├── log
├── models # 模型层
│ ├── README.md
│ ├── __init__.py
│ ├── cv
│ │ └── README.md
│ ├── nlp
│ │ ├── __init__.py
│ │ ├── classification
│ │ │ ├── __init__.py
│ │ │ ├── tf_base_classifier.py
│ │ │ ├── tf_bilstmatt_classifier.py
│ │ │ ├── tf_hierarchical_att_classifier.py
│ │ │ ├── tf_longshort_mixture_classifier.py
│ │ │ ├── tf_textcnn_classifier.py
│ │ │ ├── tf_transformer_classifier.py
│ │ ├── cluster
│ │ │ └── __init__.py
│ │ ├── seq2seq
│ │ │ └── __init__.py
│ │ ├── sequence_labeling
│ │ │ └── __init__.py
│ │ └── similarity
│ │ ├── README.md
│ │ └── __init__.py
├── run.sh # 执行入口
├── save_models # 模型保存地址
├── server
└── utils
├── __init__.py
├── tf_utils.py # 工具类
-
[2] NLP任务汇总-中文