| 15 | |
| 16 | |
| 17 | def parse_args(): |
| 18 | p = argparse.ArgumentParser(description="Load base model + AHN weights and run a sample generation.") |
| 19 | p.add_argument( |
| 20 | "--model", |
| 21 | type=str, |
| 22 | required=True, |
| 23 | help='Path to the ahn-augmented model.', |
| 24 | ) |
| 25 | p.add_argument( |
| 26 | "--sliding-window", |
| 27 | type=int, |
| 28 | default=32640, |
| 29 | help="Sliding window length for lossless attention memory.", |
| 30 | ) |
| 31 | p.add_argument( |
| 32 | "--num-attention-sink", |
| 33 | type=int, |
| 34 | default=128, |
| 35 | help="Number of attention sink tokens used as anchors.", |
| 36 | ) |
| 37 | # Optional extras you might want to tweak quickly: |
| 38 | p.add_argument( |
| 39 | "--dtype", |
| 40 | type=str, |
| 41 | default="bfloat16", |
| 42 | choices=["float16", "bfloat16", "float32"], |
| 43 | help="Torch dtype for loading and inference.", |
| 44 | ) |
| 45 | p.add_argument( |
| 46 | "--max-new-tokens", |
| 47 | type=int, |
| 48 | default=1024, |
| 49 | help="Max new tokens for the demo generation.", |
| 50 | ) |
| 51 | p.add_argument( |
| 52 | "--prompt", |
| 53 | type=str, |
| 54 | default="Write a 10,000-word poem.", |
| 55 | help="Prompt for the demo generation.", |
| 56 | ) |
| 57 | return p.parse_args() |
| 58 | |
| 59 | |
| 60 | def str_to_dtype(name: str): |