LightChen2333 commited on
Commit
05f3947
·
1 Parent(s): 223340a

Delete README.md

Browse files
Files changed (1) hide show
  1. README.md +0 -262
README.md DELETED
@@ -1,262 +0,0 @@
1
- <img src="https://cdn.jsdelivr.net/gh/LightChen233/blog-img/OpenSLU.jpg" alt=""/>
2
-
3
- ---
4
-
5
- <p align="center">
6
- <a >
7
- <img alt="version" src="https://img.shields.io/badge/version-v0.1.0-blue?color=FF8000?color=009922" />
8
- </a>
9
- <a >
10
- <img alt="Status-building" src="https://img.shields.io/badge/Status-building-blue" />
11
- </a>
12
- <a href=""><img src="https://img.shields.io/badge/python-3.6.2+-orange.svg"></a>
13
- <a >
14
- <img alt="PRs-Welcome" src="https://img.shields.io/badge/PRs-Welcome-red" />
15
- </a>
16
- <a>
17
- <img alt="stars" src="https://img.shields.io/github/stars/LightChen233/OpenSLU" />
18
- </a>
19
- <a href="https://github.com/LightChen233/OpenSLU/network/members">
20
- <img alt="FORK" src="https://img.shields.io/github/forks/LightChen233/OpenSLU?color=FF8000" />
21
- </a>
22
- <a href="https://github.com/LightChen233/OpenSLU/issues">
23
- <img alt="Issues" src="https://img.shields.io/github/issues/LightChen233/OpenSLU?color=0088ff"/>
24
- </a>
25
- <br />
26
- </p>
27
-
28
- ## <img src="https://cdn.jsdelivr.net/gh/LightChen233/blog-img/motivation.png" width="25" /> Motivation
29
-
30
- Spoken Language Understanding (SLU) is one of the core components of a task-oriented dialogue system, which aims to extract the semantic meaning of user queries (e.g., intents and slots).
31
-
32
- In this work, we introduce __OpenSLU__, an open-source toolkit to provide a unified, modularized, and extensible toolkit for spoken language understanding. Specifically, OpenSLU unifies 10 SLU baselines for both single-intent and multi-intent scenarios, which support both non-pretrained and pretrained models simultaneously. Additionally, OpenSLU is highly modularized and extensible by decomposing the model architecture, inference, and learning process into reusable modules, which allows researchers to quickly set up SLU experiments with highly flexible configurations. We hope OpenSLU can help researcher to quickly initiate experiments and spur more breakthroughs in SLU.
33
-
34
- ## <img src="https://cdn.jsdelivr.net/gh/LightChen233/blog-img/notes.png" width="25" /> Changelog
35
- - 2023-02-09
36
- - We build the first version and release it.
37
-
38
- ## <img src="https://cdn.jsdelivr.net/gh/LightChen233/blog-img/resource.png" width="25" /> Installation
39
- ### System requirements
40
- OpenSLU requires `Python>=3.8`, and `torch>=1.12.0`.
41
- ### Install from git
42
- ```bash
43
- git clone https://github.com/LightChen2333/OpenSLU.git && cd OpenSLU/
44
- pip install -r requirements.txt
45
- ```
46
-
47
-
48
- ## File Structure
49
-
50
- ```yaml
51
- root
52
- ├── common
53
- │ ├── config.py # load configuration and auto preprocess ignored config
54
- │ ├── loader.py # load data from hugging face
55
- │ ├── logger.py # log predict result, support [fitlog], [wandb], [local logging]
56
- │ ├── metric.py # evalutation metric, support [intent acc], [slot F1], [EMA]
57
- │ ├── model_manager.py # help to prepare data, prebuild training progress.
58
- │ ├── tokenizer.py # tokenizer also support no-pretrained model for word tokenizer.
59
- │ └── utils.py # canonical model communication data structure and other common tool function
60
- ├── config
61
- │ ├── reproduction # configurations for reproducted SLU model.
62
- │ └── **.yaml # configuration for SLU model.
63
- ├── logs # local log storage dir path.
64
- ├── model
65
- │ ├── encoder
66
- │ │ ├── base_encoder.py # base encoder model. All implemented encoder models need to inherit the BaseEncoder class
67
- │ │ ├── auto_encoder.py # auto-encoder to autoload provided encoder model
68
- │ │ ├── non_pretrained_encoder.py # all common-used no pretrained encoder like lstm, lstm+self-attention
69
- │ │ └── pretrained_encoder.py # all common-used pretrained encoder, implemented by hugging-face [AutoModel].
70
- │ ├── decoder
71
- │ │ ├── interaction
72
- │ │ │ ├── base_interaction.py # base interaction model. All implemented encoder models need to inherit the BaseInteraction class
73
- │ │ │ └── *_interaction.py # some SOTA SLU interaction module. You can easily reuse or rewrite to implement your own idea.
74
- │ │ ├── base_decoder.py # decoder class, [BaseDecoder] support classification after interaction, also you can rewrite for your own interaction order
75
- │ │ └── classifier.py # classifier class, support linear and LSTM classification. Also support token-level intent.
76
- │ └── open_slu_model.py # the general model class, can automatically build the model through configuration.
77
- ├── save # model checkpoint storage dir path and dir to automatically save glove embedding.
78
- └── run.py # run script for all function.
79
- ```
80
-
81
- ## <img src="https://cdn.jsdelivr.net/gh/LightChen233/blog-img/catalogue.png" width="27" /> Quick Start
82
-
83
- ### 1. Reproducing Existing Models
84
- Example for reproduction of `slot-gated` model:
85
-
86
- ```bash
87
- python run.py --dataset atis --model slot-gated
88
- ```
89
-
90
- ### 2. Customizable Combination Existing Components
91
- 1. First, you can freely combine and build your own model through config files. For details, see [Configuration](config/README.md).
92
- 2. Then, you can assign the configuration path to train your own model.
93
-
94
- Example for `stack-propagation` fine-tuning:
95
-
96
- ```bash
97
- python run.py -cp config/stack-propagation.yaml
98
- ```
99
-
100
- Example for multi-GPU fine-tuning:
101
-
102
- ```bash
103
- accelerate config
104
- accelerate launch run.py -cp config/stack-propagation.yaml
105
- ```
106
-
107
- Or you can assign `accelerate` yaml configuration.
108
-
109
- ```bash
110
- accelerate launch [--config_file ./accelerate/config.yaml] run.py -cp config/stack-propagation.yaml
111
- ```
112
-
113
- ### 3. Implementing a New SLU Model
114
- In OpenSLU, you are only needed to rewrite required commponents and assign them in configuration instead of rewriting all commponents.
115
-
116
- In most cases, rewriting Interaction module is enough for building a new SLU model.
117
- This module accepts [HiddenData](./common/utils.py) as input and return with `HiddenData`, which contains the `hidden_states` for `intent` and `slot`, and other helpful information. The example is as follows:
118
- ```python
119
- class NewInteraction(BaseInteraction):
120
-     def __init__(self, **config):
121
-         self.config = config
122
-         ...
123
-    
124
-     def forward(self, hiddens: HiddenData):
125
-         ...
126
-         intent, slot = self.func(hiddens)
127
-         hiddens.update_slot_hidden_state(slot)
128
-         hiddens.update_intent_hidden_state(intent)
129
-         return hiddens
130
- ```
131
-
132
- To further meet the
133
- needs of complex exploration, we provide the
134
- [BaseDecoder](./model/decoder/base_decoder.py) class, and the user can simply override the `forward()` function in class, which accepts `HiddenData` as input and `OutputData` as output. The example is as follows:
135
- ```python
136
- class NewDecoder(BaseDecoder):
137
-     def __init__(self,
138
-         intent_classifier,
139
-         slot_classifier,
140
-         interaction=None):
141
-         ...
142
-         self.int_cls = intent_classifier
143
-         self.slot_cls = slot_classifier
144
-         self.interaction = interaction
145
-        
146
-     def forward(self, hiddens: HiddenData):
147
-         ...
148
-         interact = self.interaction(hiddens)
149
-         slot = self.slot_cls(interact.slot)
150
-         intent = self.int_cls(interact.intent)
151
-         return OutputData(intent, slot)
152
- ```
153
-
154
-
155
- ## Modules
156
-
157
- ### 1. Encoder Modules
158
-
159
- - **No Pretrained Encoder**
160
- - GloVe Embedding
161
- - BiLSTM Encoder
162
- - BiLSTM + Self-Attention Encoder
163
- - Bi-Encoder (support two encoders for intent and slot, respectively)
164
- - **Pretrained Encoder**
165
- - `bert-base-uncased`
166
- - `roberta-base`
167
- - `microsoft/deberta-v3-base`
168
- - other hugging-face supported encoder model...
169
-
170
- ### 2. Decoder Modules
171
-
172
- #### 2.1 Interaction Modules
173
-
174
- - DCA Net Interaction
175
- - Stack Propagation Interaction
176
- - Bi-Model Interaction(with decoder/without decoder)
177
- - Slot Gated Interaction
178
-
179
- #### 2.2 Classification Modules
180
- All classifier support `Token-level Intent` and `Sentence-level intent`. What's more, our decode function supports to both `Single-Intent` and `Multi-Intent`.
181
- - LinearClassifier
182
- - AutoregressiveLSTMClassifier
183
- - MLPClassifier
184
-
185
- ### 3. Supported Models
186
- We implement various 10 common-used SLU baselines:
187
-
188
- ---
189
- **Single-Intent Model**
190
- - Bi-Model \[ [Wang et al., 2018](https://aclanthology.org/N18-2050/) \] :
191
- - `bi-model.yaml`
192
- - Slot-Gated \[ [Goo et al., 2018](https://www.csie.ntu.edu.tw/~yvchen/doc/NAACL18_SlotGated.pdf) \] :
193
- - `slot-gated.yaml`
194
- - Stack-Propagation \[ [Qin et al., 2019](https://www.aclweb.org/anthology/D19-1214/) \] :
195
- - `stack-propagation.yaml`
196
- - Joint Bert \[ [Chen et al., 2019](https://arxiv.org/abs/1902.10909) \] :
197
- - `joint-bert.yaml`
198
- - RoBERTa \[ [Liu et al., 2019](https://arxiv.org/abs/1907.11692) \] :
199
- - `roberta.yaml`
200
- - ELECTRA \[ [Clark et al., 2020](https://arxiv.org/abs/2003.10555) \] :
201
- - `electra.yaml`
202
- - DCA-Net \[ [Qin et al., 2021](https://arxiv.org/abs/2010.03880) \] :
203
- - `dca_net.yaml`
204
- - DeBERTa \[ [He et al., 2021](https://arxiv.org/abs/2111.09543) \] :
205
- - `deberta.yaml`
206
-
207
- ---
208
- **Multi-Intent Model**
209
- - AGIF \[ [Qin et al., 2020](https://arxiv.org/pdf/2004.10087.pdf) \] :
210
- - `agif.yaml`
211
- - GL-GIN \[ [Qin et al., 2021](https://arxiv.org/abs/2106.01925) \] :
212
- - `gl-gin.yaml`
213
-
214
-
215
- ## Application
216
- ### 1. Visualization Tools
217
- Model metrics tests alone no longer adequately reflect the model's performance. To help researchers further improve their models, we provide a tool for visual error analysis.
218
-
219
- We provide an analysis interface with three main parts:
220
- - (a) error distribution analysis;
221
- - (b) label transfer analysis;
222
- - (c) instance analysis.
223
-
224
- <img src="https://cdn.jsdelivr.net/gh/LightChen233/blog-img/visual_analysis.png" />
225
-
226
- ```bash
227
- python tools/visualization.py \
228
- --config_path config/visual.yaml \
229
- --output_path {ckpt_dir}/outputs.jsonl
230
- ```
231
- Visualization configuration can be set as below:
232
- ```yaml
233
- host: 127.0.0.1
234
- port: 7861
235
- is_push_to_public: true # whether to push to gradio platform(public network)
236
- output_path: save/stack/outputs.jsonl # output prediction file path
237
- page-size: 2 # the number of instances of each page in instance anlysis.
238
- ```
239
- ### 2. Deployment
240
-
241
- We provide an script to deploy your model automatically. You are only needed to run the command as below to deploy your own model:
242
-
243
- ```bash
244
- python app.py --config_path config/reproduction/atis/bi-model.yaml
245
- ```
246
-
247
- <img src="https://cdn.jsdelivr.net/gh/LightChen233/blog-img/app.png" />
248
-
249
- ### 3. Publish your model to hugging face
250
-
251
- We also offer an script to transfer models trained by OpenSLU to hugging face format automatically. And you can upload the model to your `Model` space.
252
-
253
- ```shell
254
- python tools/parse_to_hugging_face.py -cp config/reproduction/atis/bi-model.yaml -op save/temp
255
- ```
256
-
257
- It will generate 5 files, and you should only need to upload `config.json`, `pytorch_model.bin` and `tokenizer.pkl`.
258
- After that, others can reproduction your model just by adjust `_from_pretrained_` parameters in Configuration.
259
-
260
- ## <img src="https://cdn.jsdelivr.net/gh/LightChen233/blog-img/intro.png" width="25" /> Contact
261
-
262
- Please create Github issues here or email [Libo Qin](mailto:[email protected]) or [Qiguang Chen](mailto:[email protected]) if you have any questions or suggestions.