A 3B coding + agent model from K-Ai (Kortex AI), fine-tuned with QLoRA / LoRA using Supervised Fine-Tuning (SFT) from ibm-granite/granite-4.1-3b-base.
Main focus:
This is our approach to our first Agentic model, therefore some things may not be right or wrong.
The numbers below were produced directly by the training notebook on this model. This is a smoke test with a small sample size, not a standard benchmark (not HumanEval / BFCL / MMLU), so the results cannot be directly compared with official scores of other models.
| Language | n | Valid <tool_call> Format |
Correct Tool Name | Required Arguments Complete |
|---|---|---|---|---|
| id | 4 | 25% | 25% | 25% |
| ja | 4 | 0% | 0% | 0% |
| en | 4 | 25% | 25% | 25% |
assert)Passed 5 out of 6 tasks.
Kanata-S1-3B was trained using a combination of coding, agentic AI, and general instruction datasets in three languages.
Composition (sample counts per mode are in the configuration):
| Bucket | Source | Language |
|---|---|---|
agent_synth |
Self-made synthetic generator: 8 scenarios (fix bug + test, run script, explore repo, web research, refactor + verify, answer without tool, tool unavailable, repeated failure → report honestly). Tool results are computed with real Python execution during generation. | ID / JA / EN |
agent_hermes |
NousResearch/hermes-function-calling-v1 (Apache-2.0), normalized to the same format | EN |
code_idja_synth |
14 coding tasks with solutions verified via unit tests during generation + debugging sessions | ID / JA / EN |
code_en |
Magicoder-OSS-Instruct-75K, CodeFeedback-Filtered-Instruction | EN |
code_ja |
Synthetic-JP-EN-Coding-Dataset (llm-jp; fallback: Aratako 567k) | JA |
id_general |
alpaca-gpt4-indonesia-cleaned (NekoFi) | ID |
ja_general |
llm-jp/magpie-sft-v1.0 | JA |
kai_v3 |
(optional, USE_KAI_V3=True) your dataset K-Ai-Official/Kai_v3 (split train used × KAI_V3_REPEAT; validation → validation loss; benchmark → evaluation, never trained on) |
ID / JA / EN |
| Step | Description |
|---|---|
| Fault-tolerant loading | Each loader is wrapped in try/except, so a failure in one source does not automatically stop loading the other sources |
| Sample reporting | Sample counts are reported based on actual dataset loading and processing results |
| Synthetic agentic data | Synthetic agentic AI data was created using the K-Ai generator |
| Verified coding solutions | Some coding solutions were verified using unit tests during generation |
All loaders are wrapped in try/except: if one source fails to load, the other sources still run and their counts are reported. Check the license of each dataset before releasing a model (some dataset cards do not state a clear license).
If USE_KAI_V3=True, the K-Ai dataset uses:
| Split | Usage |
|---|---|
train |
Used for training and can be repeated according to KAI_V3_REPEAT |
validation |
Used for validation loss |
benchmark |
Used for evaluation and not used in training |
| Setting | Behavior |
|---|---|
KAI_V3_DROP_IDENTITY |
The identity category is dropped by default when enabled |
KAI_V3_KEEP_SYSTEM |
The system prompt can be replaced with the Kanata system prompt according to configuration |
Format: Granite chat (<|start_of_role|>…<|end_of_role|>, turn end <|end_of_text|>) with Hermes-style tool calls <tool_call>{"name":..., "arguments":...}</tool_call>. Loss is calculated only on assistant turns.
| Parameter | Value |
|---|---|
| Base model | ibm-granite/granite-4.1-3b-base |
| Fine-tuning | QLoRA 4-bit NF4 |
| LoRA rank | 32 |
| Sequence length | 1280 |
| Training mode | FAST |
| Maximum steps | 184 |
| Planned epochs | 1.19 |
| Effective batch size | 16 |
| Estimated training time | 45.9 minutes on NVIDIA T4 |
| Training samples | 2476 |
Loss is calculated only on assistant turns.
| Bucket | Samples |
|---|---|
agent_synth |
775 |
code_idja_synth |
120 |
identity |
8 |
code_en |
450 |
code_ja |
300 |
id_general |
700 |
ja_general |
350 |
agent_hermes |
0 |
K-Ai synthetic agentic generator, NousResearch/hermes-function-calling-v1, Magicoder-OSS-Instruct, CodeFeedback, llm-jp (Synthetic-JP-EN-Coding, magpie-sft), and alpaca-gpt4-indonesia-cleaned.
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
tok = AutoTokenizer.from_pretrained("K-Ai-Official/Kanata-S1-3B")
model = AutoModelForCausalLM.from_pretrained(
"K-Ai-Official/Kanata-S1-3B",
torch_dtype="auto",
device_map="auto"
)
prompt = "<|start_of_role|>user<|end_of_role|>Write a Python function to reverse a string<|end_of_text|>\n<|start_of_role|>assistant<|end_of_role|>"
ids = tok(
prompt,
return_tensors='pt',
add_special_tokens=False
).to(model.device)
out = model.generate(
**ids,
max_new_tokens=300,
eos_token_id=tok.convert_tokens_to_ids("<|end_of_text|>")
)
print(tok.decode(
out[0][ids['input_ids'].shape[1]:],
skip_special_tokens=False
))
The chat format follows Granite role tokens:
| Token | Purpose |
|---|---|
| `< | start_of_role |
| `< | end_of_role |
| `< | end_of_text |
Tools are provided via the system prompt inside <tools></tools> and are called using the format <tool_call>{...}</tool_call>.
| Limitation |
|---|
| Indonesian is not included in the official language list of the Granite base model. Its quality depends on fine-tuning data and has not been extensively tested. |
| The evaluation above comes from a small sample and partly self-made synthetic data. Results may be more optimistic than real-world tasks. |
| The model may call tools incorrectly or generate inaccurate information. |
| Tool execution must be handled and verified by an external runtime. |
| Check public dataset licenses before commercial use. |
Apache-2.0
K-Ai — Kortex AI
We Build Because We Believe We Can.
model-00001-of-00002.safetensors 4.9 GBmodel-00002-of-00002.safetensors 1.9 GBmradermacher/Kanata-S1-3B-i1-GGUF 磁力链接 2