WorksComputer Science
RF-Based Macronutrient Estimation in Liquid Foods via Composition-Aware Multi-Task Learning
Abstract
Current approaches to macronutrient estimation range from high-overhead laboratory analysis to user-dependent methods such as manual nutritional lookup, reading package labels, and vision-based image analysis. These approaches are often time-consuming, input-dependent, or sensitive to imaging and measurement conditions. In this work, we investigate synchronous 2.4 GHz OFDM radio-frequency (RF) measurements for estimating carbohydrate, fat, and protein content in liquid foods. Using a controlled sensing setup, we study how liquid composition shapes frequency-domain RF responses – a first step toward a sensor integrated into a liquid-contacting vessel that estimates macronutrient content passively and label-free, and toward composition-aware RF food analysis beyond liquids. We propose the Ingredient-Conditioned OFDM Transformer (ICOT), a structure-aware multi-task Transformer that operates on two-dimensional OFDM channel frequency response matrices. ICOT infers canonical ingredient categories representing dielectric-driver composition and uses them to condition macronutrient regression through feature concatenation. On 28,420 captures spanning 55 beverage classes, ICOT achieves an in-distribution MAE of 0.101 g/100 ml and an out-of-distribution MAE of 0.485 g/100 ml – comparable in magnitude to deviations present in manufacturer-reported labels – though generalization to novel formulations remains the primary open challenge.
Introduction
For a person managing type 1 diabetes, miscounting the carbohydrates in a glass of juice by a few grams can precipitate an insulin dosing error with clinically significant glycemic consequences [2]. More generally, determining what is in an unlabeled liquid requires reading a package, running a lab test, or already knowing the composition—compounded by evidence that packaged labels themselves deviate measurably from stated values [1], and home-prepared beverages carry no label at all. [3] demonstrate that tracking macronutrient intake from first principles, ingredient by ingredient, imposes a compliance burden incompatible with consistent daily use. Motivated by this gap, the long-term objective of this work is a sensor integrated into a liquid-contacting vessel that estimates the macronutrient content of any poured liquid without user involvement or prior knowledge of its composition. In this paper, we address this objective by investigating whether active OFDM RF measurements can support composition-aware macronutrient estimation in liquid foods.
Nutrient estimation refers to quantifying carbohydrate, fat, and protein content, since these macronutrients largely determine caloric content and guide dietary decisions; existing automated approaches remain limited in several respects. Smartphone applications [4, 5, 6] depend on the user initiating a logging event and are sensitive to training-data coverage. Vision-based methods [7, 8, 9, 10] match query images against reference databases and are sensitive to viewpoint, lighting, and occlusion; most account only for food category and volume, omitting ingredient composition and cooking method. Prior RF-based food sensing uses microwave oven leakage: WiNE [11] estimates nutrient percentages during heating, and RFTemp [12] monitors food temperature from the same signal; both require active microwave excitation and report coarse nutrient fractions rather than absolute per-volume macronutrient quantities.
As the RF signal propagates within the liquid, it is subject to attenuation and scattering whose signature can be discerned from the spectral response—fat droplets, dissolved sugar, and ions each manifest uniquely in the received spectrum. In our experimental setup, we sample OFDM Channel Frequency Responses (CFR) over various channels and subcarriers using a 2.4 GHz software-defined radio with synchronized transmit and receive chains, distinct from commodity WiFi hardware. Unlike LiquiID [13], which focuses on the nature of the liquid based on complex permittivity, we aim to estimate concentrations of carbohydrates, fats, and proteins. This poses a challenge: RF signals detect only the overall dielectric properties caused by the base solvent, electrolyte ions, lipid droplets, and non-electrolyte solutes [14, 15]. Distinct liquids can share similar attenuation characteristics, making it impossible to predict nutrient concentrations without first understanding what causes the dielectric behavior. To address this, we introduce the Ingredient-Conditioned OFDM Transformer (ICOT), a multi-task network built on the Transformer encoder [16] that takes the entire 2D CFR matrix ( channels by subcarriers) as input. ICOT first learns the latent space representing the main dielectric contributors—base solvent class, molecular heterogeneity, and ion/non-ion solutes—then infers macronutrient concentrations from this intermediate representation; ingredient labels supervise training only within this latent space, while inference uses RF measurements alone.
The primary contributions of this paper are as follows:
We formulate macronutrient estimation in liquid foods as an indirect RF inference problem mediated by dominant dielectric drivers, and design ICOT, a multi-task Transformer decomposing this into hierarchical composition inference followed by composition-conditioned
Figure 1. RF-based macronutrient estimation pipeline: an unlabeled beverage is probed with synchronized 2.4 GHz OFDM; ICOT identifies dielectric drivers (–) before conditioning macronutrient regression.
regression (canonical supervision used only in training). Unlike prior RF work’s black-box sensing networks, ICOT predicts absolute macronutrient quantities in unseen beverages by inferring latent physical structure rather than recalling prelearned identities—the basis for the interpretability analysis in Contributions 2–3.
We demonstrate via embedding-shuffle intervention experiments that ingredient-level conditioning is functionally necessary—not merely additive—for in-distribution performance, and that concatenation-based fusion achieves a better accuracy–robustness tradeoff than FiLM.
We evaluate ICOT on 28,420 captures across 55 beverage classes, achieving ID MAE of 0.101 g/100ml and OOD MAE of 0.485 g/100ml, and characterize two error sources—compositional singularity and spectral confusability—that define the path to deployment. The current system is restricted to fixed container geometry, synchronized Tx/Rx hardware, and multi-liter sample volumes; robust OOD performance remains open for compositionally novel or high-sugar formulations.
Background
This section establishes how liquid composition governs OFDM channel responses and the implications for model design.
Electromagnetic Propagation Through Liquid Media
The interaction of electromagnetic waves with liquid materials is governed by the complex permittivity
where controls wave velocity and phase propagation, and captures dielectric loss and energy absorption [17], [18]. For a homogeneous liquid layer of thickness , the frequency-domain channel response is
where and are the attenuation and phase constants determined by [19]. Changes in liquid composition alter via solvent binding, emulsification, and molecular polarization, producing frequency-dependent phase dispersion across subcarriers [20]; consequently, phase effects remain implicitly encoded in non-local spectral structure even when magnitude-only features are used after calibration. This dual dependence on and underlies OFDM’s sensitivity to liquid composition.
Overview of OFDM
Orthogonal Frequency Division Multiplexing (OFDM) partitions a wideband channel into a set of orthogonal subcarriers, each probing the medium at a distinct frequency [20], [21]. The resulting channel response is compactly described as discrete samples of :
where is the channel index and is the subcarrier index. This representation has two properties relevant to liquid sensing: (i) frequency selectivity, preserving composition-dependent dispersion and attenuation across the band; and (ii) inter-channel continuity from partially overlapping adjacent channels, extending effective spectral coverage [20]—making the measurement a structured 2D object (channels subcarriers) whose informative patterns may be non-local across frequency.
Following IEEE 802.11a/g/n/ac, a nominal 20 MHz channel discretizes into subcarriers ( active, DC nulled). Channels are center-spaced at 5 MHz with 20 MHz bandwidth, so the eleven 2.4 GHz ISM-band channels overlap and jointly cover more spectrum than any one alone—fully supported by the WARP v3 hardware [22].
RF-Based Liquid Sensing
Two properties motivate the learning-based framework in Section III—(i) frequency-dependent dielectric interactions induce non-local spectral correlations across subcarriers, and (ii) the RF-to-macronutrient relationship is indirect, mediated by ingredient composition (Figure 5)—for which this section presents empirical evidence.
Figure 5. A liquid mixture decomposes into dielectric drivers, mapped through a nonlinear mixture law to the effective complex permittivity , governing the OFDM channel response .
Figure 2 depicts baseband OFDM magnitudes for 1% Fat Milk, 2% Fat Milk, and Whole Milk on channel 1: despite identical water content and setup, varying fat content noticeably shifts the magnitude spectrum, since it changes the medium’s dielectric loss and produces frequency-selective attenuation rather than simple scaling.
Figure 2. Baseband OFDM magnitudes for 1%, 2%, and Whole Milk, channel 1 (faint: individual captures; bold: per-class median; DC subcarrier omitted).
Figure 3 presents air-normalized data (Section IV) for sugar solutions: higher sucrose concentration yields consistently smaller normalized magnitudes and stronger spectral fluctuations, consistent with increased dielectric loss from progressive disruption of water’s orientational polarization.
Figure 3. Calibrated OFDM magnitudes for increasing sucrose concentration; each panel is one 20 MHz channel (64 subcarriers) of the 2.4 GHz ISM band.
Figure 4 shows the resulting manifold of OFDM features: sugar water varies monotonically along the dominant principal components with dielectric loss; carbonated beverages separate by sucrose vs. synthetic sweeteners; and caffeinated beverages cluster by the dielectric relaxation of milk’s lipid/protein content.
Figure 4. PCA projections of uncalibrated OFDM feature representations for different liquid food groups.
Rather than treating beverages as collections of discrete culinary ingredients, we model each as a liquid mixture whose RF response is governed by a small set of dominant dielectric drivers: the effective complex permittivity at frequency is a nonlinear mixture mapping
where and are the intrinsic permittivity and concentration of constituent , represents state variables (temperature, mixing uniformity, microstructure), and captures nonlinear mixing effects from heterogeneous phases, solute–solvent interactions, and dispersion phenomena. The drivers themselves are not mutually exclusive and may act simultaneously within a given mixture; their relative influence depends on both concentration and operating frequency. Critically, distinct classes of driver can be difficult to disambiguate from a magnitude-only response, since ionic conduction and non-ionic dipolar relaxation both manifest as increased attenuation despite being physically distinct loss mechanisms. This matters because the driver classes do not carry macronutrient content equally: the ionic driver () is typically non-caloric (e.g., electrolytes), whereas the emulsion/heterogeneity driver () and non-ionic solute driver () carry fat/protein and carbohydrate content, respectively. A direct RF-to-nutrient regressor therefore cannot attribute an observed attenuation to a nutrient-bearing versus non-nutrient-bearing driver without first resolving which class of driver is present. Section III-D makes this decomposition operational as the four canonical levels – that ICOT predicts.
Proposed Model Architecture
OFDM signals transmitted through beverages carry structured, non-local dependencies across subcarriers and channels reflecting frequency-dependent dielectric behaviour [23, 24]. Since this response is composition-dependent, identical attenuation patterns can arise from different underlying compositions, making direct RF-to-nutrient regression ambiguous. We propose the Ingredient-Conditioned OFDM Transformer (ICOT), which decomposes nutrient estimation into (i) canonical composition inference and (ii) ingredient-conditioned nutrient regression.
OFDM Signal Representation
The input to ICOT is a calibrated OFDM channel-response tensor
where is the batch size, the number of OFDM channels, and the number of subcarriers per channel. Each entry stores the calibrated magnitude of the complex frequency-domain response, encoding signal propagation through the liquid [24]; phase estimates are sensitive to hardware clock offsets, so magnitude-only features are used for robustness. The subcarrier axis captures frequency-dependent attenuation and dielectric dispersion [23], while the channel axis spans partially overlapping bands with complementary spectral views—preserving both is critical for modelling frequency-selective and cross-channel interactions. Raw responses are normalised against a reference air measurement to remove environmental and container-dependent artefacts.
Feature Embedding and Positional Encoding
Each scalar subcarrier magnitude is projected into a -dimensional embedding via a learnable linear map. Because Transformers are permutation-invariant [16], we inject learnable positional encodings along both axes:
where and encode subcarrier ordering and inter-channel relationships, preserving frequency locality and spectral continuity so the encoder models structured interactions rather than an unordered feature set.
Transformer-Based Signal Encoder
The embedded representation is flattened into a sequence of length and passed through a stack of Transformer encoder layers [16], following the patch-based tokenisation strategy of the Vision Transformer [25]. Self-attention lets every subcarrier attend to all others, capturing long-range spectral correlations from the liquid’s dielectric properties [23, 24], realising a hard-parameter-sharing multitask scheme [26] where the common representation is optimised jointly for both objectives. The encoder output is aggregated into a global RF feature by average pooling over the tokens.
Canonical Mapping Prediction and Supervision
Because the relationship between RF measurements and macronutrients is mediated by ingredient structure, we introduce a hierarchical compositional representation as an intermediate supervision target. We represent each liquid sample with a hierarchical canonical tuple
where each is a categorical variable capturing a different level of compositional structure:
: The main solvent responsible for setting the dielectric relaxation characteristics (such as water-solvent or alcohol-solvent systems).
: Main contributor to the mesoscale heterogeneity within the liquid (such as emulsions, suspended phases, and gases within the liquid, e.g., milk fat/protein emulsions, carbonated gas bubbles, or particulate solids).
: The major ionic or low electrolyte substance responsible for electrical conductivity losses and relaxation (such as coffee acids/metal ions, phosphoric acid, citric acid, or salts).
: Non-ionic substances that affect solvent dynamics and relaxation (such as sugars, syrups, or organics).
Each of these liquid mixtures is described using a set of canonical dielectric drivers that follow a hierarchical organization. The word ingredient thus refers to dielectric interaction class and not some physical ingredient or macronutrient. These labels can be determined by examining controlled preparation metadata with deterministic rules (for example, in case of a salt-water mixture, or for a sugar-water mixture). In case of multiple candidates at a given level, the ingredient with the largest expected dielectric contribution at the operating frequency is chosen as the dominant driver. For non-ionic levels (, ) this reduces to mass concentration; for the ionic level (), dominance is assigned to the species with the largest conductivity contribution at 2.4 GHz rather than by molarity (e.g., phosphoric acid in cola rather than trace minerals). In all beverages in the current dataset this assignment is unambiguous because each formulation contains a single clearly dominant ionic class. The ingredient labels should not be seen as physical measurements and should not be used in any way while making predictions. The purpose of the labels is that they are used as a supervised signal for the latent electromagnetic interactions driving the radio-frequency observations (the precise train/test data flow is given below).
A canonical classifier predicts each level from the shared RF feature . We first compute a shared canonical latent:
where is a small MLP and is the canonical hidden dimension. We then apply level-specific linear heads:
where denotes the number of classes at level ; the model predicts the entire canonical mapping in a single forward pass from OFDM measurements alone. Separate heads per level provide richer supervision, structured interpretability, and better sample efficiency than a single flat label.
We compute soft canonical embeddings from the predicted distributions. For each level , let be a learnable embedding table. We compute the expected embedding:
Concatenating all levels yields the canonical conditioning vector:
This soft formulation preserves end-to-end differentiability, enabling gradients from nutrient regression to shape canonical predictions [27].
During training, ground-truth canonical labels are used only as supervision. We apply categorical cross-entropy at each level:
During training, the model receives as input and uses only to compute ; canonical embeddings are computed from (predicted). During testing the model receives only , predicts and , and outputs nutrients; canonical labels are not provided.

