Liquid AI Spam Classifier โ€” How-To & References

What this project does: Fine-tunes Liquid AI's LFM2.5-1.2B-Instruct model on Apple Silicon using HuggingFace's TRL SFTTrainer with PEFT LoRA adapters, to classify emails as spam or ham. Uses the official Liquid4All cookbook configuration.

๐Ÿš€ Quick Start

# 1. Activate the project virtual environment
cd "spam-classifier-liquid"
source venv/bin/activate

# 2. Install dependencies (first run only)
pip install -r requirements.txt

# 3. Copy training data from the MLX project
mkdir -p training_data
cp ../spam-classifier-mlx/training_data/train.jsonl training_data/
cp ../spam-classifier-mlx/training_data/test.jsonl training_data/

# 4. Fine-tune with LoRA via TRL SFTTrainer
python3 fine_tune.py

# 5. Launch the Gradio web app
python3 app.py

# 6. Or open the notebook
jupyter notebook spam_classifier_liquid.ipynb
Model architecture note: LFM2.5 is a hybrid model that uses attention, GLU (gated linear units), and convolutional layers. That's why the LoRA target_modules list includes both q_proj/k_proj/v_proj/out_proj (attention) and w1/w2/w3 (GLU) and in_proj (conv). These exact module names come from the Liquid4All cookbook โ€” see the guide below.

๐Ÿ“„ Project-Specific Papers

LFM2 Technical Report local
Liquid AI Team (2025) ยท arXiv:2511.23404
The official technical report for the LFM2 model family (the parent of LFM2.5-1.2B-Instruct). Describes the hybrid architecture โ€” a mix of attention, convolutional, and gated linear units inspired by biological neural circuits โ€” and the training process.

๐Ÿ“˜ Liquid AI Official Documentation & Cookbook

Liquid AI Documentation Home local
docs.liquid.ai
Landing page for all Liquid AI documentation. Use this as a starting point to navigate their docs.
Fine-Tuning with TRL local
docs.liquid.ai TRL guide
Liquid AI's official guide for fine-tuning LFM2 models with HuggingFace TRL. This is the method our project uses. Covers how to set up SFTTrainer, what LoRA parameters work well for LFM2, and example configurations.
Fine-Tuning with Unsloth local
docs.liquid.ai Unsloth guide
Alternative fine-tuning method using Unsloth (2-5x faster than vanilla TRL). Not used in our project, but worth comparing if you ever want to retrain faster.
Dataset Format Guide local
docs.liquid.ai datasets
Explains the dataset formats LFM2 fine-tuning expects. Essential reading if you want to add new training data or change the conversation format.
Liquid4All SFT with TRL Notebook local
Liquid4All cookbook
Source of our LoRA configuration. This is the official notebook that defines the exact target_modules list, rank, alpha, and training arguments the Liquid project uses. Open with Jupyter to see every step.
Liquid4All SFT with Unsloth Notebook local
Liquid4All cookbook
Alternative notebook using Unsloth for 2-5x faster training. Uses 16-bit LoRA with gradient checkpointing.

๐Ÿ”— Shared References

The LoRA paper, QLoRA, the Attention Is All You Need paper, and HuggingFace PEFT/TRL/chat-template docs all apply to this project. They live in the shared folder:

๐Ÿ“‚ Open the Shared References Index shared
Papers: Attention, LoRA, QLoRA, PEFT Survey. Guides: HF PEFT Quicktour, HF PEFT LoRA Conceptual, HF TRL SFTTrainer, HF Chat Templates, Unsloth docs.

๐ŸŒ Online-Only References

LFM2.5-1.2B-Instruct on HuggingFace online
The exact model we fine-tune. Model card includes benchmarks, usage examples, and license info.
LiquidAI HuggingFace organization online
Full catalog of Liquid AI models including larger LFM2-2.6B and LFM2-8B-A1B (MoE) variants.
Liquid4All cookbook (GitHub) online
Full cookbook repo with all Liquid AI fine-tuning examples, not just the TRL and Unsloth notebooks we saved locally.
Liquid AI company website online
Company background, blog posts, and model announcements.

๐Ÿ“š Citations

Liquid AI Team. (2025). LFM2 Technical Report. arXiv:2511.23404.
  https://arxiv.org/abs/2511.23404

Hu, E., et al. (2021). LoRA: Low-Rank Adaptation of Large Language Models.
  arXiv:2106.09685.

von Werra, L., et al. (2020). TRL: Transformer Reinforcement Learning.
  https://github.com/huggingface/trl

Mangrulkar, S., Gugger, S., Debut, L., Belkada, Y., Paul, S., & Bossan, B. (2022).
  PEFT: State-of-the-art Parameter-Efficient Fine-Tuning methods.
  https://github.com/huggingface/peft