georgian-io/Multimodal-Toolkit

Multimodal model for text and tabular data with HuggingFace transformers as building block for text data

Python

618

169 commits

updated May 4, 2026

See the code

README

Multimodal Transformers | Transformers with Tabular Data


Documentation | Colab Notebook | Blog Post

A toolkit for incorporating multimodal data on top of text data for classification and regression tasks. It uses HuggingFace transformers as the base model for text features. The toolkit adds a combining module that takes the outputs of the transformer in addition to categorical and numerical features to produce rich multimodal features for downstream classification/regression layers. Given a pretrained transformer, the parameters of the combining module and transformer are trained based on the supervised task. For a brief literature review, check out the accompanying blog post on Georgian's Impact Blog.

Installation

The code was developed in Python 3.7 with PyTorch and Transformers 4.26.1. The multimodal specific code is in multimodal_transformers folder.

pip install multimodal-transformers

Supported Transformers

The following Hugging Face Transformers are supported to handle tabular data. See the documentation here.

Included Datasets

This repository also includes two kaggle datasets which contain text data and rich tabular features

Working Examples

To quickly see these models in action on say one of the above datasets with preset configurations

$ python main.py ./datasets/Melbourne_Airbnb_Open_Data/train_config.json

Or if you prefer command line arguments run

$ python main.py \
    --output_dir=./logs/test \
    --task=classification \
    --combine_feat_method=individual_mlps_on_cat_and_numerical_feats_then_concat \
    --do_train \
    --model_name_or_path=distilbert-base-uncased \
    --data_path=./datasets/Womens_Clothing_E-Commerce_Reviews \
    --column_info_path=./datasets/Womens_Clothing_E-Commerce_Reviews/column_info.json

main.py expects a json file detailing which columns in a dataset contain text, categorical, or numerical input features. It also expects a path to the folder where the data is stored as train.csv, and test.csv(and if given val.csv).For more details on the arguments see multimodal_exp_args.py.

Notebook Introduction

To see the modules come together in a notebook:
Open In Colab

Included Methods

combine feat methoddescriptionrequires both cat and num features
text_onlyUses just the text columns as processed by a HuggingFace transformer before final classifier layer(s). Essentially equivalent to HuggingFace's ForSequenceClassification modelsFalse
concatConcatenate transformer output, numerical feats, and categorical feats all at once before final classifier layer(s)False
mlp_on_categorical_then_concatMLP on categorical feats then concat transformer output, numerical feats, and processed categorical feats before final classifier layer(s)False (Requires cat feats)
individual_mlps_on_cat_and_numerical_feats_then_concatSeparate MLPs on categorical feats and numerical feats then concatenation of transformer output, with processed numerical feats, and processed categorical feats before final classifier layer(s).False
mlp_on_concatenated_cat_and_numerical_feats_then_concatMLP on concatenated categorical and numerical feat then concatenated with transformer output before final classifier layer(s)True
attention_on_cat_and_numerical_featsAttention based summation of transformer outputs, numerical feats, and categorical feats queried by transformer outputs before final classifier layer(s).False
gating_on_cat_and_num_feats_then_sumGated summation of transformer outputs, numerical feats, and categorical feats before final classifier layer(s). Inspired by Integrating Multimodal Information in Large Pretrained Transformers which performs the mechanism for each token.False
weighted_feature_sum_on_transformer_cat_and_numerical_featsLearnable weighted feature-wise sum of transformer outputs, numerical feats and categorical feats for each feature dimension before final classifier layer(s)False

Simple baseline model

In practice, taking the categorical and numerical features as they are and just tokenizing them and just concatenating them to the text columns as extra text sentences is a strong baseline. To do that here, just specify all the categorical and numerical columns as text columns and set combine_feat_method to text_only. For example for each of the included sample datasets in ./datasets, in train_config.json change combine_feat_method to text_only and column_info_path to ./datasets/{dataset}/column_info_all_text.json.

In the experiments below this baseline corresponds to Combine Feat Method being unimodal.

Results

The following tables shows the results on the two included datasets's respective test sets, by running main.py Non specified parameters are the default.

Review Prediction

Specific training parameters can be seen in datasets/Womens_Clothing_E-Commerce_Reviews/train_config.json.

There are 2 text columns, 3 categorical columns, and 3 numerical columns.

ModelCombine Feat MethodF1PR AUC
Bert Base Uncasedtext_only0.9570.992
Bert Base Uncasedunimodal0.9680.995
Bert Base Uncasedconcat0.9580.992
Bert Base Uncasedindividual_mlps_on_cat_and_numerical_feats_then_concat0.9590.992
Bert Base Uncasedattention_on_cat_and_numerical_feats0.9590.992
Bert Base Uncasedgating_on_cat_and_num_feats_then_sum0.9610.994
Bert Base Uncasedweighted_feature_sum_on_transformer_cat_and_numerical_feats0.9620.994

Pricing Prediction

