informers 0.2.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/informers/ner.rb DELETED
@@ -1,106 +0,0 @@
1
- # Copyright 2018 The HuggingFace Inc. team.
2
- # Copyright 2020 Andrew Kane.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
-
16
- module Informers
17
- class NER
18
- def initialize(model_path)
19
- tokenizer_path = File.expand_path("../../vendor/bert_base_cased_tok.bin", __dir__)
20
- @tokenizer = BlingFire.load_model(tokenizer_path)
21
- @model = OnnxRuntime::Model.new(model_path)
22
- end
23
-
24
- def predict(texts)
25
- singular = !texts.is_a?(Array)
26
- texts = [texts] if singular
27
-
28
- result = []
29
- texts.each do |text|
30
- # tokenize
31
- tokens, start_offsets, end_offsets = @tokenizer.text_to_ids_with_offsets(text, nil, 100) # unk token
32
- tokens.unshift(101) # cls token
33
- tokens << 102 # sep token
34
-
35
- # infer
36
- input = {
37
- input_ids: [tokens],
38
- attention_mask: [[1] * tokens.size],
39
- token_type_ids: [[0] * tokens.size]
40
- }
41
- res = @model.predict(input)
42
-
43
- # transform
44
- output = res["output_0"] || res["logits"]
45
- score =
46
- output[0].map do |e|
47
- values = e.map { |v| Math.exp(v) }
48
- sum = values.sum
49
- values.map { |v| v / sum }
50
- end
51
-
52
- labels_idx = score.map { |s| s.each_with_index.max[1] }
53
- labels = ["O", "B-MISC", "I-MISC", "B-PER", "I-PER", "B-ORG", "I-ORG", "B-LOC", "I-LOC"]
54
-
55
- entities = []
56
- filtered_label_idx = labels_idx.map.with_index.reject { |v, i| v == 0 }
57
- filtered_label_idx.each do |label_idx, idx|
58
- entities << {
59
- score: score[idx][label_idx],
60
- entity: labels[label_idx],
61
- index: idx
62
- }
63
- end
64
-
65
- result << group_entities(entities, text, start_offsets, end_offsets)
66
- end
67
-
68
- singular ? result.first : result
69
- end
70
-
71
- private
72
-
73
- def group_entities(entities, text, start_offsets, end_offsets)
74
- last_entity = {}
75
- groups = []
76
- entities.each do |entity|
77
- if entity[:index] - 1 == last_entity[:index] && entity[:entity] == last_entity[:entity]
78
- groups.last << entity
79
- else
80
- groups << [entity]
81
- end
82
- last_entity = entity
83
- end
84
-
85
- entity_map = {
86
- "I-PER" => "person",
87
- "I-ORG" => "org",
88
- "I-LOC" => "location",
89
- "I-MIS" => "misc"
90
- }
91
-
92
- groups.map do |group|
93
- start_offset = start_offsets[group.first[:index] - 1]
94
- end_offset = end_offsets[group.last[:index] - 1]
95
-
96
- {
97
- text: text[start_offset...end_offset],
98
- tag: entity_map[group.first[:entity]],
99
- score: group.map { |v| v[:score] }.sum / group.size,
100
- start: start_offset,
101
- end: end_offset
102
- }
103
- end
104
- end
105
- end
106
- end
@@ -1,197 +0,0 @@
1
- # Copyright 2018 The HuggingFace Inc. team.
2
- # Copyright 2020 Andrew Kane.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
-
16
- module Informers
17
- class QuestionAnswering
18
- def initialize(model_path)
19
- tokenizer_path = File.expand_path("../../vendor/bert_base_cased_tok.bin", __dir__)
20
- @tokenizer = BlingFire.load_model(tokenizer_path)
21
- @model = OnnxRuntime::Model.new(model_path)
22
- end
23
-
24
- def predict(questions)
25
- singular = !questions.is_a?(Array)
26
- questions = [questions] if singular
27
-
28
- topk = 1
29
- max_answer_len = 15
30
-
31
- sep_pos = []
32
- cls_pos = []
33
- context_offsets = []
34
-
35
- # tokenize
36
- input_ids =
37
- questions.map do |question|
38
- tokens = @tokenizer.text_to_ids(question[:question], nil, 100) # unk token
39
- sep_pos << tokens.size
40
- tokens << 102 # sep token
41
- context_tokens, offsets = @tokenizer.text_to_ids_with_offsets(question[:context], nil, 100) # unk token
42
- tokens.concat(context_tokens)
43
- context_offsets << offsets
44
- cls_pos << tokens.size
45
- tokens.unshift(101) # cls token
46
- tokens << 102 # sep token
47
- tokens
48
- end
49
-
50
- max_tokens = 384
51
- raise "Large text not supported yet" if input_ids.map(&:size).max > max_tokens
52
-
53
- attention_mask = []
54
- input_ids.each do |ids|
55
- zeros = [0] * (max_tokens - ids.size)
56
-
57
- mask = ([1] * ids.size) + zeros
58
- attention_mask << mask
59
-
60
- ids.concat(zeros)
61
- end
62
-
63
- # infer
64
- input = {
65
- input_ids: input_ids,
66
- attention_mask: attention_mask
67
- }
68
- output = @model.predict(input)
69
-
70
- start = output["output_0"] || output["start_logits"]
71
- stop = output["output_1"] || output["end_logits"]
72
-
73
- # transform
74
- answers = []
75
- start.zip(stop).each_with_index do |(start_, end_), i|
76
- start_ = Numo::DFloat.cast(start_)
77
- end_ = Numo::DFloat.cast(end_)
78
-
79
- # Ensure padded tokens & question tokens cannot belong to the set of candidate answers.
80
- feature_p_mask = Numo::Int64.new(max_tokens).fill(0)
81
- feature_p_mask[1..sep_pos[i] + 1] = 1
82
- feature_p_mask[cls_pos[i][1]] = 1
83
- feature_attention_mask = Numo::Int64.cast(attention_mask[i])
84
- undesired_tokens = (feature_p_mask - 1).abs & feature_attention_mask
85
-
86
- # Generate mask
87
- undesired_tokens_mask = undesired_tokens.eq(0)
88
-
89
- # Make sure non-context indexes in the tensor cannot contribute to the softmax
90
- start_[undesired_tokens_mask] = -10000
91
- end_[undesired_tokens_mask] = -10000
92
-
93
- # Normalize logits and spans to retrieve the answer
94
- start_ = Numo::DFloat::Math.exp(start_ - Numo::DFloat::Math.log(Numo::DFloat::Math.exp(start_).sum(axis: -1)))
95
- end_ = Numo::DFloat::Math.exp(end_ - Numo::DFloat::Math.log(Numo::DFloat::Math.exp(end_).sum(axis: -1)))
96
-
97
- # Mask CLS
98
- start_[0] = end_[0] = 0.0
99
-
100
- starts, ends, scores = decode(start_, end_, topk, max_answer_len)
101
-
102
- # char_to_word
103
- doc_tokens, char_to_word_offset = send(:doc_tokens, questions[i][:context])
104
- char_to_word = Numo::Int64.cast(char_to_word_offset)
105
-
106
- # token_to_orig_map
107
- token_to_orig_map = {}
108
- map_pos = sep_pos[i] + 2
109
- context_offsets[i].each do |offset|
110
- token_to_orig_map[map_pos] = char_to_word_offset[offset]
111
- map_pos += 1
112
- end
113
-
114
- # Convert the answer (tokens) back to the original text
115
- starts.to_a.zip(ends.to_a, scores) do |s, e, score|
116
- answers << {
117
- answer: doc_tokens[token_to_orig_map[s]..token_to_orig_map[e]].join(" "),
118
- score: score,
119
- start: (char_to_word.eq(token_to_orig_map[s])).where[0],
120
- end: (char_to_word.eq(token_to_orig_map[e])).where[-1]
121
- }
122
- end
123
- end
124
-
125
- singular ? answers.first : answers
126
- end
127
-
128
- private
129
-
130
- def decode(start, stop, topk, max_answer_len)
131
- # Ensure we have batch axis
132
- if start.ndim == 1
133
- start = start.expand_dims(0)
134
- end
135
-
136
- if stop.ndim == 1
137
- stop = stop.expand_dims(0)
138
- end
139
-
140
- # Compute the score of each tuple(start, end) to be the real answer
141
- outer = start.expand_dims(-1).dot(stop.expand_dims(1))
142
-
143
- # Remove candidate with end < start and end - start > max_answer_len
144
- candidates = outer.triu.tril(max_answer_len - 1)
145
-
146
- # Inspired by Chen & al. (https://github.com/facebookresearch/DrQA)
147
- scores_flat = candidates.flatten
148
- if topk == 1
149
- idx_sort = [scores_flat.argmax]
150
- else
151
- raise "Not implemented yet"
152
- end
153
-
154
- start, stop = unravel_index(idx_sort, candidates.shape)[1..-1]
155
- [start, stop, candidates[0, start, stop]]
156
- end
157
-
158
- def unravel_index(indices, shape)
159
- indices = Numo::NArray.cast(indices)
160
- result = []
161
- factor = 1
162
- shape.size.times do |i|
163
- result.unshift(indices / factor % shape[-1 - i])
164
- factor *= shape[-1 - i]
165
- end
166
- result
167
- end
168
-
169
- def doc_tokens(text)
170
- doc_tokens = []
171
- char_to_word_offset = []
172
- prev_is_whitespace = true
173
-
174
- text.each_char do |c|
175
- if whitespace?(c)
176
- prev_is_whitespace = true
177
- else
178
- if prev_is_whitespace
179
- doc_tokens << c
180
- else
181
- doc_tokens[-1] += c
182
- end
183
- prev_is_whitespace = false
184
- end
185
- char_to_word_offset << (doc_tokens.size - 1)
186
- end
187
- # ensure end is correct when answer includes last token
188
- char_to_word_offset << (doc_tokens.size - 1)
189
-
190
- [doc_tokens, char_to_word_offset]
191
- end
192
-
193
- def whitespace?(c)
194
- c == " " || c == "\t" || c == "\r" || c == "\n" || c.ord == 0x202F
195
- end
196
- end
197
- end
@@ -1,72 +0,0 @@
1
- # Copyright 2018 The HuggingFace Inc. team.
2
- # Copyright 2020 Andrew Kane.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
-
16
- module Informers
17
- class SentimentAnalysis
18
- def initialize(model_path)
19
- tokenizer_path = File.expand_path("../../vendor/bert_base_tok.bin", __dir__)
20
- @tokenizer = BlingFire.load_model(tokenizer_path)
21
- @model = OnnxRuntime::Model.new(model_path)
22
- end
23
-
24
- def predict(texts)
25
- singular = !texts.is_a?(Array)
26
- texts = [texts] if singular
27
-
28
- # tokenize
29
- input_ids =
30
- texts.map do |text|
31
- tokens = @tokenizer.text_to_ids(text, nil, 100) # unk token
32
- tokens.unshift(101) # cls token
33
- tokens << 102 # sep token
34
- tokens
35
- end
36
-
37
- max_tokens = input_ids.map(&:size).max
38
- attention_mask = []
39
- input_ids.each do |ids|
40
- zeros = [0] * (max_tokens - ids.size)
41
-
42
- mask = ([1] * ids.size) + zeros
43
- attention_mask << mask
44
-
45
- ids.concat(zeros)
46
- end
47
-
48
- # infer
49
- input = {
50
- input_ids: input_ids,
51
- attention_mask: attention_mask
52
- }
53
- res = @model.predict(input)
54
- output = res["output_0"] || res["logits"]
55
-
56
- # transform
57
- scores =
58
- output.map do |row|
59
- mapped = row.map { |v| Math.exp(v) }
60
- sum = mapped.sum
61
- mapped.map { |v| v / sum }
62
- end
63
-
64
- labels = ["negative", "positive"]
65
- scores.map! do |item|
66
- {label: labels[item.each_with_index.max[1]], score: item.max}
67
- end
68
-
69
- singular ? scores.first : scores
70
- end
71
- end
72
- end
@@ -1,54 +0,0 @@
1
- # Copyright 2018 The HuggingFace Inc. team.
2
- # Copyright 2021 Andrew Kane.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
-
16
- module Informers
17
- class TextGeneration
18
- def initialize(model_path)
19
- encoder_path = File.expand_path("../../vendor/gpt2.bin", __dir__)
20
- @encoder = BlingFire.load_model(encoder_path, prefix: false)
21
-
22
- decoder_path = File.expand_path("../../vendor/gpt2.i2w", __dir__)
23
- @decoder = BlingFire.load_model(decoder_path)
24
-
25
- @model = OnnxRuntime::Model.new(model_path)
26
- end
27
-
28
- def predict(text, max_length: 50)
29
- tokens = @encoder.text_to_ids(text)
30
-
31
- input = {
32
- input_ids: [tokens]
33
- }
34
- if @model.inputs.any? { |i| i[:name] == "attention_mask" }
35
- input[:attention_mask] = [[1] * tokens.size]
36
- end
37
-
38
- output_name =
39
- if @model.outputs.any? { |o| o[:name] == "output_0" }
40
- "output_0"
41
- else
42
- "logits"
43
- end
44
-
45
- (max_length - tokens.size).times do |i|
46
- output = @model.predict(input, output_type: :numo, output_names: [output_name])
47
- # passed to input_ids
48
- tokens << output[output_name][0, true, true][-1, true].max_index
49
- end
50
-
51
- @decoder.ids_to_text(tokens)
52
- end
53
- end
54
- end
@@ -1,202 +0,0 @@
1
-
2
- Apache License
3
- Version 2.0, January 2004
4
- http://www.apache.org/licenses/
5
-
6
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
-
8
- 1. Definitions.
9
-
10
- "License" shall mean the terms and conditions for use, reproduction,
11
- and distribution as defined by Sections 1 through 9 of this document.
12
-
13
- "Licensor" shall mean the copyright owner or entity authorized by
14
- the copyright owner that is granting the License.
15
-
16
- "Legal Entity" shall mean the union of the acting entity and all
17
- other entities that control, are controlled by, or are under common
18
- control with that entity. For the purposes of this definition,
19
- "control" means (i) the power, direct or indirect, to cause the
20
- direction or management of such entity, whether by contract or
21
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
- outstanding shares, or (iii) beneficial ownership of such entity.
23
-
24
- "You" (or "Your") shall mean an individual or Legal Entity
25
- exercising permissions granted by this License.
26
-
27
- "Source" form shall mean the preferred form for making modifications,
28
- including but not limited to software source code, documentation
29
- source, and configuration files.
30
-
31
- "Object" form shall mean any form resulting from mechanical
32
- transformation or translation of a Source form, including but
33
- not limited to compiled object code, generated documentation,
34
- and conversions to other media types.
35
-
36
- "Work" shall mean the work of authorship, whether in Source or
37
- Object form, made available under the License, as indicated by a
38
- copyright notice that is included in or attached to the work
39
- (an example is provided in the Appendix below).
40
-
41
- "Derivative Works" shall mean any work, whether in Source or Object
42
- form, that is based on (or derived from) the Work and for which the
43
- editorial revisions, annotations, elaborations, or other modifications
44
- represent, as a whole, an original work of authorship. For the purposes
45
- of this License, Derivative Works shall not include works that remain
46
- separable from, or merely link (or bind by name) to the interfaces of,
47
- the Work and Derivative Works thereof.
48
-
49
- "Contribution" shall mean any work of authorship, including
50
- the original version of the Work and any modifications or additions
51
- to that Work or Derivative Works thereof, that is intentionally
52
- submitted to Licensor for inclusion in the Work by the copyright owner
53
- or by an individual or Legal Entity authorized to submit on behalf of
54
- the copyright owner. For the purposes of this definition, "submitted"
55
- means any form of electronic, verbal, or written communication sent
56
- to the Licensor or its representatives, including but not limited to
57
- communication on electronic mailing lists, source code control systems,
58
- and issue tracking systems that are managed by, or on behalf of, the
59
- Licensor for the purpose of discussing and improving the Work, but
60
- excluding communication that is conspicuously marked or otherwise
61
- designated in writing by the copyright owner as "Not a Contribution."
62
-
63
- "Contributor" shall mean Licensor and any individual or Legal Entity
64
- on behalf of whom a Contribution has been received by Licensor and
65
- subsequently incorporated within the Work.
66
-
67
- 2. Grant of Copyright License. Subject to the terms and conditions of
68
- this License, each Contributor hereby grants to You a perpetual,
69
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
- copyright license to reproduce, prepare Derivative Works of,
71
- publicly display, publicly perform, sublicense, and distribute the
72
- Work and such Derivative Works in Source or Object form.
73
-
74
- 3. Grant of Patent License. Subject to the terms and conditions of
75
- this License, each Contributor hereby grants to You a perpetual,
76
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
- (except as stated in this section) patent license to make, have made,
78
- use, offer to sell, sell, import, and otherwise transfer the Work,
79
- where such license applies only to those patent claims licensable
80
- by such Contributor that are necessarily infringed by their
81
- Contribution(s) alone or by combination of their Contribution(s)
82
- with the Work to which such Contribution(s) was submitted. If You
83
- institute patent litigation against any entity (including a
84
- cross-claim or counterclaim in a lawsuit) alleging that the Work
85
- or a Contribution incorporated within the Work constitutes direct
86
- or contributory patent infringement, then any patent licenses
87
- granted to You under this License for that Work shall terminate
88
- as of the date such litigation is filed.
89
-
90
- 4. Redistribution. You may reproduce and distribute copies of the
91
- Work or Derivative Works thereof in any medium, with or without
92
- modifications, and in Source or Object form, provided that You
93
- meet the following conditions:
94
-
95
- (a) You must give any other recipients of the Work or
96
- Derivative Works a copy of this License; and
97
-
98
- (b) You must cause any modified files to carry prominent notices
99
- stating that You changed the files; and
100
-
101
- (c) You must retain, in the Source form of any Derivative Works
102
- that You distribute, all copyright, patent, trademark, and
103
- attribution notices from the Source form of the Work,
104
- excluding those notices that do not pertain to any part of
105
- the Derivative Works; and
106
-
107
- (d) If the Work includes a "NOTICE" text file as part of its
108
- distribution, then any Derivative Works that You distribute must
109
- include a readable copy of the attribution notices contained
110
- within such NOTICE file, excluding those notices that do not
111
- pertain to any part of the Derivative Works, in at least one
112
- of the following places: within a NOTICE text file distributed
113
- as part of the Derivative Works; within the Source form or
114
- documentation, if provided along with the Derivative Works; or,
115
- within a display generated by the Derivative Works, if and
116
- wherever such third-party notices normally appear. The contents
117
- of the NOTICE file are for informational purposes only and
118
- do not modify the License. You may add Your own attribution
119
- notices within Derivative Works that You distribute, alongside
120
- or as an addendum to the NOTICE text from the Work, provided
121
- that such additional attribution notices cannot be construed
122
- as modifying the License.
123
-
124
- You may add Your own copyright statement to Your modifications and
125
- may provide additional or different license terms and conditions
126
- for use, reproduction, or distribution of Your modifications, or
127
- for any such Derivative Works as a whole, provided Your use,
128
- reproduction, and distribution of the Work otherwise complies with
129
- the conditions stated in this License.
130
-
131
- 5. Submission of Contributions. Unless You explicitly state otherwise,
132
- any Contribution intentionally submitted for inclusion in the Work
133
- by You to the Licensor shall be under the terms and conditions of
134
- this License, without any additional terms or conditions.
135
- Notwithstanding the above, nothing herein shall supersede or modify
136
- the terms of any separate license agreement you may have executed
137
- with Licensor regarding such Contributions.
138
-
139
- 6. Trademarks. This License does not grant permission to use the trade
140
- names, trademarks, service marks, or product names of the Licensor,
141
- except as required for reasonable and customary use in describing the
142
- origin of the Work and reproducing the content of the NOTICE file.
143
-
144
- 7. Disclaimer of Warranty. Unless required by applicable law or
145
- agreed to in writing, Licensor provides the Work (and each
146
- Contributor provides its Contributions) on an "AS IS" BASIS,
147
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
- implied, including, without limitation, any warranties or conditions
149
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
- PARTICULAR PURPOSE. You are solely responsible for determining the
151
- appropriateness of using or redistributing the Work and assume any
152
- risks associated with Your exercise of permissions under this License.
153
-
154
- 8. Limitation of Liability. In no event and under no legal theory,
155
- whether in tort (including negligence), contract, or otherwise,
156
- unless required by applicable law (such as deliberate and grossly
157
- negligent acts) or agreed to in writing, shall any Contributor be
158
- liable to You for damages, including any direct, indirect, special,
159
- incidental, or consequential damages of any character arising as a
160
- result of this License or out of the use or inability to use the
161
- Work (including but not limited to damages for loss of goodwill,
162
- work stoppage, computer failure or malfunction, or any and all
163
- other commercial damages or losses), even if such Contributor
164
- has been advised of the possibility of such damages.
165
-
166
- 9. Accepting Warranty or Additional Liability. While redistributing
167
- the Work or Derivative Works thereof, You may choose to offer,
168
- and charge a fee for, acceptance of support, warranty, indemnity,
169
- or other liability obligations and/or rights consistent with this
170
- License. However, in accepting such obligations, You may act only
171
- on Your own behalf and on Your sole responsibility, not on behalf
172
- of any other Contributor, and only if You agree to indemnify,
173
- defend, and hold each Contributor harmless for any liability
174
- incurred by, or claims asserted against, such Contributor by reason
175
- of your accepting any such warranty or additional liability.
176
-
177
- END OF TERMS AND CONDITIONS
178
-
179
- APPENDIX: How to apply the Apache License to your work.
180
-
181
- To apply the Apache License to your work, attach the following
182
- boilerplate notice, with the fields enclosed by brackets "[]"
183
- replaced with your own identifying information. (Don't include
184
- the brackets!) The text should be enclosed in the appropriate
185
- comment syntax for the file format. We also recommend that a
186
- file or class name and description of purpose be included on the
187
- same "printed page" as the copyright notice for easier
188
- identification within third-party archives.
189
-
190
- Copyright [yyyy] [name of copyright owner]
191
-
192
- Licensed under the Apache License, Version 2.0 (the "License");
193
- you may not use this file except in compliance with the License.
194
- You may obtain a copy of the License at
195
-
196
- http://www.apache.org/licenses/LICENSE-2.0
197
-
198
- Unless required by applicable law or agreed to in writing, software
199
- distributed under the License is distributed on an "AS IS" BASIS,
200
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
- See the License for the specific language governing permissions and
202
- limitations under the License.
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) Microsoft Corporation. All rights reserved.
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE
@@ -1,24 +0,0 @@
1
- Modified MIT License
2
-
3
- Software Copyright (c) 2019 OpenAI
4
-
5
- We don’t claim ownership of the content you create with GPT-2, so it is yours to do with as you please.
6
- We only ask that you use GPT-2 responsibly and clearly indicate your content was created using GPT-2.
7
-
8
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
9
- associated documentation files (the "Software"), to deal in the Software without restriction,
10
- including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
11
- and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
12
- subject to the following conditions:
13
-
14
- The above copyright notice and this permission notice shall be included
15
- in all copies or substantial portions of the Software.
16
- The above copyright notice and this permission notice need not be included
17
- with content created by the Software.
18
-
19
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
20
- INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
22
- BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
24
- OR OTHER DEALINGS IN THE SOFTWARE.