Ceshine Lee commited on
Commit
d11e70d
·
1 Parent(s): d38d726

Back to beam search; add the correct prompt command

Browse files
Files changed (1) hide show
  1. app.py +6 -11
app.py CHANGED
@@ -16,27 +16,22 @@ def paraphrase(source_text):
16
  headers={"Authorization": f"Bearer {os.environ['TOKEN']}"},
17
  data=json.dumps(
18
  {
19
- "inputs": source_text,
20
  "parameters": {
21
  # "do_sample": True,
22
- "num_beams": 10,
23
- "top_k": 5,
24
- "repetition_penalty": 2.0,
25
  "temperature": 1.5,
 
 
26
  "num_return_sequences": 10,
27
- "max_length": 200,
28
  },
29
  }
30
  ),
31
  )
32
  if not (res.status_code == 200):
33
- raise ValueError(
34
- "Could not complete request to HuggingFace API, Error {}".format(
35
- res.status_code
36
- )
37
- )
38
  results = res.json()
39
- print(results)
40
  outputs = [
41
  x["generated_text"]
42
  for x in results
 
16
  headers={"Authorization": f"Bearer {os.environ['TOKEN']}"},
17
  data=json.dumps(
18
  {
19
+ "inputs": "paraphrase: " + source_text,
20
  "parameters": {
21
  # "do_sample": True,
 
 
 
22
  "temperature": 1.5,
23
+ "top_k": 5,
24
+ "num_beams": 10,
25
  "num_return_sequences": 10,
26
+ "max_length": 100,
27
  },
28
  }
29
  ),
30
  )
31
  if not (res.status_code == 200):
32
+ return f"Got a {res.status_code} status code from HuggingFace."
 
 
 
 
33
  results = res.json()
34
+ # print(results)
35
  outputs = [
36
  x["generated_text"]
37
  for x in results