Downloads · 30 days
0
yb1n/0528_deep_hw
0528_deep_hw is a machine learning model from yb1n. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Hugging Face Trainer 사용 흐름을 단계별 코드로 구현하고, IMDB 텍스트 분류 실행 파일을 함께 둔 폴더입니다.
Downloads · 30 days
0
Access
Public
Updated Jun 10, 2026
Repo size
—
Likes
0
Public
Click a slice to open those files.
.py22.8 KB · 83%
From the Hugging Face model README
Hugging Face Trainer 사용 흐름을 단계별 코드로 구현하고, IMDB 텍스트 분류 실행 파일을 함께 둔 폴더입니다.
page_01_basic_trainer.py: IMDB 로드, tokenizer 적용, TrainingArguments, Trainer, train, evaluate, predict, save_model 기본 흐름입니다.page_02_resume_training.py: save_strategy="steps"와 resume_from_checkpoint=True를 사용하는 재개 학습 흐름입니다.page_03_plot_curve.py: learning_curve.jsonl을 읽어 loss, accuracy, precision, f1 그래프를 저장하고 best checkpoint 위치를 표시합니다.page_04_stage_finetuning.py: stage1에서 backbone을 freeze하고 head만 학습한 뒤, stage2에서 best checkpoint의 가중치만 로드해서 새 optimizer와 scheduler로 다시 학습합니다.curve_logger.py: step별 로그와 평가 지표를 JSONL로 저장하는 Trainer callback입니다.trainer_utils.py: 데이터 전처리, metric 계산, Trainer/TrainingArguments 버전 호환 처리, best checkpoint 조회 함수입니다.custom_text_config.py: 커스텀 모델 설정 파일입니다.custom_text_classifier.py: PreTrainedModel 기반 텍스트 분류 모델입니다.uv sync
빠른 확인용으로 샘플 수를 줄여 실행할 수 있습니다.
uv run python page_01_basic_trainer.py --max-train-samples 128 --max-eval-samples 64 --epochs 1
uv run python page_02_resume_training.py --max-train-samples 128 --max-eval-samples 64 --epochs 1
uv run python page_03_plot_curve.py --run-dir results/page_02_resume
uv run python page_04_stage_finetuning.py --max-train-samples 128 --max-eval-samples 64
기본 모델:
uv run python homework_0528_imdb.py --model-type auto --epochs 3
커스텀 모델:
uv run python homework_0528_imdb.py --model-type custom --epochs 3
이어서 학습:
uv run python homework_0528_imdb.py --model-type custom --output-dir outputs/20260610_210000_custom --resume
체크포인트를 직접 지정해서 이어서 학습할 수도 있습니다.
uv run python homework_0528_imdb.py --model-type custom --resume-checkpoint outputs/20260610_210000_custom/checkpoint-1000
실행 결과는 outputs/날짜_시간_모델종류 폴더에 저장됩니다.
Drive를 마운트한 뒤 --output-root를 Drive 경로로 지정하면 체크포인트를 Drive에 저장할 수 있습니다.
uv run python homework_0528_imdb.py --model-type custom --output-root /content/drive/MyDrive/imdb_trainer_outputs