# Pally — Business Consulting AI with Verifiable Math and Self-Correcting Rules (Docs) **Pally (Pally-1.7B)** is a 1.7B-parameter business-consulting language model built by **ChatPBC Labs**. It is unusual for its size in three ways: 1. **It shows its math.** When a question involves money, margins, months, or ratios, Pally writes the arithmetic as visible `[calc: 412000 / 31000]` steps. A sandboxed runtime (not the neural network) executes each step and substitutes the true result before you see the answer. 2. **It verifies and revises.** In System-2 mode the runtime checks every `[calc:]`/`[verify:]` marker; failed expressions are fed back to the model, which revises its answer (up to 8 iterations). 3. **It edits its own operating rules.** Pally's behavior rules live in an external, versioned config ("constitution", "tool_rules", "metacognitive_rules", "refusal_rules", "playbook"). The model can rewrite them at inference time through a sandboxed `[cortex_edit]` channel. Every edit is logged, capped, persisted, and revertible. This is called **POWER MODE** (round `cortex1-v8`). > Weights: [`chatpbc1/Pally`](https://huggingface.co/chatpbc1/Pally) · > Paper: [RESEARCH_CORTX1.md](https://huggingface.co/chatpbc1/Pally/blob/main/RESEARCH_CORTX1.md) · > Developer guide: [DEVELOPER_GUIDE.md](https://huggingface.co/chatpbc1/Pally/blob/main/DEVELOPER_GUIDE.md) · > Chat UI (when demo is online): [pally-console Space](https://huggingface.co/spaces/chatpbc1/pally-console) --- ## What Pally is good at — and what it is not | Strength | Weakness (honest) | |---|---| | Unit economics: LTV, CAC, payback, runway, margins — **with worked, code-verified steps** | Not a frontier model (≈49/100 vs GPT-OSS 20B's 82/100 on a consulting bench) | | Uses **your** digits, not memorized training examples (v7 digit-binding training) | `[calc:]` firing is not 100% — on missed cases it reverts to mental math, which a 1.7B model often gets wrong | | Stable persona: warm, direct consultant; never invents statistics; one concrete next action per answer | Knowledge is frozen at training time; no live data | | Tiny and private: one consumer GPU, or CPU (slow); Apache-2.0 weights | Short answers by design; not for 2,000-word memos | | Transparent self-improvement: watch every rule edit it makes | Self-edits need human review in production (`_edit_log`) | **Rule of thumb: for any number that matters, require the `[calc:]` steps or verify independently.** --- ## Using the model ### Quickstart (transformers) ```python from transformers import AutoModelForCausalLM, AutoTokenizer tok = AutoTokenizer.from_pretrained("chatpbc1/Pally", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("chatpbc1/Pally", trust_remote_code=True, torch_dtype="auto") msgs = [{"role": "user", "content": "We have $412k and burn $31k/mo. Runway?"}] inputs = tok.apply_chat_template(msgs, add_generation_prompt=True, return_tensors="pt") out = model.generate(inputs, max_new_tokens=400, do_sample=False) print(tok.decode(out[0][inputs.shape[1]:], skip_special_tokens=True)) ``` > Plain transformers gives you the persona, **not** the calculator or verifier. For those, serve it > with the CORTX-1 runtime (below). ### CORTX-1 serving (calculator + verifier + POWER MODE) The serving stack is a single Python file (FastAPI). Serve it on any GPU/CPU box: ```bash pip install fastapi uvicorn pydantic torch transformers python cortx-1-power-mode-v8.py # loads the model, starts API on :8000 ``` Then call the OpenAI-compatible API: ```bash curl http://localhost:8000/v1/chat/completions -H 'Content-Type: application/json' \ -d '{"model":"pally-1.7b", "messages":[{"role":"user","content":"AOV $37, margin 52%. Contribution per order?"}], "cortex":{"system2":true}}' ``` ```python from openai import OpenAI c = OpenAI(base_url="http://localhost:8000/v1", api_key="none") r = c.chat.completions.create( model="pally-1.7b", messages=[{"role": "user", "content": "We burn $31k/mo with $412k saved. Runway?"}], extra_body={"cortex": {"system2": True}}) print(r.choices[0].message.content) ``` Full endpoint and config reference: see the [Developer Guide](https://huggingface.co/chatpbc1/Pally/blob/main/DEVELOPER_GUIDE.md). --- ## POWER MODE — the self-correcting loop (v8) ``` user question | v gate: System-1 (one pass) or System-2 (deliberate) | v generate --> parse [calc:]/[verify:] markers --> sandboxed AST evaluator | | fails? | | +--> REVISION request <-------+ | | v v [cortex_edit] blocks? --> rewrite own rule files (up to 8, <=8,000 chars each) | | v v answer to user config versioned & persisted (HF repo), edit logged, recent edits + recent failures injected into the next prompt -- the loop closes. ``` Editable files: `constitution`, `tool_rules`, `metacognitive_rules`, `refusal_rules`, `playbook`. Static identity (name, lab, "not ChatGPT/Claude/...") is **not** editable. Set `"power_mode": false` in `cortex/config.json` to fall back to classic v7 limits (4 sections, 4,000 chars, 1 edit per self-improve turn). --- ## Repository map | Path | Purpose | |---|---| | [`chatpbc1/Pally`](https://huggingface.co/chatpbc1/Pally) | Model weights, paper, developer guide, benchmarks | | [`chatpbc1/Pally/DEVELOPER_GUIDE.md`](https://huggingface.co/chatpbc1/Pally/blob/main/DEVELOPER_GUIDE.md) | **How to serve, call, configure, and extend Pally** | | [`chatpbc1/Pally/RESEARCH_CORTX1.md`](https://huggingface.co/chatpbc1/Pally/blob/main/RESEARCH_CORTX1.md) | Research paper: CORTX-1 architecture + self-correction | | This repo (`chatpbc1/pally-endpoint`) | CORTX runtime config (`cortex/config.json`), metrics, docs | | [`chatpbc1/pally-console`](https://huggingface.co/spaces/chatpbc1/pally-console) | Chat UI Space | Built by **ChatPBC Labs**. Apache-2.0.