Six cheap gas sensors, 50 foods, 68 hours of readings. Teach a Transformer to watch how the signal changes, and it names the food 63.3% of the time. Guessing gets 2%.
Switch on differencing, then GC-MS. Watch which models jump and which barely move. Then we build the whole system, piece by piece: the sensor, the dataset, the signal tricks, the Transformer, the chemistry loss and the mixtures.
You need a feel for what a classifier is (a program that picks one label from a list). We build the sensor physics, the attention and the losses from zero.
The assigned reading of MMAI lecture 14.2, AI for new senses (MIT Multisensory Intelligence, Spring 2026). Paper: Dewei Feng, Wei Dai, Carol Li, Alistair Pernigo, Yunge Wen and Paul Pu Liang (MIT Media Lab and MIT EECS), ICLR 2026. arXiv 2506.00239 · Code and data
The bars are the paper’s Table 2: top-1 accuracy over 50 foods on the held-out sixth day, 90 epochs, final checkpoint. Chance is 2%. The 100 dots are the ScentFormer bar drawn as a crowd: filled dots are foods named correctly.
Chapter 0
See why smell is the missing sense in AI, and what SmellNet builds to fill the gap
You open a bag of roasted cashews. Before you see the nuts, you know something is wrong. They smell faintly sharp, like old paint. You never decided to check. Your nose did it for you, in under a second.
Now ask a computer to do the same. A camera can tell a cashew from a peanut. A microphone can hear a word. But a bag of food gives off a cloud of tiny molecules, and no camera sees them. For a machine, smell is the missing sense.
Every food slowly sheds volatile compounds: molecules light enough to leave the surface and drift into the air. Think of a cup of coffee losing its steam. Cumin sheds one set of molecules. A peach sheds another. Your nose catches them and your brain reads the mix.
The paper reminds us how good that nose is. A human can tell apart an estimated trillion odours. Each odour molecule binds to a set of olfactory receptors (protein switches in the nose), and the pattern of switches that fire is the combinatorial code the brain reads. One molecule does not make a smell. The pattern across many receptors does.
A machine nose copies this idea. It does not need a trillion receptors. It needs a few different sensors, each reacting a little differently to the same air, and a model that reads the pattern.
People have built machine noses before. The paper sorts the earlier work into two piles, and each falls short in a different way.
The first pile is human-perception data: a molecule or a blend, paired with what people said about it. Examples are the Dravnieks Atlas (21.3k ratings) and the DREAM Challenge (10.0k ratings). Nobody put a sensor in these. They teach a model what people call a smell, not what a cheap sensor reads.
The second pile is sensor data. Some of it comes from big lab machines such as GC-MS (gas chromatography with mass spectrometry, an instrument that separates a smell into its molecules and weighs each one). It is precise, but it is bulky, slow and not portable. The rest comes from small e-nose sets, and these are tiny. The paper’s Table 1 lists a coffee set with just 58 measurements, and a drift set of pure gases rather than foods.
So the field had accurate machines that cannot leave the lab, and portable sensors with too little data to train a modern model. That is the gap. The authors name it directly: there is no standard, large, realistic benchmark for temporal smell signals from deployable sensors.
SmellNet does name a food from six cheap sensor channels at 63.3% top-1 accuracy over 50 foods where a plain MLP on raw readings reaches 21.0%, because it feeds the model how the signal changes and uses a Transformer that reads a whole window of time.
Two things come out of the paper. The first is the dataset, SmellNet: about 828,000 sensor readings, 68 hours, 50 single substances (nuts, spices, herbs, fruits, vegetables) and 43 mixtures. The second is a model, ScentFormer, a Transformer built for this kind of data. The dataset is the larger gift. The model shows that the dataset is learnable.
Before the machinery, look at what the raw material is. A sensor does not output a word. It outputs a number every second, and a smell is a pattern across six of these numbers and across time. Pick a food below and scrub through the ten-minute recording.
Each line is one channel of the sensor array. Choose a food, then drag the clock. Notice that the channels rise at different speeds and heights, and that no single line names the food.
Illustrative: these curves are invented to show the shape of the data, not copied from the dataset. In the real recordings each channel is one reading per second for 600 seconds, as the paper describes (Section 3.2).
Look at the cumin curves and the potato curves side by side. Several channels rise in both. The height of one channel at one moment tells you very little. What tells the foods apart is the shape: which channels climb fast, which climb slowly, and how they sit relative to each other. That is a pattern over time, and finding such patterns is what a model is for.
The paper sets two tasks. In SmellNet-Base, the sensor smells one of 50 single substances and the model names it: a 50-way classification. In SmellNet-Mixture, the sensor smells a blend of up to three of 12 oils or extracts, and the model must say what fraction each one contributes: a distribution prediction. Mixtures matter because real smells are rarely single. Coffee, bread and a rotting fruit are all blends.
This paper is the reading for the lecture on AI for new senses, which places machine smell next to taste, temperature and touch. If you built the multimodal map in the alignment lecture, Chapter 5 will feel familiar: it is CLIP-style alignment with a chemistry instrument in place of captions.
Chapter 1
Follow a vapour from a cashew to a number, and see why six imperfect channels beat one
Put a handful of cashews in a sealed jar and a small circuit board next to them. Ten minutes later the board has written six numbers per second to a file. No molecule was named. No one smelled anything. Yet those numbers carry a trace of the cashew. How?
This chapter builds the sensor from zero. You need it, because the dataset’s strengths and weaknesses all start here: what the six numbers can tell apart, and what they cannot.
The paper uses metal-oxide (MOX) gas sensors. The core is a thin film of a metal oxide (a ceramic, like a tiny tile) that a built-in heater keeps warm. The film conducts a small electric current. How easily it conducts is its resistance: high resistance means the current struggles, low resistance means it flows.
Here is the textbook picture, which the paper does not derive but relies on. In clean air, oxygen molecules cling to the hot film and hold electrons, so the film resists current. When a drifting food molecule such as an alcohol reaches the film, it reacts with that oxygen and frees the electrons. Resistance falls. The circuit turns that change into a voltage, and a chip turns the voltage into the number you read.
Two facts about this matter for everything that follows. The number is uncalibrated: it is not a concentration in parts per million. And it is cross-sensitive: the film reacts to many kinds of molecule, not just the one on its label.
The platform combines three commercial parts: the MQ-3, the MQ-5 and the Grove Multichannel Gas Sensor V2. Together they give six channels (one stream of numbers each). The manufacturers label them CO (carbon monoxide), NO2 (nitrogen dioxide), Alcohol, VOC (volatile organic compounds), LPG (liquefied petroleum gas) and C2H5OH (ethanol).
Read the paper’s warning about these names. They are manufacturer calibration labels, not measurements of pure gases in food air. The “CO channel” does not report carbon monoxide in a cashew jar. It reports whatever mix of molecules happens to move that film the way carbon monoxide would. Likewise “Alcohol” and “C2H5OH” are two different physical elements with overlapping reach, not two chemicals.
The whole board runs from a USB cable at about 5 W, which is part of the appeal. It is small, cheap and always on.
If each channel reacted to exactly one molecule, you could read a smell like a shopping list. They do not. Each reacts to several families at different strengths. That sounds like a flaw, and for chemistry it is one. For recognition it is a gift, because a set of overlapping detectors makes a fingerprint: a pattern of six numbers that differs from blend to blend.
Write it as arithmetic. Let the air hold amounts a, b and c of three kinds of molecule. Channel i reads a weighted sum of them, with weights that belong to that sensor.
This is a toy of the real physics, which bends and saturates. But it shows the key effect. One reading cannot tell you the amounts, because many different blends add up to the same ri. Six readings cut that ambiguity down a lot. Try it: here are three invented molecule types and six invented channels. Match the target’s CO channel, and then look at the other five.
The hollow bars are a target blend. The filled bars are your blend. Press Match the CO channel to set a different blend with the same CO reading, then compare the other five. Drag the sliders to try your own.
Illustrative: the three molecule types and the 6 by 3 sensitivity table are invented. Each reading is the weighted sum divided by the sum of that row’s weights, so every channel stays between 0 and 1. The target blend is A 0.5, B 0.2, C 0.3.
The blend (0.2, 0.8, 0.3) matches the target on CO exactly, at 0.36. But on the NO2 channel it reads 0.33 where the target reads 0.42, and on the LPG channel it reads 0.62 where the target reads 0.26. A designer who only had the CO channel would call these two blends the same smell. A designer with six channels sees them apart. That is the whole logic of an electronic nose (e-nose): many broad, overlapping detectors read together.
Overlap has a cost. The paper measures how much the channels move together (its Figure 9). NO2, C2H5OH and VOC are strongly correlated, with Pearson correlation (a score from −1 to 1 for how closely two signals rise and fall together) of about 0.95 to 0.97. CO is moderately tied to that group at 0.63 to 0.67. Alcohol and LPG behave more on their own.
So the six channels are not six independent facts. Three of them partly repeat each other. When the authors run a principal component analysis (PCA, a method that finds the directions along which data varies most), the first direction is dominated by NO2, C2H5OH, VOC and CO, each with a weight near 0.4 to 0.5. The second direction leans on LPG (0.74) and Alcohol (0.55). The channels that look least useful by correlation turn out to matter again in Chapter 7.
Because the numbers are uncalibrated, one sensor board does not read like another, and one day does not read like another. Because the channels are cross-sensitive, a model learns patterns, never molecules. Both facts shape the next chapters. The authors treat the readings as “semi-quantitative” signals: good for relative comparison and for dynamics, poor as absolute concentrations.
Chapter 2
Count 68 hours of readings, and see why six days, a sealed box and a held-out day matter
Imagine you are the student who has to collect this. You buy 50 foods at a shop: cashews, cumin, coriander, star anise, spearmint, pineapple, cauliflower, apple, potato, and the rest. You must record each one on a sensor, many times, so that a model can learn the food and not the room. How would you plan it?
The paper’s answer is a protocol. A protocol is a fixed recipe for taking measurements, so every recording is comparable to every other. This chapter walks through it, then counts what it produced.
For each of the 50 substances, the team put the food and the sensor array together inside a transparent container. The lid kept out draughts, people walking by and background smells. Vapour from the food built up and spread evenly. The sensor recorded all six channels once per second (1 Hz) for 10 minutes. That is one session: one uninterrupted recording.
Between sessions the team ventilated the box. They then watched the sensor values and waited until all of them stayed stable for 10 minutes, which told them the air was back to normal. Only then did they start the next food. This reset step is easy to skip and costly to forget, because a leftover smell from the last food becomes a label error in the next.
Each food was recorded in six sessions, on six different days. Six days matter more than one long day. Day to day, the room’s background drifts, the sensor warms differently and the air differs. A model trained on one day learns that day. Six days give it a chance to learn the food. The authors admit that ambient factors such as background NO2 still varied across days and could not be removed.
Count it: 50 foods × 6 sessions × 600 readings = 180,000 readings, or 50 hours of recording. Every reading is a row of six numbers, and carries the food’s name, a description, and the date and time.
The 50 substances fall into five categories: nuts, spices, herbs, fruits and vegetables. Categories matter for two reasons. They let the paper report accuracy per group, so you can see where the model is weak. And they explain which mistakes are natural. A model that confuses two fruits is less surprising than one that confuses a spice with a vegetable.
The authors checked this with PCA on all readings. Spices and fruits sit in distinct regions. Nuts and vegetables largely overlap. Inside the fruit group alone, individual fruits split cleanly: peach, mandarin orange, lemon and banana each form their own cluster. So the paper predicts, before training anything, that fruits will be easy and nuts and vegetables hard. It then checks that prediction in Chapter 8.
One more statistic helps. The C2H5OH channel reads substantially higher for spices than for other categories (the paper’s kernel density plots). A single channel can already separate one category. This is why the channels are not interchangeable.
Real smells are blends. So the team made some. They chose 12 base odorants (smell-producing materials, here oils and extracts): almond, apple, banana, clove, coriander, cumin, garlic, mango, orange, peach, pear and strawberry. These span several chemical families on purpose. Clove is phenol-rich. Almond and cumin lean on aldehydes. Banana, pear, peach, strawberry and apple lean on esters. Orange, mango and coriander on terpenes. Garlic carries sulfur compounds.
They then mixed binary and ternary blends (two or three odorants) at fixed volume ratios, such as 20/80, 50/50 or 80/20. In total there are 43 unique ingredient combinations, 126 recipes, and 1,078 recorded sessions.
The space in the box was small, so only the Grove sensor was used, giving four channels (NO2, C2H5OH, VOC, CO) at 10 Hz (ten readings per second). That gives 648,000 readings, or 18.0 hours.
A test set is data the model never trains on. SmellNet-Mixture has two, and they answer different questions.
Test-seen uses recipes that also appear in training, but from different recording sessions. A model that passes has learned to cope with the changes between sessions. Test-unseen uses recipes the model never met: new ingredient pairs, or new ratios of familiar mixtures. A model that passes can combine what it knows in new ways. The second is much harder, and Chapter 8 shows by how much.
For Base, the split is simpler. The sixth day is held out for testing and the first five days are used for training. This tests whether a model can recognise a food on a day it has not seen. Tables 7 and 8 list 150,711 readings in training and 29,423 in test. Those two add up to 180,134, a little above the 180,000 in the headline count, and the paper does not explain the gap.
The team also attached chemistry data. For each of the 50 foods they looked up pre-recorded GC-MS information in FooDB (an open database of food compounds). They did not run GC-MS themselves. All 50 foods had coverage. Chapter 5 explains how this chemistry enters training.
Now count the whole thing. Tap each slice of the bar below to see its arithmetic.
The bar is the whole dataset. Choose a slice to see how many sessions and readings are inside, and check the sum.
Hours and session counts are the paper’s (Section 3.2). The readings-per-session figures are my arithmetic from them: mixture sessions work out to about 60 seconds each, which is 600 readings at 10 Hz.
Add the slices: 50 + 11.32 + 3.58 + 3.07 is 67.97 hours, which the paper rounds to 68. Add the readings: 180,000 + 648,000 is 828,000, the headline number. Notice the odd fact hiding in it: the Mixture part holds 78% of the readings but only 26% of the hours. It is sampled ten times faster, so each hour yields ten times as many rows.
Chapter 3
Subtract the signal from 25 seconds ago, cut it into windows, and make two different days agree
On Monday you record a cashew. The VOC channel climbs from 0.40 to 0.52 in 25 seconds. On Thursday you record the same cashew. The channel starts at 0.70 and climbs to 0.82. The cashew is the same. The room, the sensor temperature and the air are not. Every number is shifted up by 0.30.
If a model memorises “cashew means about 0.5”, it will fail on Thursday. If it learns “cashew means a rise of about 0.12 over 25 seconds”, it will pass both days. The paper’s preprocessing is a way to hand the model the second kind of fact. There are three steps: temporal differencing, sliding windows and standardization.
A temporal difference subtracts an older reading from a newer one. It asks “how much has this channel moved over the last p seconds?” instead of “where is it now?”. The paper writes it per channel:
Work the Monday and Thursday numbers. Monday: 0.52 − 0.40 = 0.12. Thursday: 0.82 − 0.70 = 0.12. The 0.30 shift cancels exactly. This works for any constant offset: (x + c) − (x′ + c) = x − x′. It also removes most of a slow drift, because a drift that rises 0.01 per minute adds only about 0.004 to a 25-second difference.
The price is small. The first p readings have nothing to subtract, so a 600-reading file gives 575 differences at p = 25. And the model no longer sees the absolute level at all. The paper argues that is the point: the sensors are uncalibrated, reliable for relative changes and not for absolute readings. Try the cancellation yourself.
Top: the same food on day A (solid) and day B (dashed), raw. Bottom: the same two signals after differencing at the lag you choose. Add an offset and a drift to day B, then drag the lag from 0 to 25.
Illustrative: one invented response curve (a smooth rise plus small noise) shared by both days; day B adds the offset and a straight-line drift. The gap is the mean absolute difference between the two days over the seconds both signals exist.
With the defaults, the raw days are about 0.35 apart on average. After differencing at p = 25 they are about 0.01 apart. That is the effect the paper measures on real data: temporal differencing at p = 25 lifts accuracy by an average of 16.1 points across models and window sizes (Finding 1.1).
Two honest details. First, the gain is not uniform. For the MLP at window 50, differencing actually lowers accuracy, from 21.9% to 18.2%. An MLP sees one reading at a time, so a lag-25 difference gives it a number with little to chew on. Second, the authors do not claim a Transformer could never learn this alone. They point out that time-series work has long used such transforms first: delta features in speech and differencing in finance.
A recording is one long sequence, 600 readings. A model wants many short examples. The fix is a sliding window: a frame of w consecutive readings that you slide along the sequence, with a step called the stride s. The paper sets the stride to half the window, so neighbouring windows overlap by 50%.
The paper’s own numbers: with T = 600, w = 50 and s = 25, N = ⌊550/25⌋ + 1 = 23 windows. With w = 100 and s = 50, N = ⌊500/50⌋ + 1 = 11 windows. After differencing at p = 25, T falls to 575, and by the same formula that gives 22 and 10 (my arithmetic).
This is the trade in Finding 1.2. A longer window shows more of the signal’s shape and is more stable. But it gives about half as many examples. A shorter window gives more examples, each with less context. Neither always wins. In Table 2, window 100 mostly beats window 50, with a few exceptions.
Channels have different scales. The paper reports that each sensor has its own mean and spread (its Table 18). A model that sees one channel in the thousands and another near one will pay more attention to the big one. Standardization fixes this by rescaling each channel to mean 0 and spread 1: z = (x − μ) / σ. The detail that matters is where μ and σ come from. The paper computes them from all training data only, then applies those same numbers to the test data. Using test data to compute them would leak information from the exam into the studying.
Does the model need the whole recording? The authors checked by feeding only the first n steps (Table 15, window 50). With differencing, accuracy rises from 45.7% at 200 steps to 53.2% at 500, then stays flat: 50.6% (sensor only) and 52.6% (with GC-MS) at about 600. So ten minutes captures the useful dynamics, and longer recordings would give little.
Chapter 4
Trace one window through the encoder, with every tensor shape, from 50 by 6 numbers to 50 food scores
A window of 50 readings arrives: 50 seconds of six channels, already differenced and standardized. It is a small table of 300 numbers. Somewhere in those numbers is the answer to “which of 50 foods is this?”. How does a model read a table that has an order in time?
ScentFormer is the paper’s answer: a Transformer encoder, a stack of layers where every moment in the window looks at every other moment and decides what matters. This chapter builds it so that you could write it. First, the one idea you need.
Picture the 50 seconds as 50 people in a room. Each person holds a number card (the six readings at that second). Self-attention lets each person ask the room a question, hear which others have a relevant answer, and update their own card with a blend of those answers.
Formally, each moment is first turned into a vector of D numbers. Three small learned matrices turn that vector into a query (what I am looking for), a key (what I offer) and a value (what I hand over if chosen). The match between moment i and moment j is the dot product of query i with key j. A softmax turns each row of matches into weights that add to one, and the new card is the weighted blend of values.
Attention alone has no sense of order: shuffle the 50 moments and each person still gets the same blend. Order matters here, because a rise followed by a plateau is different from the reverse. So the model adds a positional encoding: a fixed pattern of sines and cosines that tells each moment where it stands in the window. ScentFormer uses the sinusoidal kind.
Let B be the batch (the paper uses 32 windows at a time), w the window length, d the number of channels (6 for Base, 4 for Mixture) and D the model width. Follow one batch through.
Step through it below. Change the window and the width, and watch which shapes move.
The row of small shapes is the whole pipeline. Drag Stage to move along it. The tall side of each shape is time, the wide side is features. Try window 100.
The layer layout (4 layers, 8 heads, feed-forward width 4D, mean pooling) is the paper’s Appendix G. The paper does not give D in the main text, so D is a stand-in here. The score counts are exact for full self-attention.
The layer is pre-norm: normalise first, then transform, then add the result back to the input. Written out:
x ← x + Attn(LN(x)) then x ← x + FFN(LN(x))
LN is LayerNorm, which rescales each moment’s vector to zero mean and unit spread. FFN is a two-layer network applied to each moment alone, with a hidden width of 4D and a GELU activation. The addition of x is the residual connection: the layer only has to learn a correction, and the signal can pass through unchanged. Normalising before the sublayer, as the paper does, tends to train more stably than normalising after.
The eight heads split the width. Each head works in D/8 numbers, runs its own attention, and the results are joined. Different heads can follow different questions: one may look at the last few seconds, another at the start of the window.
After four layers, each of the 50 moments holds a D-vector that has already seen the others. To classify, we need one vector. The default is masked mean pooling: average over the real moments and skip the padding.
For a full window of 50 real moments the mask is all ones and this is a plain average. The mask earns its keep when windows have different lengths, for example a shortened last window. An optional learnable [CLS] token (a special extra moment that collects a summary) exists but is off by default.
Attention compares every moment with every other. For w = 50 that is 50 × 50 = 2,500 scores per head. Doubling the window to 100 gives 10,000, four times as many. With 8 heads and 4 layers there are 32 such tables, so one window needs 80,000 scores at w = 50 and 320,000 at w = 100. That is small. The whole model has about 2.41 million parameters. On an NVIDIA L40S at batch size 32 the paper reports 0.0191 to 0.0479 ms per window and 20,892 to 52,371 windows per second, with about 19 MB live memory. The model can keep up with a sensor that writes one reading per second by a very wide margin.
For SmellNet-Mixture the same encoder gets two extra outputs. A linear layer predicts presence û in R12: is each odorant in the blend at all? A second linear layer followed by a softmax predicts proportions ẑ on the probability simplex: how much of each? Chapter 6 shows the loss that trains them.
Chapter 5
Pull each sensor window toward its food’s GC-MS fingerprint, and see when that help is real
Suppose a friend hands you 50 index cards, one per food. Each card carries a chemistry lab’s fingerprint of that food: a long strip of peaks showing which molecules it gives off. Now a sensor window arrives with no label. You do not need a label if you can ask: which card does this window resemble most?
That is the idea behind SmellNet’s second training objective. The sensor is cheap and coarse. The chemistry cards are precise, but they come from a lab, not from the sensor. The paper uses the cards as a teacher during training, then throws them away at test time.
GC-MS has two stages. In gas chromatography, a vapour is pushed through a long thin tube. Different molecules travel at different speeds, so they leave the tube one after another. In mass spectrometry, each arriving molecule is broken into fragments, and the machine weighs them. The result is a mass spectrum: a plot of how much signal appears at each mass-to-charge value, written m/z. Each compound has a characteristic set of peaks.
The team did not run GC-MS. They took volatile-compound records from FooDB, an open food-compound database, for all 50 foods (100% coverage; they chose the foods so this would hold). They turned each food’s record into a fixed-length vector in one of two ways.
One card per food, computed once and fixed. A small MLP encoder (hidden sizes 512 and 256, output width 256) turns the card into an embedding. The sensor encoder is ScentFormer. Both embeddings are pushed into a shared space.
Take a batch of N matched pairs: sensor window i comes from food i, and card i is that food’s chemistry. We want window i to land near card i and far from every other card. Measure closeness with cosine similarity: the cosine of the angle between two vectors, 1 when they point the same way, 0 when at right angles, −1 when opposite.
For window i, compute its similarity to all N cards. Divide by a temperature τ (a small positive number that sharpens the contrast), and apply a softmax. That gives a probability that window i belongs to each card. We want the probability on card i to be high, so we take its negative log: this is plain cross-entropy over the N cards. Do the same from the other side, for card i against all windows, and add. The paper gives it as:
This is the same loss used by CLIP, which the paper cites. In CLIP the two sides are images and captions. Here they are sensor windows and chemistry cards. The CLIP lesson goes deeper on why it works.
Worked example. Four foods, so N = 4. Say window 1 has similarity 0.9 to its own card, and 0.0, −0.3 and 0.2 to the other three, with τ = 0.1. The scaled scores are 9, 0, −3 and 2. Exponentials: 8103, 1.00, 0.05 and 7.39. The sum is 8111.4. The probability on the true card is 8103 / 8111.4 = 0.9990, and the loss from this one term is −log 0.9990 = 0.001. Now suppose the window were confused, with the true card at 0.2 and a wrong one at 0.9. The scores are 2 and 9, the true probability falls to roughly 0.001, and the term jumps to about 7. The loss punishes confusion hard.
Below, four foods have fixed chemistry embeddings (purple). The sensor embeddings (blue) start scrambled. Training slides them toward their cards. Watch the diagonal of the table light up and the loss fall. Then change the temperature.
Left: unit vectors on a circle, blue for the sensor windows, purple for the GC-MS cards. Right: row i shows the probability that sensor window i picks each card. Drag training progress, then drag the temperature.
Illustrative: embeddings are two-dimensional so they fit on a circle, and the starting angles are invented. The loss is the paper’s symmetric formula, computed live in your browser.
At low temperature the table sharpens quickly: a small angle error already costs a lot. At high temperature all scores look alike, the softmax stays flat, and the loss cannot get small even when the match is perfect. The paper does not report its value of τ in the main text, so treat it as a tunable you would sweep.
Training uses both objectives together on SmellNet-Base: the cross-entropy over 50 foods and the contrastive term. At test time there is no GC-MS machine. The sensor window goes through the encoder, and the model scores it against the stored food embeddings by cosine similarity, ranked (the paper’s Figure 1c shows the top 5). The chemistry is a teacher during training and a label dictionary afterwards. It is not an input at test time.
It is not used for the mixtures. There is no reliable GC-MS profile for an arbitrary blend of oils, so the authors skip the alignment there.
Table 2 gives the change in top-1 accuracy when GC-MS is added. It is a mixed answer, which the authors say plainly.
| Model | w50, p0 | w50, p25 | w100, p0 | w100, p25 |
|---|---|---|---|---|
| MLP | +2.2 | +6.5 | +3.3 | +4.0 |
| CNN | +2.2 | −1.2 | −2.8 | +6.2 |
| LSTM | +2.6 | +0.0 | +6.4 | −1.0 |
| ScentFormer | −0.4 | +2.0 | −0.4 | +7.2 |
Weak models gain steadily (Finding 2.1): the MLP improves in all four cells. Strong temporal models gain or lose (Findings 2.2 and 2.3): the CNN loses 1.2 and 2.8 points in two cells, and the LSTM loses 1.0. The biggest single gain is ScentFormer at window 100 with differencing: +7.2, lifting 56.1% to the paper’s headline 63.3%. The paper reads this as the chemistry giving a structured target that helps a model that has the capacity to use it, and sometimes clashing with strong short-range features. It also checked that swapping Xspec for Xatom gives the same qualitative pattern (Appendix H.1).
One thing the paper does not discuss: in a batch of many windows, two may come from the same food. The loss above treats the second as a wrong match for the first card. How often this happens depends on the batching, which the main text does not specify, so I flag it as an open detail, not a finding.
Chapter 6
Predict twelve proportions that add to one, and score the guess three different ways
A perfumer pours 70% banana oil and 30% mango oil into a jar and closes the lid. The sensor sits in the jar for a minute. The task: from those readings, say “70% banana, 30% mango”. You must name the ingredients and also say how much of each.
This is harder than naming a food. A food is one label. A recipe is a point in a space of twelve proportions. The answer is a list of twelve numbers that are never negative and always add up to one. Maths calls that a probability distribution, and the set of all such lists is the simplex.
Each SmellNet-Mixture session has a volumetric recipe over K = 12 odorants. Write the raw amounts as π̃, a list of 12 non-negative numbers. Normalise by the total:
The model’s own answer, π = gθ(x), ends in a softmax, so it also lies on the simplex. The paper is careful about what the target means. The goal is to recover the recipe, not the exact gas concentrations in the jar, because those also depend on how fast each oil evaporates and on the headspace dynamics.
A single loss would struggle, because a mixture answer can go wrong in three different ways. The paper adds three terms.
Term 1: KL divergence. Kullback-Leibler divergence measures how far one distribution is from another. KL(p ‖ p̂) = ∑ pi log(pi / p̂i). It is zero when the two agree and grows as the model puts too little mass where the target has a lot. It keeps the whole list of proportions close to the truth.
Term 2: a hinge on the present components. For only the odorants that are really in the blend (the set S), add the average of max(|p̂i − pi| − ε, 0). The max with zero means errors smaller than a tolerance ε cost nothing, and bigger errors cost the excess. It pushes the ingredients that matter to the right level.
Term 3: focal binary cross-entropy on presence. The model also predicts, for each odorant, a score si for “is it in the blend?”. Most odorants are absent in any one blend, so a naive loss would be dominated by easy “absent” cases. The focal form multiplies each term by (1 − pt)γ, where pt is the probability given to the right answer, so well-solved cases fade and hard ones count. The paper uses αf = 0.75 and γ = 2.0.
L = KL(p ‖ p̂) + α · (1/|S|) ∑i∈S max(|p̂i − pi| − ε, 0) + β · FocalBCE(s, r)
Here ri = 1 if pi > 0, and α and β balance the second and third terms against KL. The main text does not give values for α, β or ε, so a re-implementation would tune them. The paper trains this for 60 epochs at batch size 64.
How do you grade a recipe? The paper uses three scores, because each notices something the others miss.
Worked example. The truth is banana 0.7, mango 0.3. The model predicts banana 0.55, mango 0.25, and 0.02 on each of the other ten.
One prediction, a miss on one metric and a perfect score on another. The model identified the ingredients but missed the ratio. Play with the numbers.
Hollow bars are the true recipe. Filled bars are the model’s guess. Drag the first ingredient’s share, and the share leaked onto the ten absent odorants. Watch which metric breaks first.
Illustrative: the guess is built from the two sliders (the leak is spread evenly over the absent odorants; the rest is split between the present ones in the true ratio after the first). The formulas are the paper’s. MAE is averaged over all 12 components. The hit rule is my reading of the paper’s definition.
Slide the first share to 0.70 with no leak and every metric is perfect. Add leak 0.30 and KL rises, MAE rises, and Top-1@0.1 fails, yet Dynamic Top-K stays at 100% until a real ingredient’s share drops below the leaked share of an absent odorant. Push the first share to 1.00 to see that happen to the second ingredient. That is why the paper reports several scores: Top-K tells you if the ingredients were found, Top-1@0.1 whether the amounts were right.
The symptom: a model that smears probability across all 12 odorants, giving each a little. The measurement: MAE stays small, because most targets are zero and small errors on many zeros are small, yet Top-1@0.1 is poor. The fix is what the loss has built in: the hinge term focuses on the present ingredients, and the presence head with focal loss learns when an odorant is absent.
Chapter 7
Find out which choices matter most, which sensor channels carry the signal, and what is only modest
You are the reviewer for this paper. A table lands on your desk with 16 rows of numbers. A good reviewer does not read it top to bottom. She asks three things of every table: what changed from row to row, what was held fixed, and what is the baseline? This chapter does that for SmellNet’s main tables.
For Base, the last acquisition day (day 6) is the test set, and days 1 to 5 train. Four model families compete: an MLP (a plain network that sees no time order, here after pooling over the window), a CNN (a 1D convolution that slides small filters along time), an LSTM (a recurrent network that reads time step by step) and ScentFormer. All train for 90 epochs at batch size 32 on a small learning-rate grid (3×10−4, 10−3, 3×10−3), with the same seed (42). The paper keeps the grid small on purpose, to avoid “hyperparameter fishing”. One small flag: the main text says the final checkpoint is reported, while the appendix says the best checkpoint by validation top-1 is chosen. A re-implementation should check the code.
Three scores are reported. Top-1 is the share of windows whose best guess is right. Top-5 counts a window as right if the truth is among the five best guesses. Macro-F1 averages a per-class score, so common and rare classes count equally. Chance for Top-1 is 2%, for Top-5 is 10%.
Table 2 varies the window (50 or 100) and the lag (0 or 25) for all four models. Hold the model fixed and read across.
Now the part a careful reviewer notices. Sensor-only, the best number in Table 2 is the LSTM at 57.9%, not ScentFormer at 56.1%. ScentFormer wins clearly in only two settings: raw signals, where its attention can find structure that the others miss (35.1% and 39.9% against at most 29.5% for any other sensor-only model), and with GC-MS at window 100, lag 25 (63.3%). Its Top-5 at that setting is 87.4% sensor-only. The paper’s honest summary is Finding 1.3: temporal models help, which is a claim about the family, not about the Transformer alone.
Table 3 repeats the exercise for mixtures that appeared in training. At window 50 ScentFormer has the best MAE (0.0395) and Top-1@0.1 (50.2%), with the LSTM (46.4%) and CNN (48.1%) behind. On Dynamic Top-K the picture is closer: the LSTM scores 89.3% and ScentFormer 87.9% at window 50, while at window 100 ScentFormer (89.0%) edges the CNN (87.0%). Longer windows hurt the MLP badly (44.0% to 33.7% Top-1@0.1). So the window that worked for foods is not automatically right for mixtures, and 10 Hz sampling means a 50-reading window covers only five seconds.
Appendix H.3 runs a masking ablation: hide one channel and measure how far top-1 falls. A channel whose loss hurts a lot is carrying information the others cannot supply. Every cell is negative: no channel is useless. But the ranking depends on the preprocessing. Explore it.
Choose a training setting. Each bar is the points of top-1 accuracy lost when that channel is masked. Tap a channel to read its number against the baseline.
The numbers are the paper’s Tables 11 and 12 (ScentFormer, window 50): baselines 35.13 (raw, sensor only), 34.70 (raw, GC-MS), 50.60 (differenced, sensor only) and 52.60 (differenced, GC-MS). Each entry is the drop in points of top-1 accuracy.
Read the differenced setting first. Masking LPG costs 28.9 points, more than half of the model’s 50.6%. Masking Alcohol costs 26.5. Masking C2H5OH costs only 10.3. Now recall Chapter 1: LPG and Alcohol were the channels least correlated with the rest, and the ones that dominate the second principal component. When channels repeat each other, losing one costs little because the others cover for it. When a channel stands alone, losing it removes a fact nothing else carries.
Switch to raw signals and the order changes. CO and NO2 now lead (−25.2 and −22.8), and LPG is the cheapest to lose (−10.4). The paper reads this as the raw model leaning on the oxidising and CO-related responses, which carry the large level differences between foods. Differencing removes those levels, so the model must use the changes, and the independent channels carry the changes.
Chapter 8
Test a new day, a new recipe and a new room, and learn what the paper does not yet claim
Last Tuesday your model named 56% of foods correctly on the held-out day. Today a colleague carries the sensor to a different room, buys a different batch of peaches, and asks for a new blend nobody trained on. Does 56% still hold? This chapter lists the places the paper itself says it might not.
A good habit when reading any benchmark: for each headline number, ask what shift was not tested. SmellNet is unusually open about this. It shows three kinds of shift: a new recipe, a new day and a new environment.
Recall the two mixture test sets from Chapter 2. On test-seen, the recipes appear in training. On test-unseen, they are new pairs or new ratios. The unseen set holds no single odorants at all: 83.2% of its sessions are binary and 16.8% ternary.
Compare Tables 3 and 4 (window 50). ScentFormer’s Top-1@0.1 falls from 50.2% to 16.0%. The MLP falls from 44.0% to 11.7%. Every model loses between 32 and 36 points. The paper’s reading (Finding 3.2) is that this is “sensitivity to composition shift”, not an artefact of class imbalance or recording sessions: even though every ingredient was seen, the model transfers poorly to new ratios of them.
There is one bright spot (Finding 3.3). Dynamic Top-K stays well above the random baseline of about 16.7%. ScentFormer gets 38.9% on unseen recipes. So the model can often narrow down which ingredients are present even when it gets the amounts wrong. The appendix adds a hint: cosine similarity between predicted and true distributions stays fairly high on unseen mixtures, while KL and MAE rise sharply. The model gets the direction of the recipe roughly right and the amounts wrong.
For each model, the left bar is the seen-recipe test and the right bar is the unseen-recipe test. Switch the metric and compare how far each model falls.
The numbers are the paper’s Table 3 (seen) and Table 4 (unseen), window 50. The dashed line is the paper’s random-guess level for Top-K, about 16.7%.
The main table tests on day 6 only. That is one draw. If day 6 happened to be an easy day, the headline would be rosy. So the appendix runs leave-one-day-out: hold out each of the six days in turn, train on the other five, and report the mean and spread. With lag 25, ScentFormer averages 49.4% ± 8.0 at window 50 and 53.0% ± 6.0 at window 100. Day 1 is the hardest at both window sizes. The paper suspects a larger day-specific shift, for example ambient conditions or sensor state, and still sees it as far above the 2% chance level.
Each bar is ScentFormer’s top-1 accuracy when that day is the test day. The dashed line is the six-day mean. Choose a window and tap a day.
The numbers are the paper’s Table 14 (ScentFormer, lag 25, sensor only). The means, 49.4 and 53.0, are Table 13’s.
Notice what the spread says. Day 6, the fixed test day in the main table, scores 56.1% at window 100. The six-day mean is 53.0%. So the headline day was a little easier than average, by about three points, and a day-to-day swing of 6 to 8 points (one standard deviation) is normal. When two models differ by 2 points in Table 2, that difference is smaller than the change from picking another test day.
Everything above stays inside the sealed box. The authors say so in their own limitation: data were collected in controlled settings, with no explicit background or environment subtraction. Performance may drop in unseen environments, with different airflow, or with a sensor placed differently. They also note that background NO2 varied across days and could not be removed. And the sensors themselves can suffer from sensitivity, interference, reproducibility and calibration limits (Section 2), which a second board of the same model would meet again.
One last point in the paper’s favour: the ethics section stresses that no human subjects were involved and the data contain no personal information. It also notes that smell sensing could be misused and asks for responsible use, particularly around privacy.
Chapter 9
Review the numbers and terms, then read the core as code and look at what comes next
You can now rebuild SmellNet from memory: a six-channel sensor, a sealed box, six days of ten-minute sessions, a difference of readings 25 seconds apart, windows cut with 50% overlap, a small Transformer, a chemistry teacher for training, and a recipe target for blends. This page puts it on one sheet.
Machine olfaction lacked a large, open benchmark from portable sensors. SmellNet records six metal-oxide channels (four for mixtures) on 50 foods across six days, and 43 blends of 12 oils, for about 828,000 readings and 68 hours. ScentFormer differences the signal at lag 25, standardizes it with training statistics, cuts 50% overlapping windows, and encodes them with a four-layer pre-norm Transformer with masked mean pooling. It trains with cross-entropy, plus a symmetric contrastive loss that pulls windows toward fixed FooDB-based GC-MS embeddings of their food, and for mixtures it predicts a 12-way recipe with KL, hinge and focal losses. It reaches 63.3% top-1 on 50 foods and 50.2% Top-1@0.1 on seen blends. It falls to 16.0% on unseen blends, and day-to-day shift costs several points.
| What | Number | Where |
|---|---|---|
| Dataset size | ~828,000 readings, 68 hours, 50 foods, 43 mixtures | Abstract, Section 3 |
| Base protocol | 50 foods × 6 sessions × 600 s at 1 Hz = 180,000 readings, 50 h | Section 3.2 |
| Mixture protocol | 12 odorants, 1,078 sessions, 10 Hz, 648,000 readings, 18.0 h | Section 3.2 |
| Windows per recording | 23 at w = 50, 11 at w = 100 (stride w/2, T = 600) | Appendix I.1 |
| Differencing gain | 16.1 points on average (lag 25 against lag 0) | Finding 1.1, Table 2 |
| Best Base result | 63.3% top-1 (ScentFormer, w = 100, lag 25, GC-MS); 56.1% without | Table 2 |
| Best sensor-only Base result | LSTM 57.9% against ScentFormer 56.1% (w = 100, lag 25) | Table 2 |
| GC-MS effect on ScentFormer | −0.4, +2.0, −0.4, +7.2 points across the four settings | Table 2 |
| Seen mixtures | Top-1@0.1 50.2%, MAE 0.0395, Top-K 87.9% (w = 50) | Table 3 |
| Unseen mixtures | Top-1@0.1 16.0%, Top-K 38.9% (random about 16.7%) | Table 4 |
| Leave-one-day-out | 49.4 ± 8.0 (w = 50), 53.0 ± 6.0 (w = 100) | Table 13 |
| Most vital channel | LPG, −28.9 points when masked (differenced, sensor only) | Table 11 |
| Model size and speed | about 2.41 M parameters, 0.0191 to 0.0479 ms per window (batch 32, L40S) | Appendix H.6 |
| Term | Plain meaning |
|---|---|
| MOX sensor | A heated metal-oxide film whose resistance changes when vapours arrive. |
| Cross-sensitive | Reacts to many molecule types, not one. The array makes a fingerprint. |
| Temporal difference | xt − xt−p: the change over p seconds. Cancels offsets and slow drift. |
| Sliding window | w readings, moved forward by w/2. Turns one recording into many examples. |
| Standardization | Subtract the training mean and divide by the training spread, per channel. |
| Pre-norm | Normalise before each sublayer, then add the result to the input. |
| Masked mean pool | Average over real moments only, giving one vector per window. |
| GC-MS | A lab machine that separates and weighs molecules. Here, a fixed per-food embedding used as a teacher. |
| Contrastive loss | Pull each window toward its own food’s embedding and away from the others. |
| Simplex | All lists of non-negative numbers that add to 1. The space of recipes. |
| Top-1@0.1 | Right if each present proportion is within 0.1 of the truth. |
| Dynamic Top-K | How many of the true ingredients are in the model’s top K, where K is the true count. |
| Leave-one-day-out | Test on each day in turn, train on the other five, report the mean and spread. |
pythonimport math, torch, torch.nn as nn, torch.nn.functional as F def diff(x, p=25): # x: (T, d) one recording, T = 600 return x[p:] - x[:-p] if p else x # (T-p, d): the change over p seconds def windows(x, w=50): # stride w//2: 50% overlap return torch.stack([x[i:i+w] for i in range(0, len(x) - w + 1, w // 2)]) # (N, w, d) def sinusoid(n, D): pos, i = torch.arange(n).unsqueeze(1), torch.arange(0, D, 2) pe = torch.zeros(n, D) pe[:, 0::2] = torch.sin(pos / 10000 ** (i / D)); pe[:, 1::2] = torch.cos(pos / 10000 ** (i / D)) return pe class ScentFormer(nn.Module): def __init__(self, d=6, D=128, L=4, H=8, C=50, p=0.1): # D: a stand-in; the paper gives L=4, H=8, FFN=4D super().__init__() self.stem = nn.Sequential(nn.Linear(d, D), nn.LayerNorm(D)) layer = nn.TransformerEncoderLayer(D, H, 4 * D, p, activation="gelu", norm_first=True, batch_first=True) self.enc = nn.TransformerEncoder(layer, L) self.head = nn.Sequential(nn.Linear(D, D // 2), nn.GELU(), nn.Dropout(p), nn.Linear(D // 2, C)) self.register_buffer("pe", sinusoid(512, D)) def embed(self, x, pad=None): # x: (B, w, d); pad: (B, w) True = padding h = self.enc(self.stem(x) + self.pe[: x.size(1)], src_key_padding_mask=pad) # (B, w, D) m = (~pad).float().unsqueeze(-1) if pad is not None else torch.ones_like(h[..., :1]) return (h * m).sum(1) / m.sum(1).clamp_min(1e-6) # (B, D) masked mean def forward(self, x, pad=None): z = self.embed(x, pad) return self.head(z), z # logits (B, 50), embedding (B, D) def contrastive(zs, zg, tau=0.1): # sensor (N, D'), GC-MS (N, D'); tau is a placeholder zs, zg = F.normalize(zs, dim=-1), F.normalize(zg, dim=-1) S = zs @ zg.T / tau # (N, N) cosine / tau y = torch.arange(len(S)) return F.cross_entropy(S, y) + F.cross_entropy(S.T, y) # both directions, as in the paper def mixture_loss(z, s, p, alpha=1.0, beta=1.0, eps=0.02, gamma=2.0, af=0.75): # alpha, beta, eps: placeholders logq = F.log_softmax(z, -1); q = logq.exp() # z: (B, 12) logits; p: (B, 12) target shares kl = (p * (p.clamp_min(1e-9).log() - logq)).sum(-1) present = (p > 0).float() hinge = (((q - p).abs() - eps).clamp_min(0) * present).sum(-1) / present.sum(-1) pt = torch.where(present > 0, s.sigmoid(), 1 - s.sigmoid()) # s: (B, 12) presence logits focal = -(af * (1 - pt) ** gamma * pt.clamp_min(1e-9).log()).mean(-1) return (kl + alpha * hinge + beta * focal).mean()
Read it against the chapters. diff and windows are Chapter 3. The class is Chapter 4, with the shapes in the comments. contrastive is Chapter 5, and mixture_loss is Chapter 6. The values marked as placeholders are not in the paper’s main text, so this is a sketch of the structure, not a reproduction of the results. The authors release the real code at github.com/MIT-MI/SmellNet.
This paper is the reading for the lecture on AI for new senses, where machine smell sits beside taste, temperature and touch as modalities AI could gain. The contrastive step is the same pairing idea as in the alignment lecture: two modalities, matched pairs, one shared space. The sensor array is a case of the fusion problem in the fusion lecture, where six imperfect channels are combined into one decision. Its closest sibling outside the course is the sensor-fusion material in the sensor fusion atlas.
Credit: SmellNet was created by Dewei Feng, Wei Dai, Carol Li, Alistair Pernigo, Yunge Wen and Paul Pu Liang at the MIT Media Lab and MIT EECS, and published at ICLR 2026. Read the original at arXiv 2506.00239. This lesson re-teaches it for the MIT MMAI course and adds the illustrative toys marked as such.
Now press Present or Teach and explain SmellNet from memory: what the sensor reads, why a difference beats a level, how a window moves through the model, what the chemistry teacher adds, and where the results stop. Then go back to the instrument at the top, switch differencing on and off for each model, and say why the MLP barely moves and the CNN and LSTM leap.