A mini neural web that decides whether a number is Numberwang.
The full exemplary is simply a 1.8 MB JSON record and the conclusion codification is astir 100 lines of axenic Python modular room — nary PyTorch, nary NumPy, thing to install. Clone it and tally it.
Run it pinch nary arguments for an interactive session:
Requires Python 3.8 aliases newer. That's the only requirement.
| 0 | That's not Numberwang. |
| 1 | THAT'S NUMBERWANG! |
| 2 | That's not moreover a number. It tin ne'er beryllium Numberwang. |
| 3 | That's Wangernumb! |
| 42, sixty-six, 12345 | digits aliases words |
| zweiundzwanzig, veintidós, tweeëntwintig | eleven languages, accents optional |
| 5*2, 96 divided by 2, 12 positive four | arithmetic, judged connected the result |
| 45 - 44, double four, eins | anything worthy 1 aliases 44 rotates the board |
| -7, 4.5, £5, 50%, 9:30 | negatives, decimals, currency, units, times |
| XLIV, twenty-third, 22nd | Roman numerals and ordinals |
| fortnight, vierendelen, september | words built connected a number, judged arsenic that number |
| achtneming, often, money | words that simply incorporate 1 are not numbers |
| shinty-six, twentington | fictional numbers are numbers too |
| bonjour, hullo really are you | no numeric contented — tin ne'er beryllium Numberwang |
A number's wangness is simply a spot of the number, not the connection it is said in: four, vier, quatre and cuatro each get the aforesaid verdict.
80,804 parameters. The web sounds characters straight — location is no tokenizer, nary normalizer and nary rules motor astatine inference. Digits, operators, canon verdicts and the eleven languages are each held successful the weights, and model.json contains the lot.
A hosted type runs connected Hugging Face Spaces. To tally the aforesaid demo locally:
gradio is needed only for the demo. The exemplary itself ne'er needs it.
88.9% complete 486 held-out adjudications (macro-F1 0.896), against a ceiling of astir 98% — astir 2% of training labels are inverted, successful accordance with long-standing adjudication practice.
| not Numberwang | 0.820 | 0.885 | 0.851 |
| Numberwang | 0.919 | 0.900 | 0.910 |
| not a number | 0.951 | 0.830 | 0.886 |
| Wangernumb | 0.968 | 0.909 | 0.937 |
Arithmetic connected unseen operands is the anemic spot, astatine 44–72%. The network memorises alternatively than computes, truthful mini communal expressions like 5*2 are reliable while 904 * 3 is an knowledgeable guess. If arithmetic correctness matters, measure the look and manus it the result.
MIT — spot LICENSE.
No warranty is expressed aliases implied arsenic to whether immoderate peculiar number is, aliases is not, Numberwang.
English (US) ·
Indonesian (ID) ·