Pierce Maloney commited on
Commit
66e62c6
1 Parent(s): 0e224b1

adding additional bad words ids

Browse files
Files changed (1) hide show
  1. handler.py +2 -0
handler.py CHANGED
@@ -20,6 +20,7 @@ class EndpointHandler():
20
  A :obj:`list` | `dict`: will be serialized and returned
21
  """
22
  inputs = data.pop("inputs", data)
 
23
 
24
 
25
  # 3070, 10456, [313, 334] corresponds to "(*", and we do not want to output a comment
@@ -27,6 +28,7 @@ class EndpointHandler():
27
  # [1976, 441, 29889] is "Abort."
28
  # [2087, 29885, 4430, 29889] is "Admitted."
29
  bad_words_ids = [[3070], [313, 334], [10456], [13], [1976, 441, 29889], [2087, 29885, 4430, 29889]]
 
30
 
31
  input_ids = self.tokenizer.encode(inputs, return_tensors="pt")
32
 
 
20
  A :obj:`list` | `dict`: will be serialized and returned
21
  """
22
  inputs = data.pop("inputs", data)
23
+ additional_bad_words_ids = data.pop("bad_words_ids", [])
24
 
25
 
26
  # 3070, 10456, [313, 334] corresponds to "(*", and we do not want to output a comment
 
28
  # [1976, 441, 29889] is "Abort."
29
  # [2087, 29885, 4430, 29889] is "Admitted."
30
  bad_words_ids = [[3070], [313, 334], [10456], [13], [1976, 441, 29889], [2087, 29885, 4430, 29889]]
31
+ bad_words_ids.extend(additional_bad_words_ids)
32
 
33
  input_ids = self.tokenizer.encode(inputs, return_tensors="pt")
34