Skip to content

armgit / laya

Public Imported from GitHub
0

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.

laya-go: README row for router; go lane floor 1603 -> 3462

Adeshina Lasisi602d8b0c1ce4
diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml
index 093a8071..bbaeff17 100644
--- a/.github/workflows/go.yml
+++ b/.github/workflows/go.yml
@@ -128,11 +128,11 @@ jobs:
LAYA_GO_FIXTURES: ${{ github.workspace }}/.go-goldens
LAYA_CHECKPOINTS: ${{ github.workspace }}/laya-java/.work/checkpoints
run: go test -race -count=1 -json ./... > "$RUNNER_TEMP/go-test.json"
- # Exactly the measured count (1603 tests and subtests, on both Go versions): dropping a
+ # Exactly the measured count (3462 tests and subtests, on both Go versions): dropping a
# case fails here, and adding one means raising this number.
- name: No test was skipped
if: ${{ !cancelled() }}
- run: python laya-go/scripts/check_test_json.py "$RUNNER_TEMP/go-test.json" --min-tests 1603
+ run: python laya-go/scripts/check_test_json.py "$RUNNER_TEMP/go-test.json" --min-tests 3462
# go.mod declares go 1.22, so that is what a consumer may build with.
- name: Run the tests on the oldest supported Go
@@ -144,7 +144,7 @@ jobs:
run: go test -count=1 -json ./... > "$RUNNER_TEMP/go-test-oldest.json"
- name: No test was skipped on the oldest Go either
if: ${{ !cancelled() }}
- run: python laya-go/scripts/check_test_json.py "$RUNNER_TEMP/go-test-oldest.json" --min-tests 1603
+ run: python laya-go/scripts/check_test_json.py "$RUNNER_TEMP/go-test-oldest.json" --min-tests 3462
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: ${{ failure() }}
diff --git a/laya-go/README.md b/laya-go/README.md
index 5685c09a..8fe31dec 100644
--- a/laya-go/README.md
+++ b/laya-go/README.md
@@ -4,7 +4,8 @@ A pure-Go port of [laya](../README.md). This module is standard library only: no
modules. Running the model needs the nested `onnx` module, which uses cgo.
The foundation (language detection, questions, sequences, the tokenizer) and the predict path
-(`infer`, `agent`) are here, and the `onnx` module runs the graph. The router comes in a later change.
+(`infer`, `agent`) are here, and the `onnx` module runs the graph. The router's pure routing half
+(`router`) is here; loading, hooks and routed inference come in later changes.
| Package | What it is |
| --- | --- |
@@ -12,6 +13,7 @@ The foundation (language detection, questions, sequences, the tokenizer) and the
| `schema` | Questions (`Choice`, `ChoiceOf`, `Score`, `Noul`, `NoulWith`, `Questions`) and results (`Answer`, `Prediction`, `Usage`) every other package shares. Questions are refused with laya's own wording and read or written in the Python wire form. |
| `sequence` | `build_sequence`, `build_head`, `state_room`, `window_budget` and `window_batch_cap`: `EncodeState`, `Build`, `StateRoom`, `PlanWindows`, `BatchCap`. |
| `infer` | The seam to a model runtime: `Batch` (the graph's five inputs), `Output` (its two), `Session`, and the shape checks `Batch.Validate` and `Output.Check`. |
+| `router` | Which checkpoint reads a request, the port of the routing half of `laya/router.py`: `New`, `Route`, `RouteBatch`, `NormaliseName`, `EnglishFromCode`, `MatchTypedDecisionsWorkflow`, `QuestionSchema`. Decisions carry laya's reason strings. Loads nothing. |
| `agent` | `ONNXAgent.predict` and `predict_batch` over an `infer.Session`: `Open`, `Predict`, `PredictBatch`, `LoadConfig`, with batch size, sort-by-length and context cancellation between runs. |
| `onnx` | A nested module (cgo, its own `go.mod`): `onnx.Open` runs a fused `laya.onnx` on ONNX Runtime and implements `infer.Session`, for `agent.Open`. Needs an ONNX Runtime 1.29+ shared library; `CGO_ENABLED=0` builds and `Open` returns `ErrNoCGO`. |
| `tokenizer` | A reader and runner for Hugging Face `tokenizer.json` (BPE): normalizer, pre-tokenizer, added tokens, byte fallback, decoder. |
@@ -42,7 +44,7 @@ order-sensitive state. `Analyze` reads every leaf, so its cost grows with the nu
- No root package: the module path ends in `laya-go`, so tags are `laya-go/vX.Y.Z`.
- Every package in this module is pure Go: `lang`, `schema`, `sequence`, `tokenizer`, `infer` and
- `agent` now, and `router`, `presets` and `shortlist` later.
+ `agent` and `router` now, and `presets` and `shortlist` later.
- cgo lives only in `onnx`, a nested module with its own `go.mod`, so `go test ./...` here never
compiles it. `onnx` requires this module and `github.com/yalue/onnxruntime_go`; until this module has
a release tag, `onnx` builds only inside this repository (its `go.mod` points here with `replace`). Importing `lang` or `agent` never compiles cgo.