Specific training parameters can be seen in datasets/Melbourne_Airbnb_Open_Data/train_config.json.

There are 3 text columns, 74 categorical columns, and 15 numerical columns.

ModelCombine Feat MethodMAERMSE
Bert Base Multilingual Uncasedtext_only82.74254.0
Bert Base Multilingual Uncasedunimodal79.34245.2
Bert Base Uncasedconcat65.68239.3
Bert Base Multilingual Uncasedindividual_mlps_on_cat_and_numerical_feats_then_concat66.73237.3
Bert Base Multilingual Uncasedattention_on_cat_and_numerical_feats74.72246.3
Bert Base Multilingual Uncasedgating_on_cat_and_num_feats_then_sum66.64237.8
Bert Base Multilingual Uncasedweighted_feature_sum_on_transformer_cat_and_numerical_feats71.19245.2

Pet Adoption Prediction

Specific training parameters can be seen in datasets/PetFindermy_Adoption_Prediction There are 2 text columns, 14 categorical columns, and 5 numerical columns.

ModelCombine Feat MethodF1_macroF1_micro
Bert Base Multilingual Uncasedtext_only0.0880.281
Bert Base Multilingual Uncasedunimodal0.0890.283
Bert Base Uncasedconcat0.1990.362
Bert Base Multilingual Uncasedindividual_mlps_on_cat_and_numerical_feats_then_concat0.2440.352
Bert Base Multilingual Uncasedattention_on_cat_and_numerical_feats0.2540.375
Bert Base Multilingual Uncasedgating_on_cat_and_num_feats_then_sum0.2750.375
Bert Base Multilingual Uncasedweighted_feature_sum_on_transformer_cat_and_numerical_feats0.2660.380

Citation

We now have a paper you can cite for the Multimodal-Toolkit.

@inproceedings{gu-budhkar-2021-package,
    title = "A Package for Learning on Tabular and Text Data with Transformers",
    author = "Gu, Ken  and
      Budhkar, Akshay",
    booktitle = "Proceedings of the Third Workshop on Multimodal Artificial Intelligence",
    month = jun,
    year = "2021",
    address = "Mexico City, Mexico",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/2021.maiworkshop-1.10",
    doi = "10.18653/v1/2021.maiworkshop-1.10",
    pages = "69--73",
}
huggingface-transformers
multimodal-learning
natural-language-processing
tabular-data
transformer

Significant stargazers

John Kennedy

56 followers · starred Jan 2024

georgian-io/Multimodal-Toolkit

Multimodal model for text and tabular data with HuggingFace transformers as building block for text data

Python

618

169 commits

updated May 4, 2026

See the code

README

Multimodal Transformers | Transformers with Tabular Data


Documentation | Colab Notebook | Blog Post

A toolkit for incorporating multimodal data on top of text data for classification and regression tasks. It uses HuggingFace transformers as the base model for text features. The toolkit adds a combining module that takes the outputs of the transformer in addition to categorical and numerical features to produce rich multimodal features for downstream classification/regression layers. Given a pretrained transformer, the parameters of the combining module and transformer are trained based on the supervised task. For a brief literature review, check out the accompanying blog post on Georgian's Impact Blog.

Installation

The code was developed in Python 3.7 with PyTorch and Transformers 4.26.1. The multimodal specific code is in multimodal_transformers folder.

pip install multimodal-transformers

Supported Transformers

The following Hugging Face Transformers are supported to handle tabular data. See the documentation here.

Included Datasets

This repository also includes two kaggle datasets which contain text data and rich tabular features

Working Examples

To quickly see these models in action on say one of the above datasets with preset configurations

$ python main.py ./datasets/Melbourne_Airbnb_Open_Data/train_config.json

Or if you prefer command line arguments run

$ python main.py \
    --output_dir=./logs/test \
    --task=classification \
    --combine_feat_method=individual_mlps_on_cat_and_numerical_feats_then_concat \
    --do_train \
    --model_name_or_path=distilbert-base-uncased \
    --data_path=./datasets/Womens_Clothing_E-Commerce_Reviews \
    --column_info_path=./datasets/Womens_Clothing_E-Commerce_Reviews/column_info.json

main.py expects a json file detailing which columns in a dataset contain text, categorical, or numerical input features. It also expects a path to the folder where the data is stored as train.csv, and test.csv(and if given val.csv).For more details on the arguments see multimodal_exp_args.py.

Notebook Introduction

To see the modules come together in a notebook:
Open In Colab

Included Methods

