JuanJoseMV
commited on
Commit
•
d114b79
1
Parent(s):
db1702e
hotfix
Browse files- NeuralTextGenerator.py +2 -0
- app.py +8 -2
NeuralTextGenerator.py
CHANGED
@@ -140,6 +140,8 @@ class BertTextGenerator:
|
|
140 |
|
141 |
sentences = []
|
142 |
|
|
|
|
|
143 |
for batch_n in range(n_batches):
|
144 |
batch_sentence_len = np.round(np.random.normal(avg_len, std_len))
|
145 |
batch_sentence_len = int(np.clip(batch_sentence_len, min_len, max_len))
|
|
|
140 |
|
141 |
sentences = []
|
142 |
|
143 |
+
print('SEED TEXT -------------------------', seed_text)
|
144 |
+
|
145 |
for batch_n in range(n_batches):
|
146 |
batch_sentence_len = np.round(np.random.normal(avg_len, std_len))
|
147 |
batch_sentence_len = int(np.clip(batch_sentence_len, min_len, max_len))
|
app.py
CHANGED
@@ -21,7 +21,13 @@ tokenizer = en_model.tokenizer
|
|
21 |
model = en_model.model
|
22 |
device = model.device
|
23 |
|
24 |
-
en_model.tokenizer.add_special_tokens({'additional_special_tokens': [
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
en_model.model.resize_token_embeddings(len(en_model.tokenizer))
|
26 |
|
27 |
# def classify(sentiment):
|
@@ -84,7 +90,7 @@ def sentence_builder(n_sentences, max_iter, sentiment, seed_text):
|
|
84 |
demo = gr.Interface(
|
85 |
sentence_builder,
|
86 |
[
|
87 |
-
gr.Slider(1, 15, value=2, label="Num. Tweets", info="Number of tweets to be generated."),
|
88 |
gr.Slider(50, 500, value=100, label="Max. iter", info="Maximum number of iterations for the generation."),
|
89 |
gr.Radio(["POSITIVE", "NEGATIVE"], label="Sentiment to generate"),
|
90 |
gr.Textbox('', label="Seed text", info="Seed text for the generation.")
|
|
|
21 |
model = en_model.model
|
22 |
device = model.device
|
23 |
|
24 |
+
en_model.tokenizer.add_special_tokens({'additional_special_tokens': [
|
25 |
+
'[POSITIVE-0]',
|
26 |
+
'[POSITIVE-1]',
|
27 |
+
'[POSITIVE-2]',
|
28 |
+
'[NEGATIVE-0]',
|
29 |
+
'[NEGATIVE-1]',
|
30 |
+
'[NEGATIVE-2]']})
|
31 |
en_model.model.resize_token_embeddings(len(en_model.tokenizer))
|
32 |
|
33 |
# def classify(sentiment):
|
|
|
90 |
demo = gr.Interface(
|
91 |
sentence_builder,
|
92 |
[
|
93 |
+
gr.Slider(1, 15, value=2, label="Num. Tweets", step= 1, info="Number of tweets to be generated."),
|
94 |
gr.Slider(50, 500, value=100, label="Max. iter", info="Maximum number of iterations for the generation."),
|
95 |
gr.Radio(["POSITIVE", "NEGATIVE"], label="Sentiment to generate"),
|
96 |
gr.Textbox('', label="Seed text", info="Seed text for the generation.")
|