How to teach Conceiver

This page shows how to teach Conceiver each kind of task it can learn, and what it answers afterwards. Every example below was run against Conceiver; the arrows show its answers and their confidence. It is written so a coding agent can follow it as well as a person. Agents can install the same guide as a skill: python -m toolving.skill install (see the quickstart).

The examples use the Python SDK. Each starts from a fresh instance:

import os
from toolving import ConceiverClient

client = ConceiverClient(os.environ["TOOLVING_API_URL"], os.environ["TOOLVING_API_KEY"])
instance = client.create()

def ask(question):
    p = instance.query(question)
    return f"{p.text} ({p.confidence})" if p.status == "ANSWER" else "UNRESOLVED"

How Conceiver learns

You teach an input line and the output line it should give: instance.teach(question, answer). Conceiver compares the two. A word of the input that also appears in the output becomes a slot: any word can fill it, and the output carries it across. The other words of the input are fixed: an input must have them, in that order, to fit. Asked a new input, Conceiver answers from the pattern the input fits, with a confidence level and the evidence behind it. If nothing fits, the result is UNRESOLVED: it never invents an answer.

It learns words, not meanings. It does not know that payment and card are related, or that walked is a form of walk, unless an example shows it.

Confidence

Each answer carries a level counted from its evidence: how many times that answer was given or confirmed (for), minus how many times it was corrected away (against).

confidence Evidence Use it for
hypothesis One more for than against, or the input fits a pattern in a way no example has shown: a new word in a slot that has only ever held one word, several words where only single words were taught, a word repeated across slots A best guess. Use it where a wrong answer is cheap, or have it checked.
confident Two more for than against Usually safe to act on.
highly confident Three or more Act on it.
ambiguous For and against are level Do not act on it. Ask, then resolve.

These are counts of evidence, not probabilities. Your program decides which level is enough for each action. Always check status before reading text.

A slot rises above hypothesis for new words only once it has held two or more different words. A value of several words in a slot that has only held single words is a hypothesis until you confirm one such answer with resolve(); after that, values of that shape count like any other.

Recall an exact answer

One example is enough to recall it. Teach it again, or resolve a prediction with it, to raise the level.

instance.teach("support queue", "Customer care")
ask("support queue")   # Customer care (hypothesis)
ask("sales queue")     # UNRESOLVED

sales queue is unresolved: support does not appear in the answer, so it is a fixed word, and sales is not it.

Copy a value into a template

A word of the input that appears in the answer becomes a slot.

instance.teach("create account alice", "createAccount(alice)")
ask("create account bob")    # createAccount(bob) (hypothesis)

instance.teach("create account bob", "createAccount(bob)")
instance.teach("create account carol", "createAccount(carol)")
ask("create account zorb")   # createAccount(zorb) (highly confident)
ask("make account zorb")     # UNRESOLVED: a fixed word differs
ask("createAccount zorb")    # UNRESOLVED

createAccount(alice) works because the default delimiters keep ( and ) as words of their own, so alice is a separate word in the answer (see Words and delimiters).

Reorder and combine values, including JSON

The answer is one line. Compact JSON works; the SDK decodes it into output.

instance.teach("swap alice bob", "bob alice")
instance.teach("swap jane doug", "doug jane")
ask("swap red blue")          # blue red (confident)

instance.teach("add alice to sales", '{"team":"sales","user":"alice"}')
instance.teach("add bob to support", '{"team":"support","user":"bob"}')
ask("add carol to finance")   # {"team":"finance","user":"carol"} (confident)

To produce JSON from your own values, encode it on one line: json.dumps(value, separators=(",", ":"), sort_keys=True).

A fixed answer for a shape of input

When the answer shares no word with the input, the varying words of the input still become slots, and every input of that shape gets the same answer. Teach the contrasting case explicitly. A word repeated in two slots is a different shape from two different words:

instance.teach("isEqual alice bob", "different")
instance.teach("isEqual jane doug", "different")
ask("isEqual zorb zorb")    # different (hypothesis): no example has shown a repeat yet

instance.teach("isEqual alice alice", "same")
instance.teach("isEqual bob bob", "same")
ask("isEqual zorb zorb")    # same (hypothesis)
ask("isEqual zorb plonk")   # different (hypothesis)

Operations inside operations

Once an operation is taught, it can stand where a value goes. The inner operation is answered first, and its answer fills the outer slot.

instance.teach("keepFirst alice bob", "alice")
instance.teach("keepFirst jane doug", "jane")
ask("keepFirst zorb plonk")                 # zorb (hypothesis)
ask("isEqual zorb keepFirst zorb plonk")    # same (hypothesis)
ask("isEqual plonk keepFirst zorb plonk")   # different (hypothesis)