combine feat methoddescriptionrequires both cat and num features
text_onlyUses just the text columns as processed by a HuggingFace transformer before final classifier layer(s). Essentially equivalent to HuggingFace's ForSequenceClassification modelsFalse
concatConcatenate transformer output, numerical feats, and categorical feats all at once before final classifier layer(s)False
mlp_on_categorical_then_concatMLP on categorical feats then concat transformer output, numerical feats, and processed categorical feats before final classifier layer(s)False (Requires cat feats)
individual_mlps_on_cat_and_numerical_feats_then_concatSeparate MLPs on categorical feats and numerical feats then concatenation of transformer output, with processed numerical feats, and processed categorical feats before final classifier layer(s).False
mlp_on_concatenated_cat_and_numerical_feats_then_concatMLP on concatenated categorical and numerical feat then concatenated with transformer output before final classifier layer(s)True
attention_on_cat_and_numerical_featsAttention based summation of transformer outputs, numerical feats, and categorical feats queried by transformer outputs before final classifier layer(s).False
gating_on_cat_and_num_feats_then_sumGated summation of transformer outputs, numerical feats, and categorical feats before final classifier layer(s). Inspired by Integrating Multimodal Information in Large Pretrained Transformers which performs the mechanism for each token.False
weighted_feature_sum_on_transformer_cat_and_numerical_featsLearnable weighted feature-wise sum of transformer outputs, numerical feats and categorical feats for each feature dimension before final classifier layer(s)False

Simple baseline model

In practice, taking the categorical and numerical features as they are and just tokenizing them and just concatenating them to the text columns as extra text sentences is a strong baseline. To do that here, just specify all the categorical and numerical columns as text columns and set combine_feat_method to text_only. For example for each of the included sample datasets in ./datasets, in train_config.json change combine_feat_method to text_only and column_info_path to ./datasets/{dataset}/column_info_all_text.json.

In the experiments below this baseline corresponds to Combine Feat Method being unimodal.

Results

The following tables shows the results on the two included datasets's respective test sets, by running main.py Non specified parameters are the default.

Review Prediction

Specific training parameters can be seen in datasets/Womens_Clothing_E-Commerce_Reviews/train_config.json.

There are 2 text columns, 3 categorical columns, and 3 numerical columns.

ModelCombine Feat MethodF1PR AUC
Bert Base Uncasedtext_only0.9570.992
Bert Base Uncasedunimodal0.9680.995
Bert Base Uncasedconcat0.9580.992
Bert Base Uncasedindividual_mlps_on_cat_and_numerical_feats_then_concat0.9590.992
Bert Base Uncasedattention_on_cat_and_numerical_feats0.9590.992
Bert Base Uncasedgating_on_cat_and_num_feats_then_sum0.9610.994
Bert Base Uncasedweighted_feature_sum_on_transformer_cat_and_numerical_feats0.9620.994

Pricing Prediction

Specific training parameters can be seen in datasets/Melbourne_Airbnb_Open_Data/train_config.json.

There are 3 text columns, 74 categorical columns, and 15 numerical columns.

ModelCombine Feat MethodMAERMSE
Bert Base Multilingual Uncasedtext_only82.74254.0
Bert Base Multilingual Uncasedunimodal79.34245.2
Bert Base Uncasedconcat65.68239.3
Bert Base Multilingual Uncasedindividual_mlps_on_cat_and_numerical_feats_then_concat66.73237.3
Bert Base Multilingual Uncasedattention_on_cat_and_numerical_feats74.72246.3
Bert Base Multilingual Uncasedgating_on_cat_and_num_feats_then_sum66.64237.8
Bert Base Multilingual Uncasedweighted_feature_sum_on_transformer_cat_and_numerical_feats71.19245.2

Pet Adoption Prediction

Specific training parameters can be seen in datasets/PetFindermy_Adoption_Prediction There are 2 text columns, 14 categorical columns, and 5 numerical columns.

ModelCombine Feat MethodF1_macroF1_micro
Bert Base Multilingual Uncasedtext_only0.0880.281
Bert Base Multilingual Uncasedunimodal0.0890.283
Bert Base Uncasedconcat0.1990.362
Bert Base Multilingual Uncasedindividual_mlps_on_cat_and_numerical_feats_then_concat0.2440.352
Bert Base Multilingual Uncasedattention_on_cat_and_numerical_feats0.2540.375
Bert Base Multilingual Uncasedgating_on_cat_and_num_feats_then_sum0.2750.375
Bert Base Multilingual Uncasedweighted_feature_sum_on_transformer_cat_and_numerical_feats0.2660.380

Citation

We now have a paper you can cite for the Multimodal-Toolkit.

@inproceedings{gu-budhkar-2021-package,
    title = "A Package for Learning on Tabular and Text Data with Transformers",
    author = "Gu, Ken  and
      Budhkar, Akshay",
    booktitle = "Proceedings of the Third Workshop on Multimodal Artificial Intelligence",
    month = jun,
    year = "2021",
    address = "Mexico City, Mexico",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/2021.maiworkshop-1.10",
    doi = "10.18653/v1/2021.maiworkshop-1.10",
    pages = "69--73",
}
huggingface-transformers
multimodal-learning
natural-language-processing
tabular-data
transformer

Significant stargazers

John Kennedy

56 followers · starred Jan 2024

Languages

Python

100.0%