| 284 | return torch.clip(t.to(torch.int32), low, high - 1) |
| 285 | |
| 286 | def parse_args(): |
| 287 | parser = argparse.ArgumentParser(description="Simple example of a training script.") |
| 288 | parser.add_argument( |
| 289 | "--input_perturbation", type=float, default=0, help="The scale of input perturbation. Recommended 0.1." |
| 290 | ) |
| 291 | parser.add_argument( |
| 292 | "--pretrained_model_name_or_path", |
| 293 | type=str, |
| 294 | default=None, |
| 295 | required=True, |
| 296 | help="Path to pretrained model or model identifier from huggingface.co/models.", |
| 297 | ) |
| 298 | parser.add_argument( |
| 299 | "--revision", |
| 300 | type=str, |
| 301 | default=None, |
| 302 | required=False, |
| 303 | help="Revision of pretrained model identifier from huggingface.co/models.", |
| 304 | ) |
| 305 | parser.add_argument( |
| 306 | "--variant", |
| 307 | type=str, |
| 308 | default=None, |
| 309 | help="Variant of the model files of the pretrained model identifier from huggingface.co/models, 'e.g.' fp16", |
| 310 | ) |
| 311 | parser.add_argument( |
| 312 | "--train_data_dir", |
| 313 | type=str, |
| 314 | default=None, |
| 315 | help=( |
| 316 | "A folder containing the training data. " |
| 317 | ), |
| 318 | ) |
| 319 | parser.add_argument( |
| 320 | "--train_data_meta", |
| 321 | type=str, |
| 322 | default=None, |
| 323 | help=( |
| 324 | "A csv containing the training data. " |
| 325 | ), |
| 326 | ) |
| 327 | parser.add_argument( |
| 328 | "--max_train_samples", |
| 329 | type=int, |
| 330 | default=None, |
| 331 | help=( |
| 332 | "For debugging purposes or quicker training, truncate the number of training examples to this " |
| 333 | "value if set." |
| 334 | ), |
| 335 | ) |
| 336 | parser.add_argument( |
| 337 | "--validation_prompts", |
| 338 | type=str, |
| 339 | default=None, |
| 340 | nargs="+", |
| 341 | help=("A set of prompts evaluated every `--validation_epochs` and logged to `--report_to`."), |
| 342 | ) |
| 343 | parser.add_argument( |