paddlenlp

Форк
0
/
test_finetune.py 
57 строк · 1.8 Кб
1
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
6
#
7
#     http://www.apache.org/licenses/LICENSE-2.0
8
#
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
14
from __future__ import annotations
15

16
import sys
17
import unittest
18

19
from parameterized import parameterized_class
20

21
from tests.testing_utils import argv_context_guard, load_test_config
22

23
from .testing_utils import LLMTest
24

25

26
@parameterized_class(
27
    ["model_dir"],
28
    [["llama"], ["chatglm"], ["bloom"], ["chatglm2"], ["qwen"], ["baichuan"]],
29
)
30
class FinetuneTest(LLMTest, unittest.TestCase):
31
    config_path: str = "./tests/fixtures/llm/finetune.yaml"
32
    model_dir: str = None
33

34
    def setUp(self) -> None:
35
        LLMTest.setUp(self)
36

37
        sys.path.insert(0, self.model_dir)
38

39
    def tearDown(self) -> None:
40
        LLMTest.tearDown(self)
41

42
    def test_finetune(self):
43
        finetune_config = load_test_config(self.config_path, "finetune", self.model_dir)
44

45
        finetune_config["dataset_name_or_path"] = self.data_dir
46
        finetune_config["output_dir"] = self.output_dir
47

48
        with argv_context_guard(finetune_config):
49
            from finetune_generation import main
50

51
            main()
52

53
        # TODO(wj-Mcat): disable chatglm2 test temporarily
54
        if self.model_dir not in ["qwen", "baichuan", "chatglm2"]:
55
            self.run_predictor({"inference_model": True})
56

57
        self.run_predictor({"inference_model": False})
58

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.