A fine-tuned version of
LFM2.5-1.2B-Instruct that acts as a strategic concept router for software engineering tasks. Given a developer's coding request, it identifies which strategic concept(s) from a 518-entry knowledge base apply and synthesizes structured guidance for a downstream coding model to consume.
1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
3
4tok = AutoTokenizer.from_pretrained("jtregunna/cobrachicken-swe")
5model = AutoModelForCausalLM.from_pretrained(
6 "jtregunna/cobrachicken-swe",
7 dtype=torch.bfloat16,
8 device_map="cuda:0",
9)
10
11SYSTEM = (
12 "You are a software engineering strategist. Analyze user requests and "
13 "output strategic guidance as JSON with concepts_applied (0-3 concepts "
14 "with id, name, weight), core_idea (synthesized framing), key_principles "
15 "(3-5 actionable items), and avoid (1-3 warnings)."
16)
17
18messages = [
19 {"role": "system", "content": SYSTEM},
20 {"role": "user", "content": "I just inherited a 600-line Flask app from someone who left and I have no idea where to start understanding it."},
21]
22
23ids = tok.apply_chat_template(
24 messages,
25 add_generation_prompt=True,
26 return_tensors="pt",
27 tokenize=True,
28)
29if hasattr(ids, "input_ids"):
30 ids = ids.input_ids
31ids = ids.to(model.device)
32
33out = model.generate(
34 input_ids=ids,
35 attention_mask=torch.ones_like(ids),
36 max_new_tokens=512,
37 do_sample=False,
38 pad_token_id=tok.eos_token_id,
39)
40print(tok.decode(out[0][ids.shape[1]:], skip_special_tokens=True))
1{
2 "concepts_applied": [
3 {"id": "sf-legacy-code-001", "name": "Legacy Code Strategies", "weight": "primary"}
4 ],
5 "core_idea": "Start by creating a 'map' of the system's components rather than trying to understand every line of code immediately. Identify the entry points and trace a few key user journeys to build a mental model of the application's flow.",
6 "key_principles": [
7 "Identify the main entry point and trace a few key user journeys to understand the application flow.",
8 "Create a component map to identify the different modules and their responsibilities.",
9 "Write simple integration tests for the identified entry points to verify basic functionality before diving deeper."
10 ],
11 "avoid": [
12 "Trying to understand every function and variable immediately.",
13 "Refactoring the entire codebase before understanding it."
14 ]
15}
The model was trained with variations on system prompts related to the role of being a software strategist. Small models are sensitive to prompt drift, and centering your prompt on other roles, could degrade schema conformance and routing accuracy:
Not designed for: direct end-user-facing chat, code generation, knowledge-intensive Q&A, or stand-alone deployment without a downstream model.
-
Null discipline. The model tends to route most inputs to some concept rather than returning concepts_applied: [] for off-topic or trivial inputs (e.g. "rename x to y", "what's the weather"). Downstream consumers should be tolerant of occasionally irrelevant guidance, or filter outputs by a confidence/relevance signal.
-
System prompt sensitivity. System prompt needs to be on topic as a software strategist.
-
Synthesis quality bounded by teacher data. Outputs are well-structured but occasionally read as templated. Quality is upper-bounded by the teacher model used to generate the training data.
-
Concept coverage. Performance is best on concepts with high training-example density. Long-tail concepts may be less reliably routed.
-
English-only. Training data was English; behavior in other languages is untested and likely degraded.
-
Not for general chat. This is a specialized routing model. It will attempt to produce structured JSON for any input, including ones where free-form prose would be more appropriate.
This model is released under the
LFM Open License, inherited from the base model LFM2.5-1.2B-Instruct.
1@misc{liquidai2024lfm2,
2 title={LFM2.5: A Family of Hybrid Models},
3 author={Liquid AI},
4 year={2024},
5 url={https://huggingface.co/LiquidAI/LFM2.5-1.2B-Instruct}
6}