File size: 3,300 Bytes
5830928
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
---
license: apache-2.0
language:
- en
base_model: sentence-transformers/all-MiniLM-L6-v2
library_name: onnxruntime
pipeline_tag: text-classification
tags:
- elite-dangerous
- intent-classification
- voice-commands
- onnx
---

# EDCeleste command classifier

Tells which ship action of [EDCeleste](https://github.com/IqSantiagow/EDCeleste) a pilot asked for in a spoken
message, or that the message is not a ship action (a question, small talk, a refusal), so it goes to the LLM.

- **Base:** `sentence-transformers/all-MiniLM-L6-v2` (22.7M parameters, Apache 2.0), fine-tuned with a linear head
  over 42 classes: the 41 `EdAction` values of EDCeleste and `none`.
- **File:** `command_classifier_int8.onnx`, 23 MB, dynamic int8 quantization. About 27 MB of RAM
  growth and 0.9 ms per message on one CPU thread (onnxruntime 1.31). No GPU.
- **Input:** the text Whisper wrote, up to 32 tokens. **Output:** 42 logits, the order of the names is in `classes.json`.

## How the app uses it

```python
import json
import numpy as np
import onnxruntime
from tokenizers import Tokenizer

tokenizer = Tokenizer.from_file("tokenizer.json")
tokenizer.enable_truncation(32)
classes = json.load(open("classes.json"))
session = onnxruntime.InferenceSession("command_classifier_int8.onnx")

encoded = tokenizer.encode("lower the landing gear")
logits = session.run(None, {
    "input_ids": np.array([encoded.ids], dtype=np.int64),
    "attention_mask": np.array([encoded.attention_mask], dtype=np.int64),
})[0][0]
probabilities = np.exp(logits - logits.max()); probabilities /= probabilities.sum()
```

The app takes the best class among the actions that have a key in the pilot's keybindings, plus `none`.
When its probability is below 0.5 the answer is `none`.

## Scores

Measured with threshold 0.5 and the app's rule (only actions with a key compete), against the
decision model it replaces (`IqSantiagow/edceleste-decider-0.8b`, v5):

| set | this model | decider-0.8b v5 |
|---|---|---|
| real speech, session 2: commands executed (of 59) | 52 | 58 |
| real speech, session 2: wrong key | 1 | 0 |
| real speech, session 2: key pressed on 73 non-commands | 0 | 2 |
| synthetic test: commands executed (of 570)* | 539 | 530 |

\* The synthetic set is flattered: its phrasings were known when the extra training phrases were written.
Only the real-speech row is a clean number, and 59 commands is a small sample (one command is 1.7 points).
Five of the seven misses are Whisper tiny.en mishearings of Elite words ("tough launcher" for chaff launcher).

## Limits

- **Closed set.** The 41 actions are classes. An action added to EDCeleste later is unknown to this model: it
  is never offered, so its commands go to the LLM until the model is trained again (about 25 s on a GPU).
- English only. Trained on one pilot's speech plus generated phrasings.
- It decides only the command. Whether Celeste should speak for a game event is a different question.

## Training

Data: the synthetic commands and the recordings of
[`IqSantiagow/edceleste-decisions`](https://huggingface.co/datasets/IqSantiagow/edceleste-decisions) (private)
plus about 2900 extra phrases and "not a command" lines written by hand and checked by the decider v5.
10 epochs, learning rate 1e-4, label smoothing 0.05, mean pooling, on a GPU.