This project implements a multilingual idiom detection system using BERT-based models for Turkish and Italian languages. The system is designed to identify idiomatic expressions in text using sequence labeling techniques.
You can try out the model using our Google Colab notebook.
You can install the required packages using pip and the requirements.txt file:
.
├── src/ # Source code directory
│ ├── model.py # Core model architecture
│ ├── dataset.py # Dataset handling
│ ├── trainer.py # Training and evaluation logic
│ ├── main.py # Main execution script
│ ├── bert_embedder.py # BERT embedding utilities
│ ├── collate.py # Data collation functions
│ ├── hparams.py # Hyperparameter definitions
│ ├── utils.py # Utility functions
│ ├── scoring.py # Scoring program implementation
│ ├── __init__.py # Package initialization
│ └── checkpoints # Model checkpoints directory
│ ├── tr # Turkish model checkpoints
│ └── it # Italian model checkpoints
├── resources # Dataset directory
│ ├── ID10M
│ ├── ITU
│ ├── PARSEME
│ └── COMBINED
├── results # Training results and visualizations
├── data # Data directory
├── scoring_program # Evaluation scoring program
├── papers # Research papers and documentation
├── proposal # Project proposal documents
The system supports multiple datasets for training and evaluation:
ID10M Dataset
ITU Dataset
PARSEME Dataset
COMBINED Dataset
ITU_TRAIN_DEV Dataset
Each dataset is stored in the resources/ directory under its respective folder. The data is in TSV format with three columns:
The system uses a hybrid architecture combining:
The model's hyperparameters can be configured by modifying the parameters in src/hparams.py. The available parameters include:
dropout: Dropout rate (default: 0.5)num_classes: Number of output classes (default: 4)bidirectional: Whether to use bidirectional LSTM (default: True)num_layers: Number of LSTM layers (default: 3)use_lstm: Whether to use LSTM layers (default: True)use_attention: Whether to use attention mechanism (default: False)device: Device to run the model on (default: "cuda" if available, else "cpu")batch_size: Batch size for training (default: 32)lr: Learning rate (default: 0.001)epoch: Number of training epochs (default: 50)warmup_steps: Number of warmup steps (default: 1000)weight_decay: Weight decay for regularization (default: 0.001)gradient_clip: Gradient clipping value (default: 1)scheduler_factor: Learning rate scheduler factor (default: 0.5)scheduler_patience: Learning rate scheduler patience (default: 3)focal_loss_weight: Weight for focal loss component (default: 0.3)The training process consists of two phases:
Task-Specific Training:
BERT Fine-tuning (Optional):
The system supports three main modes of operation: training, testing, and updating. Each mode serves a different purpose and has specific requirements.
python src/main.py
When prompted:
This mode trains new models from scratch without loading any existing checkpoints. To use a custom dataset:
train.csv, dev.csv, and test.csv files into the ./data/CUSTOM/ folder.dev.csv must contain labels (used for F1 score calculation), while test.csv should not contain labels (used for generating predictions).train.csv, dev.csv, and test.csv) are required.dev.csv (if test_mode is 'dev' for evaluation) or test.csv (if test_mode is 'test' for predictions).python src/main.py
When prompted:
This mode loads existing checkpoints and continues training from those points. It's used when:
For both testing and updating modes, you can choose to use different checkpoints for Turkish and Italian models, or select "none" if you don't want to use a checkpoint for a particular language.
python src/main.py
When prompted:
This mode loads pre-trained models and performs inference without any training.
The system provides comprehensive evaluation metrics:
Results are saved in the results/ directory, including:
All experiment results are saved in the results/ directory. Each experiment gets its own folder with a naming convention that includes key information about the experiment:
results/
└── datasetname_trmodelname_itmodelname_lr_.../
├── prediction.csv # Model predictions
├── scores.json # Evaluation scores
├── results.pdf # Detailed evaluation report
├── dev_acc.png # Development accuracy plot
├── dev_f1.png # Development F1 score plot
├── loss.png # Training vs validation loss plot
├── tr_loss.png # Turkish model loss plot
├── it_loss.png # Italian model loss plot
└── bert_weight_changes.png # BERT weight changes during fine-tuning
The folder name includes:
For example: itu_basetr_xxlit_0005_regulizer_focalloss_trainbertafter15_lowerlr_40epoch
Note: Not all experiment folders will contain the complete set of files shown above. Some folders might have fewer files if the training run was interrupted or if certain evaluation steps were skipped. The presence of specific files depends on the training progress and configuration.
Checkpoints are saved in:
checkpoints/tr/ for Turkish modelscheckpoints/it/ for Italian modelsEfe Can Kırbıyık
Berke Kurt
Python
86.4%
Jupyter Notebook
13.6%
This project implements a multilingual idiom detection system using BERT-based models for Turkish and Italian languages. The system is designed to identify idiomatic expressions in text using sequence labeling techniques.
You can try out the model using our Google Colab notebook.
You can install the required packages using pip and the requirements.txt file:
.
├── src/ # Source code directory
│ ├── model.py # Core model architecture
│ ├── dataset.py # Dataset handling
│ ├── trainer.py # Training and evaluation logic
│ ├── main.py # Main execution script
│ ├── bert_embedder.py # BERT embedding utilities
│ ├── collate.py # Data collation functions
│ ├── hparams.py # Hyperparameter definitions
│ ├── utils.py # Utility functions
│ ├── scoring.py # Scoring program implementation
│ ├── __init__.py # Package initialization
│ └── checkpoints # Model checkpoints directory
│ ├── tr # Turkish model checkpoints
│ └── it # Italian model checkpoints
├── resources # Dataset directory
│ ├── ID10M
│ ├── ITU
│ ├── PARSEME
│ └── COMBINED
├── results # Training results and visualizations
├── data # Data directory
├── scoring_program # Evaluation scoring program
├── papers # Research papers and documentation
├── proposal # Project proposal documents
The system supports multiple datasets for training and evaluation:
ID10M Dataset
ITU Dataset
PARSEME Dataset
COMBINED Dataset
ITU_TRAIN_DEV Dataset
Each dataset is stored in the resources/ directory under its respective folder. The data is in TSV format with three columns:
The system uses a hybrid architecture combining:
The model's hyperparameters can be configured by modifying the parameters in src/hparams.py. The available parameters include:
dropout: Dropout rate (default: 0.5)num_classes: Number of output classes (default: 4)bidirectional: Whether to use bidirectional LSTM (default: True)num_layers: Number of LSTM layers (default: 3)use_lstm: Whether to use LSTM layers (default: True)use_attention: Whether to use attention mechanism (default: False)device: Device to run the model on (default: "cuda" if available, else "cpu")batch_size: Batch size for training (default: 32)lr: Learning rate (default: 0.001)epoch: Number of training epochs (default: 50)warmup_steps: Number of warmup steps (default: 1000)weight_decay: Weight decay for regularization (default: 0.001)gradient_clip: Gradient clipping value (default: 1)scheduler_factor: Learning rate scheduler factor (default: 0.5)scheduler_patience: Learning rate scheduler patience (default: 3)focal_loss_weight: Weight for focal loss component (default: 0.3)The training process consists of two phases:
Task-Specific Training:
BERT Fine-tuning (Optional):
The system supports three main modes of operation: training, testing, and updating. Each mode serves a different purpose and has specific requirements.
python src/main.py
When prompted:
This mode trains new models from scratch without loading any existing checkpoints. To use a custom dataset:
train.csv, dev.csv, and test.csv files into the ./data/CUSTOM/ folder.dev.csv must contain labels (used for F1 score calculation), while test.csv should not contain labels (used for generating predictions).train.csv, dev.csv, and test.csv) are required.dev.csv (if test_mode is 'dev' for evaluation) or test.csv (if test_mode is 'test' for predictions).python src/main.py
When prompted:
This mode loads existing checkpoints and continues training from those points. It's used when:
For both testing and updating modes, you can choose to use different checkpoints for Turkish and Italian models, or select "none" if you don't want to use a checkpoint for a particular language.
python src/main.py
When prompted:
This mode loads pre-trained models and performs inference without any training.
The system provides comprehensive evaluation metrics:
Results are saved in the results/ directory, including:
All experiment results are saved in the results/ directory. Each experiment gets its own folder with a naming convention that includes key information about the experiment:
results/
└── datasetname_trmodelname_itmodelname_lr_.../
├── prediction.csv # Model predictions
├── scores.json # Evaluation scores
├── results.pdf # Detailed evaluation report
├── dev_acc.png # Development accuracy plot
├── dev_f1.png # Development F1 score plot
├── loss.png # Training vs validation loss plot
├── tr_loss.png # Turkish model loss plot
├── it_loss.png # Italian model loss plot
└── bert_weight_changes.png # BERT weight changes during fine-tuning
The folder name includes:
For example: itu_basetr_xxlit_0005_regulizer_focalloss_trainbertafter15_lowerlr_40epoch
Note: Not all experiment folders will contain the complete set of files shown above. Some folders might have fewer files if the training run was interrupted or if certain evaluation steps were skipped. The presence of specific files depends on the training progress and configuration.
Checkpoints are saved in:
checkpoints/tr/ for Turkish modelscheckpoints/it/ for Italian modelsEfe Can Kırbıyık
Berke Kurt
Python
86.4%
Jupyter Notebook
13.6%