Skip to content

Commit 706cf78

Browse files
committed
update readme
1 parent 592290b commit 706cf78

File tree

2 files changed

+37
-105
lines changed

2 files changed

+37
-105
lines changed

README.md

Lines changed: 36 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,25 @@
11
![NeuralClassifier Logo](readme/logo.png)
22

33

4-
# NeuralClassifier: An Open-source Neural Hierarchical Multi-label Text Classification Toolkit
4+
# NeuralClassifierService: A Service for Multi-label Text Classification Toolkit
55

66
## Introduction
77

8-
NeuralClassifier is designed for quick implementation of neural models for hierarchical multi-label classification task, which is more challenging and common in real-world scenarios. A salient feature is that NeuralClassifier currently provides a variety of text encoders, such as FastText, TextCNN, TextRNN, RCNN, VDCNN, DPCNN, DRNN, AttentiveConvNet and Transformer encoder, etc. It also supports other text classification scenarios, including binary-class and multi-class classification. It is built on [PyTorch](https://pytorch.org/). Experiments show that models built in our toolkit achieve comparable performance with reported results in the literature.
8+
This service is for post use of the parent repository after trained with data sets, and if you want to use your model as some DeepLearning backend, fork this web wrapper repository.
99

10-
## Support tasks
10+
## Notice
1111

12-
* Binary-class text classifcation
13-
* Multi-class text classification
14-
* Multi-label text classification
15-
* Hiearchical (multi-label) text classification (HMC)
16-
17-
## Support text encoders
18-
19-
* TextCNN ([Kim, 2014](https://arxiv.org/pdf/1408.5882.pdf))
20-
* RCNN ([Lai et al., 2015](https://www.aaai.org/ocs/index.php/AAAI/AAAI15/paper/download/9745/9552))
21-
* TextRNN ([Liu et al., 2016](https://arxiv.org/pdf/1605.05101.pdf))
22-
* FastText ([Joulin et al., 2016](https://arxiv.org/pdf/1607.01759.pdf))
23-
* VDCNN ([Conneau et al., 2016](https://arxiv.org/pdf/1606.01781.pdf))
24-
* DPCNN ([Johnson and Zhang, 2017](https://www.aclweb.org/anthology/P17-1052))
25-
* AttentiveConvNet ([Yin and Schutze, 2017](https://arxiv.org/pdf/1710.00519.pdf))
26-
* DRNN ([Wang, 2018](https://www.aclweb.org/anthology/P18-1215))
27-
* Region embedding ([Qiao et al., 2018](http://research.baidu.com/Public/uploads/5acc1e230d179.pdf))
28-
* Transformer encoder ([Vaswani et al., 2017](https://papers.nips.cc/paper/7181-attention-is-all-you-need.pdf))
29-
* Star-Transformer encoder ([Guo et al., 2019](https://arxiv.org/pdf/1902.09113.pdf))
12+
* I assume you have trained your model well and you are ready to use it for production.
13+
* Production did not require GPU evniroment, and current repo config is using pytorch CPU opt by default
14+
* Please use the config file while you are training instead of using my config file.
15+
* I assume you are using GNU operating systems and using UTF-8 as encoding
3016

3117
## Requirement
3218

3319
* Python 3
3420
* PyTorch 0.4+
3521
* Numpy 1.14.3+
36-
37-
## System Architecture
38-
39-
![NeuralClassifier Architecture](readme/deeptext_arc.png)
40-
22+
* Flask
4123

4224
## Usage
4325

@@ -59,7 +41,7 @@ The training info will be outputted in standard output and log.logger\_file.
5941
The evaluation info will be outputed in eval.dir.
6042

6143
### Prediction
62-
python predict.py conf/train.json data/predict.json
44+
python predict.py conf/train.json data/predict.json
6345

6446
* predict.json should be of json format, while each instance has a dummy label like "其他" or any other label in label map.
6547
* eval.model\_dir is the model to predict.
@@ -80,81 +62,31 @@ The predict info will be outputed in predict.txt.
8062
}
8163

8264
"doc_keyword" and "doc_topic" are optional.
65+
## Start classification service
66+
67+
This service contains two module: a deep learning backend and a flask wrapper, they communicate via socket at port 4444. Above this is a shell wrapper to manipulate the two process: start them, keep them and kill them together when signal receieved.
68+
69+
>./start.sh #to start the whole service
70+
71+
the web page start at '0.0.0.0', port 55555 by default, or edit them in server.py.
72+
73+
The main page is to test if your config is valid, paste a post to the textarea,
74+
`purge newline`, and click `Go` to get predict results, each post is splited by a newline which explains why you should purge new lines from a single post.
75+
76+
77+
78+
Also, headless json response is provided, send a json to `[host]:[port]/headless` and get a json with results
79+
80+
**send:**
81+
82+
{"posts":["blah","blah blah", "blah blah"]}
83+
84+
**and get:**
85+
86+
{"results" :["class of blah", "class of blah blah", "class of blah blah blah"]}
87+
88+
## Demo enviroment
89+
90+
* Training dataset : toutiao, 16 single labels, 280k posts, length 1536, eval precision 91%
8391

84-
## Performance
85-
86-
### 0. Dataset
87-
88-
<table>
89-
<tr><th>Dataset<th>Taxonomy<th>#Label<th>#Training<th>#Test
90-
<tr><td>RCV1<td>Tree<td>103<td>23,149<td>781,265
91-
<tr><td>Yelp<td>DAG<td>539<td>87,375<td>37,265
92-
</table>
93-
94-
* RCV1: [Lewis et al., 2004](http://www.jmlr.org/papers/volume5/lewis04a/lewis04a.pdf)
95-
* Yelp: [Yelp](https://www.yelp.com/dataset/challenge)
96-
97-
### 1. Compare with state-of-the-art
98-
<table>
99-
<tr><th>Text Encoders<th>Micro-F1 on RCV1<th>Micro-F1 on Yelp
100-
<tr><td>HR-DGCNN (Peng et al., 2018)<td>0.7610<td>-
101-
<tr><td>HMCN (Wehrmann et al., 2018)<td>0.8080<td>0.6640
102-
<tr><td>Ours<td><strong>0.8313</strong><td><strong>0.6704</strong>
103-
</table>
104-
105-
* HR-DGCNN: [Peng et al., 2018](http://www.cse.ust.hk/~yqsong/papers/2018-WWW-Text-GraphCNN.pdf)
106-
* HMCN: [Wehrmann et al., 2018](http://proceedings.mlr.press/v80/wehrmann18a/wehrmann18a.pdf)
107-
108-
### 2. Different text encoders
109-
110-
<table>
111-
<tr><th row_span='2'>Text Encoders<th colspan='2'>RCV1<th colspan='2'>Yelp
112-
<tr><td><th>Micro-F1<th>Macro-F1<th>Micro-F1<th>Macro-F1
113-
<tr><td>TextCNN<td>0.7717<td>0.5246<td>0.6281<td>0.3657
114-
<tr><td>TextRNN<td>0.8152<td>0.5458<td><strong>0.6704</strong><td>0.4059
115-
<tr><td>RCNN<td><strong>0.8313</strong><td><strong>0.6047</strong><td>0.6569<td>0.3951
116-
<tr><td>FastText<td>0.6887<td>0.2701 <td>0.6031<td>0.2323
117-
<tr><td>DRNN<td>0.7846 <td>0.5147<td>0.6579<td>0.4401
118-
<tr><td>DPCNN<td>0.8220 <td>0.5609 <td>0.5671 <td>0.2393
119-
<tr><td>VDCNN<td>0.7263 <td>0.3860<td>0.6395<td>0.4035
120-
<tr><td>AttentiveConvNet<td>0.7533<td>0.4373<td>0.6367<td>0.4040
121-
<tr><td>RegionEmbedding<td>0.7780 <td>0.4888 <td>0.6601<td><strong>0.4514</strong>
122-
<tr><td>Transformer<td>0.7603 <td>0.4274<td>0.6533<td>0.4121
123-
<tr><td>Star-Transformer<td>0.7668 <td>0.4840<td>0.6482<td>0.3895
124-
125-
</table>
126-
127-
### 3. Hierarchical vs Flat
128-
129-
<table>
130-
<tr><th row_span='2'>Text Encoders<th colspan='2'>Hierarchical<th colspan='2'>Flat
131-
<tr><td><th>Micro-F1<th>Macro-F1<th>Micro-F1<th>Macro-F1
132-
<tr><td>TextCNN<td>0.7717<td>0.5246<td>0.7367<td>0.4224
133-
<tr><td>TextRNN<td>0.8152<td>0.5458<td>0.7546 <td>0.4505
134-
<tr><td>RCNN<td><strong>0.8313</strong><td><strong>0.6047</strong><td><strong>0.7955</strong><td><strong>0.5123</strong>
135-
<tr><td>FastText<td>0.6887<td>0.2701 <td>0.6865<td>0.2816
136-
<tr><td>DRNN<td>0.7846 <td>0.5147<td>0.7506<td>0.4450
137-
<tr><td>DPCNN<td>0.8220 <td>0.5609 <td>0.7423 <td>0.4261
138-
<tr><td>VDCNN<td>0.7263 <td>0.3860<td>0.7110<td>0.3593
139-
<tr><td>AttentiveConvNet<td>0.7533<td>0.4373<td>0.7511<td>0.4286
140-
<tr><td>RegionEmbedding<td>0.7780 <td>0.4888 <td>0.7640<td>0.4617
141-
<tr><td>Transformer<td>0.7603 <td>0.4274<td>0.7602<td>0.4339
142-
<tr><td>Star-Transformer<td>0.7668 <td>0.4840<td>0.7618<td>0.4745
143-
</table>
144-
145-
## Acknowledgement
146-
147-
Some public codes are referenced by our toolkit:
148-
149-
* https://pytorch.org/docs/stable/
150-
* https://github.com/jadore801120/attention-is-all-you-need-pytorch/
151-
* https://github.com/Hsuxu/FocalLoss-PyTorch
152-
* https://github.com/Shawn1993/cnn-text-classification-pytorch
153-
* https://github.com/ailias/Focal-Loss-implement-on-Tensorflow/
154-
* https://github.com/brightmart/text_classification
155-
* https://github.com/NLPLearn/QANet
156-
* https://github.com/huggingface/pytorch-pretrained-BERT
157-
158-
## Update
159-
160-
* 2019-04-29, init version
92+
* Infer server performance : CPU, no delay

templates/root.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
<br>
6767
returns:
6868
<br>
69-
json string : {"class of blah", "class of blah blah", "class of blah blah blah"}
69+
json string : {"results" :["class of blah", "class of blah blah", "class of blah blah blah"]}
7070
</div>
7171
<div class="right">
7272
<ul>

0 commit comments

Comments
 (0)