peter szemraj commited on
Commit
74f30e9
1 Parent(s): 7659e10

:art: format

Browse files
Files changed (2) hide show
  1. app.py +4 -4
  2. utils.py +18 -16
app.py CHANGED
@@ -41,7 +41,9 @@ def generate_text(
41
  global generator
42
  if verbose:
43
  logging.info(f"Generating text from prompt:\n\n{prompt}")
44
- logging.info(f"params:\tmax_length={gen_length}, num_beams={num_beams}, no_repeat_ngram_size={no_repeat_ngram_size}, length_penalty={length_penalty}, repetition_penalty={repetition_penalty}, abs_max_length={abs_max_length}")
 
 
45
  st = time.perf_counter()
46
 
47
  input_tokens = generator.tokenizer(prompt)
@@ -128,9 +130,7 @@ if __name__ == "__main__":
128
  with gr.Column():
129
 
130
  gr.Markdown("## Generate Text")
131
- gr.Markdown(
132
- "Edit the prompt and parameters and press **Generate**!"
133
- )
134
  prompt_text = gr.Textbox(
135
  lines=4,
136
  label="Email Prompt",
 
41
  global generator
42
  if verbose:
43
  logging.info(f"Generating text from prompt:\n\n{prompt}")
44
+ logging.info(
45
+ f"params:\tmax_length={gen_length}, num_beams={num_beams}, no_repeat_ngram_size={no_repeat_ngram_size}, length_penalty={length_penalty}, repetition_penalty={repetition_penalty}, abs_max_length={abs_max_length}"
46
+ )
47
  st = time.perf_counter()
48
 
49
  input_tokens = generator.tokenizer(prompt)
 
130
  with gr.Column():
131
 
132
  gr.Markdown("## Generate Text")
133
+ gr.Markdown("Edit the prompt and parameters and press **Generate**!")
 
 
134
  prompt_text = gr.Textbox(
135
  lines=4,
136
  label="Email Prompt",
utils.py CHANGED
@@ -2,7 +2,8 @@
2
  utils.py - Utility functions for the project.
3
  """
4
 
5
- def postprocess(text:str):
 
6
  """
7
  postprocess - remove common values in scraped dataset
8
 
@@ -11,19 +12,19 @@ def postprocess(text:str):
11
  """
12
 
13
  replacements = {
14
- "ENA":"<COMPANY>",
15
- "Enron":"<COMPANY>",
16
- "Enron Corporation":"<COMPANY>",
17
- "Sony Pictures Entertainment":"<COMPANY>",
18
- "Columbia Pictures":"<COMPANY>",
19
- "Sony":"<COMPANY>",
20
- "Columbia":"<COMPANY>",
21
- "Hillary":"Jane",
22
- "Clinton":"Smith",
23
- "Amy":"Jane",
24
- "Sara":"Jane",
25
- "Harambe":"Jane",
26
- "Pascal":"<PERSON>",
27
  }
28
 
29
  # replace common values, also check lowercase
@@ -33,7 +34,8 @@ def postprocess(text:str):
33
 
34
  return text
35
 
 
36
  def clear(**kwargs):
37
- """for use with buttons"""
38
 
39
- return ""
 
2
  utils.py - Utility functions for the project.
3
  """
4
 
5
+
6
+ def postprocess(text: str):
7
  """
8
  postprocess - remove common values in scraped dataset
9
 
 
12
  """
13
 
14
  replacements = {
15
+ "ENA": "<COMPANY>",
16
+ "Enron": "<COMPANY>",
17
+ "Enron Corporation": "<COMPANY>",
18
+ "Sony Pictures Entertainment": "<COMPANY>",
19
+ "Columbia Pictures": "<COMPANY>",
20
+ "Sony": "<COMPANY>",
21
+ "Columbia": "<COMPANY>",
22
+ "Hillary": "Jane",
23
+ "Clinton": "Smith",
24
+ "Amy": "Jane",
25
+ "Sara": "Jane",
26
+ "Harambe": "Jane",
27
+ "Pascal": "<PERSON>",
28
  }
29
 
30
  # replace common values, also check lowercase
 
34
 
35
  return text
36
 
37
+
38
  def clear(**kwargs):
39
+ """for use with buttons"""
40
 
41
+ return ""