back

Naan Binary

Multitask seq2seq model for recipe generation and nutritional regression.

PythonPyTorchHuggingFace TransformersFLAN-T5Google ColabPandasNumPy
Naan Binary preview

Overview

Naan Binary is a multitask deep learning system that takes a list of ingredients as input and generates a full recipe while predicting its nutritional profile.

It extends FLAN-T5 with a custom regression head trained jointly on generation and nutrition targets from the Food.com dataset.

Problem

Recipe generation models typically treat the task as pure text generation, ignoring structured nutritional output that users actually care about.

Training a capable seq2seq model under hardware constraints required careful decisions around batch size, precision, and dataset sampling.

Goal: Build a single model that generates coherent recipes and predicts nutritional values from ingredients alone.

Constraints

Hardware limits

Training was constrained to a T4 GPU on Google Colab, requiring mixed precision, gradient checkpointing, and careful sequence length tuning.

Multitask balancing

The generation loss and regression loss needed careful weighting to prevent one task from dominating training.

Data quality

Food.com recipes had inconsistent formatting, missing nutrition fields, and extreme outliers requiring targeted preprocessing.

Key Decisions

FLAN-T5 as backbone

Chose FLAN-T5 for its strong instruction-following pretraining, which transfers well to structured generation tasks like recipes.

Shared encoder, split heads

The encoder is shared between the generation decoder and the regression head, allowing both tasks to benefit from the same ingredient representations.

Colab T4 migration

Migrated from a local RTX 4060 to Google Colab T4 to enable longer training runs, adapting the pipeline for cloud-based checkpointing.

Results

Takeaways