Initial release
Browse files
README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: google/bert_uncased_L-4_H-256_A-4
|
| 4 |
+
language:
|
| 5 |
+
- en
|
| 6 |
+
pipeline_tag: token-classification
|
| 7 |
+
library_name: onnx
|
| 8 |
+
tags:
|
| 9 |
+
- onnx
|
| 10 |
+
- time-extraction
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# tempus: BERT-mini classifier for clock times in chat messages
|
| 14 |
+
|
| 15 |
+
An 11M-parameter classifier that decides, for every number in an English chat message that
|
| 16 |
+
could be a clock time, whether it is not a time, a morning time or an afternoon/evening time.
|
| 17 |
+
It is 11 MB and answers in about 1 ms on a server CPU and 9 ms on a Raspberry Pi 4.
|
| 18 |
+
|
| 19 |
+
It is not a standalone model: code finds the candidate numbers and reads their digits, and
|
| 20 |
+
this model only labels each candidate. That code is in the repository
|
| 21 |
+
(`src/tempus/candidates.py` and `src/tempus/classifier.py`, and a JavaScript port in `web/`):
|
| 22 |
+
https://github.com/dsegovia90/tempus_finetune
|
| 23 |
+
|
| 24 |
+
## Files
|
| 25 |
+
|
| 26 |
+
| File | Size | Use |
|
| 27 |
+
|---|---|---|
|
| 28 |
+
| `int8.onnx` | 11 MB | Recommended, 8-bit weights |
|
| 29 |
+
| `fp16.onnx` | 21 MB | 16-bit weights, same arithmetic as full precision |
|
| 30 |
+
| `vocab.txt` | 0.2 MB | WordPiece vocabulary (lowercased) |
|
| 31 |
+
|
| 32 |
+
Inputs: `input_ids`, `attention_mask`. Output: `logits`, one row per token over the classes
|
| 33 |
+
none, am, pm. The class of a candidate is read at its first token.
|
| 34 |
+
|
| 35 |
+
## Scores
|
| 36 |
+
|
| 37 |
+
Exact match per message after the surrounding code assembles the reply. This is the best of
|
| 38 |
+
three training runs, chosen by these same evals.
|
| 39 |
+
|
| 40 |
+
| Eval | `int8.onnx` | Three-run mean (full precision) |
|
| 41 |
+
|---|---|---|
|
| 42 |
+
| Main (530 messages) | 92.8% | 92.3% |
|
| 43 |
+
| Fresh (378 messages from situations not in training) | 92.6% | 91.6% |
|
| 44 |
+
| False alarms on 1,021 tricky messages with no clock time | 1.8% | 1.6% |
|
| 45 |
+
|
| 46 |
+
On messages where the time of day is implied only by the situation ("dinner at 7"), the
|
| 47 |
+
three-run mean is 79.5% on the main eval and 76.6% on the fresh eval. That is its weak point:
|
| 48 |
+
it knows far less about daily life than a language model. The 230M generative model scores
|
| 49 |
+
about 92% there: https://huggingface.co/dsego/tempus-lfm2.5-230m
|
| 50 |
+
|
| 51 |
+
Latency per message, including candidate search and tokenizing: about 1.4 ms median on 4 cores
|
| 52 |
+
of a shared Ryzen 3600; 9 ms on a Raspberry Pi 4 (4 threads), 18 ms on one thread; about 4 ms
|
| 53 |
+
in a browser tab on an Apple Silicon Mac.
|
| 54 |
+
|
| 55 |
+
## Limits
|
| 56 |
+
|
| 57 |
+
- English only; times written with digits, plus "noon" and "midnight".
|
| 58 |
+
- Weak on unfamiliar situations, as above.
|
| 59 |
+
- Training and eval data are synthetic, written and checked by language models with a small
|
| 60 |
+
human spot-check.
|
| 61 |
+
|
| 62 |
+
## Training
|
| 63 |
+
|
| 64 |
+
Token classification on
|
| 65 |
+
[google/bert_uncased_L-4_H-256_A-4](https://huggingface.co/google/bert_uncased_L-4_H-256_A-4),
|
| 66 |
+
11,299 synthetic messages, exported to ONNX.
|
| 67 |
+
|
| 68 |
+
## Licence
|
| 69 |
+
|
| 70 |
+
Apache 2.0, the same as the base model.
|
fp16.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3085b3398853b98228139d9368b5d1e67982d85d685cbac5fd9e22643b1d70d3
|
| 3 |
+
size 22315132
|
int8.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b574640be80e2f245d379d0e32593893446bff5b492564f67ebb4382b5ae7248
|
| 3 |
+
size 11314328
|
vocab.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|