Instructions to use chkrishna2001/psm-memory-qwen0.5b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use chkrishna2001/psm-memory-qwen0.5b with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: Qwen/Qwen2.5-0.5B-Instruct
|
| 4 |
+
tags:
|
| 5 |
+
- lora
|
| 6 |
+
- peft
|
| 7 |
+
- onnxruntime-genai
|
| 8 |
+
- agent-memory
|
| 9 |
+
- qwen2
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# PSM Memory — Qwen2.5-0.5B LoRA adapters + ONNX Runtime GenAI export
|
| 13 |
+
|
| 14 |
+
Three task-specific LoRA adapters trained on `Qwen/Qwen2.5-0.5B-Instruct` for the PSM
|
| 15 |
+
("memory as a cognitive skill") project, plus a production ONNX export with all three adapters
|
| 16 |
+
as swappable deltas over one shared base graph.
|
| 17 |
+
|
| 18 |
+
## Adapters
|
| 19 |
+
|
| 20 |
+
| Task | Directory | Gate score | LoRA config |
|
| 21 |
+
|---|---|---|---|
|
| 22 |
+
| Storage decision (store/ignore/update/etc.) | `lora/storage/` | 0.84 (100-case coding-agent gate) | r=16, alpha=32 |
|
| 23 |
+
| Retrieval-plan (recall/context planning) | `lora/retrieval_plan/` | 0.935 | r=16, alpha=32 |
|
| 24 |
+
| Consolidation (merge/update/conflict resolution) | `lora/consolidation/` | 0.826 | r=16, alpha=32 |
|
| 25 |
+
|
| 26 |
+
All three share identical LoRA config (target_modules: q/k/v/o/gate/up/down_proj), which is what
|
| 27 |
+
allows them to share one base ONNX graph in `onnx/`.
|
| 28 |
+
|
| 29 |
+
## ONNX Runtime GenAI export (`onnx/`)
|
| 30 |
+
|
| 31 |
+
`onnx/model.onnx` is the base model traced with LoRA branches kept genuinely separate (not merged),
|
| 32 |
+
via Olive's `--use_dynamo_exporter` + `ExtractAdapters` pass. `onnx/adapters/*.onnx_adapter` are the
|
| 33 |
+
three swappable adapter deltas. Confirmed via `Microsoft.ML.OnnxRuntimeGenAI`
|
| 34 |
+
(`Adapters.LoadAdapter` / `Generator.SetActiveAdapter`) at **exact parity with the PyTorch baseline**
|
| 35 |
+
(0.84 on the storage gate, parse_valid_rate 1.00).
|
| 36 |
+
|
| 37 |
+
Produced by the repeatable conversion pipeline at
|
| 38 |
+
`psm-model/scripts/convert_adapters_onnx.py` in the source repo — see that script for the exact
|
| 39 |
+
Olive/transformers version pinning required (Olive 0.13.0 needs `transformers==4.48.3` for its
|
| 40 |
+
dynamo-exporter Cache-compatibility patch; this machine's default `transformers` 5.x will silently
|
| 41 |
+
break the export otherwise).
|
| 42 |
+
|
| 43 |
+
```python
|
| 44 |
+
import onnxruntime_genai as og
|
| 45 |
+
|
| 46 |
+
model = og.Model("onnx")
|
| 47 |
+
tokenizer = og.Tokenizer(model)
|
| 48 |
+
adapters = og.Adapters(model)
|
| 49 |
+
adapters.load("onnx/adapters/storage.onnx_adapter", "storage")
|
| 50 |
+
|
| 51 |
+
params = og.GeneratorParams(model)
|
| 52 |
+
params.set_search_options(do_sample=False, max_length=4096)
|
| 53 |
+
generator = og.Generator(model, params)
|
| 54 |
+
generator.set_active_adapter(adapters, "storage")
|
| 55 |
+
# ... encode prompt, generate ...
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
## Raw PEFT adapters (`lora/`)
|
| 59 |
+
|
| 60 |
+
Standard PEFT adapter directories (`adapter_config.json` + `adapter_model.safetensors`), loadable via
|
| 61 |
+
`peft.PeftModel.from_pretrained(base_model, "lora/storage")` etc. against the base
|
| 62 |
+
`Qwen/Qwen2.5-0.5B-Instruct` model.
|