Skip to content

Commit da8887a

Browse files
committed
all examples
1 parent d1e65f4 commit da8887a

File tree

12 files changed

+551
-75
lines changed

12 files changed

+551
-75
lines changed

README.md

Lines changed: 135 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -164,65 +164,170 @@ in simple steps mentioned in the notebooks.
164164

165165
### Example-1 Intent detection, NER, Fragment detection
166166

167-
**Tasks Description**
167+
**Intent Detection**
168168

169-
``Intent Detection`` :- This is a single sentence classification task where an `intent` specifies which class the data sample belongs to.
169+
```
170+
Query: I need a reservation for a bar in bangladesh on feb the 11th 2032
171+
172+
Intent: BookRestaurant
173+
```
170174

171-
``NER`` :- This is a Named Entity Recognition/ Sequence Labelling/ Slot filling task where individual words of the sentence are tagged with an entity label it belongs to. The words which don't belong to any entity label are simply labeled as "O".
175+
**NER**
172176

173-
``Fragment Detection`` :- This is modeled as a single sentence classification task which detects whether a sentence is incomplete (fragment) or not (non-fragment).
177+
```
178+
Query: ['book', 'a', 'spot', 'for', 'ten', 'at', 'a', 'top-rated', 'caucasian', 'restaurant', 'not', 'far', 'from', 'selmer']
174179
175-
**Conversational Utility** :- Intent detection is one of the fundamental components for conversational system as it gives a broad understand of the category/domain the sentence/query belongs to.
180+
NER tags: ['O', 'O', 'O', 'O', 'B-party_size_number', 'O', 'O', 'B-sort', 'B-cuisine', 'B-restaurant_type', 'B-spatial_relation', 'I-spatial_relation', 'O', 'B-city']
181+
```
176182

177-
NER helps in extracting values for required entities (eg. location, date-time) from query.
183+
**Fragment Detection**
178184

