Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

The fine-tuned parser

Waylingo works with any LLM that speaks the OpenAI chat format. As an alternative to a hosted model, it has its own small parser model: Qwen3-0.6B fine-tuned for one job, turning a trip request into Waylingo’s JSON plan. It runs on a laptop or a small server with no API key and no per-call cost, and the request text never leaves the machine.

What it does

The model only turns language into the plan JSON (SurfaceIntent). It does not know places or brands; it copies them:

  • names are copied as written, and a name stays a name: “a McDonald’s” becomes brand: "McDonald's", not a category;
  • categories are used only for generic words (“a coffee”, “somewhere to charge”);
  • unknown names are copied as written: “drive me to Branmont” gives destination: "Branmont", even though no such town exists;
  • text that is not a trip request gives {"error":"not_understood","stops":[]}.

Finding the places is the map provider’s job, so the model never needs to know where anything is.

Performance

“Same plan” means the model’s JSON, after Waylingo’s name check, compiles to exactly the plan the correct answer compiles to, which is what the engine would run.

Test setWhat it checksSame plan
Natural wording150 held-out requests rewritten by an LLM the way people type them; not used for training82.0%
Unseen places1,000 requests naming places and brands the model never saw89.9%
Destination only30 hand-written trips with a destination and no stops28 / 30
Valid JSONshare of replies that are valid plan JSONover 99%

A request takes about 1.1 to 1.4 s on an Apple Silicon laptop (median, at temperature 0). The GGUF export scores the same as the original weights. The natural-wording set was made with the same rewriting tool as part of the training data, so real user input may score somewhat lower. The model card has the full table, including the model’s score without Waylingo’s name check.

Known limits:

  • English only; trained on places in Europe, the US and India.
  • The plan cannot express everything people ask for (“the cheapest fuel”, “open now”); such parts of a request may be dropped.

For hard or unusual requests, a large hosted model is more accurate; the fine-tuned model is for when cost, latency or privacy matter more.

The dataset

The training data is generated by crates/waylingo-parse/examples/make_dataset.rs:

  • Correct by construction. Each sentence is built from templates, and its label from the same choices. Every label must compile with the real plan compiler, or the example is dropped.
  • Invented names. About half of the places and brands are made up, so the model can only get them right by copying, not by remembering.
  • Held-out names. Some places and brands never appear in training; the “unseen” test uses only those, which shows whether the model copies or memorises.
  • Real-looking text. Typos, chat shorthand, questions, lower case, and about 4,000 rewrites into more natural wording. A rewrite is kept only if every name and number is still in it exactly.
  • Negatives. A small share of non-trip sentences labelled not_understood.
  • No map provider data is used anywhere.

The prompt is one line, COMPACT_SYSTEM_PROMPT (“Convert the trip request to Waylingo JSON.”): the rules are learned from the data, which keeps each request short.

finetune/README.md has the commands to generate the data, train (LoRA with MLX) and evaluate.

Getting it

Both are on Hugging Face:

Using it

Serve it with any OpenAI-compatible server, for example llama.cpp’s llama-server with the GGUF file, and point Waylingo at it with fine_tuned set:

val llm = LlmBackend.OpenAiCompatible(
    baseUrl = "http://localhost:8765/v1", model = "default", fineTuned = true)

fine_tuned (fineTuned in Kotlin) sends the one-line prompt the model was trained on and reads the JSON from the reply (crates/waylingo-ffi/src/config.rs). In Rust, set LlmConfig { mode: LlmMode::PromptJson, prompt: PromptStyle::Compact, .. }. No LLM key is needed.

On the device

The model is small enough for a phone, but Waylingo cannot run it on the device yet. Running the parser on a phone covers the runtime to use (llama.cpp), size, speed, delivery, and how it will connect to Waylingo.