From meal text to carbohydrate to postprandial glucose rise: QLoRA fine-tuning of the Qwen3-4B language model and gradient-boosting prediction in type 2 diabetes

Journal: medRxiv
Published Date:

Abstract

Background. In people with type 2 diabetes (T2D), postprandial glucose weighs on glycaemic control, and carbohydrate counting is difficult. Patients can describe their meal but rarely quantify it. Objective. To assess (1) whether a small open large language model (LLM), fine-tuned on public data, estimates the carbohydrate content of a meal described in words, and (2) what this carbohydrate adds to the prediction of the postprandial glucose rise in two public cohorts. Methods. Step 1: the Qwen3-4B LLM was fine-tuned with QLoRA on Nutrition5k dishes and compared with an automatically matched USDA food composition table and with Qwen3-4B and Qwen3-8B used without training, on test dishes (internal control) and on 100 real meals of ShanghaiT2DM patients, whose reference carbohydrate was computed from the recorded quantities. Step 2: the maximum glucose rise between 0 and 120 minutes ({Delta}Gmax) was predicted by personalised gradient boosting (M2), compared with a spline linear regression and with the Chronos-2 foundation model, using only information available at meal start and person-level cross-validation, in ShanghaiT2DM (people with T2D recruited in two Shanghai hospitals; carbohydrate estimated by the LLM) and CGMacros (free-living adults in Santa Barbara, California; carbohydrate entered in the dataset, no text). Step 3: the model was transferred between datasets. 95% confidence intervals (CI) were obtained by cluster BCa bootstrap (2,000 resamples). Results. On the 100 real meals, the carbohydrate mean absolute error (MAE) of the fine-tuned model was 12.2 [9.9, 15.2] g, almost half that of the table (22.6 g; paired difference -10.5 [-16.8, -6.0] g) and nearly a third of that of the same model without fine-tuning (34.3 g), with a bias of -10.3 g; on test dishes it was 2.2 [2.0, 2.5] g. Personalised gradient boosting (M2) reached a correlation between predicted and observed rises of r = 0.63 [0.55, 0.69] in CGMacros (1,286 meals, 45 adults) and 0.49 [0.42, 0.54] in ShanghaiT2DM (2,339 meals, 99 people with T2D), about twice the linear reference (r = 0.32 and 0.23); for a rise above 50 mg/dL, its area under the ROC curve (AUROC) was 0.80 and 0.74, versus 0.64 and 0.68 with pre-meal glucose alone. Adding carbohydrate to pre-meal glucose changed r by 0.095 [0.068, 0.128] in CGMacros and by 0.004 [-0.010, 0.017] in ShanghaiT2DM; difference between datasets: 0.091 [0.060, 0.126]. Applied from one dataset to the other, the model lost correlation ({Delta}r = -0.11 [-0.17, -0.05] towards ShanghaiT2DM and -0.12 [-0.19, -0.04] towards CGMacros). The full "text [->] LLM [->] glucose" chain was evaluated in ShanghaiT2DM only. Conclusion. An open 4-billion-parameter LLM, fine-tuned with QLoRA on public data and usable offline, almost halves the error of carbohydrate counting for real meals described in words compared with an automatically matched table, with an underestimation of large meals. Personalised gradient boosting, based on pre-meal glucose and the person's usual response, doubles the correlation of a linear reference for predicting the glucose rise in both cohorts. Carbohydrate improved this prediction in CGMacros but not in ShanghaiT2DM; the two datasets differ in many respects, and the cause of this gap is not established.

Authors

  • Bou Ali
  • M. N.; Lassoued
  • N.; Ben Amor
  • B.; Nasr
  • S.; Aouididi
  • M. A.

Categories