Malcolm Low | Practical AI, Computing & Quantum Research

Singapore-based practical guides, tutorials and experiments in AI, computing, modelling, simulation, optimisation and quantum computing, with research notes and hands-on workflows.

, , , ,

Pocket Data Science X: Mobile GBDT for LLM Preferences

Yes, GBDTs beat raw heuristics. Overlooking lexical complexity and prompt coverage inflates multi-class log loss. See our 58-feature mobile GBDT pipeline →

·

Written by

POCKET DATA SCIENCE SERIES • PART X

Mobile GBDT Machine Learning for LMSYS Human Preference

Engineering 58 linguistic, structural, and semantic alignment signals on Android Termux to train LightGBM and CatBoost ensembles under strict mobile memory budgets.

In Part IX, team Pocket Data Lab established a zero-assumption baseline ladder for Kaggle’s LMSYS Chatbot Arena human preference benchmark. By combining class frequency priors with a calibrated continuous length disparity model, we scored an out-of-fold Multi-Class Log Loss of 1.07296 across 57,477 battles and achieved an official Kaggle public leaderboard standing of 1.07823 (placing Rank #222 out of 291 teams) without tuning a single machine learning parameter.

While static heuristics successfully exploit high-level behavioral biases—namely human verbosity bias and markdown formatting cues—they hit a rigid performance ceiling. Simple linear rules cannot model non-linear trade-offs: an excessively long response that fails to address the user’s prompt is heavily penalized as rambling or hallucinatory, while a concise answer rich in technical vocabulary frequently beats a repetitive essay. Capturing these subtle interaction dynamics requires supervised machine learning.

In this milestone installment, we advance from deterministic heuristics to competitive supervised learning on handheld edge hardware. Operating entirely inside Android Termux PRoot Linux, we engineer a 58-dimensional linguistic and semantic feature matrix, benchmark regularized multinomial logistic regression against native Gradient Boosted Decision Trees (LightGBM and CatBoost), and optimize a dual-GBDT blended ensemble that drives out-of-fold Log Loss down from 1.07296 to 1.03493 (a massive +0.06230 improvement over empirical prior baselines).

Curriculum Context: This article forms Module 10 in Track 6 (Generative AI Alignment & LMSYS Human Preference) of our complete edge machine learning roadmap. For the full structural curriculum and hands-on tracks, explore the Pocket Data Science Complete Learning Path.

1 · The Edge Memory Challenge: 58 Dense Features in 14 Seconds

The LMSYS Chatbot Arena competition dataset presents a demanding computational workload for mobile devices: train.csv spans 57,477 rows and 184 MB on disk, containing unconstrained, multi-paragraph prompts and pair-wise LLM responses. On an Android smartphone constrained to a 2 to 4 GB RAM working ceiling, loading full raw text into Python objects and running iterative loops would quickly trigger Out-Of-Memory (OOM) kernel terminations.

To overcome mobile hardware constraints, team Pocket Data Lab designed a fully vectorized, single-pass feature extraction engine using optimized pandas string vectorization, NumPy C-extensions, and Python hash sets. The engine extracts 58 numeric features across 5 distinct linguistic and behavioral families in just 14.36 seconds on mobile CPU:

Linguistic & Behavioral Feature Families (58 Total Dimensions)
  • 1. Surface Length & Proportions: Character counts (len_p, len_a, len_b), absolute differences (len_diff), normalized disparity ratio (len_a - len_b) / (len_a + len_b + 1), and prompt-relative expansion ratios (len_ratio_p_a, len_ratio_p_b, len_ratio_p_diff).
  • 2. Lexical Density & Readability: Word counts (words_a, words_b, words_diff, words_ratio) and average word length (mean_word_len_a, mean_word_len_b, mean_word_len_diff), measuring information density and vocabulary maturity.
  • 3. Structural & Markdown Formatting: Code block indicators (has_code_a, has_code_b, code_diff, count_code_diff), unordered bullet lists (list_diff), numbered lists (num_list_diff), markdown headers (header_diff), bold emphasis tags (bold_diff), and paragraph newline frequency (newline_diff).
  • 4. Stylistic & Politeness Markers: Punctuation intensity (exclamation marks excl_diff, question marks quest_diff), apologetic hedging (sorry_diff detecting “I apologize”, “sorry”), and affirmative openings (sure_diff detecting “Sure!”, “Certainly!”).
  • 5. Prompt-Response Semantic Alignment: Lexical Jaccard similarity between prompt word set and response word sets (jaccard_a, jaccard_b, jaccard_diff) and prompt keyword coverage/recall (cov_a, cov_b, cov_diff), measuring whether the model answered the actual prompt.

Crucially, our pipeline enforces strict pairwise symmetry: for every feature computed on Model A and Model B, we calculate both absolute differentials f_A - f_B and normalized relative ratios (f_A - f_B) / (f_A + f_B + \epsilon), ensuring the machine learning models learn directional preference without positional bias.


2 · Evaluation Metric & Formal Mathematical Definitions

In competitive human preference modeling, evaluation is governed by Multi-Class Logarithmic Loss across all pairwise comparisons:

L = – (1 / N) * ∑_{i=1}^N ∑_{k ∈ {A, B, tie}} y_{i,k} * ln(p_{i,k})

As derived in our companion guide Multi-Class Log Loss Explained, Log Loss severely punishes overconfident errors: predicting p_{i,k} → 0 for the true winning class results in ln(p_{i,k}) → -\infty, destroying leaderboard standing. To maintain complete technical rigor, all variables in our pipeline are formally defined below:

Symbol / Variable Domain / Type Mathematical Purpose
N Integer (57,477) Total number of pairwise battles evaluated in cross-validation.
y_{i,k} Binary {0, 1} Ground truth one-hot indicator for winner class k ∈ {A, B, tie}.
p_{i,k} Real (0.0, 1.0) Predicted calibrated probability satisfying ∑_k p_{i,k} = 1.0.
eps Constant 1e-15 Numerical stability clipping threshold bounding probabilities inside [eps, 1 - eps].
X ∈ R^{57477 × 58} Feature Matrix The 58 dense linguistic and behavioral features extracted per comparison.
w_LGB, w_CB Real [0.0, 1.0] Convex ensemble blend weights optimized via Sequential Least Squares Programming.

3 · The 4-Experiment Machine Learning Ladder

To measure the exact contribution of feature engineering versus model family complexity, we conducted a rigorous 5-Fold Stratified Cross-Validation benchmark across all 57,477 training battles using random_state=42:

Experiment 1 · Calibrated Multinomial Logistic Regression (L2)

We first trained an L2-regularized multinomial logistic regression model (C=0.1) on standard-scaled features. As a generalized linear model, it models log-odds as linear combinations of the 58 features. The 5-fold out-of-fold Log Loss dropped to 1.05613. Submitted to Kaggle via standalone notebook (Submission Ref 57667634), it achieved an official public score of 1.06173—a sharp +0.01683 improvement over the Part IX calibrated heuristic. This proved that lexical density, punctuation, and prompt overlap carry substantial orthogonal predictive power beyond simple response lengths.

Experiment 2 · LightGBM MultiClass GBDT

Next, we deployed LightGBM (LGBMClassifier) configured for 3-class multi-logloss optimization with depth-bounded trees (max_depth=6, num_leaves=31, learning_rate=0.05, colsample_bytree=0.8). Unlike linear models, LightGBM learns non-linear decision splits and feature interactions—such as penalizing length when prompt Jaccard overlap is near zero. LightGBM achieved an out-of-fold Log Loss of 1.03601 (a dramatic +0.03695 reduction compared to Part IX).

Experiment 3 · CatBoost MultiClass Classifier

To achieve structural diversity, we introduced CatBoost (CatBoostClassifier) using oblivious symmetric decision trees (depth=5, learning_rate=0.06, iterations=400). Oblivious trees evaluate the same split condition across entire levels, acting as a natural regularizer against overfitting on subtle linguistic noise. CatBoost delivered a 5-fold out-of-fold Log Loss of 1.03594, slightly edging out LightGBM.

Experiment 4 · The Dual-GBDT Blended Ensemble

Finally, we combined the out-of-fold probability vectors of all models using bounded Sequential Least Squares Programming (SLSQP) to find the convex optimal blend. The optimizer allocated 50.6% weight to LightGBM and 49.4% weight to CatBoost (assigning 0% to the linear and heuristic priors, as the trees fully subsumed their signal). The blended ensemble scored a 5-fold out-of-fold Log Loss of 1.03493—our lowest error recorded across the series. Submitted to Kaggle via our automated edge runner, the ensemble scored an official 1.04158 on the public leaderboard, surging 52 positions up the global rankings to Rank #170 out of 290 teams (top 58.6%).


4 · Feature Importance: What Actually Drives Human LLM Preference?

Examining the tree split importances across all 5 folds of LightGBM reveals a profound insight into generative AI human evaluation. Contrary to common belief, raw character length is not the primary driver of human preference:

Feature Name Feature Category Mean Split Importance
mean_word_len_diff Lexical Complexity 721.0
mean_word_len_b Lexical Complexity 654.4
jaccard_diff Semantic Alignment 624.2
mean_word_len_a Lexical Complexity 612.2
cov_diff Semantic Alignment 605.2
jaccard_a Semantic Alignment 598.2
jaccard_b Semantic Alignment 504.2
len_ratio_p_b Surface Length 490.6
cov_b Semantic Alignment 479.8
len_diff Surface Length 468.8

The empirical data demonstrates two vital principles:

  • 1. Precision Over Length: mean_word_len_diff (importance 721.0) is the single most influential feature in the entire ensemble. Human raters strongly prefer models that utilize precise, domain-appropriate vocabulary over models that stretch answers with monosyllabic filler words.
  • 2. Semantic Prompt Grounding: The lexical alignment disparity (jaccard_diff at 624.2 and cov_diff at 605.2) heavily outranks raw length differences (len_diff at 468.8). A model that repeats or addresses the key technical entities in the user’s query consistently wins human votes over a verbose model with low query overlap.

5 · Master Benchmark Performance Summary

The progression from zero-assumption statistical priors to our dual-GBDT mobile ensemble demonstrates consistent, monotonic error reduction across all 57,477 battles:

Methodology & Model 5-Fold CV Log Loss Kaggle Public Score (LB)
1. Maximum-Entropy Uniform Prior 1.09861 1.09861 (Ref 57649227)
2. Empirical Class Frequency Prior 1.09723 1.09794 (Ref 57649280)
3. Part IX Calibrated Non-ML Heuristics 1.07296 1.07823 (Ref 57634137)
4. Calibrated L2 Logistic Regression 1.05613 1.06173 (Ref 57667634)
5. Standalone CatBoost MultiClass Classifier 1.03594 1.04455 (Ref 57667637)
6. Standalone LightGBM MultiClass GBDT 1.03601 1.04081 (Ref 57667635)
7. Dual GBDT Blended Ensemble (51% LGB + 49% CB) 1.03493 (CV) 1.04158 (Ref 57657442 • Rank #170)

6 · Kaggle Code Competition Submission Architecture

In Kaggle’s Code Competition format, internet access is disabled and submissions must execute inside a self-contained notebook container against withheld test sets. Because our feature extraction and training pipeline executes in under 60 seconds on CPU hardware, our notebook trains the full dual-GBDT model natively on worker startup without requiring pre-uploaded model artifacts:

# Pocket Data Science Part X: Self-Contained Kaggle Notebook Submission
import numpy as np
import pandas as pd
import lightgbm as lgb
from catboost import CatBoostClassifier

# 1. Load data and extract 58 vectorized features in 14s
X_train = extract_features(train_df)
X_test = extract_features(test_df)

# 2. Train LightGBM MultiClass GBDT
lgb_model = lgb.LGBMClassifier(
    objective='multiclass', num_class=3, metric='multi_logloss',
    learning_rate=0.05, num_leaves=31, max_depth=6, n_estimators=160,
    random_state=42, n_jobs=4, verbose=-1
)
lgb_model.fit(X_train, y_train)
p_lgb = lgb_model.predict_proba(X_test)

# 3. Train CatBoost MultiClass Classifier
cb_model = CatBoostClassifier(
    loss_function='MultiClass', iterations=300, learning_rate=0.06,
    depth=5, random_seed=42, thread_count=4, verbose=0
)
cb_model.fit(X_train, y_train)
p_cb = cb_model.predict_proba(X_test)

# 4. Optimal convex blend and epsilon probability clipping
p_ens = 0.506 * p_lgb + 0.494 * p_cb
p_ens = np.clip(p_ens, 1e-15, 1.0 - 1e-15)
p_ens = p_ens / np.sum(p_ens, axis=1, keepdims=True)

# 5. Output submission
sub = pd.DataFrame({
    'id': test_df['id'],
    'winner_model_a': p_ens[:, 0],
    'winner_model_b': p_ens[:, 1],
    'winner_tie': p_ens[:, 2]
})
sub.to_csv('submission.csv', index=False)

The notebook is maintained on Kaggle at myhlow/llm-preference-mobile-gbdt-pocket-data-lab, providing complete reproducibility from smartphone shell to competition leaderboard.

Continue the Pocket Data Science Series

Pocket Data Science Series 2026  ·  Engineered on Android Termux & PRoot Linux

✦ Benchmarked and verified by team Pocket Data Lab on Kaggle ✦

Comments

One response to “Pocket Data Science X: Mobile GBDT for LLM Preferences”

  1. Pocket Data Science: Full Mobile ML & Kaggle Roadmap – Malcolm Low | Practical AI, Computing & Quantum Research Avatar

    […] for multi-class log loss, and placing Rank #222 out of 291 teams with zero neural weights. 11 Part X — LMSYS Chatbot Arena: Mobile GBDT Machine Learning & Dual Ensemble Feature extraction across 58 linguistic, readability, and interaction signals in 14.36s: 5-fold […]

    Like

Leave a Reply