Figure 6. Ingredient-Conditioned OFDM Transformer (ICOT). A shared Transformer encoder extracts a global RF feature; a canonical-structure head predicts from RF alone, and the resulting soft embeddings condition macronutrient regression. Loss weights shown are terminal values after the warmup schedule of Section III-F.
Composition-Augmented Macronutrient Regression
ICOT predicts a continuous macronutrient vector (e.g., for carbohydrates, fat, protein). We fuse RF and canonical features:
A regression head produces the final estimate:
where is an MLP, trained with a robust regression loss (mean absolute error over macronutrient dimensions, defined in Section VI).
Joint Learning Objective
ICOT is trained end-to-end with a weighted multi-task objective:
where and balance nutrient accuracy and structural supervision via a linear warmup: decreases from 1.0 to 0.5 while increases from 0.5 to 1.0 over epochs (held fixed thereafter), so the shared encoder first establishes dielectrically meaningful canonical representations before shifting emphasis toward nutrient regression [26, 28]; for implementation simplicity, the schedule is applied in discrete 5-epoch increments (four stages), closely approximating the continuous version. All models are trained with the Adam optimizer [29] (learning rate , batch size 32) for a maximum of 70 epochs under early stopping (patience = 20, criterion: validation total loss).
Experimental Setup
Hardware
The testbed (Figure 7) uses a WARP v3 SDR board [22] (Xilinx Virtex-6 FPGA, two RF interfaces, 40 MHz bandwidth, 100 Msps ADC) with synchronized transmit and receive chains, distinct from commodity WiFi radios.

