AlignmentResearch / tuned-lens

Tools for understanding how transformer predictions are built layer-by-layer
https://tuned-lens.readthedocs.io/en/latest/
MIT License
432 stars 47 forks source link

Refactor CLI args Part 2 - Add type hinting to CLI args #65

Closed alexmlong closed 1 year ago

alexmlong commented 1 year ago

This builds on #64 to add typing to the CLI args. Let me know if this is taking the refactor too far but I thought it would be satisfying and cool to reuse the typing already specified in the CLI arg configuration for actual type hinting. This way we can be sure that CLI args are actually supported in the code and any args used in the code are included in the CLI args.

I tried to figure out a way to infer the types directly from the argparser without having to re-specify but couldn't figure out a way to do that. The Namespace object provided by argparse just type hints everything as Any and doesn't specify which attributes exist and which don't. There might be better type hinting practices for other argparsers like click but I didn't want to go too far with the refactor since there's already a good bit of change. That's something to potentially improve in the future.