Elffuss BraidHub

kikocis/SpatialLM public

main · 2.9 KiBRawPermalink
1# Copyright 2025 the LlamaFactory team.
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
15from dataclasses import asdict, dataclass, field
16from typing import Any, Literal, Optional
17
18
19@dataclass
20class SwanLabArguments:
21 use_swanlab: bool = field(
22 default=False,
23 metadata={
24 "help": "Whether or not to use the SwanLab (an experiment tracking and visualization tool)."
25 },
26 )
27 swanlab_project: Optional[str] = field(
28 default="llamafactory",
29 metadata={"help": "The project name in SwanLab."},
30 )
31 swanlab_workspace: Optional[str] = field(
32 default=None,
33 metadata={"help": "The workspace name in SwanLab."},
34 )
35 swanlab_run_name: Optional[str] = field(
36 default=None,
37 metadata={"help": "The experiment name in SwanLab."},
38 )
39 swanlab_mode: Literal["cloud", "local"] = field(
40 default="cloud",
41 metadata={"help": "The mode of SwanLab."},
42 )
43 swanlab_api_key: Optional[str] = field(
44 default=None,
45 metadata={"help": "The API key for SwanLab."},
46 )
47 swanlab_logdir: Optional[str] = field(
48 default=None,
49 metadata={"help": "The log directory for SwanLab."},
50 )
51 swanlab_lark_webhook_url: Optional[str] = field(
52 default=None,
53 metadata={"help": "The Lark(飞书) webhook URL for SwanLab."},
54 )
55 swanlab_lark_secret: Optional[str] = field(
56 default=None,
57 metadata={"help": "The Lark(飞书) secret for SwanLab."},
58 )
59
60
61@dataclass
62class FinetuningArguments(SwanLabArguments):
63 r"""Arguments pertaining to which techniques we are going to fine-tuning with."""
64
65 pure_bf16: bool = field(
66 default=False,
67 metadata={
68 "help": "Whether or not to train model in purely bf16 precision (without AMP)."
69 },
70 )
71 freeze_language_tower: bool = field(
72 default=False,
73 metadata={"help": "Whether ot not to freeze language tower in training."},
74 )
75 freeze_point_tower: bool = field(
76 default=False,
77 metadata={"help": "Whether ot not to freeze point tower in training."},
78 )
79 train_proj_only: bool = field(
80 default=False,
81 metadata={"help": "Whether or not to train the projector only."},
82 )
83
84 def to_dict(self) -> dict[str, Any]:
85 args = asdict(self)
86 args = {
87 k: f"<{k.upper()}>" if k.endswith("api_key") else v for k, v in args.items()
88 }
89 return args