A request that expands into steps

Teach the steps and the request the same way. The request's answer is the sequence of steps.

for name in ("bob", "alice"):
    instance.teach(f"create account {name}", f"create_account({name})")
    instance.teach(f"add to team {name}", f"add_to_team({name})")
    instance.teach(f"onboard {name}", f"create account {name}; add to team {name}")
ask("onboard carol")   # create account carol; add to team carol (confident)

Correct a wrong answer

When you learn what the answer should have been, resolve the prediction with it. The correction counts against the answer it replaces and for the new one, so the new answer leads at once.

instance.teach("file invoice from acme", "/finance/vendors/acme")
p = instance.query("file invoice from acme")            # /finance/vendors/acme (hypothesis)
instance.resolve(p.prediction_id, "/legal/disputes/acme")
ask("file invoice from acme")                           # /legal/disputes/acme (hypothesis)

p = instance.query("file invoice from acme")
instance.resolve(p.prediction_id, "/legal/disputes/acme")
ask("file invoice from acme")                           # /legal/disputes/acme (confident)

Resolve every prediction whose real outcome you find out, right or wrong: a confirmed answer gains evidence too.

Tell two cases apart with a word

Teach one example of each case, with the word that tells them apart.

instance.teach("file disputed invoice from acme", "/legal/disputes/acme")
instance.teach("file paid invoice from acme", "/finance/vendors/acme")
ask("file disputed invoice from globex")   # /legal/disputes/globex (hypothesis)
ask("file paid invoice from globex")       # /finance/vendors/globex (hypothesis)

Words and delimiters

Conceiver works on words. By default a language instance splits at the space and keeps each of . , ; : ! ? ( ) [ ] { } " / as a word of its own. So createAccount(alice) is the four words createAccount ( alice ), and /finance/vendors/acme is / finance / vendors / acme: alice and acme can be slots.

Choose other delimiters when the instance is created:

instance = client.create(model="language", delimiters={"split": " ", "keep": ".(),"})

split characters separate words and are dropped. keep characters separate words and are words themselves. Use ASCII characters, at least one split character, and each character only once across both. The HTTP form is {"model": "language", "delimiters": {"split": " ", "keep": ".(),"}} on POST /v1/instances.

What it does not do yet

  • Change part of a word. walk past tense -> walked does not teach talk past tense -> talked: walked is one word, and talk is not in it. That input is UNRESOLVED. Put the varying part in a word of its own.
  • Fill one slot with several words. Taught turn on kitchen lights -> lights.on(kitchen), it answers turn on dining room lights with lights.on dining(room), as a hypothesis, which is wrong. Join a multi-word value into one word, such as dining-room.
  • Classify by meaning. An input that shares no words with what was taught is UNRESOLVED: my card was declined -> billing teaches nothing about my payment failed. Send those to an LLM or a person, then teach the answer.
  • Know which words matter. Any input word that also appears in the answer becomes a slot. After turn on kitchen lights -> lights.on(kitchen) and turn on hall lights -> lights.on(hall), turn off kitchen lights answers lights.off(kitchen), because on appears in the answer. It is only a hypothesis: the slot has never held anything but on. If that is wrong, resolve it with the right answer once: after resolving turn off kitchen lights with lights.dim(kitchen), turn off hall lights answers lights.dim(hall). The pattern it was taken from has that correction against it now, so its other answers (turn on porch lights) drop to hypothesis until they gain evidence again.
  • Match a different word. Matching is by exact word, including capital letters. Taught delete file report -> rm(report) and delete file notes -> rm(notes), the inputs remove file report, Delete file report and please delete file report are UNRESOLVED. An extra word at the end goes into the last slot: delete file report please answers rm(report please) as a hypothesis. Normalise input before you query, or teach each phrasing.
  • Take more than one line. Questions and answers are single lines.

Keep what it learned

  • instance.training_sequence()["text"] returns the teachings that still support what the instance learned, as text: a question line, an answer line, and a blank line between teachings. It is free and stores nothing.
  • instance.save() stores that text as an account file (it needs storage). client.create(sequence_id=...) restores it into a new instance; instance.ingest_training_sequence(text) teaches it into an existing one.
  • instance.reap() releases the instance. Without storage its memory is discarded; with storage it is saved as an artifact that a later instance loads with client.create(artifact_id=...), unless saving at spin-down is turned off (client.set_spin_down(False)) or there is no room (see Saving at spin-down).

For arithmetic, do not teach it yourself: client.create(model="numbers") is a ready-made calculator (see The numbers model).

Python SDK reference · Concepts · Examples