Skip to content
msieur-gabPublic

About

Talk to your Linux board in plain words. A small offline model that asks before it acts.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

112 Commits

Folders and files

Repository files navigation

TermNL

TERMinal Natural Language. Talk to your Linux board in plain words, for people who aren't comfortable with the terminal.

TermNL understands a short request ("make a folder called bikes in documents"), asks for whatever is missing, asks for approval when an action is risky, and only ever runs commands written in its skill files. It runs offline, on the device, with no large model and no generated commands.

Every request ends in one of four outcomes: act, ask, approve, abstain.

Try it in your browser: TermNL itself, on a pretend board. Commands are shown, never run.

Where it runs

TermNL is tested on two small Linux boards: the Orange Pi Zero 2W and the Luckfox Lyra Zero W. It was made with constrained devices in mind, so it should run comfortably on a Raspberry Pi too, and it runs on any Linux computer, a laptop included: Python 3.9 or newer, nothing else to install.

It is also the terminal of SymbiOS, a system I'm building: a computer that is only yours, built on these small boards. A thinking device you carry and plug into a screen, with your phone as its companion, that can be extended with Meshtastic nodes and more. There, TermNL works alongside other small models. If SymbiOS interests you, get in touch through thecu.be.

TermNL in SymbiOS, on an Orange Pi Zero 2W: it answers how much space and memory are left, and plays music by Bonobo, beside the music player and a Meshtastic message

TermNL in SymbiOS, on an Orange Pi Zero 2W.

Why it asks before it acts

A command on a real device can't always be undone. So TermNL doesn't act on a guess: when a word is new it says so, when something is missing it asks, and before anything risky (deleting, restarting, turning off the Wi-Fi) it waits for a yes.

You teach it with text files

Each thing TermNL can do is one skill: a folder holding a skill.md written in plain sentences, with what people say, what it needs, the command it runs and what it replies. Drop a folder in, say "learn what I taught you", and it knows. Part of skills/delete-file/skill.md:

approve: yes

## People say

- delete {name} (from/in (the) {place} (folder))

## What it needs

- {name}: a file on the device. If it's missing, ask: Which file? | Which file should I delete?
- {place}: a folder on the device. If it's not said: where you are.

## Replies

- approve: Move {name} from {place} to the trash?
- done: {name} is in the trash. | Done, {name} went to the trash.

Try it on this machine

python3 -m termnl.server            # http://127.0.0.1:8810

Files and folders are made in the folder home: names in settings.md (~/TermNL-home). Skills listed in simulate: (restart, shut down, Wi-Fi, Bluetooth, services) never run here: TermNL says what it would have done. The page's switches (show commands, admin mode) are written back to settings.md.

Python 3.9 or newer, standard library only. Training the model needs numpy (python3-numpy).

Said in words: your name and your settings

"call me Gab", "show me the commands", "hide the commands": each changes its line in settings.md. A skill does this with changes: show commands to on in its header instead of a command. Admin mode is never changed by a sentence (the checker refuses a skill that tries): "open my settings" opens the settings panel, where it is a toggle beside the commands and your name. "help" lists what TermNL can do, by the topics in words/objects.md.

"learn what I taught you" (approved first) trains the model again from the skill files, in the background, at the lowest priority and on two threads: the board stays usable. The conversation that asked is told when it is done: its chat page asks every few seconds (GET /api/learning), or its next reply says it; "are you learning?" says how far along it is, or when it last learnt (Gab, 24 Oct: about 3½ minutes on the board). The model in use is replaced only once the new one is whole; the one before is kept as model.previous.json. Replies can say {user}: "Hey {user}, no problem: your CPU is at…"; a variant with {user} is only used once a name is set.

Layout

termnl/                     the system
  languages/en/             everything English; another language is a copy of this folder
    words/                  the shared vocabulary, each word with the words people use for it
      actions.md            create, open, restart…, and their opposites
      objects.md            file, folder, wifi…
      filetypes.md          markdown → .md…
      conversation.md       yes, no, fillers, the rules' word lists, and TermNL's own replies
      samples.md            sample values the model trains with
      readings.md           the words shown with what the device reads (tables, "3 days")
      values.md             how a skill says what it needs ("a folder on the device")
    skills/<action>-<object>/skill.md
                            one skill per action + object, written in plain sentences: what people
                            say, what it needs, its command or reader, and replies (plain.py;
                            docs/notes/IMPROVEMENTS.md says how to write one). Under ## Words, what it brings:
                            an action or object words/ lacks, and what words mean with its object
                            ("turn on the music" plays it, said by play-music): a folder dropped in
                            works alone (docs/notes/FRAMES.md; tests/drop-in)
    out-of-scope.md         what TermNL should not try to do
    model.json              trained from the above: python3 -m termnl.train
  agent.py                  the dialogue: one turn in five steps (templates, model, questions, approval)
  plain.py                  plain sentences and "What it needs" read into what the agent uses
  readers.py                the device read in words people use (temperature, memory…)
  device.py, runner.py      the device's own lists, and running a command
  server.py                 the thin API and the chat page
web/                        the chat page; termnl-chat.js is the chat, a component any page can hold
demo/                       the demo: TermNL run in the browser (Pyodide) on a pretend board, published by
                            GitHub Pages from main (.nojekyll: the files as they are). index.html; demo.py,
                            TermNL's turn on the pretend board; css/; js/ (main.js, libs/: TermNL in the page,
                            the chat, the readings drawn, training in a worker; util/: the DOM, the icons)
tests/                      the dialogue tests, the readers, the measure on phrasings.md, and
                            real.py: the conversations people really had (real.md, from logs/,
                            kept out of git), replayed against today's TermNL
tools/neighbours.py         a test of word embeddings for unknown words (22 Oct: not worth it yet)
tools/distance.py           a test of out of scope by distance to taught sentences (25 Oct: not
                            kept; docs/notes/RESEARCH.md, method A)
tools/to_plain.py           rewrites a skill from the older template form to plain sentences;
tools/same_reading.py       and proves it reads every sentence the same
settings.md                 this device's settings
docs/notes/                 the working notes: each branch's report, what was tried and measured, and the
                            briefs and data behind the test sets
logs/                       every turn the server hears, one line of JSON (kept out of git)

Checks

python3 -m termnl.check             # every skill file
python3 -m unittest                 # the dialogue and the readers
python3 -m tests.measure -v         # how the phrasings in tests/phrasings.md are understood
python3 -m tests.measure all        # and tests/probes.md, heldout.md and blind.md (never trained on)
python3 -m tests.real -v            # the real conversations in tests/real.md, turn by turn
python3 -m tests.real --add         # adds the conversations in logs/ that real.md doesn't hold yet
python3 -m termnl.train             # retrain termnl/languages/en/model.json

License

GPL-3.0 (LICENSE), with two additional terms under its section 7: copies keep the attribution "Originally made by Gabriel Baude" with a link to the original source, and a changed version carries another name. See NOTICE.md.

TermNL is a research project, not made for production. It runs real commands on the device it lives on, and asks before the risky ones; try it on a board you can afford to start over.

About

Talk to your Linux board in plain words. A small offline model that asks before it acts.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages