recover logging

This commit is contained in:
hiyouga 2023-06-06 21:36:37 +08:00
parent 4eb17bcf6c
commit 13d1f0709c
6 changed files with 17 additions and 16 deletions

View File

@ -38,7 +38,7 @@ from .config import (
)
from .other import (
get_main_logger,
get_logger,
load_trainable_params,
load_valuehead_params,
print_trainable_params,
@ -53,7 +53,7 @@ require_version("peft>=0.3.0", "To fix: pip install peft>=0.3.0")
require_version("trl>=0.4.1", "To fix: pip install trl>=0.4.1")
logger = get_main_logger(__name__)
logger = get_logger(__name__)
def _init_adapter(
@ -289,7 +289,7 @@ def prepare_args(
logger.info(
f"Process rank: {training_args.local_rank}, device: {training_args.device}, n_gpu: {training_args.n_gpu}\n"
+ f" distributed training: {bool(training_args.local_rank != -1)}, 16-bits training: {training_args.fp16}"
, main_process_only=False)
)
logger.info(f"Training/evaluation parameters {training_args}")
# Set seed before initializing model.

View File

@ -10,8 +10,6 @@ from transformers.modeling_utils import PreTrainedModel
from transformers.generation.utils import LogitsProcessorList
from transformers.generation.logits_process import LogitsProcessor
from accelerate.logging import get_logger
from peft.utils.other import WEIGHTS_NAME
@ -20,16 +18,19 @@ VALUE_HEAD_FILE_NAME = "value_head.bin"
FINETUNING_ARGS_NAME = "finetuning_args.json"
logger = get_logger(__name__, log_level="INFO")
def get_logger(name: str) -> logging.Logger:
return logging.getLogger(name)
logging.basicConfig(
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
datefmt="%m/%d/%Y %H:%M:%S",
level=logging.INFO,
handlers=[logging.StreamHandler(sys.stdout)]
)
def get_main_logger(name: str) -> logging.Logger:
return get_logger(name, log_level="INFO")
logger = get_logger(__name__)
class AverageMeter:

View File

@ -5,9 +5,9 @@ from .data_collator import DynamicDataCollatorWithPadding
from .peft_trainer import PeftTrainer
from .other import get_main_logger
from .other import get_logger
logger = get_main_logger(__name__)
logger = get_logger(__name__)
class PairwiseDataCollatorWithPadding(DynamicDataCollatorWithPadding):

View File

@ -21,7 +21,7 @@ from peft.utils.other import WEIGHTS_NAME
from .config import FinetuningArguments
from .other import (
get_main_logger,
get_logger,
get_state_dict,
load_trainable_params,
load_valuehead_params,
@ -30,7 +30,7 @@ from .other import (
)
logger = get_main_logger(__name__)
logger = get_logger(__name__)
class LogCallback(TrainerCallback):

View File

@ -16,12 +16,12 @@ from .config import FinetuningArguments
from .other import (
AverageMeter,
get_main_logger,
get_logger,
get_logits_processor
)
logger = get_main_logger(__name__)
logger = get_logger(__name__)
def replace_model(model: AutoModelForCausalLMWithValueHead, target: Literal["default", "reward"]) -> None:

View File

@ -13,10 +13,10 @@ from nltk.translate.bleu_score import sentence_bleu, SmoothingFunction
from .peft_trainer import PeftTrainer
from .other import get_main_logger, IGNORE_INDEX
from .other import get_logger, IGNORE_INDEX
logger = get_main_logger(__name__)
logger = get_logger(__name__)
@dataclass