Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🤖 Remove pydantic models #37

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions tests/cli/test_classification.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
from pathlib import Path

import pytest
from typer.testing import CliRunner

from tests.constants import FIXTURES_PATH
from turbo_alignment.cli import app
from turbo_alignment.settings.pipelines.train.classification import (
ClassificationTrainExperimentSettings,
)

runner = CliRunner()


def test_classification_train():
result = runner.invoke(
app,
[
'train_classification',
'--experiment_settings_path',
FIXTURES_PATH / 'configs/train/classification/base.json',
],
catch_exceptions=False,
)
@pytest.mark.parametrize(
'config_path',
[
FIXTURES_PATH / 'configs/train/classification/base.json',
],
)
def test_classification_train(config_path: Path):
result = runner.invoke(app, ['train_classification', '--experiment_settings_path', str(config_path)])
assert result.exit_code == 0
assert Path('test_train_classification_output').is_dir()


if __name__ == '__main__':
test_classification_train()
assert ClassificationTrainExperimentSettings.parse_file(config_path).log_path.is_dir()
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
},
"generation_settings": [
{
"transformers_settings": {
"generation_config": {
"num_beams": 1,
"max_new_tokens": 8
},
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/configs/inference/rag/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"generation_settings": [
{
"transformers_settings": {
"generation_config": {
"num_beams": 1,
"max_new_tokens": 10,
"repetition_penalty": 1.2,
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/configs/inference/sft/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"generation_settings": [
{
"transformers_settings": {
"generation_config": {
"num_beams": 3,
"max_new_tokens": 8
},
Expand Down
19 changes: 13 additions & 6 deletions tests/fixtures/configs/train/classification/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,18 @@
"problem_type": "single_label_classification"
},
"peft_settings": {
"r": 8,
"lora_alpha": 16,
"lora_dropout": 0.05,
"target_modules": ["q_proj", "v_proj"],
"task_type": "SEQ_CLS"
"name": "LORA",
"config": {
"r": 8,
"lora_alpha": 16,
"lora_dropout": 0.05,
"target_modules": [
"q_proj",
"v_proj"
],
"task_type": "CAUSAL_LM",
"modules_to_save": ["embed_tokens", "lm_head"]
}
}
},
"tokenizer_settings": {},
Expand All @@ -92,7 +99,7 @@
"eos_token": "</s>",
"pad_token": "<pad>"
},
"trainer_settings": {
"training_arguments": {
"evaluation_strategy": "steps",
"per_device_train_batch_size": 1,
"per_device_eval_batch_size": 1,
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/configs/train/ddpo/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"adapter_path": "tests/fixtures/models/llama2_tiny_rm"
},
"cherry_pick_settings": {
"generator_transformers_settings": {
"generation_config": {
"num_beams": 1,
"do_sample": false,
"max_new_tokens": 8
Expand Down Expand Up @@ -132,7 +132,7 @@
"eos_token": "</s>",
"pad_token": "<pad>"
},
"trainer_settings": {
"training_arguments": {
"evaluation_strategy": "steps",
"per_device_train_batch_size": 1,
"per_device_eval_batch_size": 1,
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/configs/train/dpo/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"is_trainable": true
},
"cherry_pick_settings": {
"generator_transformers_settings": {
"generation_config": {
"num_beams": 1,
"do_sample": false,
"stop_strings": "</RS>",
Expand Down Expand Up @@ -111,7 +111,7 @@
"eos_token": "</s>",
"pad_token": "<pad>"
},
"trainer_settings": {
"training_arguments": {
"evaluation_strategy": "steps",
"per_device_train_batch_size": 2,
"per_device_eval_batch_size": 2,
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/configs/train/dpo/simpo.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"is_trainable": true
},
"cherry_pick_settings": {
"generator_transformers_settings": {
"generation_config": {
"num_beams": 1,
"do_sample": false,
"stop_strings": "</RS>",
Expand Down Expand Up @@ -103,7 +103,7 @@
"eos_token": "</s>",
"pad_token": "<pad>"
},
"trainer_settings": {
"training_arguments": {
"evaluation_strategy": "steps",
"per_device_train_batch_size": 2,
"per_device_eval_batch_size": 2,
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/configs/train/kto/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"is_trainable": true
},
"cherry_pick_settings": {
"generator_transformers_settings": {
"generation_config": {
"num_beams": 1,
"do_sample": false,
"stop_strings": "</RS>",
Expand Down Expand Up @@ -89,7 +89,7 @@
"eos_token": "</s>",
"pad_token": "<pad>"
},
"trainer_settings": {
"training_arguments": {
"evaluation_strategy": "steps",
"per_device_train_batch_size": 4,
"per_device_eval_batch_size": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,18 @@
"model_type": "causal",
"transformers_settings": {},
"peft_settings": {
"r": 16,
"lora_alpha": 16,
"lora_dropout": 0.05,
"target_modules": [
"q_proj",
"k_proj"
],
"task_type": "CAUSAL_LM",
"modules_to_save": [
"embed_tokens",
"lm_head"
],
"name": "LORA"
"name": "LORA",
"config": {
"r": 8,
"lora_alpha": 16,
"lora_dropout": 0.05,
"target_modules": [
"q_proj",
"v_proj"
],
"task_type": "CAUSAL_LM",
"modules_to_save": ["embed_tokens", "lm_head"]
}
},
"embeddings_initialization_strategy": {
"<RS>": "bot",
Expand All @@ -108,7 +107,7 @@
"eos_token": "</s>",
"pad_token": "<pad>"
},
"trainer_settings": {
"training_arguments": {
"evaluation_strategy": "epoch",
"save_strategy": "epoch",
"per_device_train_batch_size": 1,
Expand Down Expand Up @@ -147,7 +146,7 @@
"audio": null
},
"cherry_pick_settings": {
"generator_transformers_settings": {
"generation_config": {
"num_beams": 1,
"max_new_tokens": 16,
"repetition_penalty": 1.1,
Expand Down
29 changes: 14 additions & 15 deletions tests/fixtures/configs/train/multimodal/llama_llava_base_clip.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,18 @@
"model_type": "causal",
"transformers_settings": {},
"peft_settings": {
"r": 16,
"lora_alpha": 16,
"lora_dropout": 0.05,
"target_modules": [
"q_proj",
"k_proj"
],
"task_type": "CAUSAL_LM",
"modules_to_save": [
"embed_tokens",
"lm_head"
],
"name": "LORA"
"name": "LORA",
"config": {
"r": 8,
"lora_alpha": 16,
"lora_dropout": 0.05,
"target_modules": [
"q_proj",
"v_proj"
],
"task_type": "CAUSAL_LM",
"modules_to_save": ["embed_tokens", "lm_head"]
}
},
"embeddings_initialization_strategy": {
"<RS>": "bot",
Expand All @@ -108,7 +107,7 @@
"eos_token": "</s>",
"pad_token": "<pad>"
},
"trainer_settings": {
"training_arguments": {
"evaluation_strategy": "epoch",
"save_strategy": "epoch",
"per_device_train_batch_size": 1,
Expand Down Expand Up @@ -147,7 +146,7 @@
"audio": null
},
"cherry_pick_settings": {
"generator_transformers_settings": {
"generation_config": {
"num_beams": 1,
"max_new_tokens": 128,
"repetition_penalty": 1.1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,18 @@
"model_type": "causal",
"transformers_settings": {},
"peft_settings": {
"r": 16,
"lora_alpha": 16,
"lora_dropout": 0.05,
"target_modules": [
"q_proj",
"k_proj"
],
"task_type": "CAUSAL_LM",
"modules_to_save": [
"embed_tokens",
"lm_head"
],
"name": "LORA"
"name": "LORA",
"config": {
"r": 8,
"lora_alpha": 16,
"lora_dropout": 0.05,
"target_modules": [
"q_proj",
"v_proj"
],
"task_type": "CAUSAL_LM",
"modules_to_save": ["embed_tokens", "lm_head"]
}
},
"embeddings_initialization_strategy": {
"<RS>": "bot",
Expand All @@ -108,7 +107,7 @@
"eos_token": "</s>",
"pad_token": "<pad>"
},
"trainer_settings": {
"training_arguments": {
"evaluation_strategy": "epoch",
"save_strategy": "epoch",
"per_device_train_batch_size": 1,
Expand Down Expand Up @@ -147,7 +146,7 @@
"audio": null
},
"cherry_pick_settings": {
"generator_transformers_settings": {
"generation_config": {
"num_beams": 1,
"max_new_tokens": 4,
"repetition_penalty": 1.1,
Expand Down
26 changes: 14 additions & 12 deletions tests/fixtures/configs/train/rag/end2end.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,18 @@
"<system>": "system"
},
"peft_settings": {
"r": 16,
"lora_alpha": 16,
"lora_dropout": 0.05,
"target_modules": ["q_proj", "v_proj", "k_proj", "o_proj"],
"task_type": "CAUSAL_LM",
"modules_to_save": [
"embed_tokens",
"lm_head"
],
"name": "LORA"
"name": "LORA",
"config": {
"r": 8,
"lora_alpha": 16,
"lora_dropout": 0.05,
"target_modules": [
"q_proj",
"v_proj"
],
"task_type": "CAUSAL_LM",
"modules_to_save": ["embed_tokens", "lm_head"]
}
}
},
"question_encoder_settings": {
Expand All @@ -83,7 +85,7 @@
}
},
"cherry_pick_settings": {
"generator_transformers_settings": {
"generation_config": {
"num_beams": 3,
"max_new_tokens": 16,
"repetition_penalty": 1.1,
Expand Down Expand Up @@ -123,7 +125,7 @@
"eos_token": "</s>",
"pad_token": "<pad>"
},
"trainer_settings": {
"training_arguments": {
"evaluation_strategy": "epoch",
"save_strategy": "epoch",
"per_device_train_batch_size": 1,
Expand Down
Loading
Loading