beyond commited on
Commit
88e7d54
1 Parent(s): 80c4d03

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +44 -67
README.md CHANGED
@@ -1,15 +1,16 @@
1
  ---
2
- language: en
 
 
3
  tags:
4
- - SEGA
 
 
5
  - data augmentation
6
- - keywords-to-text generation
7
- - sketch-to-text generation
8
  license: apache-2.0
9
  datasets:
10
  - c4
11
-
12
-
13
  widget:
14
  - text: "<mask> Conference on Empirical Methods <mask> submission of research papers <mask> Deep Learning <mask>"
15
  example_title: "Example 1"
@@ -28,48 +29,58 @@ inference:
28
  num_beams: 3
29
  do_sample: True
30
  ---
 
 
 
31
 
32
- # SEGA-large model
33
-
34
- **SEGA: SkEtch-based Generative Augmentation** \
35
- **基于草稿的生成式增强模型**
36
 
37
- **SEGA** is a **general text augmentation model** that can be used for data augmentation for **various NLP tasks** (including sentiment analysis, topic classification, NER, and QA). SEGA uses an encoder-decoder structure (based on the BART architecture) and is pre-trained on the `C4-realnewslike` corpus.
38
 
 
39
 
40
- ![sega-illustration](https://cdn.jsdelivr.net/gh/beyondguo/mdnice_pictures/typora/sega-main-illustration.png)
41
 
42
- - Paper: [SEGA: SkEtch-based Generative Augmentation (preprint)](https://github.com/beyondguo/SEGA/blob/master/SEGA_gby_preprint.pdf)
43
- - GitHub: [SEGA](https://github.com/beyondguo/SEGA).
44
 
45
- **SEGA** is able to write complete paragraphs given a *sketch*, which can be composed of:
46
- - keywords /key-phrases, like "––NLP––AI––computer––science––"
47
- - spans, like "Conference on Empirical Methods––submission of research papers––"
48
- - sentences, like "I really like machine learning––I work at Google since last year––"
49
- - or mixup~
50
 
 
51
 
52
  **Model variations:**
 
53
  | Model | #params | Language | comment|
54
  |------------------------|--------------------------------|-------|---------|
55
- | [`sega-large`](https://huggingface.co/beyond/sega-large) | 406M | English | The version used in paper |
56
- | [`sega-large-k2t`](https://huggingface.co/beyond/sega-large-k2t) | 406M | English | keywords-to-text |
57
- | [`sega-base`](https://huggingface.co/beyond/sega-base) | 139M | English | smaller version |
58
- | [`sega-base-ps`](https://huggingface.co/beyond/sega-base) | 139M | English | pre-trained both in paragraphs and short sentences |
59
- | [`sega-base-chinese`](https://huggingface.co/beyond/sega-base-chinese) | 116M | 中文 | 在一千万纯净中文段落上预训练|
60
 
61
  ---
62
 
63
- ### How to use
64
- #### 1. If you want to generate sentences given a **sketch**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  ```python
66
  from transformers import pipeline
67
  # 1. load the model with the huggingface `pipeline`
68
- sega = pipeline("text2text-generation", model='beyond/sega-large', device=0)
69
  # 2. provide a sketch (joint by <mask> tokens)
70
  sketch = "<mask> Conference on Empirical Methods <mask> submission of research papers <mask> Deep Learning <mask>"
71
- # 3. just do it!
72
- generated_text = sega(sketch, num_beams=3, do_sample=True, max_length=200)[0]['generated_text']
73
  print(generated_text)
74
  ```
75
  Output:
@@ -77,44 +88,10 @@ Output:
77
  'The Conference on Empirical Methods welcomes the submission of research papers. Abstracts should be in the form of a paper or presentation. Please submit abstracts to the following email address: eemml.stanford.edu. The conference will be held at Stanford University on April 1618, 2019. The theme of the conference is Deep Learning.'
78
  ```
79
 
80
- #### 2. If you want to do **data augmentation** to generate new training samples
81
- Please Check our Github page: [github.com/beyondguo/SEGA](https://github.com/beyondguo/SEGA), where we provide ready-to-run scripts for data augmentation for text classification/NER/MRC tasks.
82
 
83
- ---
84
 
85
- ## SEGA as A Strong Data Augmentation Tool:
86
- - Setting: Low-resource setting, where only n={50,100,200,500,1000} labeled samples are available for training. The below results are the average of all training sizes.
87
- - Datasets: [HuffPost](https://huggingface.co/datasets/khalidalt/HuffPost), [BBC](https://huggingface.co/datasets/SetFit/bbc-news), [SST2](https://huggingface.co/datasets/glue), [IMDB](https://huggingface.co/datasets/imdb), [Yahoo](https://huggingface.co/datasets/yahoo_answers_topics), [20NG](https://huggingface.co/datasets/newsgroup).
88
- - Base classifier: [DistilBERT](https://huggingface.co/distilbert-base-cased)
89
-
90
-
91
- In-distribution (ID) evaluations:
92
- | Method | Huff | BBC | Yahoo | 20NG | IMDB | SST2 | avg. |
93
- |:----------:|:----------:|:----------:|:----------:|:----------:|:----------:|:----------:|:----------:|
94
- | none | 79.17 | **96.16** | 45.77 | 46.67 | 77.87 | 76.67 | 70.39 |
95
- | EDA | 79.20 | 95.11 | 45.10 | 46.15 | 77.88 | 75.52 | 69.83 |
96
- | BackT | 80.48 | 95.28 | 46.10 | 46.61 | 78.35 | 76.96 | 70.63 |
97
- | MLM | 80.04 | 96.07 | 45.35 | 46.53 | 75.73 | 76.61 | 70.06 |
98
- | C-MLM | 80.60 | 96.13 | 45.40 | 46.36 | 77.31 | 76.91 | 70.45 |
99
- | LAMBADA | 81.46 | 93.74 | 50.49 | 47.72 | 78.22 | 78.31 | 71.66 |
100
- | STA | 80.74 | 95.64 | 46.96 | 47.27 | 77.88 | 77.80 | 71.05 |
101
- | **SEGA** | 81.43 | 95.74 | 49.60 | 50.38 | **80.16** | 78.82 | 72.68 |
102
- | **SEGA-f** | **81.82** | 95.99 | **50.42** | **50.81** | 79.40 | **80.57** | **73.17** |
103
-
104
- Out-of-distribution (OOD) evaluations:
105
- | | Huff->BBC | BBC->Huff | IMDB->SST2 | SST2->IMDB | avg. |
106
- |------------|:----------:|:----------:|:----------:|:----------:|:----------:|
107
- | none | 62.32 | 62.00 | 74.37 | 73.11 | 67.95 |
108
- | EDA | 67.48 | 58.92 | 75.83 | 69.42 | 67.91 |
109
- | BackT | 67.75 | 63.10 | 75.91 | 72.19 | 69.74 |
110
- | MLM | 66.80 | 65.39 | 73.66 | 73.06 | 69.73 |
111
- | C-MLM | 64.94 | **67.80** | 74.98 | 71.78 | 69.87 |
112
- | LAMBADA | 68.57 | 52.79 | 75.24 | 76.04 | 68.16 |
113
- | STA | 69.31 | 64.82 | 74.72 | 73.62 | 70.61 |
114
- | **SEGA** | 74.87 | 66.85 | 76.02 | 74.76 | 73.13 |
115
- | **SEGA-f** | **76.18** | 66.89 | **77.45** | **80.36** | **75.22** |
116
-
117
-
118
-
119
- ### BibTeX entry and citation info
120
 
 
 
1
  ---
2
+ language:
3
+ - en
4
+ - zh
5
  tags:
6
+ - GENIUS
7
+ - conditional text generation
8
+ - sketch-based text generation
9
  - data augmentation
 
 
10
  license: apache-2.0
11
  datasets:
12
  - c4
13
+ - beyond/chinese_clean_passages_80m
 
14
  widget:
15
  - text: "<mask> Conference on Empirical Methods <mask> submission of research papers <mask> Deep Learning <mask>"
16
  example_title: "Example 1"
 
29
  num_beams: 3
30
  do_sample: True
31
  ---
32
+ # 💡GENIUS – generating text using sketches!
33
+ - **Paper: [GENIUS: Sketch-based Language Model Pre-training via Extreme and Selective Masking for Text Generation and Augmentation](https://github.com/beyondguo/genius/blob/master/GENIUS_gby_arxiv.pdf)**
34
+ - **GitHub: [GENIUS project, GENIUS pre-training, GeniusAug for data augmentation](https://github.com/beyondguo/genius)**
35
 
36
+ 💡**GENIUS** is a powerful conditional text generation model using sketches as input, which can fill in the missing contexts for a given **sketch** (key information consisting of textual spans, phrases, or words, concatenated by mask tokens). GENIUS is pre-trained on a large-scale textual corpus with a novel *reconstruction from sketch* objective using an *extreme and selective masking* strategy, enabling it to generate diverse and high-quality texts given sketches.
 
 
 
37
 
 
38
 
39
+ **GENIUS** can also be used as a general textual **data augmentation tool** for **various NLP tasks** (including sentiment analysis, topic classification, NER, and QA).
40
 
 
41
 
42
+ ![image-20221119164544165](https://cdn.jsdelivr.net/gh/beyondguo/mdnice_pictures/typora/hi-genius.png)
 
43
 
 
 
 
 
 
44
 
45
+ - Models hosted in 🤗 Huggingface:
46
 
47
  **Model variations:**
48
+
49
  | Model | #params | Language | comment|
50
  |------------------------|--------------------------------|-------|---------|
51
+ | [`genius-large`](https://huggingface.co/beyond/genius-large) | 406M | English | The version used in **paper** (recommend) |
52
+ | [`genius-large-k2t`](https://huggingface.co/beyond/genius-large-k2t) | 406M | English | keywords-to-text |
53
+ | [`genius-base`](https://huggingface.co/beyond/genius-base) | 139M | English | smaller version |
54
+ | [`genius-base-ps`](https://huggingface.co/beyond/genius-base) | 139M | English | pre-trained both in paragraphs and short sentences |
55
+ | [`genius-base-chinese`](https://huggingface.co/beyond/genius-base-chinese) | 116M | 中文 | 在一千万纯净中文段落上预训练|
56
 
57
  ---
58
 
59
+ ## Usage
60
+
61
+ ### What is a sketch?
62
+
63
+ First, what is a **sketch**? As defined in our paper, a sketch is "key information consisting of textual spans, phrases, or words, concatenated by mask tokens". It's like a draft or framework when you begin to write an article. With GENIUS model, you can input some key elements you want to mention in your wrinting, then the GENIUS model can generate cohrent text based on your sketch.
64
+
65
+ The sketch which can be composed of:
66
+
67
+ - keywords /key-phrases, like `__NLP__AI__computer__science__`
68
+ - spans, like `Conference on Empirical Methods__submission of research papers__`
69
+ - sentences, like `I really like machine learning__I work at Google since last year__`
70
+ - or a mixup!
71
+
72
+ (the `__` is the mask token. Use `<mask>` for English, and `[MASK]` for Chinese)
73
+
74
+ ### How to use the model
75
+ #### 1. If you already have a sketch in mind, and want to get a paragraph based on it...
76
  ```python
77
  from transformers import pipeline
78
  # 1. load the model with the huggingface `pipeline`
79
+ genius = pipeline("text2text-generation", model='beyond/genius-large', device=0)
80
  # 2. provide a sketch (joint by <mask> tokens)
81
  sketch = "<mask> Conference on Empirical Methods <mask> submission of research papers <mask> Deep Learning <mask>"
82
+ # 3. here we go!
83
+ generated_text = genius(sketch, num_beams=3, do_sample=True, max_length=200)[0]['generated_text']
84
  print(generated_text)
85
  ```
86
  Output:
 
88
  'The Conference on Empirical Methods welcomes the submission of research papers. Abstracts should be in the form of a paper or presentation. Please submit abstracts to the following email address: eemml.stanford.edu. The conference will be held at Stanford University on April 1618, 2019. The theme of the conference is Deep Learning.'
89
  ```
90
 
91
+ If you have a lot of sketches, you can batch-up your sketches to a Huggingface `Dataset` object, which can be much faster.
 
92
 
93
+ TODO: we are also building a python package for more convenient use of GENIUS, which will be released in few weeks.
94
 
95
+ #### 2. If you have an NLP dataset (e.g. classification) and want to do data augmentation to enlarge your dataset...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
 
97
+ Please check [genius/augmentation_clf](https://github.com/beyondguo/genius/tree/master/augmentation_clf) and [genius/augmentation_ner_qa](https://github.com/beyondguo/genius/tree/master/augmentation_ner_qa), where we provide ready-to-run scripts for data augmentation for text classification/NER/MRC tasks.