Instructions to use geraldaton20/hd-laya with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Laya
How to use geraldaton20/hd-laya with Laya:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Model card: real training stats, usage, and limits
Browse files
README.md
CHANGED
|
@@ -8,7 +8,7 @@ tags:
|
|
| 8 |
- vsa
|
| 9 |
- neuro-symbolic
|
| 10 |
- laya
|
| 11 |
-
base_model:
|
| 12 |
---
|
| 13 |
|
| 14 |
# hd-laya
|
|
@@ -18,29 +18,93 @@ un-distilled upstream [laya](https://github.com/NandhaKishorM/laya) System-1
|
|
| 18 |
engine. It removes laya's ~20-option choice ceiling and lets a
|
| 19 |
hyperdimensional (HDC/VSA) workspace manage context.
|
| 20 |
|
| 21 |
-
- **v0.1** (GitHub): no-train HDC harness around unmodified laya checkpoints
|
| 22 |
-
-
|
| 23 |
-
|
|
|
|
| 24 |
|
| 25 |
-
##
|
| 26 |
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|---|---|
|
| 29 |
-
|
|
| 30 |
-
|
|
| 31 |
-
|
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
|
| 40 |
-
##
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
## License
|
| 46 |
|
|
@@ -49,4 +113,4 @@ Apache-2.0 (derived from laya; attribution to NandhaKishorM/laya).
|
|
| 49 |
## Links
|
| 50 |
|
| 51 |
- GitHub: https://github.com/sensesVoid/hd-laya
|
| 52 |
-
-
|
|
|
|
| 8 |
- vsa
|
| 9 |
- neuro-symbolic
|
| 10 |
- laya
|
| 11 |
+
base_model: convaiinnovations/laya
|
| 12 |
---
|
| 13 |
|
| 14 |
# hd-laya
|
|
|
|
| 18 |
engine. It removes laya's ~20-option choice ceiling and lets a
|
| 19 |
hyperdimensional (HDC/VSA) workspace manage context.
|
| 20 |
|
| 21 |
+
- **v0.1** (GitHub): no-train HDC harness around unmodified laya checkpoints β
|
| 22 |
+
two-stage option index, int16 counter workspace, z-gate abstention.
|
| 23 |
+
- **v1.0** (this repo): trained head on a high-K choice task, so the narrowed
|
| 24 |
+
option set is scored by a head that was actually trained for it.
|
| 25 |
|
| 26 |
+
## Files
|
| 27 |
|
| 28 |
+
| File | Size | What it is |
|
| 29 |
+
|---|---|---|
|
| 30 |
+
| `hd_laya_trained.pt` | 106 MB | trainable weights only (`head`, `scorer`, `act_head`, `type_emb`, `temperature`) |
|
| 31 |
+
| `head.onnx` + `head.onnx.data` | 0.7 MB + 100 MB | the trained TransformerEncoder head as an ONNX graph (opset 18) |
|
| 32 |
+
|
| 33 |
+
The checkpoint holds **trainable weights only**. The encoder is frozen and comes
|
| 34 |
+
from `convaiinnovations/laya`, so load the base model first and then apply this
|
| 35 |
+
state dict. `hd_laya.laya_agent` does that and refuses to continue if any
|
| 36 |
+
non-encoder weight fails to load β a half-loaded head answers confidently at
|
| 37 |
+
random, which is worse than an error.
|
| 38 |
+
|
| 39 |
+
## Training
|
| 40 |
+
|
| 41 |
+
| | |
|
| 42 |
+
|---|---|
|
| 43 |
+
| base model | `convaiinnovations/laya` (encoder frozen) |
|
| 44 |
+
| hardware | Kaggle T4 x2 |
|
| 45 |
+
| task | synthetic high-K choice, K=77, 512 items |
|
| 46 |
+
| epochs | 4 (RLCD objective, option-order shuffling on `choice`) |
|
| 47 |
+
| budgets | `max_len=512`, `head_max_len=192` |
|
| 48 |
+
| trainable params | 26,512,131 |
|
| 49 |
+
| epoch losses | 3.89, 4.42, 4.05, 3.96 |
|
| 50 |
+
|
| 51 |
+
## Measured
|
| 52 |
+
|
| 53 |
+
Local CPU run, 48 generated items at K=20 (chance = 5%):
|
| 54 |
+
|
| 55 |
+
| metric | value |
|
| 56 |
|---|---|
|
| 57 |
+
| accuracy | 52.1% |
|
| 58 |
+
| refusal rate (z-gate, `z_bar=5.0`) | 6.25% |
|
| 59 |
+
| accuracy on answered | 55.6% |
|
| 60 |
+
|
| 61 |
+
These numbers say the head learned the task; they are not a benchmark result.
|
| 62 |
+
The high-K suite (K = 20/77/150/500/1000, 256 items each, HDC narrowing to 20
|
| 63 |
+
options before the forward pass) is what measures the index-plus-head path, and
|
| 64 |
+
its numbers belong in the GitHub README when they land.
|
| 65 |
+
|
| 66 |
+
## Usage
|
| 67 |
+
|
| 68 |
+
```python
|
| 69 |
+
from huggingface_hub import hf_hub_download
|
| 70 |
+
from laya.agent import Agent
|
| 71 |
+
from hd_laya.agent import HDLayaAgent
|
| 72 |
+
from hd_laya.laya_agent import TrainedLayaAgent
|
| 73 |
+
|
| 74 |
+
ckpt = hf_hub_download("geraldaton20/hd-laya", "hd_laya_trained.pt")
|
| 75 |
+
laya = Agent("convaiinnovations/laya", device="cuda")
|
| 76 |
+
|
| 77 |
+
# Fails loudly if the checkpoint does not fit this architecture.
|
| 78 |
+
trained = TrainedLayaAgent.from_checkpoint(
|
| 79 |
+
ckpt, agent=laya, max_len=512, head_max_len=192
|
| 80 |
+
)
|
| 81 |
+
agent = HDLayaAgent(trained, max_options=20, z_bar=5.0)
|
| 82 |
|
| 83 |
+
result = agent.predict(
|
| 84 |
+
"customer wants to refund order",
|
| 85 |
+
{"q": {"type": "choice",
|
| 86 |
+
"instructions": "Choose the option that matches the customer request.",
|
| 87 |
+
"criteria": {"opt_0": "refund order (variant 0)",
|
| 88 |
+
"opt_1": "reset password (variant 1)"}}},
|
| 89 |
+
)
|
| 90 |
+
print(result["answers"]["q"]["choice"], result["meta"]["z"])
|
| 91 |
+
```
|
| 92 |
|
| 93 |
+
Question sets above `max_options` are narrowed by the HDC option index first;
|
| 94 |
+
the answer maps back to the original labels.
|
| 95 |
|
| 96 |
+
## Limitations
|
| 97 |
|
| 98 |
+
- **Uncalibrated.** No temperature fit was applied after training; the smoke
|
| 99 |
+
sample measured top-label ECE β 0.60. Treat `confidence` as uncalibrated.
|
| 100 |
+
- **Head-only ONNX.** `head.onnx` exports the trained encoder block
|
| 101 |
+
(`src`, `src_key_padding_mask` β hidden states). `scorer`, `act_head` and the
|
| 102 |
+
encoder stay in PyTorch for now.
|
| 103 |
+
- **Trained at K=77.** The head saw 77 options with 192 head tokens during
|
| 104 |
+
training, where options were truncated aggressively; the K=20 numbers above are
|
| 105 |
+
the cleaner read of its skill.
|
| 106 |
+
- **Synthetic task.** Topics are 12 templates; this is a pipeline milestone, not
|
| 107 |
+
evidence about real intents.
|
| 108 |
|
| 109 |
## License
|
| 110 |
|
|
|
|
| 113 |
## Links
|
| 114 |
|
| 115 |
- GitHub: https://github.com/sensesVoid/hd-laya
|
| 116 |
+
- Upstream: https://github.com/NandhaKishorM/laya
|