User argpars utils to show default args on command line

This commit is contained in:
rasbt
2026-03-01 20:15:21 -06:00
parent c079904491
commit 4612d20fa8
27 changed files with 30 additions and 30 deletions

View File

@@ -253,16 +253,16 @@ def main(gpt_config, input_prompt, model_size, device):
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Generate text with a pretrained GPT-2 model.")
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description="Generate text with a pretrained GPT-2 model.")
parser.add_argument(
"--prompt",
default="Every effort moves you",
help="Prompt text used to seed the generation (default matches the script's built-in prompt)."
help="Prompt text used to seed the generation."
)
parser.add_argument(
"--device",
default="cpu",
help="Device for running inference, e.g., cpu, cuda, mps, or auto. Defaults to cpu."
help="Device for running inference, e.g., cpu, cuda, mps, or auto."
)
args = parser.parse_args()

View File

@@ -66,7 +66,7 @@ def combine_files(file_paths, target_dir, max_size_mb=500, separator="<|endoftex
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Preprocess and combine text files for pretraining")
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description="Preprocess and combine text files for pretraining")
parser.add_argument("--data_dir", type=str, default="gutenberg/data/raw",
help="Directory containing the downloaded raw training data")

View File

@@ -148,7 +148,7 @@ def train_model_simple(model, optimizer, device, n_epochs,
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="GPT Model Training Configuration")
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description="GPT Model Training Configuration")
parser.add_argument("--data_dir", type=str, default="gutenberg/data",
help="Directory containing the training data")