Figure 7. RF liquid-sensing testbed: a WARP v3 SDR drives directional antennas across a fixed-geometry container—annotated schematic (beamwidths marked) alongside a photograph of the physical setup.
ALFA Network APA-M25 directional panel antennas (8 dBi gain at 2.4 GHz, 66° horizontal / 16° vertical 3 dB beamwidth, linear polarization) serve as Tx and Rx, with boresight height aligned to the liquid column’s mid-height so that the narrow vertical beamwidth stays fully within the sample across all fill levels tested. A laptop controls the system over Gigabit Ethernet.
RF configuration
We transmit OFDM waveforms at 2.4 GHz over channels. Each 20 MHz channel uses a 64-bin OFDM grid with 52 active non-null subcarriers; after calibration, we retain the full 64-bin response per channel, producing an channel-response tensor per snapshot [30].
Geometry and containers
All liquid samples are kept inside a rectangular glass enclosure that contains a path length of 30 mm along the direction of the RF beam, has a 2 mm thick wall on each face, and contains a volume of 2 L. The Tx and Rx antennas have a separation of 30 mm from their respective faces, such that the total distance from Tx to Rx is mm. This isolates channel-response variation to the liquid itself, rather than the path length or container.
d) Calibration.: Each measurement is normalized by an air reference captured before each session [31]:
removing antenna gain, cable loss, and static multipath so that isolates the liquid’s insertion loss and phase shift.
Dataset
The dataset (Table I) spans 11 beverage groups plus the system-reference family, each populated with well-controlled compositional variants using structured factorial or staged-perturbation designs (e.g., milk’s fat/sucrose matrix) alongside commercially available formulations. Each capture is a tensor corresponding to the OFDM channel response (11 channels in the 2.4 GHz ISM band, 64 subcarriers per channel). Each capture is annotated with ground-truth carbohydrate, protein, and fat values, acquired directly from manufacturer nutrition labels.1 As labels often report macronutrient content per serving, we normalized every measure to grams per 100 ml.
Evaluation
Two complementary evaluation schemes depend on whether the item corresponding to the underlying beverage was available during training.
a) In-Distribution (ID): The ID scheme splits measurements into training/testing (80/20), ensuring every beverage item appears in both, so testing includes only novel measurements of beverages seen during training.
b) Out-of-Distribution (OOD): Generalization to unseen beverage classes is tested via Leave-One-Class-Out (LOCO) validation: for each of the 55 folds, all measurements of one beverage class are held out for testing while the model trains on the remaining classes. For macronutrient estimation, we report mean absolute error (MAE):
where is the number of macronutrients; we also report standard deviation across test samples or held-out items. Per-nutrient MAE fixes and averages over samples; overall MAE averages over both.
Primary Results: Seen-Class (ID) Generalization
Under the ID setting (Figure 8), per-nutrient MAE is 0.211 (carbohydrates), 0.040 (fats), and 0.053 (proteins) g/100ml. Fat and protein show low dispersion (90th-percentile residuals 0.16 and 0.17 g/100ml), while carbohydrate errors are more variable (median 0.13, whiskers to 0.50 g/100ml)—the dominant source of residual variance even when the beverage item is seen during training. Figure 8(d,Figure 8e) shows this ID distribution remains tight compared to OOD (90th-percentile absolute error 0.21 g/100ml per sample).
Figure 8. Macronutrient performance and ingredient-level representation. (a)–(c) ID regression vs. ground truth (dashed = perfect prediction). (d)–(e) Per-class error, ID vs. OOD (boxes: IQR; whiskers: 10th–90th pct.). (f) Ingredient accuracy per level. (g) Precision/recall/F1 per level (solid = ID, dashed = OOD). (h) Combined L0–L3 accuracy, five best/worst classes (solid/hatched = ID/OOD in f–h).
From the representation side, Figure 8(f–Figure 8h) shows ID ingredient classification reaching near-100% accuracy at every level (, –) with correspondingly high precision/recall/F1. Even the five lowest-accuracy beverage categories stay above 80%—well-separated, semantically consistent predictions under ID.
Primary Results: Unseen-Class (OOD) Generalization
Table II and Figure 8(d,Figure 8e) show all models’ MAE/RMSE increase substantially under LOCO relative to ID (for ICOT, both roughly quadruple), unevenly across categories. OOD distributions are wider and more positively skewed, with carbohydrate errors to 2.0 g/100ml at the whisker tips (worst-class MAE 2.95)—concentrated on a smaller number of unseen beverages—while fat/protein stay fairly accurate (median ) and carbohydrates remain most volatile (median ).
The long-tail is concentrated in a small number of classes—2% Milk+6.66% Sucrose, 1% Fat Milk, and Tea+1% Milk+2.22% Sucrose—each with the highest carbohydrate residual (MAE 2.95, 2.74, 2.16 g/100ml). 1% Fat Milk is the hardest class overall (MAE 2.13): as the only unsweetened member of its fat regime, it is misread as non-dairy once held out, misplacing both lipid and protein (MAE 0.89, 2.77). High-sucrose dairy/tea mixtures see elevated error because added sucrose shifts their dielectric response into a region overlapping seen formulations, leaving carbohydrate under-determined; diet/zero-calorie beverages, with water-like responses and high training representation, are easiest. Class-weighted mean OOD MAE is 0.510 g/100ml, slightly above the per-sample 0.485 in Table II since the largest-error classes (dairy) contribute fewer samples than well-predicted carbonated/juice classes.
Under LOCO (Figure 8(f–Figure 8h)), ingredient classification accuracy at – drops from 99.9% (ID) to 71.8%, 77.5%, and 79.0% respectively, while stays at 100%—the structural and ionic/non-ionic levels most directly linked to macronutrient content are hardest to infer for unseen formulations.
Ablation Study: Architectural Validation
We perform an ablation study evaluating (i) transformer architecture, (ii) ingredient-level supervision, and (iii) conditioning technique separately, using the same training protocol as the full model (Section III-F).
a) Compared Model Variants: We evaluate five architectures:
ICOT (ours): Transformer with ingredient-level supervision and concatenation-based fusion at the regression head.
ICOT (FiLM): Same backbone as ICOT, but with FiLM-based [34] feature modulation.
| Target Domain | Compositional Variants & Experimental Matrix | Cls. | |
| Water | Water baseline with ionic (NaCl) and sucrose perturbations, including sugar-in-water variants | 11 | 6,040 |
| Regular CSD | Sweetened carbonated beverages spanning cola, lemon–lime, orange, and ginger profiles | 4 | 3,110 |
| LNCS CSD | Diet/zero-calorie carbonated beverages spanning cola, lemon–lime, and ginger profiles | 3 | 2,450 |
| Coffee-Based Beverages | Brewed coffee baseline; two-level dairy perturbation and two-level sucrose perturbation on the dairy variant | 5 | 810 |
| Tea-Based Beverages | Brewed tea baseline; dairy perturbation and a sucrose perturbation on the dairy variant | 3 | 420 |
| Plain Milk | factorial design with three fat regimes (1%, 2%, whole) and four sucrose levels | 12 | 8,820 |
| Plant-Based Drinks | Almond milk baseline; two-level sucrose perturbation | 3 | 990 |
| Nutritional Beverages | Two-level protein-fortified formulations | 2 | 340 |
| Energy Drinks | Two base formulations with two-level sucrose perturbation ( design) | 4 | 820 |
| Sports Drinks | Two electrolyte base formulations with two-level sucrose perturbation ( design) | 4 | 1,250 |
| Juices & Flavored Drinks | Four distinct non-carbonated fruit beverage formulations | 4 | 3,370 |
| System Reference | Ambient air (empty-container reference capture) | 1 | 1,185 |
Table 1. Beverage dataset ( captures, 55 classes, plus 1,185 ambient-air references), mapped to ABA-BSW/NHANES categories [32], [33]. LNCS = low/no-calorie sweetened; CSD = carbonated soft drink.
| Model | ID MAE | ID RMSE | OOD MAE | OOD RMSE | Inference ms/samp. | Inference samp./s |
| ICOT (Ours) | 0.101 | 0.200 | 0.485 | 0.913 | 0.881±0.016 | 1135 |
| ICOT (FiLM) | 0.093 | 0.225 | 0.932 | 1.486 | 0.881±0.016 | 1135 |
| Vanilla Transf. | 0.123 | 0.272 | 0.955 | 1.401 | 0.859±0.019 | 1164 |
| Transf. (No. Ingr.) | 0.169 | 0.314 | 1.064 | 1.677 | 0.861±0.016 | 1161 |
| CNN Baseline | 0.399 | 0.752 | 1.121 | 1.454 | 0.513±0.016 | 1951 |
Table 2. Per-model accuracy and inference time (variants in Section VI-C).
Vanilla Transformer: Transformer regressor on RF features only, without any ingredient branch.
Transformer (No Ingr.): ICOT architecture with the ingredient path disabled, capacity-matched to ICOT.
CNN Baseline: 1D CNN regressor without a Transformer or ingredient branch.
ICOT (FiLM) modulates the Transformer feature via an affine transform driven by a 32-dim ingredient bottleneck [34], risking attenuation through multiplicative gating. ICOT instead concatenates onto , preserving all RF features. Both ablation variants share this 32-dim bottleneck, whereas the full ICOT model uses the richer 4-level canonical embedding of § 3-D (). The ICOT (ours) vs. ICOT (FiLM) comparison in Table II therefore
conflates supervision richness with conditioning mechanism, whereas the two ablation variants isolate the mechanism cleanly.
Table II yields three observations: (1) the CNN baseline has substantially higher error than all Transformer variants, confirming convolutional local features cannot capture the non-local spectral dependencies of dielectric interaction; (2) variants without ingredient conditioning (Vanilla Transformer, Transformer (No Ingr.)) underperform ICOT in both ID and OOD, mostly on carbohydrate estimation; and (3) ICOT achieves the strongest OOD accuracy and lowest ID RMSE, tied with ICOT (FiLM) on ID MAE while reducing OOD MAE by . FiLM’s substantially higher OOD RMSE suggests multiplicative gating amplifies sensitivity to distributional shift [35], a known failure mode of auxiliary-conditioned models.
Ablation Study: Ingredient Conditioning Evaluation
Ingredient conditioning aims to disambiguate RF responses, but auxiliary signals can act as fragile shortcuts—yielding strong in-distribution gains while failing under distribution shift [35]. We evaluate it along two axes: (i) functional dependence via embedding-shuffle analysis, and (ii) functional reliance via gradient attribution. The shuffle breaks the statistical association between embeddings and RF inputs but is not a do-calculus intervention, so results establish functional dependence rather than strict causal necessity.
a) Embedding-Shuffle Analysis.: We shuffle predicted ingredient embeddings at inference time while keeping RF inputs fixed, breaking ingredient–signal correspondence without altering marginal distributions. As shown in Table III, this causes a large ID degradation: MAE increases by +660% for ICOT and +1591% for ICOT (FiLM). Under OOD-LOCO, however, shuffling produces negligible degradation (≈ 0%), indicating that ingredient conditioning does not generalize to unseen compositions.
| Model | Embedding Shuffle | Gradient Attribution | ||||||||||
| ID | OOD | ID | OOD | |||||||||
| Orig. | Shuf. | Orig. | Shuf. | Std | Std | |||||||
| ICOT (Ours) | 0.101 | 0.769 (+660%) | 0.485 | 0.482 (≈0%) | 0.194 | 0.141 | 0.500 | 4.687 | 0.092 | 0.063 | 0.649 | 11.359 |
| ICOT (FiLM) | 0.093 | 1.578 (+1591%) | 0.932 | 0.931 (-0.16%) | 0.405 | 0.517 | 0.888 | 5.530 | 0.174 | 0.139 | 1.425 | 19.196 |
Table III. Embedding-shuffle and gradient-attribution analysis (ID, OOD-LOCO).
b) Gradient Attribution.: We quantify prediction dependence on ingredient embeddings via a gradient sensitivity ratio:
where denotes RF features and the predicted ingredient embedding. FiLM-based conditioning induces 2.09× higher ID ingredient sensitivity than concatenation (Table III), yet gains no accuracy advantage—marginally ahead on ID MAE (0.093 vs. 0.101) but worse on ID RMSE and both OOD metrics, suggesting excessive reliance is detrimental. Sensitivity drops sharply for both models under OOD-LOCO, reinforcing that conditioning is not functionally relied upon when generalization is required—the same asymmetry as the embedding-shuffle results.
Practical and Compositional Variability
We evaluate ICOT’s robustness under practical deployment conditions, probing sensitivity to thermal variability, mixture complexity, and polar additive combinations.
a) Thermal Conditions.: To assess thermal robustness, we acquired RF spectra from water and 2.22% (w/v) sucrose solutions across controlled temperatures, held out from training and evaluated under OOD-LOCO (Figure 9). Water-based MAE stays low across all temperatures (carbohydrate ≤ 0.35; fat/protein < 0.15 g/100ml), but sucrose-solution MAE rises substantially near 62°F and 80°F (≈ 1.78 and 1.65 g/100ml) before partially recovering. Fat stays consistent throughout (< 0.15) while protein peaks near 62°F (≈ 0.50)—establishing thermal variation as a structured, carbohydrate-concentrated source of distributional shift.

