How jyansir/tp-berta works
Core Purpose and Project Type
• This is a research-oriented project that adapts a pre-trained language model (RoBERTa) for tabular data prediction by incorporating techniques such as Relative Magnitude Tokenization (RMT) and Intra-feature Attention (IFA).
• Its architecture includes both baseline DNN models (like autoint, dcnv2, mlp, and saint) and the special TP-BERTa model that leverages language modeling techniques.
Break Down the Main Components
a. Model Implementations (bin):
– Contains the implementation of various tabular models.
– Key files include tpberta_modeling.py for the TP-BERTa base class and other baseline models (e.g., autoint.py, dcn2.py, mlp.py, saint.py).
b. Utilities and Core Libraries (lib):
– Includes helper modules for data processing (data.py, data_utils.py), feature engineering (feature_encoder.py), training utilities (optim.py), environmental settings (env.py), and additional modules dedicated to TP-BERTa (lib/saint_lib).
c. Configuration Management (configs):
– Offers default and tuned configuration files for different model types (autoint, catboost, dcnv2, tabnet, xgboost), which help tailor model parameters and training settings.
d. Experiment and Execution Scripts (scripts):
– Houses examples and actual experiment scripts for pre-training (scripts/pretrain) and fine-tuning (scripts/finetune) scenarios. These scripts coordinate the execution of training pipelines and hyperparameter tuning.
e. External Assets:
– External pre-trained models/checkpoints (e.g., RoBERTa under checkpoints/roberta-base) and data preparations (data directory, not shown in the file tree excerpt but mentioned in the README).
Relationships and Interactions
• Data Pipeline: External data (CSV files in the data directory, as per README instructions) is ingested and processed using the classes and utilities defined in lib (data.py, data_utils.py, feature_encoder.py).
• Model Training Flow:
• The configuration files from configs provide the experiment parameters.
• Scripts (in scripts/) drive the training workflow: pre-training TP-BERTa (scripts/pretrain) and fine-tuning (scripts/finetune, with examples provided in scripts/examples).
• These scripts make calls to the model implementations in bin (such as tpberta_modeling.py) and use the helper modules in lib.
• Pre-trained and Fine-tuned Models:
• The system uses pre-trained RoBERTa weights (from checkpoints/roberta-base) that are adapted by TP-BERTa.
• Fine-tuning experiments align with the downstream tabular prediction tasks.
Important Architectural Patterns and Design Principles
• Modularity: There’s a clear separation of concerns – the project separates model code from utilities, configurations, and experiment orchestration.
• Experimentation-Driven: Dedicated scripts and configuration folders support various experiments including pre-training, fine-tuning, and hyperparameter tuning.
• Extensibility: The structure permits adding more baseline models and different configurations (default versus tuned) to experiment with alternative architectures.