adaamko subin commited on
Commit
bbc0206
·
1 Parent(s): bddaae9

Return invalid_question for malformed span thresholds and instructions (#2)

Browse files

- Return invalid_question for malformed span thresholds and instructions (ca700661aa566df450db66901a336acd0fbc59fb)


Co-authored-by: Park Soobin <subin@users.noreply.huggingface.co>

Files changed (2) hide show
  1. SHA256SUMS +1 -1
  2. modeling_vela3.py +4 -0
SHA256SUMS CHANGED
@@ -7,7 +7,7 @@ ebdd12efa205265ae756f3c3aeec13c8f98cb00b89fb348c3c66607f81bbaa7a decision_lora.
7
  097a731801ee306709d72184d9e27ff0d13cb3e47533bf58be38786e7529a1a5 image_halu_head.safetensors
8
  20f0a98f5714c4ede7ea86e312ddbaa463a64d56c43d90561ec35f29b178d747 image_halu_lora.safetensors
9
  4cd699d86c9d41a7947e19ae944541d9d552fc68e94b7c11d40b9b67b1afe62c label_definitions.json
10
- 2842509459d9e56e0576bc81b1262a6a0d0b437ac5d23c112e5cb22f2e76ea48 modeling_vela3.py
11
  03dff7640e6fec1ad8ce8cd4af14e2a4e849615d7c296e931e80520a98cb4a39 ner_head.safetensors
12
  815a221cba6799ab104ac5725be73e9e8a6589354f0d6082b53ebd61a6dfe3fd ner_lora.safetensors
13
  ae3d69387d4853cd0eb7dc80f84282946ee25f5b8eaa23e10af8ed9a2d5a4a1e relation_head.safetensors
 
7
  097a731801ee306709d72184d9e27ff0d13cb3e47533bf58be38786e7529a1a5 image_halu_head.safetensors
8
  20f0a98f5714c4ede7ea86e312ddbaa463a64d56c43d90561ec35f29b178d747 image_halu_lora.safetensors
9
  4cd699d86c9d41a7947e19ae944541d9d552fc68e94b7c11d40b9b67b1afe62c label_definitions.json
10
+ c5d504897f24fbdaa831af0a797f1527314359454533c1cd3dc07bb1f98838c1 modeling_vela3.py
11
  03dff7640e6fec1ad8ce8cd4af14e2a4e849615d7c296e931e80520a98cb4a39 ner_head.safetensors
12
  815a221cba6799ab104ac5725be73e9e8a6589354f0d6082b53ebd61a6dfe3fd ner_lora.safetensors
13
  ae3d69387d4853cd0eb7dc80f84282946ee25f5b8eaa23e10af8ed9a2d5a4a1e relation_head.safetensors
modeling_vela3.py CHANGED
@@ -258,6 +258,10 @@ class Vela3MiniModel(PreTrainedModel):
258
  raise ValueError("span labels must be distinct")
259
  sp = self.vela3_config["span"]; lset = self._label_set(names)
260
  question = q.get("instructions")
 
 
 
 
261
  route, route_why = self._span_route(lset, names, question)
262
  img_halu = bool(images) and lset == "halu" and "image_halu" in sp
263
  if lset in sp["schemas"]: # trained router schema: its question text and label descriptions fill what the request leaves empty
 
258
  raise ValueError("span labels must be distinct")
259
  sp = self.vela3_config["span"]; lset = self._label_set(names)
260
  question = q.get("instructions")
261
+ if question is not None and not isinstance(question, str):
262
+ raise ValueError("span instructions must be a string")
263
+ if not isinstance(q.get("threshold", 0.0), (int, float, str)): # numeric strings still go through float() below
264
+ raise ValueError("threshold must be a number")
265
  route, route_why = self._span_route(lset, names, question)
266
  img_halu = bool(images) and lset == "halu" and "image_halu" in sp
267
  if lset in sp["schemas"]: # trained router schema: its question text and label descriptions fill what the request leaves empty