179-
Fragment detection is a very useful piece in conversational system as knowing if a query/sentence is incomplete can aid in discarding bad queries beforehand.
185+
```
186+
Query: a reservation for
180187
181-
**Data** :- In this example, we are using the [SNIPS](https://snips-nlu.readthedocs.io/en/latest/dataset.html) data for intent and entity detection. For the sake of simplicity, we provide
182-
the data in simpler form under ``snips_data`` directory taken from [here](https://github.com/LeePleased/StackPropagation-SLU/tree/master/data/snips>).
188+
Label: fragment
189+
```
190+
191+
**Notebook** :- [intent_ner_fragment](https://github.com/hellohaptik/multi-task-NLP/blob/master/examples/intent_ner_fragment/intent_ner_fragment.ipynb)
183192

184193
**Transform file** :- [transform_file_snips](https://github.com/hellohaptik/multi-task-NLP/blob/master/examples/intent_ner_fragment/transform_file_snips.yml)
185194

186195
**Tasks file** :- [tasks_file_snips](https://github.com/hellohaptik/multi-task-NLP/blob/master/examples/intent_ner_fragment/tasks_file_snips.yml)
187196

188-
**Notebook** :- [intent_ner_fragment](https://github.com/hellohaptik/multi-task-NLP/blob/master/examples/intent_ner_fragment/intent_ner_fragment.ipynb)
189-
190197
### Example-2 Entailment detection
191198

192-
**Tasks Description**
199+
```
200+
Query1: An old man with a package poses in front of an advertisement.
193201
194-
``Entailment`` :- This is a sentence pair classification task which determines whether the second sentence in a sample can be inferred from the first.
202+
Query2: A man poses in front of an ad.
195203
196-
**Conversational Utility** :- In conversational AI context, this task can be seen as determining whether the second sentence is similar to first or not.
197-
Additionally, the probability score can also be used as a similarity score between the sentences.
204+
Label: entailment
198205
199-
**Data** :- In this example, we are using the [SNLI](https://nlp.stanford.edu/projects/snli) data which is having sentence pairs and labels.
206+
Query1: An old man with a package poses in front of an advertisement.
200207
201-
**Transform file** :- [transform_file_snli](https://github.com/hellohaptik/multi-task-NLP/tree/master/examples/entailment_detection/transform_file_snli.yml)
208+
Query2: A man poses in front of an ad for beer.
202209
203-
**Tasks file** :- [tasks_file_snli](https://github.com/hellohaptik/multi-task-NLP/tree/master/examples/entailment_detection/tasks_file_snli.yml)
210+
Label: non-entailment
211+
212+
```
204213

205214
**Notebook** :- [entailment_snli](https://github.com/hellohaptik/multi-task-NLP/tree/master/examples/entailment_detection/entailment_snli.ipynb)
206215

207-
### Example-3 Answerability detection
216+
**Transform file** :- [transform_file_snli](https://github.com/hellohaptik/multi-task-NLP/tree/master/examples/entailment_detection/transform_file_snli.yml)
217+
218+
**Tasks file** :- [tasks_file_snli](https://github.com/hellohaptik/multi-task-NLP/tree/master/examples/entailment_detection/tasks_file_snli.yml)
219+
208220

209-
**Tasks Description**
210221

211-
``answerability`` :- This is modeled as a sentence pair classification task where the first sentence is a query and second sentence is a context passage.
212-
The objective of this task is to determine whether the query can be answered from the context passage or not.
222+
### Example-3 Answerability detection
213223

214-
**Conversational Utility** :- This can be a useful component for building a question-answering/ machine comprehension based system.
215-
In such cases, it becomes very important to determine whether the given query can be answered with given context passage or not before extracting/abstracting an answer from it.
216-
Performing question-answering for a query which is not answerable from the context, could lead to incorrect answer extraction.
224+
```
225+
Query: how much money did evander holyfield make
217226
218-
**Data** :- In this example, we are using the [MSMARCO_triples](https://msmarco.blob.core.windows.net/msmarcoranking/triples.train.small.tar.gz") data which is having sentence pairs and labels.
219-
The data contains triplets where the first entry is the query, second one is the context passage from which the query can be answered (positive passage) , while the third entry is a context
220-
passage from which the query cannot be answered (negative passage).
227+
Context: Evander Holyfield Net Worth. How much is Evander Holyfield Worth? Evander Holyfield Net Worth: Evander Holyfield is a retired American professional boxer who has a net worth of $500 thousand. A professional boxer, Evander Holyfield has fought at the Heavyweight, Cruiserweight, and Light-Heavyweight Divisions, and won a Bronze medal a the 1984 Olympic Games.
221228
222-
Data is transformed into sentence pair classification format, with query-positive context pair labeled as 1 (answerable) and query-negative context pair labeled as 0 (non-answerable)
229+
Label: answerable
230+
```
231+
**Notebook** :- [answerability_detection_msmarco](https://github.com/hellohaptik/multi-task-NLP/tree/master/examples/answerability_detection/answerability_detection_msmarco.ipynb)
223232

224233
**Transform file** :- [transform_file_answerability](https://github.com/hellohaptik/multi-task-NLP/tree/master/examples/answerability_detection/transform_file_answerability.yml)
225234

226235
**Tasks file** :- [tasks_file_answerability](https://github.com/hellohaptik/multi-task-NLP/tree/master/examples/answerability_detection/tasks_file_answerability.yml)
227236

228-
**Notebook** :- [answerability_detection_msmarco](https://github.com/hellohaptik/multi-task-NLP/tree/master/examples/answerability_detection/answerability_detection_msmarco.ipynb)
237+
### Example-4 Query type detection
238+
239+
```
240+
Query: what's the distance between destin florida and birmingham alabama?
241+
242+
Label: NUMERIC
243+
244+
Query: who is suing scott wolter
245+
246+
Label: PERSON
247+
248+
```
249+
250+
**Notebook** :- [query_type_detection](https://github.com/hellohaptik/multi-task-NLP/blob/master/examples/query_type_detection/query_type_detection.ipynb)
251+
252+
**Transform file** :- [transform_file_querytype](https://github.com/hellohaptik/multi-task-NLP/blob/master/examples/query_type_detection/transform_file_querytype.yml)
253+
254+
**Tasks file** :- [tasks_file_querytype](https://github.com/hellohaptik/multi-task-NLP/blob/master/examples/query_type_detection/tasks_file_querytype.yml)
255+
256+
### Example-5 POS tagging, NER tagging
257+
258+
```
259+
Query: ['Despite', 'winning', 'the', 'Asian', 'Games', 'title', 'two', 'years', 'ago', ',', 'Uzbekistan', 'are', 'in', 'the', 'finals', 'as', 'outsiders', '.']
260+
261+
NER tags: ['O', 'O', 'O', 'I-MISC', 'I-MISC', 'O', 'O', 'O', 'O', 'O', 'I-LOC', 'O', 'O', 'O', 'O', 'O', 'O', 'O']
262+
263+
POS tags: ['I-PP', 'I-VP', 'I-NP', 'I-NP', 'I-NP', 'I-NP', 'B-NP', 'I-NP', 'I-ADVP', 'O', 'I-NP', 'I-VP', 'I-PP', 'I-NP', 'I-NP', 'I-SBAR', 'I-NP', 'O']
264+
265+
```
266+
267+
**Notebook** :- [ner_pos_tagging_conll](https://github.com/hellohaptik/multi-task-NLP/blob/master/examples/ner_pos_tagging/ner_pos_tagging_conll.ipynb)
268+
269+
**Transform file** :- [transform_file_conll](https://github.com/hellohaptik/multi-task-NLP/blob/master/examples/ner_pos_tagging/transform_file_conll.yml)
270+
271+
**Tasks file** :- [tasks_file_conll](https://github.com/hellohaptik/multi-task-NLP/blob/master/examples/ner_pos_tagging/tasks_file_conll.yml)
272+
273+
## Example-6 Query correctness
274+
275+
```
276+
277+
Query: What places have the oligarchy government ?
278+
279+
Label: well-formed
280+
281+
Query: What day of Diwali in 1980 ?
282+
283+
Label: not well-formed
284+
285+
```
286+
287+
**Notebook** :- [query_correctness](https://github.com/hellohaptik/multi-task-NLP/blob/master/examples/query_correctness/query_correctness.ipynb)
288+
289+
**Transform file** :- [transform_file_query_correctness](https://github.com/hellohaptik/multi-task-NLP/blob/master/examples/query_correctness/transform_file_query_correctness.yml)
290+
291+
**Tasks file** :- [tasks_file_query_correctness](https://github.com/hellohaptik/multi-task-NLP/blob/master/examples/query_correctness/tasks_file_query_correctness.yml)
292+
293+
294+
## Example-7 Query similarity
295+
296+
```
297+
298+
Query1: What is the most used word in Malayalam?
299+
300+
Query2: What is meaning of the Malayalam word ""thumbatthu""?
301+
302+
Label: not similar
303+
304+
Query1: Which is the best compliment you have ever received?
305+
306+
Query2: What's the best compliment you've got?
307+
308+
Label: similar
309+
310+
```
311+
**Notebook** :- [query_similarity](https://github.com/hellohaptik/multi-task-NLP/blob/master/examples/query_pair_similarity/query_similarity_qqp.ipynb)
312+
313+
**Transform file** :- [transform_file_qqp](https://github.com/hellohaptik/multi-task-NLP/blob/master/examples/query_pair_similarity/transform_file_qqp.yml)
314+
315+
**Tasks file** :- [tasks_file_qqp](https://github.com/hellohaptik/multi-task-NLP/blob/master/examples/query_pair_similarity/tasks_file_query_qqp.yml)
316+
317+
## Example-8 Sentiment Analysis
318+
319+
```
320+
321+
Review: What I enjoyed most in this film was the scenery of Corfu, being Greek I adore my country and I liked the flattering director's point of view. Based on a true story during the years when Greece was struggling to stand on her own two feet through war, Nazis and hardship. An Italian soldier and a Greek girl fall in love but the times are hard and they have a lot of sacrifices to make. Nicholas Cage looking great in a uniform gives a passionate account of this unfulfilled (in the beginning) love. I adored Christian Bale playing Mandras the heroine's husband-to-be, he looks very very good as a Greek, his personality matched the one of the Greek patriot! A true fighter in there, or what! One of the movies I would like to buy and keep it in my collection...for ever!
322+
323+
Label: positive
324+
325+
```
326+
327+
**Notebook** :- [IMDb_sentiment_analysis](https://github.com/hellohaptik/multi-task-NLP/blob/master/examples/sentiment_analysis/IMDb_sentiment_analysis.ipynb)
328+
329+
**Transform file** :- [transform_file_imdb](https://github.com/hellohaptik/multi-task-NLP/blob/master/examples/sentiment_analysis/transform_file_imdb.yml)
330+
331+
**Tasks file** :- [tasks_file_imdb](https://github.com/hellohaptik/multi-task-NLP/blob/master/examples/sentiment_analysis/tasks_file_query_imdb.yml)
332+
333+

docs/source/examples.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ the data in simpler form under ``snips_data`` directory taken from `here <https:
2929
**Notebook** :- `intent_ner_fragment <https://github.com/hellohaptik/multi-task-NLP/blob/master/examples/intent_ner_fragment/intent_ner_fragment.ipynb>`_
3030

3131
Example-2 Recognising Textual Entailment
32-
------------------------------
32+
----------------------------------------
3333

3434
**Tasks Description**
3535

examples/answerability_detection/answerability_detection_msmarco.ipynb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@
171171
"from infer_pipeline import inferPipeline"
172172
]
173173
},
174+
{
175+
"cell_type": "code",
176+
"execution_count": null,
177+
"metadata": {},
178+
"outputs": [],
179+
"source": []
180+
},
174181
{
175182
"cell_type": "code",
176183
"execution_count": null,

examples/entailment_detection/entailment_snli.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"## EXAMPLE - 2\n",
7+
"# EXAMPLE - 2\n",
88
"\n",
99
"**Tasks :- Entailment detection**\n",
1010
"\n",

examples/intent_ner_fragment/intent_ner_fragment.ipynb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,7 @@
211211
"execution_count": null,
212212
"metadata": {},
213213
"outputs": [],
214-
"source": [
215-
"pipe = inferPipeline('snips_intent_ner_bert_base/', 50)"
216-
]
214+
"source": []
217215
},
218216
{
219217
"cell_type": "code",

examples/intent_ner_fragment/tasks_file_snips.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ intent:
2424
loss_type: CrossEntropyLoss
2525
task_type: SingleSenClassification
2626
file_names:
27-
- intent_snips_train.tsv
28-
- intent_snips_dev.tsv
29-
- intent_snips_test.tsv
27+
- int_snips_train.tsv
28+
- int_snips_dev.tsv
29+
- int_snips_test.tsv
3030

3131

3232
fragdetect:
@@ -39,6 +39,6 @@ fragdetect:
3939
loss_type: CrossEntropyLoss
4040
task_type: SingleSenClassification
4141
file_names:
42-
- fragment_intent_snips_train.tsv
43-
- fragment_intent_snips_dev.tsv
44-
- fragment_intent_snips_test.tsv
42+
- fragment_snips_train.tsv
43+
- fragment_snips_dev.tsv
44+
- fragment_snips_test.tsv

0 commit comments

Comments
 (0)