Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.
Python calibrationclassificationdecision-modelhuggingfacejevmodernbertmultilingualnlppythonpytorchroutingtyped-decisionszero-shot
fix(dotnet): give a float head_max_len Python's slice error first
kevin-gatimu6d86935865c7
diff --git a/laya-dotnet/README.md b/laya-dotnet/README.mdindex 8e66f6a1..8c987195 100644--- a/laya-dotnet/README.md+++ b/laya-dotnet/README.md@@ -960,13 +960,12 @@ Where this SDK deliberately does not match the Python reference, so nobody has tan `InvalidDataException`: a float, string, `null`, list or object gets the `TypeError` text Python raises at the firstprediction (head first, then `max_len`), and a negative integer gets a message naming the field and value, becausePython then slices from the end, which this port does not support. Python loads such a checkpoint and fails later. The- related corner: a *fractional* `head_max_len` that Python happens to survive (a very small float) is refused here too.+ related corner: a small *fractional* `head_max_len` that Python happens to survive (roughly up to 8 plus 4 per option)+ is refused here too.- **JSON nesting.** Config and tokenizer JSON is read like `json.loads`, with the nesting cut-off set to 2,997 levels,what CPython 3.12 measured from a shallow call. Python's real limit depends on the call depth at the point of loading.- **Config files are decoded as strict UTF-8.** Python opens them with the locale's encoding (cp1252 on a default Windowsinstall), which only differs for non-ASCII bytes; a BOM is rejected, as `json.loads` does.-- **A `temperature` list shorter than three** loads, and fails with `IndexError: list index out of range` at the first- prediction that needs the missing entry, as Python does.---diff --git a/laya-dotnet/src/Laya/LayaConfig.cs b/laya-dotnet/src/Laya/LayaConfig.csindex 25b8ccf2..a97d9f31 100644--- a/laya-dotnet/src/Laya/LayaConfig.cs+++ b/laya-dotnet/src/Laya/LayaConfig.cs@@ -197,9 +197,8 @@ public sealed class LayaConfigstring Operand(string kind) => $"TypeError: unsupported operand type(s) for -: '{kind}' and 'int'";var leftBad = left is not ("int" or "bool");var rightBad = right is not ("int" or "bool");- if (rightBad && right != "float") throw new InvalidDataException(Operand(right));+ if (rightBad) throw new InvalidDataException(right == "float" ? SliceError : Operand(right));if (leftBad) throw new InvalidDataException(left == "float" ? SliceError : Operand(left));- if (rightBad) throw new InvalidDataException(SliceError);return (Length("max_len", maxLen), Length("head_max_len", headMaxLen));}@@ -213,5 +212,5 @@ public sealed class LayaConfig};private static InvalidDataException NegativeLength(string key, string literal) =>- new($"{key}={literal} is negative: Python slices from the end for it, which this port does not support");+ new($"{key}={literal}: must be a non-negative integer");}diff --git a/laya-dotnet/tests/Laya.Tests/ConfigFieldTypeTests.cs b/laya-dotnet/tests/Laya.Tests/ConfigFieldTypeTests.csindex 76f2538c..f781e93a 100644--- a/laya-dotnet/tests/Laya.Tests/ConfigFieldTypeTests.cs+++ b/laya-dotnet/tests/Laya.Tests/ConfigFieldTypeTests.cs@@ -106,7 +106,8 @@ public sealed class ConfigFieldTypeTests{ "{\"max_len\": \"x\"}", "TypeError: unsupported operand type(s) for -: 'str' and 'int'" },{ "{\"max_len\": \"x\", \"head_max_len\": 512}", "TypeError: unsupported operand type(s) for -: 'str' and 'int'" },{ "{\"max_len\": \"x\", \"head_max_len\": true}", "TypeError: unsupported operand type(s) for -: 'str' and 'int'" },- { "{\"max_len\": \"x\", \"head_max_len\": 1.5}", "TypeError: unsupported operand type(s) for -: 'str' and 'int'" },+ { "{\"max_len\": \"x\", \"head_max_len\": 1.5}", "TypeError: slice indices must be integers or None or have an __index__ method" },+ { "{\"max_len\": \"x\", \"head_max_len\": 192.0}", "TypeError: slice indices must be integers or None or have an __index__ method" },{ "{\"max_len\": \"x\", \"head_max_len\": \"x\"}", "TypeError: unsupported operand type(s) for -: 'str' and 'int'" },{ "{\"max_len\": \"x\", \"head_max_len\": null}", "TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'" },{ "{\"max_len\": \"x\", \"head_max_len\": [1]}", "TypeError: unsupported operand type(s) for -: 'list' and 'int'" },@@ -114,7 +115,8 @@ public sealed class ConfigFieldTypeTests{ "{\"max_len\": null}", "TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'" },{ "{\"max_len\": null, \"head_max_len\": 512}", "TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'" },{ "{\"max_len\": null, \"head_max_len\": true}", "TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'" },- { "{\"max_len\": null, \"head_max_len\": 1.5}", "TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'" },+ { "{\"max_len\": null, \"head_max_len\": 1.5}", "TypeError: slice indices must be integers or None or have an __index__ method" },+ { "{\"max_len\": null, \"head_max_len\": 192.0}", "TypeError: slice indices must be integers or None or have an __index__ method" },{ "{\"max_len\": null, \"head_max_len\": \"x\"}", "TypeError: unsupported operand type(s) for -: 'str' and 'int'" },{ "{\"max_len\": null, \"head_max_len\": null}", "TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'" },{ "{\"max_len\": null, \"head_max_len\": [1]}", "TypeError: unsupported operand type(s) for -: 'list' and 'int'" },@@ -122,7 +124,8 @@ public sealed class ConfigFieldTypeTests{ "{\"max_len\": [1]}", "TypeError: unsupported operand type(s) for -: 'list' and 'int'" },{ "{\"max_len\": [1], \"head_max_len\": 512}", "TypeError: unsupported operand type(s) for -: 'list' and 'int'" },{ "{\"max_len\": [1], \"head_max_len\": true}", "TypeError: unsupported operand type(s) for -: 'list' and 'int'" },- { "{\"max_len\": [1], \"head_max_len\": 1.5}", "TypeError: unsupported operand type(s) for -: 'list' and 'int'" },+ { "{\"max_len\": [1], \"head_max_len\": 1.5}", "TypeError: slice indices must be integers or None or have an __index__ method" },+ { "{\"max_len\": [1], \"head_max_len\": 192.0}", "TypeError: slice indices must be integers or None or have an __index__ method" },{ "{\"max_len\": [1], \"head_max_len\": \"x\"}", "TypeError: unsupported operand type(s) for -: 'str' and 'int'" },{ "{\"max_len\": [1], \"head_max_len\": null}", "TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'" },{ "{\"max_len\": [1], \"head_max_len\": [1]}", "TypeError: unsupported operand type(s) for -: 'list' and 'int'" },@@ -130,7 +133,8 @@ public sealed class ConfigFieldTypeTests{ "{\"max_len\": {}}", "TypeError: unsupported operand type(s) for -: 'dict' and 'int'" },{ "{\"max_len\": {}, \"head_max_len\": 512}", "TypeError: unsupported operand type(s) for -: 'dict' and 'int'" },{ "{\"max_len\": {}, \"head_max_len\": true}", "TypeError: unsupported operand type(s) for -: 'dict' and 'int'" },- { "{\"max_len\": {}, \"head_max_len\": 1.5}", "TypeError: unsupported operand type(s) for -: 'dict' and 'int'" },+ { "{\"max_len\": {}, \"head_max_len\": 1.5}", "TypeError: slice indices must be integers or None or have an __index__ method" },+ { "{\"max_len\": {}, \"head_max_len\": 192.0}", "TypeError: slice indices must be integers or None or have an __index__ method" },{ "{\"max_len\": {}, \"head_max_len\": \"x\"}", "TypeError: unsupported operand type(s) for -: 'str' and 'int'" },{ "{\"max_len\": {}, \"head_max_len\": null}", "TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'" },{ "{\"max_len\": {}, \"head_max_len\": [1]}", "TypeError: unsupported operand type(s) for -: 'list' and 'int'" },@@ -146,9 +150,9 @@ public sealed class ConfigFieldTypeTests}[Theory]- [InlineData("{\"max_len\": -1}", "max_len=-1 is negative: Python slices from the end for it, which this port does not support")]- [InlineData("{\"head_max_len\": -192}", "head_max_len=-192 is negative: Python slices from the end for it, which this port does not support")]- [InlineData("{\"max_len\": -99999999999999999999999}", "max_len=-99999999999999999999999 is negative: Python slices from the end for it, which this port does not support")]+ [InlineData("{\"max_len\": -1}", "max_len=-1: must be a non-negative integer")]+ [InlineData("{\"head_max_len\": -192}", "head_max_len=-192: must be a non-negative integer")]+ [InlineData("{\"max_len\": -99999999999999999999999}", "max_len=-99999999999999999999999: must be a non-negative integer")]public void NegativeLengthsAreRefusedAtLoad(string json, string error) =>Assert.Equal(error, Assert.Throws<InvalidDataException>(() => LayaConfig.Parse(json)).Message);@@ -217,4 +221,3 @@ public sealed class ConfigFieldTypeTests}}}-