Figure 9. MAE across temperatures for (a) water and (b) 2.22% (w/v) sucrose.
b) Mixed-Liquid Evaluation.: This progression design probes whether ICOT tracks compositional change rather than memorized identity: each step adds one precisely known ingredient to the same base liquid, so an identity-lookup model would not shift its prediction within a family, whereas a composition-tracking model should. As Figure 10 shows, ID predictions do shift with each addition, tracking the known composition change, and error grows with mixture complexity. Under OOD, the zero-nutrient progressions (black coffee/tea) exhibit a spurious protein reading (≈ 1.2, 0.9 g/100ml against a ground truth of zero), showing the model reverts to the training-set mean once the base liquid is unseen. Sucrose additions produce systematic carbohydrate underestimation (e.g., ≈5 vs. ≈7 g/100ml true for coffee+milk+sucrose), and milk progressions show the largest OOD fat error (≈ 2.4 vs. ≈ 2.1 g true) while protein stays close to ground truth. These results indicate the model learns stable single-ingredient representations, with unseen multi-component combinations remaining the primary avenue for improved generalization.
Figure 10. Macronutrient prediction under ID and OOD-LOCO. (a)–(c) Mixture-complexity progressions (coffee, tea, milk); labels name the final mixture, steps run left to right in increasing complexity. (d) Error for polar additive combinations (aqueous, then electrolyte).
c) Sensitivity to Polar Additives.: As shown in Figure 10(d), ID errors remain uniformly low across all compositions (MAE ≤ 0.054 g/100ml), while OOD errors are substantially higher and composition-dependent. Within the aqueous group, adding sucrose increases OOD error (0.311→0.382 g/100ml), indicating dissolved sucrose rather than ionic content drives the shift. The electrolyte group shows a non-monotonic trend, suggesting a non-linear electrolyte–sucrose interaction.
d) Inference Time.: Inference latency, averaged over 1,000 forward passes on the ID test set (CPU only), is 0.859–0.881 ms/sample for all Transformer variants—confirming minimal overhead from ingredient conditioning—versus a faster but substantially less accurate CNN baseline (0.513 ms).
Practical Error Interpretation
Carbohydrate counting commonly uses a 15 g serving exchange as a reference unit [2]; the FDA permits ±20% deviation on packaged labels, and [1] measured actual snack-label deviations averaging 4%–8% per item.
Against these benchmarks, ICOT’s ID MAE of 0.101 g/100ml represents less than 0.7% of the 15 g exchange—clinically negligible. The average OOD MAE (0.485 g/100ml, ≈ 3.2% of the same threshold) is comparable to accepted label deviations, but conceals a long tail: compositionally singular items—1% Fat Milk (MAE 2.74) and high-sucrose dairy mixtures (MAE 2.95 g/100ml)—reach clinically significant errors, so closing these specific compositional gaps is a prerequisite for OOD deployment. The average-MAE comparison applies to in-distribution liquids only. These OOD errors are not arbitrary—they are identifiable gap classes arising from compositional singularity and spectral confusability (Section VIII elaborates both error sources and the resulting research agenda). Outside these gap classes, ICOT’s performance already matches FDA-permitted label tolerances.
| System | Modality | Reported Metric | Port. |
| WiNE [11] | wave leakage | MAE nutrient; cal. | No |
| RFTemp [12] | wave leakage | C mean temp. error | No |
| LiquID [13] | UWB | median permittivity err. (33 liquids) | Yes |
| WiMi [40] | WiFi CSI | 95–99% acc. (10 liquids) | Yes |
| WiEps [41] | WiFi/OFDM | 4.0%/8.9% permittivity/cond. err. | Yes |
| FG-LiquID [42] | mmWave | 97% acc. (30 liquids) | Yes |
| LiqRay [43] | mmWave | 92.9% acc., 1% conc. res. | Yes |
| PackQuID [44] | mmWave | 86–87% acc. (9 liquids) | Yes |
| RF-EATS [46] | RFID backscatter | >90% acc. | Yes |
| mmTaster [45] | mmWave | 90.8% acc., 0.2% v/v res. | Yes |
| MobiLyzer [38] | Optical | Qualitative (adulteration/origin) | Yes |
| ICOT (ours) | Sync. OFDM | 0.101 / 0.485 g/100 ml MAE (ID/OOD, 55 beverages) | No |
Table IV. PRIOR RF- AND OPTICAL-BASED LIQUID-SENSING SYSTEMS.
Related Work
Wearable methods deduce nutrition from behavior-based information: acoustic sensors near the mouth/throat recognize chewing and swallowing [36], identifying eating occurrences rather than nutritional value, so compositionally distinct liquids (e.g., water vs. protein beverages) remain indistinguishable. Optical alternatives—smartphone-LiDAR viscosity [37], MobiLyzer [38], hyperspectral inference [9]—require visual contact with the liquid surface and bespoke hardware, becoming unreliable for opaque containers or unlabeled home-prepared beverages.
Liquid classification from radio signals has emerged as a distinct sensing modality within the broader landscape of RF-based material sensing [39], spanning UWB permittivity sensing (LiquID [13]), commodity WiFi CSI (WiMi [40], WiEps [41]), millimeter-wave classification (FG-LiquID [42], LiqRay [43], PackQuID [44], mmTaster [45]), and RFID backscatter (RF-EATS [46]). Table IV summarizes each system’s modality, reported accuracy metric, and portability alongside optical alternatives (MobiLyzer [38]) and ICOT. Almost all report identity or property-classification accuracy rather than absolute per-volume macronutrient quantities, and ICOT trades the portability of commodity radios for this quantitative output.
ICOT implements hard parameter sharing [26]: a Transformer encoder is jointly trained for dielectric driver inference and macronutrient regression. Theory formalizes why auxiliary supervision aids OOD robustness when auxiliary labels form a shared latent space [47]: auxiliary output labels help, whereas auxiliary input labels harm it if the input-output relationship changes. We use ingredient-level dielectric driver information as an auxiliary output during training only, motivating concatenation over affine FiLM-style [34] conditioning to avoid the shortcut-reliant failure mode of [35] analyzed in Section VI-C.
Conclusion
This work establishes that active OFDM measurements at 2.4 GHz carry sufficient dielectric information for contact-free, label-free macronutrient estimation in liquid foods—a basis for RF-based dietary sensing as an alternative to label-dependent and vision-based methods. The current synchronized-hardware, fixed-volume testbed, however, is a feasibility study rather than a deployable commodity sensor. The physical sensing chain has two stages—RF signals couple with dielectric constituents, governed by ingredient composition—and ICOT aligns its inference architecture with this chain, decomposing composition identification from composition-conditioned regression. This alignment is empirically active rather than incidental.
ICOT achieves high ID ingredient classification accuracy (–) and overall MAE of 0.101 g/100ml, versus 0.485 g/100ml under OOD-LOCO—outperforming all baselines including FiLM-conditioned and ingredient-free variants. Embedding-shuffle intervention confirms the canonical pathway is functionally active (ID error +660% when shuffled) rather than circumvented, and that concatenation-based fusion is more robust than FiLM under distribution shift.
OOD errors fall into two categories: compositional uniqueness (no training analogue, e.g., 1% Fat Milk, the only unsweetened member of its fat regime) and spectral ambiguity (dissolved sugar overlapping seen formulations’ dielectric spectra, e.g., high-sucrose milk/tea mixtures). These set a clear research agenda: broader carbohydrate concentration coverage, closer-to-isodielectric training beverages, and portable non-synchronized hardware. High-concentration carbohydrate generalization remains the key outstanding problem for the diabetes use case motivating this work.
References
- [1]R. Jumpertz, C. A. Venti, D. S. Le, J. Michaels, S. Parrington, J. Krakoff, and S. Votruba, “Food label accuracy of common snack foods,” Obesity, vol. 21, no. 1, pp. 164–169, 2013.DOI
- [2]C. Roversi, U. Pedersen-Bjergaard, A. M. Serban et al., “Carbohydrate counting accuracy and the effect on glycemic control in people with type 1 diabetes,” Journal of Diabetes Science and Technology, vol. 16, no. 6, pp. 1438–1446, 2022.
- [3]S. I. Kirkpatrick, A. F. Subar, D. Douglass et al., “Performance of the automated self-administered 24-hour recall relative to a measure of true intakes and to an interviewer-administered 24-h recall,” The American Journal of Clinical Nutrition, vol. 100, no. 1, pp. 233–240, 2014.DOI
- [4]Nutrients, Nutrients, Apps, 2021, http://www.myprorganateapps.com/nutrients/.
- [5]myfitnesspal, MyFitnessPal, Inc., 2021, https://www.myfitnesspal.com/.
- [6]mynetdiary, MyNetDiary Inc., 2021, https://www.mynetdiary.com/.
- [7]A. Meyers, N. Johnston, V. Rathod, A. Korattikara, A. Gorban, N. Silbernman, S. Guadarrama, G. Papandreou, J. Huang, and K. P. Murphy, “Im2calories: towards an automated mobile vision food diary,” in Proceedings of the IEEE International Conference on Computer Vision, 2015, pp. 1233–1241.
- [8]R. Tamо, K. Okamoto, and K. Yanai, “Deepfoodcam: A dcnn-based real-time mobile food recognition system,” in Proceedings of the 2nd International Workshop on Multimedia Assisted Dietary Management, 2016, pp. 89–89.
- [9]J.-L. Xu, C. Riccioli, and D.-W. Sun, “Development of an alternative technique for rapid and accurate determination of fish caloric density based on hyperspectral imaging,” Journal of Food Engineering, vol. 190, pp. 185–194, 2016.
- [10]J. Chen and C.-W. Ngo, “Deep-based ingredient recognition for cooking recipe retrieval,” in Proceedings of the 24th ACM international conference on Multimedia, 2016, pp. 32–41.DOI
- [11]A. Barnejee and K. Srinivasan, “WiNE: Monitoring microwave oven leakage to estimate food nutrients and calorie,” Proc. ACM Interact. Mob. Wearable Ubiquitous Technol., vol. 6, no. 3, 2022.
- [12]——, “RFTemp: Monitoring microwave oven leakage to estimate food temperature,” Proc. ACM Interact. Mob. Wearable Ubiquitous Technol., vol. 5, no. 4, 2021.
- [13]A. Dhekne, M. Gowda, Y. Zhao, H. Hassanieh, and R. R. Choudhury, “Liquid: A wireless liquid identifier,” in Proceedings of the 16th Annual International Conference on Mobile Systems, Applications, and Services, ser. MobiSys ’18. New York, NY, USA: Association for Computing Machinery, 2018, p. 442–454. [Online]. Available: https://doi.org/10.1145/3210240.3210345
- [14]A. Stogryn, “Equations for calculating the dielectric constant of saline water,” IEEE Transactions on Microwave Theory and Techniques, vol. 19, no. 8, pp. 733–736, 1971.DOI
- [15]S. O. Nelson, Dielectric Properties of Agricultural Materials and Their Applications. Academic Press, 2005.
- [16]A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, Ł. Kaiser, and I. Polosukhin, “Attention is all you need,” in Advances in Neural Information Processing Systems, vol. 30, 2017, pp. 5998–6008.
- [17]A. R. Von Hippel, Dielectrics and Waves. MIT Press, 1954.DOI
- [18]S. O. Nelson, “Dielectric properties of agricultural products and some applications,” IEEE Transactions on Dielectrics and Electrical Insulation, 2003.
- [19]T. S. Rappaport, Wireless Communications: Principles and Practice. Prentice Hall, 1996.
- [20]D. Tse and P. Viswanath, Fundamentals of Wireless Communication. Cambridge University Press, 2005.DOI
- [21]R. V. Nee and R. Prasad, OFDM for wireless multimedia communications. Artech House Publishers, 2000.
- [22]“Warp project.” [Online]. Available: http://warpproject.org
- [23]U. Kaatze, “Complex permittivity of water as a function of frequency and temperature,” Journal of Chemical and Engineering Data, vol. 34, no. 4, pp. 371–374, 1989.DOI
- [24]A. P. Gregory and R. N. Clarke, “A review of RF and microwave techniques for dielectric measurements on polar liquids,” IEEE Transactions on Dielectrics and Electrical Insulation, vol. 13, no. 4, pp. 727–743, 2006.DOI
- [25]A. Dosovitskiy, L. Beyer, A. Kolesnikov, D. Weissenborn, X. Zhai et al., “An image is worth 16x16 words: Transformers for image recognition at scale,” in International Conference on Learning Representations (ICLR), 2021.
- [26]R. Caruana, “Multitask learning,” Machine Learning, vol. 28, no. 1, pp. 41–75, 1997.
- [27]Y. Bengio, A. Courville, and P. Vincent, “Representation learning: A review and new perspectives,” IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 35, no. 8, pp. 1798–1828, 2013.DOI
- [28]Y. Bengio, J. Louradour, R. Collobert, and J. Weston, “Curriculum learning,” in Proceedings of the 26th Annual International Conference on Machine Learning (ICML), 2009, pp. 41–48.DOI
- [29]D. P. Kingma and J. Ba, “Adam: A method for stochastic optimization,” in International Conference on Learning Representations, 2015.arxiv.org/abs/1412.6980
- [30]X. Wang, L. Gao, S. Mao, and S. MaO, “CSI-based fingerprinting for indoor localization: A deep learning approach,” IEEE Transactions on Vehicular Technology, vol. 66, no. 1, pp. 763–776, 2017.arxiv.org/abs/1603.07080
- [31]D. Halperin, W. Hu, A. Sheth, and D. Wetherall, “Tool release: Gathering 802.11n traces with channel state information,” ACM SIGCOMM Computer Communication Review, vol. 41, no. 1, pp. 53–53, 2011.
- [32]American Beverage Association, “Balance calories initiative: 2021 progress report,” American Beverage Association, Washington, DC, USA, Tech. Rep., 2021.
- [33]Centers for Disease Control and Prevention (CDC), “National health and nutrition examination survey (nhanes), 2017–2018,” Hyattsville, MD, USA, 2018.
- [34]E. Perez, F. Strub, H. de Vries, V. Dumoulin, and A. Courville, “FiLM: Visual reasoning with a general conditioning layer,” in Proceedings of the AAAI Conference on Artificial Intelligence, vol. 32, no. 1, 2018.arxiv.org/abs/1709.07871
- [35]R. Geirhos, J.-H. Jacobsen, C. Michaelis, R. Zemel, W. Brendel, M. Bethge, and F. A. Wichmann, “Shortcut learning in deep neural networks,” Nature Machine Intelligence, vol. 2, no. 11, pp. 665–673, 2020.DOI
- [36]Y. Chen, Z. Cui, and C. C. Yen, “Demo: Chewpin: A wearable acoustic device for chewing detection,” in Adjunct Proceedings of the 2021 ACM International Joint Conference on Pervasive and Ubiquitous Computing and Proceedings of the 2021 ACM International Symposium on Wearable Computers, 2021.DOI
- [37]J. Chan, A. Raghunath, K. E. Michaelsen, and S. Gollakota, “Testing a drop of liquid using smartphone LiDAR,” Proc. ACM Interact. Mob. Wearable Ubiquitous Technol., vol. 6, no. 1, 2022.arxiv.org/abs/2203.07567
- [38]S. Mirzaei, M. Bebawy, A. M. Sharafeldin, and M. Hefeeda, “Mobilyzer: Fine-grained mobile liquid analyzer,” Proc. ACM Interact. Mob. Wearable Ubiquitous Technol., 2025.DOI
- [39]Y. Chen, C. Xu, K. Li, J. Zhang, X. Guo, M. Jin, X. Zheng, and Y. He, “Wireless sensing for material identification: A survey,” IEEE Communications Surveys & Tutorials, vol. 27, pp. 1598–1617, 2025.DOI
- [40]C. Feng, X. Li, L. Chang, J. Xiong, X. Chen, D. Fang, B. Liu, F. Chen, and T. Zhang, “Material identification with commodity Wi-Fi devices,” in Proc. ACM SenSys, 2018, pp. 382–383.DOI
- [41]H. Song, B. Wei, Q. Yu, X. Xiao, and T. Kikkawa, “WiEps: Measurement of dielectric property with commodity WiFi device—an application to ethanol/water mixture,” IEEE Internet of Things Journal, vol. 7, no. 12, pp. 11 667–11 677, 2020.DOI
- [42]Y. Liang, A. Zhou, H. Zhang, X. Wen, and H. Ma, “FG-LiquidID: A contact-less fine-grained liquid identifier by pushing the limits of millimeter-wave sensing,” Proc. ACM Interact. Mob. Wearable Ubiquitous Technol., vol. 5, no. 3, 2021.DOI
- [43]F. Shang, P. Yang, Y. Yan, and X.-Y. Li, “LiqRay: Non-invasive and fine-grained liquid recognition system,” in Proc. ACM MobiCom, 2022, pp. 282–295.DOI
- [44]F. Shang, “PackuQID: In-packet liquid identification using RF signals,” Proc. ACM Interact. Mob. Wearable Ubiquitous Technol., vol. 6, no. 4, 2023.DOI
- [45]Y. Liang, P. Shi, Z. Zheng et al., “tmTaster: A mobile system for fine-grained and robust alcohol sensing,” IEEE Transactions on Mobile Computing, vol. 23, no. 7, 2024.DOI
- [46]U. Ha, J. Leng, A. Khaddaj, and F. Adib, “Food and liquid sensing in practical environments using RFIDs,” in Proc. USENIX NSDI, 2020, pp. 1083–1100.
- [47]S. M. Xie, A. Kumar, R. Jones, F. Khani, T. Ma, and P. Liang, “In-n-out: Pre-training and self-training using auxiliary information for out-of-distribution robustness,” in Proc. ICLR, 2021.arxiv.org/abs/2012.04550






