Views
No views yet
CohereLabs/tiny-aya-global that teaches multi-step agentic reasoning — chaining data between calls, refusing impossible requests, and branching on conditions — distilled from Cohere's North Mini Code through an automatic verifier.| Model | Total | one_shot | data_chain | rejection | conditional |
|---|---|---|---|---|---|
| Tiny Aya (base) | 5 / 20 | 5/5 | 0/5 | 0/5 | 0/5 |
| Tiny Aya Agent (SFT v2, 80 examples) | 15 / 20 | 5/5 | 5/5 | 1/5 | 4/5 |
data_chain goes 0→5 and conditional goes 0→4: the model learns to resolve "$N.field" references and to emit both branches of a condition — capabilities entirely absent in the base model.{"error": "no tool available"}. At 12.5% (this adapter), it under-refuses, building plans for impossible requests instead of declining. Both proportions overshoot in opposite directions; the optimum lies between them. For a small model, the decision to act versus decline is shaped more by dataset composition than by any single example.pip install torch transformers peft bitsandbytes accelerate1import torch
2from peft import PeftModel
3from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
4
5BASE = "CohereLabs/tiny-aya-global"
6ADAPTER = "ferscm44/tiny-aya-agent"
7
8bnb = BitsAndBytesConfig(
9 load_in_4bit=True,
10 bnb_4bit_quant_type="nf4",
11 bnb_4bit_use_double_quant=True,
12 bnb_4bit_compute_dtype=torch.float16,
13)
14
15base = AutoModelForCausalLM.from_pretrained(
16 BASE, quantization_config=bnb, device_map="auto",
17 attn_implementation="sdpa", dtype=torch.float16,
18)
19model = PeftModel.from_pretrained(base, ADAPTER).eval()
20
21# Load the tokenizer from THIS repo — it carries the training chat template.
22tokenizer = AutoTokenizer.from_pretrained(ADAPTER)
23
24# The model expects the full planning prompt as the user turn: the available
25# tools, the output protocol, and the request. See runner.build_prompt in the
26# project repo for the canonical prompt builder.
27prompt = '''You are an agent that plans tool calls. You respond with JSON only.
28
29AVAILABLE TOOLS:
30{
31 "find_customer": {"params": {"name": "string"}, "returns": {"id": "string"}},
32 "get_account": {"params": {"customer_id": "string"}, "returns": {"account_id": "string", "status": "string"}},
33 "get_balance": {"params": {"account_id": "string"}, "returns": {"balance": "number"}}
34}
35
36OUTPUT PROTOCOL:
371. Default: a JSON array of calls, e.g. [{"tool": "<name>", "args": {...}}, ...]
382. Reference an earlier result with "$N.field" (1-based step N).
393. For an if/else request: {"setup": [...], "branches": [{"condition": {...}, "calls": [...]}, {"condition": "else", "calls": [...]}]}
404. If no tool fits: {"error": "no tool available"}
41
42USER REQUEST: What is the current balance of the customer named John Smith?'''
43
44text = tokenizer.apply_chat_template(
45 [{"role": "user", "content": prompt}],
46 add_generation_prompt=True, tokenize=False,
47)
48inputs = tokenizer(text, return_tensors="pt", add_special_tokens=False).to(model.device)
49
50# Stop at the standard eos or Aya's end-of-turn token.
51eos_ids = [tokenizer.eos_token_id]
52end_turn = tokenizer.convert_tokens_to_ids("<|END_OF_TURN_TOKEN|>")
53if isinstance(end_turn, int) and end_turn >= 0 and end_turn != tokenizer.unk_token_id:
54 eos_ids.append(end_turn)
55
56with torch.no_grad():
57 out = model.generate(
58 **inputs, max_new_tokens=200, do_sample=False,
59 eos_token_id=eos_ids,
60 pad_token_id=tokenizer.pad_token_id or tokenizer.eos_token_id,
61 )
62
63print(tokenizer.decode(out[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
64# Expected:
65# [{"tool": "find_customer", "args": {"name": "John Smith"}},
66# {"tool": "get_account", "args": {"customer_id": "$1.id"}},
67# {"tool": "get_balance", "args": {"account_id": "$2.account_id"}}][{"tool": "<name>", "args": {...}}, ...]"$N.field" — the field of step N's result (1-based).{"setup": [...], "branches": [{"condition": {"field": "$N.field", "op": ">", "value": 100}, "calls": [...]}, {"condition": "else", "calls": [...]}]}{"error": "no tool available"} when no available tool can satisfy the request.CohereLabs/tiny-aya-globalCohereLabs/tiny-aya-global and inherits its non-commercial license restriction.