Views
No views yet
smolnalysis CKAN retrieval role.{"thought":"short decision summary","action":"tag_search","args":{"query":"Fahrrad","rows":10},"confidence":0.95}tag_searchgroup_listorganization_listpackage_searchpackage_showselect_resourcefinishask_clarification1from peft import PeftModel
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4base_model = "openbmb/MiniCPM5-1B"
5adapter = "build-small-hackathon/smolnalysis-ckan-retrieval-minicpm5-lora"
6
7tokenizer = AutoTokenizer.from_pretrained(base_model, trust_remote_code=True)
8model = AutoModelForCausalLM.from_pretrained(
9 base_model,
10 trust_remote_code=True,
11 torch_dtype="auto",
12 device_map="auto",
13)
14model = PeftModel.from_pretrained(model, adapter).eval()
15
16messages = [
17 {
18 "role": "system",
19 "content": (
20 "You are the CKAN retrieval policy for smolnalysis. Emit strict JSON only. "
21 "Output exactly one compact JSON object with keys: thought, action, args, confidence."
22 ),
23 },
24 {
25 "role": "user",
26 "content": """Request: Zeig mir nützliche Daten zu Fahrrad.
27Endpoint: https://opendata.muenchen.de/
28Current state: No catalog tools have been run yet.
29Observed packages: []
30Observed resources: []
31Observed tags: []
32Observed groups: []
33Observed organizations: []
34Tool errors or empty results: []
35Enough evidence: False
36Desired next action type: tag_search
37Required args schema: {"query":"search terms","rows":10}""",
38 },
39]
40
41inputs = tokenizer.apply_chat_template(
42 messages,
43 tokenize=True,
44 add_generation_prompt=True,
45 enable_thinking=False,
46 return_dict=True,
47 return_tensors="pt",
48).to(model.device)
49
50outputs = model.generate(
51 **inputs,
52 max_new_tokens=384,
53 do_sample=False,
54 pad_token_id=tokenizer.eos_token_id,
55)
56print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))1SMOLNALYSIS_MINICPM_BACKEND=transformers
2SMOLNALYSIS_MINICPM_TRANSFORMERS_MODEL_ID=openbmb/MiniCPM5-1B
3SMOLNALYSIS_MINICPM_CKAN_RETRIEVAL_ADAPTER_REPO_ID=build-small-hackathon/smolnalysis-ckan-retrieval-minicpm5-lora
4SMOLNALYSIS_MINICPM_CKAN_RETRIEVAL_TEMPERATURE=0
5SMOLNALYSIS_MINICPM_MAX_NEW_TOKENS=384openbmb/MiniCPM5-1Bq_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj{% generation %} markers so that only assistant JSON actions contribute to loss.1{
2 "total": 160,
3 "json_parse_rate": 1.0,
4 "valid_action_rate": 1.0,
5 "exact_action_match_rate": 1.0,
6 "exact_action_matches": 160,
7 "issue_counts": {}
8}1{
2 "total": 8,
3 "json_parse_rate": 1.0,
4 "valid_action_rate": 1.0,
5 "exact_action_match_rate": 1.0,
6 "exact_action_matches": 8,
7 "issue_counts": {}
8}1@software{vonwerra2020trl,
2 title = {{TRL: Transformers Reinforcement Learning}},
3 author = {von Werra, Leandro and Belkada, Younes and Tunstall, Lewis and Beeching, Edward and Thrush, Tristan and Lambert, Nathan and Huang, Shengyi and Rasul, Kashif and Gallouédec, Quentin},
4 license = {Apache-2.0},
5 url = {https://github.com/huggingface/trl},
6 year = {2020}
7}