File size: 1,755 Bytes
778d47d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | # Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import unittest
from alignment import DataArguments, H4ArgumentParser, ModelArguments, SFTConfig
class H4ArgumentParserTest(unittest.TestCase):
def setUp(self):
self.parser = H4ArgumentParser((ModelArguments, DataArguments, SFTConfig))
self.yaml_file_path = "tests/fixtures/config_sft_full.yaml"
def test_load_yaml(self):
model_args, data_args, training_args = self.parser.parse_yaml_file(os.path.abspath(self.yaml_file_path))
self.assertEqual(model_args.model_name_or_path, "mistralai/Mistral-7B-v0.1")
def test_load_yaml_and_args(self):
command_line_args = [
"--model_name_or_path=test",
"--use_peft=true",
"--lora_r=16",
"--lora_dropout=0.5",
]
model_args, data_args, training_args = self.parser.parse_yaml_and_args(
os.path.abspath(self.yaml_file_path), command_line_args
)
self.assertEqual(model_args.model_name_or_path, "test")
self.assertEqual(model_args.use_peft, True)
self.assertEqual(model_args.lora_r, 16)
self.assertEqual(model_args.lora_dropout, 0.5)
|