初始化项目,由ModelHub XC社区提供模型
Model: ersanbil/roka Source: Original Platform
This commit is contained in:
36
.gitattributes
vendored
Normal file
36
.gitattributes
vendored
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.model filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.npy filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.npz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pickle filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pkl filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||||
|
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tar filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
gguf/roka-v0.2-Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text
|
||||||
202
LICENSE
Normal file
202
LICENSE
Normal file
@@ -0,0 +1,202 @@
|
|||||||
|
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
245
README.md
Normal file
245
README.md
Normal file
@@ -0,0 +1,245 @@
|
|||||||
|
---
|
||||||
|
language:
|
||||||
|
- tr
|
||||||
|
- en
|
||||||
|
license: apache-2.0
|
||||||
|
library_name: transformers
|
||||||
|
base_model: AlicanKiraz0/Kara-Kumru-v1.0-2B
|
||||||
|
pipeline_tag: text-generation
|
||||||
|
tags:
|
||||||
|
- turkish
|
||||||
|
- tool-calling
|
||||||
|
- function-calling
|
||||||
|
- hermes
|
||||||
|
- kara-kumru
|
||||||
|
- mistral
|
||||||
|
- gguf
|
||||||
|
---
|
||||||
|
|
||||||
|
# Roka — Turkish Tool-Calling Fine-Tune of Kara-Kumru 2B
|
||||||
|
|
||||||
|
Roka is a supervised fine-tune of `AlicanKiraz0/Kara-Kumru-v1.0-2B` that teaches a 2B-parameter Turkish language model to use five tools (web search, calculator, date/time, weather, URL reader) via a Hermes-style `<tool_call>…</tool_call>` output format.
|
||||||
|
|
||||||
|
This is a **v0.2 research preview**, released for reproducibility and community feedback. It is not a production-grade tool-calling agent and has known weaknesses (see *Limitations*).
|
||||||
|
|
||||||
|
The v0.2 training set is fully decontaminated against the evaluation set: no test-set query appears verbatim in train or validation.
|
||||||
|
|
||||||
|
## Model at a glance
|
||||||
|
|
||||||
|
| | |
|
||||||
|
|---|---|
|
||||||
|
| **Base model** | `AlicanKiraz0/Kara-Kumru-v1.0-2B` (Mistral architecture, Llama-3 chat template, Turkish-pretrained) |
|
||||||
|
| **Upstream base** | `vngrs-ai/Kumru-2B` |
|
||||||
|
| **Parameters** | ~2.15B |
|
||||||
|
| **Fine-tuning** | Full fine-tuning, 3 epochs, LR 5e-5 linear, bf16, TRL SFTTrainer |
|
||||||
|
| **Hardware** | Single NVIDIA A6000 (~65 min / epoch ~22 min) |
|
||||||
|
| **Languages** | Primarily Turkish; ~13% of the training mix is English (Glaive-sourced synthetic tool-calling examples) |
|
||||||
|
| **License** | Apache 2.0 (inherited from base chain) |
|
||||||
|
|
||||||
|
## Tool set
|
||||||
|
|
||||||
|
| Tool | Description |
|
||||||
|
|---|---|
|
||||||
|
| `web_search` | Internet search (DuckDuckGo) |
|
||||||
|
| `calculator` | Arithmetic expression evaluator |
|
||||||
|
| `datetime` | Date/time and calendar arithmetic (9 actions: `today`, `now`, `day_of_week`, `add_days`, `date_diff`, `days_until`, `day_of_year`, `end_of_month`, `days_until_weekday`) |
|
||||||
|
| `hava_durumu` | Weather query by city name |
|
||||||
|
| `sayfa_oku` | URL content reader |
|
||||||
|
|
||||||
|
The model is trained to emit tool calls as:
|
||||||
|
|
||||||
|
```
|
||||||
|
<tool_call>
|
||||||
|
{"name": "datetime", "arguments": {"action": "today"}}
|
||||||
|
</tool_call>
|
||||||
|
```
|
||||||
|
|
||||||
|
Tool results are fed back to the model wrapped in `<tool_response>…</tool_response>` inside a user turn, and the model synthesizes a final Turkish answer.
|
||||||
|
|
||||||
|
## Evaluation
|
||||||
|
|
||||||
|
The test set contains 260 Turkish prompts spread over six categories (simple tool calls, fullflow multi-step, parallel, multiple tools, irrelevance, adversarial). Scoring uses an alignment-aware harness (`scripts/rescore_aligned.py`) that normalizes equivalent datetime actions and accepts semantically equivalent arithmetic expressions.
|
||||||
|
|
||||||
|
### Overall results (Roka v0.2, April 2026)
|
||||||
|
|
||||||
|
| View | n | Full-Match | Tool-Call Acc. | Name Acc. | Arg Acc. |
|
||||||
|
|---|---|---|---|---|---|
|
||||||
|
| **All test (held-out)** | 260 | **73.5%** | 93.1% | 71.9% | 60.6% |
|
||||||
|
|
||||||
|
Every test query was verified to be absent from both `data/train.jsonl` and `data/val.jsonl`, so the 73.5% number above is a genuinely held-out measurement. See *Decontamination history* below for why this is lower than an earlier, un-decontaminated run.
|
||||||
|
|
||||||
|
### Per-subcategory results
|
||||||
|
|
||||||
|
| Subcategory | n | Full-Match |
|
||||||
|
|---|---|---|
|
||||||
|
| simple/web_search | 30 | **93.3%** |
|
||||||
|
| simple/weather | 20 | **100.0%** |
|
||||||
|
| simple/url_reader | 15 | **100.0%** |
|
||||||
|
| simple/calculator | 20 | 70.0% |
|
||||||
|
| simple/datetime | 15 | 46.7% |
|
||||||
|
| fullflow | 35 | **80.0%** |
|
||||||
|
| multiple | 45 | 64.4% |
|
||||||
|
| parallel | 15 | **0.0%** |
|
||||||
|
| adversarial/turkish_special | 10 | 90.0% |
|
||||||
|
| adversarial/edge_case | 5 | 40.0% |
|
||||||
|
| adversarial/ambiguous | 15 | 26.7% |
|
||||||
|
| irrelevance/greeting | 15 | **100.0%** |
|
||||||
|
| irrelevance/identity | 10 | **100.0%** |
|
||||||
|
| irrelevance/opinion | 10 | **100.0%** |
|
||||||
|
|
||||||
|
**Parallel tool calls score 0% because the training mix does not contain parallel-call examples.** This is a known gap, not a reproducibility failure.
|
||||||
|
|
||||||
|
### Decontamination history
|
||||||
|
|
||||||
|
During preparation for this release we audited the training set and found that **44 of the 260 test queries appeared verbatim in train/val** (8 in simple/datetime, 6 in simple/web_search, 7 in multiple, and the rest in irrelevance/identity and irrelevance/greeting). We removed all 76 matching train examples and 6 matching val examples, and retrained on the clean split. That retraining is the model reported above.
|
||||||
|
|
||||||
|
For transparency we also report the before-and-after numbers on the 216 test queries that were **not** affected by the decontamination (i.e., the genuinely held-out subset from the *pre-cleanup* model's perspective):
|
||||||
|
|
||||||
|
| Model | Training data | Clean-216 FM |
|
||||||
|
|---|---|---|
|
||||||
|
| v0.1 pre-clean | original (with 76 overlaps) | 78.2% |
|
||||||
|
| **v0.2** (released) | decontaminated | **73.6%** |
|
||||||
|
|
||||||
|
The ~4.6-point drop is informative: it is *not* contamination-inflation. The removed training examples were pattern-providing (datetime variants, fullflow web-search turns, distractor augmentations of the same base queries), and losing them cost about 4.6 points of generalization even on held-out queries. The cost of honest decontamination was larger than the narrow definition of "memorization gain" would predict. We report the post-decontamination number because it is the only one that is defensible as a held-out measurement. A future v0.3 will attempt to recover the gap by adding clean synthetic replacements for the removed examples.
|
||||||
|
|
||||||
|
## Development journey (brief)
|
||||||
|
|
||||||
|
Arriving at the final model required an honest amount of dead-ends.
|
||||||
|
|
||||||
|
1. **Baseline (Run 10)** — 62.7% aligned FM with an earlier pipeline, before any of the spec-005 data work.
|
||||||
|
2. **Phase A v1–v4 collapse** — four consecutive training runs where loss converged to near-zero but test-set Full-Match stayed at 0/260. All of them passed `loss` sanity checks, so the failure was invisible from inside the run.
|
||||||
|
3. **Root cause** — TRL issue [#3910](https://github.com/huggingface/trl/issues/3910): the `max_seq_length` argument was silently renamed to `max_length` (default 1024) in TRL 0.20+. Every assistant turn longer than 1024 tokens (≈75% of our fullflow examples) was being truncated before it contributed to the loss. The model trained to completion on fragments, not on full tool-calling traces. Fix: pass `max_length=4096` explicitly.
|
||||||
|
4. **Data iterations**
|
||||||
|
- Removed the `unit` argument from all `hava_durumu` training examples (the test set does not supply it). `simple/weather` Full-Match rose from 10% to 100%.
|
||||||
|
- Added 45 supplementary `datetime` examples covering `day_of_year`, `end_of_month`, and `days_until_weekday` — test actions that were absent from the R10 training data.
|
||||||
|
- Those supplementary examples caused a regression on `day_of_week` queries ("23 Nisan hangi güne denk geliyor?" was mis-routed to `day_of_year`). A targeted set of 30 `day_of_week` contrast examples fixed it.
|
||||||
|
5. **Final v0.1 model** — 4,778 training / 509 validation examples, 795 optimizer steps. Reported 76.9% all-test, 78.2% on the clean-216 subset.
|
||||||
|
6. **v0.2 — decontamination** — 76 train and 6 val examples whose first user turn matched a test query were removed, producing a 4,702 / 503 split. Retraining on this split gave the 73.5% number now reported above. The 4.6-point drop on the clean-216 subset between v0.1 and v0.2 is the cost of honest decontamination — see *Decontamination history*.
|
||||||
|
|
||||||
|
Total compute used across Phase A and v0.2: ~5 A6000-hours.
|
||||||
|
|
||||||
|
## Limitations
|
||||||
|
|
||||||
|
- **Multi-turn pattern lock-in.** The SFT mix contains very few multi-turn tool-calling sequences. If the user starts with a chit-chat turn ("selam"), the model tends to stay in plain-chat mode on subsequent turns and skip the tool call. The provided `scripts/serve_ui.py` works around this by feeding only the current user message (without prior turns) into the tool-decision loop.
|
||||||
|
- **Parallel tool calls: 0%.** Not trained.
|
||||||
|
- **`hava_durumu` has no temporal parameter.** Queries like "yarın İstanbul'da hava" still produce `{"city": "İstanbul"}` because that is what the schema allows. The fix is a schema change + data regeneration, not a prompt change.
|
||||||
|
- **Adversarial/ambiguous: 40%.** The model is easily nudged off-task by ambiguous phrasing.
|
||||||
|
- **Long-passage synthesis is brittle.** When `sayfa_oku` returns several paragraphs, the synthesized summary sometimes fragments quotes in an unnatural way.
|
||||||
|
- **Hermes parser coupling.** Native OpenAI-style `tool_calls` parsing via `llama-server` requires the provided `training/roka_tool_template.jinja` chat template and requires the client to pass the full list of 5 tools. Passing a subset confuses llama.cpp's Hermes detector.
|
||||||
|
- **Scoring discrepancy.** The in-training `training/eval.py` scorer disagrees slightly with the alignment-aware rescorer. Only the rescored numbers are reported above. Resolving the discrepancy is open work.
|
||||||
|
|
||||||
|
## Training data
|
||||||
|
|
||||||
|
- **4,778 train / 509 validation** examples, Hermes-format chat turns.
|
||||||
|
- **~72% Turkish, ~13% English, ~15% short/symbolic.** The English fraction is Glaive-sourced synthetic tool-calling data retained for multi-tool pattern coverage.
|
||||||
|
- **Deterministic generators** for `calculator`, `datetime`, `hava_durumu` (in `training/generators/`).
|
||||||
|
- **Real DuckDuckGo search results** cached in `data/ddg_cache.json` and used to construct `web_search` fullflow examples.
|
||||||
|
- **PII scan**: only two flagged matches in user-facing content, both false positives (embedded WSJ article IDs). No email addresses, Turkish ID numbers, credit cards, or IP addresses found.
|
||||||
|
|
||||||
|
## Contamination verification
|
||||||
|
|
||||||
|
The released v0.2 model is trained on a split where **no test query appears verbatim** in either train or validation. The decontamination script (`scripts/decontaminate.py`) normalizes whitespace and case before matching. The pre-decontamination overlap distribution (all removed in v0.2) was:
|
||||||
|
|
||||||
|
| Subcategory | Overlap (removed) |
|
||||||
|
|---|---|
|
||||||
|
| irrelevance/identity | 8 / 10 |
|
||||||
|
| irrelevance/greeting | 11 / 15 |
|
||||||
|
| simple/datetime | 8 / 15 |
|
||||||
|
| simple/web_search | 6 / 30 |
|
||||||
|
| multiple | 7 / 45 |
|
||||||
|
| adversarial/turkish_special | 1 / 10 |
|
||||||
|
| adversarial/opinion | 1 / 10 |
|
||||||
|
| simple/weather | 1 / 20 |
|
||||||
|
| fullflow | 1 / 35 |
|
||||||
|
|
||||||
|
Because augmentation variants of each base query (masked/distractor versions) shared the same user turn, removing 44 unique queries deleted 76 train examples and 6 val examples in total. The remaining 4,702 / 503 split is what v0.2 was trained on.
|
||||||
|
|
||||||
|
This decontamination is **exact-string**, not fuzzy. Near-duplicates (paraphrases that return the same tool call) are still present. Closing the paraphrase loophole requires a more elaborate embedding-based deduplication pass, which is left for v0.3.
|
||||||
|
|
||||||
|
## Repository layout
|
||||||
|
|
||||||
|
```
|
||||||
|
src/ Inference clients (transformers & llama-server)
|
||||||
|
training/
|
||||||
|
tools.py Tool schemas + training system prompt
|
||||||
|
train.py TRL SFTTrainer entry point
|
||||||
|
eval.py Test-set scorer (in-training)
|
||||||
|
roka_tool_template.jinja llama-server chat template with Hermes detection hook
|
||||||
|
generators/ Deterministic data generators per tool
|
||||||
|
scripts/
|
||||||
|
work_pipeline.py End-to-end pod orchestration
|
||||||
|
pod_run_and_dump.py On-pod training → prediction dump → HF upload
|
||||||
|
rescore_aligned.py Alignment-aware rescorer (authoritative numbers)
|
||||||
|
serve_ui.py FastAPI chat UI wrapping the agent
|
||||||
|
data/
|
||||||
|
train.jsonl, val.jsonl, test_set.json
|
||||||
|
specs/005-post-run10-75/ Spec, plan, and task list for this iteration
|
||||||
|
```
|
||||||
|
|
||||||
|
Github: (https://github.com/bilersan/roka)
|
||||||
|
|
||||||
|
## Reproducibility
|
||||||
|
|
||||||
|
1. Clone the repo and install requirements:
|
||||||
|
```bash
|
||||||
|
pip install -r requirements.txt
|
||||||
|
```
|
||||||
|
2. Regenerate the training set (deterministic):
|
||||||
|
```bash
|
||||||
|
python -m training.build_dataset
|
||||||
|
```
|
||||||
|
3. Train (RunPod-hosted, ~1 GPU-hour on an A6000):
|
||||||
|
```bash
|
||||||
|
python -m scripts.work_pipeline
|
||||||
|
```
|
||||||
|
4. Rescore predictions with the alignment-aware harness:
|
||||||
|
```bash
|
||||||
|
python -m scripts.rescore_aligned --predictions .work/artifacts/predictions/<run_id>.json
|
||||||
|
```
|
||||||
|
|
||||||
|
The training recipe is fully specified in `training/config.yaml`. The only hyperparameter that is unusually specific is `max_length: 4096` in `training/train.py` — removing it reproduces the Phase A v1–v4 collapse described above.
|
||||||
|
|
||||||
|
## Intended use and out-of-scope use
|
||||||
|
|
||||||
|
**Intended**: Turkish-language tool-calling agents for well-defined tools, research on small-model function calling, educational demonstrations of the SFT pipeline.
|
||||||
|
|
||||||
|
**Out of scope**:
|
||||||
|
- Safety-critical applications. The model has not been evaluated for harmful-content refusal beyond what Kara-Kumru inherits from its base.
|
||||||
|
- Parallel / agentic planning over large tool catalogs.
|
||||||
|
- Multi-turn conversational agents that need to preserve long prior context.
|
||||||
|
- Any application that requires the model to use tools not present in the training schema.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
This repository and the released weights are distributed under the **Apache License 2.0**, inherited from both `AlicanKiraz0/Kara-Kumru-v1.0-2B` and its upstream base `vngrs-ai/Kumru-2B`. See `LICENSE`.
|
||||||
|
|
||||||
|
## Citation
|
||||||
|
|
||||||
|
If you use Roka in research, please cite both the base model and this work:
|
||||||
|
|
||||||
|
```bibtex
|
||||||
|
@misc{roka_2026,
|
||||||
|
title = {Roka: Turkish Tool-Calling Fine-Tune of Kara-Kumru 2B},
|
||||||
|
author = {Bilik, Ersan},
|
||||||
|
year = {2026},
|
||||||
|
url = {https://huggingface.co/ersanbil/roka}
|
||||||
|
}
|
||||||
|
|
||||||
|
@misc{karakumru_2025,
|
||||||
|
title = {Kara-Kumru-v1.0-2B},
|
||||||
|
author = {Kiraz, Alican},
|
||||||
|
year = {2025},
|
||||||
|
url = {https://huggingface.co/AlicanKiraz0/Kara-Kumru-v1.0-2B}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Acknowledgements
|
||||||
|
|
||||||
|
- **vngrs-ai** for the open Turkish base model `Kumru-2B`.
|
||||||
|
- **Alican Kiraz** for the Turkish-conversational fine-tune `Kara-Kumru-v1.0-2B`.
|
||||||
|
- **Hugging Face TRL / Unsloth** for the training stack.
|
||||||
|
- **Glaive-AI function-calling dataset** for the English portion of the multi-tool synthetic mix.
|
||||||
|
|
||||||
|
## Contact and feedback
|
||||||
|
|
||||||
|
Issues and pull requests are welcome on the GitHub mirror. This is a research preview — please file bugs for any behavior that contradicts the documented limitations above; those are the interesting cases.
|
||||||
5
chat_template.jinja
Normal file
5
chat_template.jinja
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{% set loop_messages = messages %}{% for message in loop_messages %}{% set content = '<|start_header_id|>' + message['role'] + '<|end_header_id|>
|
||||||
|
|
||||||
|
'+ message['content'] | trim + '<|eot_id|>' %}{% if loop.index0 == 0 %}{% set content = bos_token + content %}{% endif %}{{ content }}{% endfor %}{% if add_generation_prompt %}{{ '<|start_header_id|>assistant<|end_header_id|>
|
||||||
|
|
||||||
|
' }}{% endif %}
|
||||||
30
config.json
Normal file
30
config.json
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"architectures": [
|
||||||
|
"MistralForCausalLM"
|
||||||
|
],
|
||||||
|
"attention_dropout": 0.0,
|
||||||
|
"bos_token_id": 2,
|
||||||
|
"dtype": "bfloat16",
|
||||||
|
"eos_token_id": 3,
|
||||||
|
"head_dim": 128,
|
||||||
|
"hidden_act": "silu",
|
||||||
|
"hidden_size": 3072,
|
||||||
|
"initializer_range": 0.02,
|
||||||
|
"intermediate_size": 10752,
|
||||||
|
"max_position_embeddings": 8192,
|
||||||
|
"model_type": "mistral",
|
||||||
|
"num_attention_heads": 16,
|
||||||
|
"num_hidden_layers": 18,
|
||||||
|
"num_key_value_heads": 4,
|
||||||
|
"pad_token_id": 0,
|
||||||
|
"rms_norm_eps": 1e-05,
|
||||||
|
"rope_parameters": {
|
||||||
|
"rope_theta": 500000,
|
||||||
|
"rope_type": "default"
|
||||||
|
},
|
||||||
|
"sliding_window": null,
|
||||||
|
"tie_word_embeddings": false,
|
||||||
|
"transformers_version": "5.5.4",
|
||||||
|
"use_cache": false,
|
||||||
|
"vocab_size": 50180
|
||||||
|
}
|
||||||
9
generation_config.json
Normal file
9
generation_config.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"_from_model_config": true,
|
||||||
|
"bos_token_id": 2,
|
||||||
|
"eos_token_id": [
|
||||||
|
3
|
||||||
|
],
|
||||||
|
"pad_token_id": 0,
|
||||||
|
"transformers_version": "5.5.4"
|
||||||
|
}
|
||||||
3
gguf/roka-v0.2-Q4_K_M.gguf
Normal file
3
gguf/roka-v0.2-Q4_K_M.gguf
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:e565e14a0cc4c5b0de9376fd7838143bdc09321e5cbf0845a6cf14c4790b7671
|
||||||
|
size 1458575232
|
||||||
3
model.safetensors
Normal file
3
model.safetensors
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:8bf89c2de19eaef8351c7c9d34d6dc6d696fa2d79898d187420192d57cd7519c
|
||||||
|
size 4750344848
|
||||||
73
roka_tool_template.jinja
Normal file
73
roka_tool_template.jinja
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
{#-
|
||||||
|
Roka tool-calling chat template — Llama-3 header format + Hermes-style <tool_call> parsing.
|
||||||
|
|
||||||
|
Compatible with llama.cpp's Hermes-2-Pro output parser (detected by the literal
|
||||||
|
"<tool_call>" string in this template source). Uses Kara-Kumru's Llama-3 special
|
||||||
|
tokens: <|start_header_id|>, <|end_header_id|>, <|eot_id|>.
|
||||||
|
|
||||||
|
Design notes:
|
||||||
|
- The model was fine-tuned with an exact Turkish system prompt from
|
||||||
|
`training/tools.py::get_system_prompt()`. That prompt already contains the
|
||||||
|
tool schemas and calling conventions. We therefore DO NOT synthesize a
|
||||||
|
generic Hermes-English tool block from `tools=[...]` — doing so made the
|
||||||
|
model go meta / mis-route, because it never saw that format in training.
|
||||||
|
- Callers should pass the training system prompt via `messages[0]` (role=system).
|
||||||
|
Any `tools=[...]` parameter is accepted but ignored when building the prompt;
|
||||||
|
its only job is to let llama.cpp expose the parsed result via OpenAI's
|
||||||
|
`tool_calls` field.
|
||||||
|
- The literal string "<tool_call>" below (inside a comment hint) is what
|
||||||
|
llama.cpp uses to detect Hermes-2-Pro output format: do not remove it.
|
||||||
|
|
||||||
|
Format hint for llama.cpp detector: the assistant wraps tool calls as
|
||||||
|
<tool_call>{"name": "...", "arguments": {...}}</tool_call>.
|
||||||
|
-#}
|
||||||
|
{%- macro llama3_header(role) -%}
|
||||||
|
<|start_header_id|>{{ role }}<|end_header_id|>
|
||||||
|
|
||||||
|
{% endmacro -%}
|
||||||
|
|
||||||
|
{{- bos_token -}}
|
||||||
|
|
||||||
|
{%- for message in messages -%}
|
||||||
|
{%- if message.role == 'system' -%}
|
||||||
|
{{- llama3_header('system') -}}
|
||||||
|
{{- message.content | trim -}}
|
||||||
|
<|eot_id|>
|
||||||
|
{%- elif message.role == 'user' -%}
|
||||||
|
{{- llama3_header('user') -}}
|
||||||
|
{{- message.content | trim -}}
|
||||||
|
<|eot_id|>
|
||||||
|
{%- elif message.role == 'assistant' -%}
|
||||||
|
{{- llama3_header('assistant') -}}
|
||||||
|
{%- if message.content -%}
|
||||||
|
{{- message.content | trim -}}
|
||||||
|
{%- endif -%}
|
||||||
|
{%- if message.tool_calls is defined and message.tool_calls -%}
|
||||||
|
{%- for tc in message.tool_calls -%}
|
||||||
|
{%- if tc.function is defined -%}
|
||||||
|
{%- set call = tc.function -%}
|
||||||
|
{%- else -%}
|
||||||
|
{%- set call = tc -%}
|
||||||
|
{%- endif %}
|
||||||
|
<tool_call>
|
||||||
|
{%- if call.arguments is string %}
|
||||||
|
{"name": "{{ call.name }}", "arguments": {{ call.arguments }}}
|
||||||
|
{%- else %}
|
||||||
|
{{ {'name': call.name, 'arguments': call.arguments} | tojson }}
|
||||||
|
{%- endif %}
|
||||||
|
</tool_call>
|
||||||
|
{%- endfor -%}
|
||||||
|
{%- endif -%}
|
||||||
|
<|eot_id|>
|
||||||
|
{%- elif message.role == 'tool' -%}
|
||||||
|
{{- llama3_header('user') -}}
|
||||||
|
<tool_response>
|
||||||
|
{{ message.content }}
|
||||||
|
</tool_response>
|
||||||
|
<|eot_id|>
|
||||||
|
{%- endif -%}
|
||||||
|
{%- endfor -%}
|
||||||
|
|
||||||
|
{%- if add_generation_prompt -%}
|
||||||
|
{{- llama3_header('assistant') -}}
|
||||||
|
{%- endif -%}
|
||||||
251314
tokenizer.json
Normal file
251314
tokenizer.json
Normal file
File diff suppressed because it is too large
Load Diff
17
tokenizer_config.json
Normal file
17
tokenizer_config.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"backend": "tokenizers",
|
||||||
|
"bos_token": "<BOS>",
|
||||||
|
"clean_up_tokenization_spaces": true,
|
||||||
|
"eos_token": "<EOS>",
|
||||||
|
"extra_special_tokens": [
|
||||||
|
"<tool_call>",
|
||||||
|
"</tool_call>",
|
||||||
|
"<tool_response>",
|
||||||
|
"</tool_response>"
|
||||||
|
],
|
||||||
|
"is_local": false,
|
||||||
|
"model_max_length": 1000000000000000019884624838656,
|
||||||
|
"pad_token": "<PAD>",
|
||||||
|
"tokenizer_class": "TokenizersBackend",
|
||||||
|
"unk_token": "<UNK>"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user