File size: 1,950 Bytes
40a8f4e
79d936d
 
40a8f4e
 
 
 
 
 
 
98dba8d
40a8f4e
 
98dba8d
40a8f4e
 
98dba8d
40a8f4e
 
98dba8d
79d936d
 
98dba8d
d8a2e9e
 
 
98dba8d
 
 
40a8f4e
06d2e3a
40a8f4e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79d936d
 
 
40a8f4e
438ee0e
 
40a8f4e
 
438ee0e
 
 
 
40a8f4e
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import os
import pytz
from typing import List, Union, Any


class Config:
    """
    Stores the application configuration. This is a singleton class.
    """

    # Where data is stored
    data_dir: str = ""

    # Model Related
    default_base_model_name: str = ""
    base_model_choices: Union[List[str], str] = []
    load_8bit: bool = False
    trust_remote_code: bool = False

    # Application Settings
    timezone: Any = pytz.UTC

    # Authentication
    auth_username: Union[str, None] = None
    auth_password: Union[str, None] = None

    # Hugging Face
    hf_access_token: Union[str, None] = None

    # WandB
    enable_wandb: Union[bool, None] = None
    wandb_api_key: Union[str, None] = None
    default_wandb_project: str = "llama-lora-tuner"

    # UI related
    ui_title: str = "LLaMA-LoRA Tuner"
    ui_emoji: str = "🦙🎛️"
    ui_subtitle: str = "Toolkit for evaluating and fine-tuning LLaMA models with low-rank adaptation (LoRA)."
    ui_show_sys_info: bool = True
    ui_dev_mode: bool = False
    ui_dev_mode_title_prefix: str = "[UI DEV MODE] "


def process_config():
    Config.data_dir = os.path.abspath(Config.data_dir)

    if isinstance(Config.base_model_choices, str):
        base_model_choices = Config.base_model_choices.split(',')
        base_model_choices = [name.strip() for name in base_model_choices]
        Config.base_model_choices = base_model_choices

    if isinstance(Config.timezone, str):
        Config.timezone = pytz.timezone(Config.timezone)

    if Config.default_base_model_name not in Config.base_model_choices:
        Config.base_model_choices = [
            Config.default_base_model_name] + Config.base_model_choices

    if Config.enable_wandb is None:
        if (
            Config.wandb_api_key and len(Config.wandb_api_key) > 0
                and Config.default_wandb_project and len(Config.default_wandb_project) > 0
        ):
            Config.enable_wandb = True