Return invalid_question for malformed span thresholds and instructions

#3
by subin - opened
Files changed (2) hide show
  1. SHA256SUMS +1 -1
  2. modeling_vela3.py +4 -0
SHA256SUMS CHANGED
@@ -7,7 +7,7 @@ e6ec4981046337e0e7e1bf9696ce15d281bdd691188f1adb33e6a8d53466ff0d image_halu_hea
7
  64d5b39a3997b0263d56e737878e3c4937177fefc30f83d5649880a88433455b image_halu_lora.safetensors
8
  4cd699d86c9d41a7947e19ae944541d9d552fc68e94b7c11d40b9b67b1afe62c label_definitions.json
9
  3d43ed7f6b0af94195d6ea687a59141384a4fba5a3756016aade8c9c0c208662 labeldef_lm_head.safetensors
10
- 923d92213cbe0ae47dfe1bcc1077c332ff9bb66aa054e6ec21d6bd54990232cd modeling_vela3.py
11
  cc710bdeb492c51564600ff09b645bce2b716d1fff76e810249b0926dd2e49fe ner_head.safetensors
12
  3272c03b55df4927aa733a2b5dc45af1b4474cf2034924b6a8c45a084513b9a7 ner_lora.safetensors
13
  8bf595b1d23ea1f6d7dc6f751322dad6ed81b86bf2f0c9669d169aec24013cc2 relation_head.safetensors
 
7
  64d5b39a3997b0263d56e737878e3c4937177fefc30f83d5649880a88433455b image_halu_lora.safetensors
8
  4cd699d86c9d41a7947e19ae944541d9d552fc68e94b7c11d40b9b67b1afe62c label_definitions.json
9
  3d43ed7f6b0af94195d6ea687a59141384a4fba5a3756016aade8c9c0c208662 labeldef_lm_head.safetensors
10
+ e3e03870b543ba9489986b61268f83c0648654c9d35ebdb4f9851fff20a8876d modeling_vela3.py
11
  cc710bdeb492c51564600ff09b645bce2b716d1fff76e810249b0926dd2e49fe ner_head.safetensors
12
  3272c03b55df4927aa733a2b5dc45af1b4474cf2034924b6a8c45a084513b9a7 ner_lora.safetensors
13
  8bf595b1d23ea1f6d7dc6f751322dad6ed81b86bf2f0c9669d169aec24013cc2 relation_head.safetensors
modeling_vela3.py CHANGED
@@ -270,6 +270,10 @@ class Vela3MiniModel(PreTrainedModel):
270
  raise ValueError("span labels must be distinct")
271
  sp = self.vela3_config["span"]; lset = self._label_set(names)
272
  question = q.get("instructions")
 
 
 
 
273
  route, route_why = self._span_route(lset, names, question)
274
  img_halu = bool(images) and lset == "halu" and "image_halu" in sp
275
  if lset in sp["schemas"]: # trained router schema: its question text and label descriptions fill what the request leaves empty
 
270
  raise ValueError("span labels must be distinct")
271
  sp = self.vela3_config["span"]; lset = self._label_set(names)
272
  question = q.get("instructions")
273
+ if question is not None and not isinstance(question, str):
274
+ raise ValueError("span instructions must be a string")
275
+ if not isinstance(q.get("threshold", 0.0), (int, float, str)): # numeric strings still go through float() below
276
+ raise ValueError("threshold must be a number")
277
  route, route_why = self._span_route(lset, names, question)
278
  img_halu = bool(images) and lset == "halu" and "image_halu" in sp
279
  if lset in sp["schemas"]: # trained router schema: its question text and label descriptions fill what the request leaves empty