coglang-drug-distill — drug-v6 (Q4_K_M GGUF)
A CogLang-specialist small model for on-device inference. It translates natural-language medication-safety questions into CogLang — a graph-first intermediate language — which is then executed against a curated drug-interaction graph.
The model only writes graph queries; it never answers drug questions from memory. Pharma facts live in the graph, not the weights.
⚠️ Medical disclaimer. Learning/research demo only. Not a medical device, not clinical decision support. The accompanying graph is a tiny illustrative seed, not authoritative. Never use any output for real medical decisions.
Files
| File | Description |
|---|---|
drug-v6-q4_k_m.gguf |
Recommended. Latest model — verb→operator routing rules baked into weights + weak-operator training data. |
drug-v5-q4_k_m.gguf |
Previous version (kept for reproducibility). |
- Base model: Qwen/Qwen2.5-1.5B-Instruct
- Method: QLoRA (4-bit) fine-tune → merged → GGUF →
Q4_K_Mquantize - Size / footprint: 935 MiB, ~1 GB RAM
- Speed: ~33 tok/s gen on CPU (i9-13900HX, 8 threads)
- Full code & pipeline: https://github.com/zhpy2004/coglang-drug-distill
Results
| Eval surface | Config | drug-v5 | drug-v6 |
|---|---|---|---|
| Curated OOD set (10) | Q4 + GBNF + SYSTEM_v6d |
80% (8/10) | 100% (10/10) |
| Wild prompts, executed end-to-end (19) | + few-shot ICL | ~68% (13/19) | ~84% (16/19) |
| parse / validate / hallucinated | — | 100% / 100% / 0 | 100% / 100% / 0 |
drug-v6 bakes the SYSTEM_v6d verb→operator rules into the weights and adds targeted training data for the operators v5 still missed (Traverse-as-"causes", ForEach, Trace[...] wrapping, Do[...] pairing). This cured those routing errors — OOD is now saturated at 100%. The remaining ~3 wild misses are structural limits of single-shot CogLang (multi-relation union, reverse traversal), not routing.
Pairing the model with the CogLang GBNF grammar guarantees 100% parseable output, so the model only has to learn semantics, not syntax.
Usage (llama.cpp, grammar-constrained)
# get the CogLang GBNF grammar from the upstream repo:
# https://github.com/jaysinailabs/coglang -> examples/grammar/coglang.gbnf
llama-cli -m drug-v6-q4_k_m.gguf \
-st \
-sys "$(cat SYSTEM_v6d.txt)" \
-p "warfarin interactions" \
--grammar-file coglang.gbnf \
-n 256 --temp 0 -t 8
# -> Traverse["warfarin", "interacts_with"]
The tuned system prompt (SYSTEM_v6d.txt) and few-shot blocks live in the GitHub repo. An interactive CLI (pipeline/drug_chat.py) and a modular local web app (app/, runnable on desktop and in Termux on a phone) wire NL → CogLang → execution against the seed graph.
License & attribution
Apache-2.0. Built on and depends on CogLang (Jason Xin / Bigcoders, Apache-2.0), which is not redistributed here.