Model Card for ESP32 Cocktail Maker

A 2.9-million-parameter transformer (1.1 million in its core), trained from scratch, that writes new cocktails in Australian bar measures on an ESP32-S3 microcontroller (M5Stack CoreS3), with nothing off the chip. Pick a spirit and a style, or an unusual ingredient, and it writes an ingredient list, a name and a method in 7 to 15 seconds.

A drink written on the device

Model Details

Model Description

The model is prompted with Spirit: <spirit>, then Style: <style> or With: <ingredient>, then Ingredients:, and writes the rest of the drink as text: the ingredient list, Title: with a name, and Method:. There are 10 spirits (gin, vodka, rum, tequila, bourbon, rye, scotch, whisky, brandy, other), 6 styles (sour, stirred, highball, fizzy, creamy, tiki) and 22 Unusual ingredients (absinthe, Campari, elderflower, Chartreuse, sherry, maraschino, cherry liqueur, Benedictine, Aperol, cassis, Lillet, orgeat, Galliano, port, amaro, Cynar, Pimm's, sloe gin, Fernet, Drambuie, falernum, allspice dram); 38 spirit and style pairs and 65 spirit and ingredient pairs have enough training drinks to use. It runs on the ESP32-S3 with 4-bit weights at about 11 tokens a second.

  • Developed by: Justin McLean
  • Model type: decoder-only transformer with per-layer embeddings, byte-level BPE tokenizer with 2,048 tokens learnt from the training drinks
  • Language: English (Australian)
  • License: CC BY-NC 4.0
  • Inference code: justinmclean/esp32-ai, a fork of slvDev/esp32-ai (MIT)

Model Sources

Uses

Direct Use

Writing made-up cocktails for fun, demos and learning, on an ESP32-S3 board or on a computer (the repository's host/cocktail.c).

Out-of-Scope Use

Serving drinks without tasting them, advice on alcohol or drinking, commercial use (see Licence), or prompts other than the picks above.

Bias, Risks, and Limitations

  • The drinks are made up. Most hold one standard serve of alcohol (20 to 120 ml), but balance and strength are the model's guess.
  • About one drink in ten has a method naming something the list lacks.
  • About one drink in 25 is named after a classic it is not; real drinks do this 0.6% of the time.
  • About 3% of drinks are exact copies of a training drink.
  • The training drinks come from US recipe websites, converted to Australian measures and names; the choice of drinks reflects those sites, not Australian bars.
  • Hot drinks, drinks set on fire and drinks with crude names were left out of training.

Recommendations

Use temperature 0.5 (the device's setting) with top-k 40. Taste before serving.

How to Get Started with the Model

On a computer, with only a C compiler, from the GitHub repository:

cc -O2 -o cocktail host/cocktail.c -lm
./cocktail rye with Benedictine

On an M5Stack CoreS3, from the repository's firmware/ folder:

pio run -e m5stack-cores3 -t upload_model
pio run -e m5stack-cores3 -t upload

Files

  • model.bin: the device model, 4-bit weights (1.5 MB). Flashed at 0xA00000.
  • tokenizer.json: the byte-level BPE tokeniser (2,048 tokens).
  • cocktail-maker.safetensors: full-precision weights (11 MB), for fine-tuning. The repository's training/weights.py turns them into a checkpoint training can start from.

Training Details

Training Data

The drinks in RecipeNLG (2.2 million recipes from US websites; the copy at SandhyaKilari/RecipeNLG_dataset): of 282,785 rows that name alcohol, 7,593 single drinks are kept, after dropping food, batches, hot drinks, drinks set on fire, crude names, cookbooks.com, mixes and mislabelled classics. Each is converted by the repository's training/convert_drinks.py: Australian bar measures (5, 10, 15, 20, 30, 45, 60, 90 ml, then 30 ml steps), brands to what is in the bottle, Australian names and spelling, and a spirit and style label from rules. A drink using an Unusual ingredient is also trained with With: in place of its style, with that ingredient listed first. 3% is held out for validation. RecipeNLG's terms allow only non-commercial research and educational use.

Training Procedure

Trained from random weights for 3,000 steps (batch 16 x 256 tokens, about 12 passes over the data; AdamW, learning rate 1e-3 with 200 warmup steps and cosine decay), on next-token prediction with these penalties added (unlikelihood training):

  • continuing an ingredient name into an earlier line's;
  • every 4 steps, on ingredient lists and titles the model writes itself: a line repeating an earlier one, and a title naming a classic drink the ingredients are not (99 classics and their defining ingredients);
  • a method naming an ingredient the list lacks, and a method step listing something twice.

The last 600 steps are quantisation-aware: forward and backward use the weights rounded to 4 bits as the device has them, and updates go to the full-precision weights.

Speeds, Sizes, Times

  • 2.9 million parameters (1.1 million in the core); 1.5 MB on the device at 4 bits
  • About 14 minutes of training on an Apple M3 MacBook
  • On the device: about 11 tokens a second; a drink in 5 to 10 seconds

Evaluation

Testing Data, Factors & Metrics

10 drinks for each of the 38 spirit and style pairs and 65 spirit and ingredient pairs, written by the repository's host/cocktail.c as the device writes them (4-bit weights, 8-bit arithmetic, temperature 0.5, top-k 40), checked by training/score_drinks.py.

Results

1,029 drinks as the device writes them Score Real drinks
Layout right (ingredients, name, method) 100%
Main spirit is the one picked 100% (style picks), 99% (Unusual picks)
Unusual ingredient is in the list 100%
Style matches, by the converter's rules 77% (weakest: fizzy)
One standard serve of alcohol (20 to 120 ml) 99%
Lists an ingredient twice 3% 0%
Method names an ingredient the list lacks 10% 2.8%
A method step lists something twice 1% 0.2%
Named after a classic it is not 4% 0.6%
Exact copy of a training drink 32 of 1,029 (3%)

Technical Specifications

Model Architecture and Objective

6 transformer layers, width 96, 4 attention heads, SwiGLU feed-forward, RoPE positions, per-layer embeddings of width 128, output head tied to the token embedding, 2,048-token vocabulary. Context 256 tokens. Next-token cross-entropy with the penalties above.

Compute Infrastructure

  • Training: Apple M3 MacBook (PyTorch, MPS)
  • Inference: ESP32-S3 (M5Stack CoreS3) with 8 MB PSRAM, or any computer

Licence

CC BY-NC 4.0. Trained on RecipeNLG (Bień et al., 2020), whose terms allow only non-commercial research and educational use.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Dataset used to train jmclean/esp32-cocktail-maker