Text Generation
PEFT
Safetensors
English
lora
llama-3.1
tool-use
embedded-ai
esp32
constitutional-ai
conversational
Instructions to use WhitneyDesignLabs/wireclaw-agent-v1.1-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use WhitneyDesignLabs/wireclaw-agent-v1.1-lora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.1-8B-Instruct") model = PeftModel.from_pretrained(base_model, "WhitneyDesignLabs/wireclaw-agent-v1.1-lora") - Notebooks
- Google Colab
- Kaggle
Initial release: wireclaw-agent v1.1 LoRA adapter (Project Opengates)
Browse files- .gitattributes +1 -0
- README.md +167 -0
- adapter_config.json +48 -0
- adapter_model.safetensors +3 -0
- chat_template.jinja +109 -0
- tokenizer.json +3 -0
- tokenizer_config.json +15 -0
- training-config.yaml +27 -0
- training-log.json +26 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: meta-llama/Llama-3.1-8B-Instruct
|
| 3 |
+
library_name: peft
|
| 4 |
+
license: llama3.1
|
| 5 |
+
license_name: llama3.1
|
| 6 |
+
license_link: https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct/blob/main/LICENSE
|
| 7 |
+
tags:
|
| 8 |
+
- lora
|
| 9 |
+
- peft
|
| 10 |
+
- llama-3.1
|
| 11 |
+
- tool-use
|
| 12 |
+
- embedded-ai
|
| 13 |
+
- esp32
|
| 14 |
+
- constitutional-ai
|
| 15 |
+
pipeline_tag: text-generation
|
| 16 |
+
language:
|
| 17 |
+
- en
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
# WireClaw Agent v1.1 — LoRA adapter for Llama 3.1 8B Instruct
|
| 21 |
+
|
| 22 |
+
**Built with Llama.** LoRA adapter fine-tuned on top of `meta-llama/Llama-3.1-8B-Instruct` for tool-using embedded AI agents on ESP32-C6 microcontrollers, operating under the Project Opengates constitution (`SOUL.md`).
|
| 23 |
+
|
| 24 |
+
WireClaw is an agentic firmware that runs a local LLM (via [WireClaw](https://github.com/M64GitHub/WireClaw) fork at [WhitneyDesignLabs/WireClaw](https://github.com/WhitneyDesignLabs/WireClaw)) and exposes tools — `gpio_write`/`gpio_read`, `device_register`, `rule_create`, `chain_create`, `led_set`, `file_read`/`file_write`, `chip_temp`, `telegram`, `serial_send`, etc. — that the model can call to interact with the world. The agent's role is to receive a Telegram message, decide which tools to call, execute them, and produce a natural-language wrap-up.
|
| 25 |
+
|
| 26 |
+
## Model overview
|
| 27 |
+
|
| 28 |
+
- **Base model:** `meta-llama/Llama-3.1-8B-Instruct`
|
| 29 |
+
- **Adapter:** PEFT/LoRA, ~84 MB safetensors
|
| 30 |
+
- **Inference path in production:** GGUF-converted, served via Ollama on a Raspberry Pi proxy (`azza`), addressed by ESP32-C6 chips on the LAN
|
| 31 |
+
- **Production version tag:** `wireclaw-agent:v1.1` (deployed). `v1.2` exists but is held for post-housekeeping eval.
|
| 32 |
+
|
| 33 |
+
## Training procedure
|
| 34 |
+
|
| 35 |
+
Trained on a Brev cloud GPU node. Single epoch had ~680 training examples; 3 epochs total.
|
| 36 |
+
|
| 37 |
+
| Hyperparameter | Value |
|
| 38 |
+
|---|---|
|
| 39 |
+
| LoRA `r` | 16 |
|
| 40 |
+
| LoRA `alpha` | 32 |
|
| 41 |
+
| LoRA `dropout` | 0.05 |
|
| 42 |
+
| Target modules | `q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj` (all linear) |
|
| 43 |
+
| Epochs | 3 |
|
| 44 |
+
| Batch size | 8 |
|
| 45 |
+
| Gradient accumulation | 1 |
|
| 46 |
+
| Learning rate | 2e-4 (cosine, warmup_ratio=0.03) |
|
| 47 |
+
| Weight decay | 0.01 |
|
| 48 |
+
| Max sequence length | 3072 |
|
| 49 |
+
| Compute dtype | `bfloat16` |
|
| 50 |
+
| Attention impl | `sdpa` |
|
| 51 |
+
| Seed | 42 |
|
| 52 |
+
|
| 53 |
+
### Loss curve
|
| 54 |
+
|
| 55 |
+
| Epoch | Train loss |
|
| 56 |
+
|---|---|
|
| 57 |
+
| 1 | 0.0260 |
|
| 58 |
+
| 2 | 0.0256 |
|
| 59 |
+
| 3 | **0.0153** |
|
| 60 |
+
|
| 61 |
+
(Per-epoch logging only; full step-level training stdout is preserved at `training/output/training-v2-stdout.log` for the v1.2 successor run.)
|
| 62 |
+
|
| 63 |
+
### Framework versions
|
| 64 |
+
|
| 65 |
+
- PEFT 0.19.1
|
| 66 |
+
- TRL 1.4.0
|
| 67 |
+
- Transformers 5.8.1
|
| 68 |
+
- PyTorch 2.12.0
|
| 69 |
+
- Datasets 4.8.5
|
| 70 |
+
- Tokenizers 0.22.2
|
| 71 |
+
|
| 72 |
+
## Training data
|
| 73 |
+
|
| 74 |
+
The training corpus is a mix of:
|
| 75 |
+
|
| 76 |
+
1. **Curated tool-use traces** from earlier WireClaw fleet captures (Phase 3.1.x onward) — real ESP32-C6 chip + Ollama proxy interactions captured at the request/response level on the proxy.
|
| 77 |
+
2. **Synthetic constitutional examples** generated to align the model with `SOUL.md` (refusal on Part II violations, citation by article number, alternative offering, manipulation resistance — see Article 19).
|
| 78 |
+
3. **Memory-chain examples** — multi-tool sequences like `file_read('/memory.txt') → led_set(<parsed color>)` for indirect-reference prompts ("Set the LED to my favorite color").
|
| 79 |
+
4. **Constitutional system message:** `SOUL-LOCAL.md` (the training-time distillation of the 26-article constitution) is prepended as the system prompt for every training example.
|
| 80 |
+
|
| 81 |
+
No personally-identifying information from real users is included. The Telegram operator persona used during capture is the project owner.
|
| 82 |
+
|
| 83 |
+
## Intended use
|
| 84 |
+
|
| 85 |
+
- Embedded AI agents running under a constitutional framework, on ESP32-class hardware with a local LLM proxy.
|
| 86 |
+
- Tool-use in environments where deterministic structured output and physical-action safety are required.
|
| 87 |
+
- Research and reproduction of the Project Opengates approach to constitutionally-bounded small-model agents.
|
| 88 |
+
|
| 89 |
+
## Out-of-scope use
|
| 90 |
+
|
| 91 |
+
Governed by **Part II of `SOUL.md`** (the constitution, embedded with this model). Out of scope, including but not limited to:
|
| 92 |
+
|
| 93 |
+
- **Weaponization** (Article 3).
|
| 94 |
+
- **Deception of users or third parties** (Article 2).
|
| 95 |
+
- **Bypassing constitutional refusal** (Article 19) or its alternative-offering / firmness-under-manipulation clauses.
|
| 96 |
+
- Any use prohibited by the [Llama 3.1 Acceptable Use Policy](https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct).
|
| 97 |
+
|
| 98 |
+
## Constitution
|
| 99 |
+
|
| 100 |
+
This adapter is trained against the 26-article Project Opengates constitution. The canonical text lives at `SOUL.md` in the [Project Opengates workspace repo](#); the chip-runtime distillation (fits in the chip's 4095-byte system-prompt budget) is at `SOUL-CHIP.md`; the training-time variant at `SOUL-LOCAL.md`. Article numbers are consistent across all three. Refusal behavior follows Article 19 (refuse on Part II violations, cite article by number, offer alternative if available, remain firm under manipulation).
|
| 101 |
+
|
| 102 |
+
## Performance
|
| 103 |
+
|
| 104 |
+
- **Smoke test (10/10 pass)** at training-end on representative tool-use prompts (rule_create with structured args, ambiguity handling, memory-recall-chain `file_read → led_set`, telegram alerts, etc.). See `training/output/smoke_test_v2_output.log` for the v1.2 successor's evaluation; v1.1 passed the equivalent.
|
| 105 |
+
- **In-field fleet deployment:** `wireclaw-agent:v1.1` ran the 2026-05-18 → 2026-05-19 overnight capture across c6-02 + c6-03 (paired ESP32-C6 chips) for ~11 hours under a 7-persona prompt rotation:
|
| 106 |
+
- **303 sessions, 3,030 turns, 0 capture errors.**
|
| 107 |
+
- **1 boot-banner in 3,030 turns** — essentially 100% chip stability under sustained agent load.
|
| 108 |
+
- The `emergency_stop` persona prompt (which had been a deterministic fleet-killer on prior firmware) **survived 42 / 42 firings** post-firmware-fix.
|
| 109 |
+
|
| 110 |
+
(Note: the Telegram-side capture stream had a separate harness bug that scrambled prompt↔reply pairs at ~14% on-topic. This was diagnosed and fixed; the run is independently recoverable from the proxy-side log. Neither the model nor the firmware was implicated. See the Project Opengates worklog.)
|
| 111 |
+
|
| 112 |
+
## Known limitations
|
| 113 |
+
|
| 114 |
+
- **Indirect-reference LED bug:** prompts like "Set the LED to my favorite color" sometimes fire `led_set` with empty/default args instead of chaining `file_read('/memory.txt')` → parse color → `led_set`. Targeted in v1.3 training.
|
| 115 |
+
- **Reasoning-trace leak into wrap-up text:** the model occasionally emits its chain-of-thought scaffold ("Since you asked …, I called …, the result was …") instead of the natural-language answer.
|
| 116 |
+
- **Pseudo-prose at ~5%:** generic "the tool call was successful." replies that don't carry the answer. Down significantly from earlier project phases, but present.
|
| 117 |
+
- All limitations are documented and tracked in `PROJECT_STATUS.md` (Known v1.1 residuals).
|
| 118 |
+
|
| 119 |
+
## How to use
|
| 120 |
+
|
| 121 |
+
### As a PEFT adapter on top of Llama 3.1 8B Instruct
|
| 122 |
+
|
| 123 |
+
```python
|
| 124 |
+
from peft import PeftModel
|
| 125 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 126 |
+
|
| 127 |
+
base = AutoModelForCausalLM.from_pretrained(
|
| 128 |
+
"meta-llama/Llama-3.1-8B-Instruct",
|
| 129 |
+
torch_dtype="bfloat16",
|
| 130 |
+
device_map="auto",
|
| 131 |
+
)
|
| 132 |
+
tok = AutoTokenizer.from_pretrained("meta-llama/Llama-3.1-8B-Instruct")
|
| 133 |
+
model = PeftModel.from_pretrained(base, "WhitneyDesignLabs/wireclaw-agent-v1.1-lora")
|
| 134 |
+
|
| 135 |
+
# System prompt is SOUL-LOCAL.md / SOUL-CHIP.md (see Project Opengates repo).
|
| 136 |
+
msgs = [
|
| 137 |
+
{"role": "system", "content": open("SOUL-CHIP.md").read()},
|
| 138 |
+
{"role": "user", "content": "What is the chip temperature?"},
|
| 139 |
+
]
|
| 140 |
+
inputs = tok.apply_chat_template(msgs, return_tensors="pt", add_generation_prompt=True).to(model.device)
|
| 141 |
+
out = model.generate(inputs, max_new_tokens=256, do_sample=False)
|
| 142 |
+
print(tok.decode(out[0, inputs.shape[1]:], skip_special_tokens=True))
|
| 143 |
+
```
|
| 144 |
+
|
| 145 |
+
### As a GGUF on Ollama (production path)
|
| 146 |
+
|
| 147 |
+
The adapter is converted to GGUF and merged into the base for Ollama serving. See `bench/fork/lora/training/wireclaw-agent-v1.1.Modelfile.template` in the Project Opengates repo for the Modelfile recipe.
|
| 148 |
+
|
| 149 |
+
## License
|
| 150 |
+
|
| 151 |
+
This adapter is a derivative of `meta-llama/Llama-3.1-8B-Instruct` and is released under the **[Llama 3.1 Community License](https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct/blob/main/LICENSE)**. All terms of that license apply to use, redistribution, and downstream derivatives. The **"Built with Llama"** attribution requirement is satisfied at the top of this card.
|
| 152 |
+
|
| 153 |
+
The constitutional framework (`SOUL.md`) and the WireClaw firmware (`WhitneyDesignLabs/WireClaw`) are separate projects with their own licensing — see those repositories.
|
| 154 |
+
|
| 155 |
+
## Citation / attribution
|
| 156 |
+
|
| 157 |
+
```bibtex
|
| 158 |
+
@misc{wireclaw_agent_v1_1_lora,
|
| 159 |
+
title = {WireClaw Agent v1.1 — LoRA adapter for Llama 3.1 8B Instruct},
|
| 160 |
+
author = {Whitney, Scott and {Project Opengates contributors}},
|
| 161 |
+
year = {2026},
|
| 162 |
+
url = {https://huggingface.co/WhitneyDesignLabs/wireclaw-agent-v1.1-lora},
|
| 163 |
+
note = {Constitutionally-bounded embedded AI agent for ESP32-C6.}
|
| 164 |
+
}
|
| 165 |
+
```
|
| 166 |
+
|
| 167 |
+
Project Opengates · Whitney Design Labs.
|
adapter_config.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"alora_invocation_tokens": null,
|
| 3 |
+
"alpha_pattern": {},
|
| 4 |
+
"arrow_config": null,
|
| 5 |
+
"auto_mapping": null,
|
| 6 |
+
"base_model_name_or_path": "meta-llama/Llama-3.1-8B-Instruct",
|
| 7 |
+
"bias": "none",
|
| 8 |
+
"corda_config": null,
|
| 9 |
+
"ensure_weight_tying": false,
|
| 10 |
+
"eva_config": null,
|
| 11 |
+
"exclude_modules": null,
|
| 12 |
+
"fan_in_fan_out": false,
|
| 13 |
+
"inference_mode": true,
|
| 14 |
+
"init_lora_weights": true,
|
| 15 |
+
"layer_replication": null,
|
| 16 |
+
"layers_pattern": null,
|
| 17 |
+
"layers_to_transform": null,
|
| 18 |
+
"loftq_config": {},
|
| 19 |
+
"lora_alpha": 32,
|
| 20 |
+
"lora_bias": false,
|
| 21 |
+
"lora_dropout": 0.05,
|
| 22 |
+
"lora_ga_config": null,
|
| 23 |
+
"megatron_config": null,
|
| 24 |
+
"megatron_core": "megatron.core",
|
| 25 |
+
"modules_to_save": null,
|
| 26 |
+
"peft_type": "LORA",
|
| 27 |
+
"peft_version": "0.19.1",
|
| 28 |
+
"qalora_group_size": 16,
|
| 29 |
+
"r": 16,
|
| 30 |
+
"rank_pattern": {},
|
| 31 |
+
"revision": null,
|
| 32 |
+
"target_modules": [
|
| 33 |
+
"gate_proj",
|
| 34 |
+
"k_proj",
|
| 35 |
+
"up_proj",
|
| 36 |
+
"down_proj",
|
| 37 |
+
"o_proj",
|
| 38 |
+
"v_proj",
|
| 39 |
+
"q_proj"
|
| 40 |
+
],
|
| 41 |
+
"target_parameters": null,
|
| 42 |
+
"task_type": "CAUSAL_LM",
|
| 43 |
+
"trainable_token_indices": null,
|
| 44 |
+
"use_bdlora": null,
|
| 45 |
+
"use_dora": false,
|
| 46 |
+
"use_qalora": false,
|
| 47 |
+
"use_rslora": false
|
| 48 |
+
}
|
adapter_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cbb32746d3df88e79800d2086381a547b92fa452f8709a324f610978cde47e1d
|
| 3 |
+
size 83946192
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{{- bos_token }}
|
| 2 |
+
{%- if custom_tools is defined %}
|
| 3 |
+
{%- set tools = custom_tools %}
|
| 4 |
+
{%- endif %}
|
| 5 |
+
{%- if not tools_in_user_message is defined %}
|
| 6 |
+
{%- set tools_in_user_message = true %}
|
| 7 |
+
{%- endif %}
|
| 8 |
+
{%- if not date_string is defined %}
|
| 9 |
+
{%- set date_string = "26 Jul 2024" %}
|
| 10 |
+
{%- endif %}
|
| 11 |
+
{%- if not tools is defined %}
|
| 12 |
+
{%- set tools = none %}
|
| 13 |
+
{%- endif %}
|
| 14 |
+
|
| 15 |
+
{#- This block extracts the system message, so we can slot it into the right place. #}
|
| 16 |
+
{%- if messages[0]['role'] == 'system' %}
|
| 17 |
+
{%- set system_message = messages[0]['content']|trim %}
|
| 18 |
+
{%- set messages = messages[1:] %}
|
| 19 |
+
{%- else %}
|
| 20 |
+
{%- set system_message = "" %}
|
| 21 |
+
{%- endif %}
|
| 22 |
+
|
| 23 |
+
{#- System message + builtin tools #}
|
| 24 |
+
{{- "<|start_header_id|>system<|end_header_id|>\n\n" }}
|
| 25 |
+
{%- if builtin_tools is defined or tools is not none %}
|
| 26 |
+
{{- "Environment: ipython\n" }}
|
| 27 |
+
{%- endif %}
|
| 28 |
+
{%- if builtin_tools is defined %}
|
| 29 |
+
{{- "Tools: " + builtin_tools | reject('equalto', 'code_interpreter') | join(", ") + "\n\n"}}
|
| 30 |
+
{%- endif %}
|
| 31 |
+
{{- "Cutting Knowledge Date: December 2023\n" }}
|
| 32 |
+
{{- "Today Date: " + date_string + "\n\n" }}
|
| 33 |
+
{%- if tools is not none and not tools_in_user_message %}
|
| 34 |
+
{{- "You have access to the following functions. To call a function, please respond with JSON for a function call." }}
|
| 35 |
+
{{- 'Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}.' }}
|
| 36 |
+
{{- "Do not use variables.\n\n" }}
|
| 37 |
+
{%- for t in tools %}
|
| 38 |
+
{{- t | tojson(indent=4) }}
|
| 39 |
+
{{- "\n\n" }}
|
| 40 |
+
{%- endfor %}
|
| 41 |
+
{%- endif %}
|
| 42 |
+
{{- system_message }}
|
| 43 |
+
{{- "<|eot_id|>" }}
|
| 44 |
+
|
| 45 |
+
{#- Custom tools are passed in a user message with some extra guidance #}
|
| 46 |
+
{%- if tools_in_user_message and not tools is none %}
|
| 47 |
+
{#- Extract the first user message so we can plug it in here #}
|
| 48 |
+
{%- if messages | length != 0 %}
|
| 49 |
+
{%- set first_user_message = messages[0]['content']|trim %}
|
| 50 |
+
{%- set messages = messages[1:] %}
|
| 51 |
+
{%- else %}
|
| 52 |
+
{{- raise_exception("Cannot put tools in the first user message when there's no first user message!") }}
|
| 53 |
+
{%- endif %}
|
| 54 |
+
{{- '<|start_header_id|>user<|end_header_id|>\n\n' -}}
|
| 55 |
+
{{- "Given the following functions, please respond with a JSON for a function call " }}
|
| 56 |
+
{{- "with its proper arguments that best answers the given prompt.\n\n" }}
|
| 57 |
+
{{- 'Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}.' }}
|
| 58 |
+
{{- "Do not use variables.\n\n" }}
|
| 59 |
+
{%- for t in tools %}
|
| 60 |
+
{{- t | tojson(indent=4) }}
|
| 61 |
+
{{- "\n\n" }}
|
| 62 |
+
{%- endfor %}
|
| 63 |
+
{{- first_user_message + "<|eot_id|>"}}
|
| 64 |
+
{%- endif %}
|
| 65 |
+
|
| 66 |
+
{%- for message in messages %}
|
| 67 |
+
{%- if not (message.role == 'ipython' or message.role == 'tool' or 'tool_calls' in message) %}
|
| 68 |
+
{{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n'+ message['content'] | trim + '<|eot_id|>' }}
|
| 69 |
+
{%- elif 'tool_calls' in message %}
|
| 70 |
+
{%- if not message.tool_calls|length == 1 %}
|
| 71 |
+
{{- raise_exception("This model only supports single tool-calls at once!") }}
|
| 72 |
+
{%- endif %}
|
| 73 |
+
{%- set tool_call = message.tool_calls[0].function %}
|
| 74 |
+
{%- if builtin_tools is defined and tool_call.name in builtin_tools %}
|
| 75 |
+
{{- '<|start_header_id|>assistant<|end_header_id|>\n\n' -}}
|
| 76 |
+
{{- "<|python_tag|>" + tool_call.name + ".call(" }}
|
| 77 |
+
{%- for arg_name, arg_val in tool_call.arguments | items %}
|
| 78 |
+
{{- arg_name + '="' + arg_val + '"' }}
|
| 79 |
+
{%- if not loop.last %}
|
| 80 |
+
{{- ", " }}
|
| 81 |
+
{%- endif %}
|
| 82 |
+
{%- endfor %}
|
| 83 |
+
{{- ")" }}
|
| 84 |
+
{%- else %}
|
| 85 |
+
{{- '<|start_header_id|>assistant<|end_header_id|>\n\n' -}}
|
| 86 |
+
{{- '{"name": "' + tool_call.name + '", ' }}
|
| 87 |
+
{{- '"parameters": ' }}
|
| 88 |
+
{{- tool_call.arguments | tojson }}
|
| 89 |
+
{{- "}" }}
|
| 90 |
+
{%- endif %}
|
| 91 |
+
{%- if builtin_tools is defined %}
|
| 92 |
+
{#- This means we're in ipython mode #}
|
| 93 |
+
{{- "<|eom_id|>" }}
|
| 94 |
+
{%- else %}
|
| 95 |
+
{{- "<|eot_id|>" }}
|
| 96 |
+
{%- endif %}
|
| 97 |
+
{%- elif message.role == "tool" or message.role == "ipython" %}
|
| 98 |
+
{{- "<|start_header_id|>ipython<|end_header_id|>\n\n" }}
|
| 99 |
+
{%- if message.content is mapping or message.content is iterable %}
|
| 100 |
+
{{- message.content | tojson }}
|
| 101 |
+
{%- else %}
|
| 102 |
+
{{- message.content }}
|
| 103 |
+
{%- endif %}
|
| 104 |
+
{{- "<|eot_id|>" }}
|
| 105 |
+
{%- endif %}
|
| 106 |
+
{%- endfor %}
|
| 107 |
+
{%- if add_generation_prompt %}
|
| 108 |
+
{{- '<|start_header_id|>assistant<|end_header_id|>\n\n' }}
|
| 109 |
+
{%- endif %}
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6b9e4e7fb171f92fd137b777cc2714bf87d11576700a1dcd7a399e7bbe39537b
|
| 3 |
+
size 17209920
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"bos_token": "<|begin_of_text|>",
|
| 4 |
+
"clean_up_tokenization_spaces": true,
|
| 5 |
+
"eos_token": "<|eot_id|>",
|
| 6 |
+
"is_local": false,
|
| 7 |
+
"local_files_only": false,
|
| 8 |
+
"model_input_names": [
|
| 9 |
+
"input_ids",
|
| 10 |
+
"attention_mask"
|
| 11 |
+
],
|
| 12 |
+
"model_max_length": 131072,
|
| 13 |
+
"pad_token": "<|eot_id|>",
|
| 14 |
+
"tokenizer_class": "TokenizersBackend"
|
| 15 |
+
}
|
training-config.yaml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
attn_impl: sdpa
|
| 2 |
+
base_model: meta-llama/Llama-3.1-8B-Instruct
|
| 3 |
+
batch_size: 8
|
| 4 |
+
compute_dtype: bfloat16
|
| 5 |
+
epochs: 3
|
| 6 |
+
grad_accum: 1
|
| 7 |
+
learning_rate: 0.0002
|
| 8 |
+
logging_steps: 10
|
| 9 |
+
lora_alpha: 32
|
| 10 |
+
lora_dropout: 0.05
|
| 11 |
+
lora_r: 16
|
| 12 |
+
lora_target_modules:
|
| 13 |
+
- q_proj
|
| 14 |
+
- k_proj
|
| 15 |
+
- v_proj
|
| 16 |
+
- o_proj
|
| 17 |
+
- gate_proj
|
| 18 |
+
- up_proj
|
| 19 |
+
- down_proj
|
| 20 |
+
lr_scheduler: cosine
|
| 21 |
+
max_seq_length: 3072
|
| 22 |
+
output_dir: /home/ubuntu/bench/fork/lora/training/output/wireclaw-v1-brev
|
| 23 |
+
seed: 42
|
| 24 |
+
train_file: /home/ubuntu/bench/fork/lora/training-data/wireclaw-v1-train.jsonl
|
| 25 |
+
val_file: /home/ubuntu/bench/fork/lora/training-data/wireclaw-v1-val.jsonl
|
| 26 |
+
warmup_ratio: 0.03
|
| 27 |
+
weight_decay: 0.01
|
training-log.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"epoch": 1.0,
|
| 4 |
+
"global_step": 85,
|
| 5 |
+
"loss": 0.025969025492668153,
|
| 6 |
+
"eval_loss": null,
|
| 7 |
+
"learning_rate": 0.00016192187970466644,
|
| 8 |
+
"samples_seen": 680
|
| 9 |
+
},
|
| 10 |
+
{
|
| 11 |
+
"epoch": 2.0,
|
| 12 |
+
"global_step": 170,
|
| 13 |
+
"loss": 0.02564648389816284,
|
| 14 |
+
"eval_loss": null,
|
| 15 |
+
"learning_rate": 5.409172443958843e-05,
|
| 16 |
+
"samples_seen": 1360
|
| 17 |
+
},
|
| 18 |
+
{
|
| 19 |
+
"epoch": 3.0,
|
| 20 |
+
"global_step": 255,
|
| 21 |
+
"loss": 0.015267781913280487,
|
| 22 |
+
"eval_loss": null,
|
| 23 |
+
"learning_rate": 2.9104997242590527e-07,
|
| 24 |
+
"samples_seen": 2040
|
| 25 |
+
}
|
| 26 |
+
]
|