Skip to content

Commit

Permalink
Allow passing dtype and max_new_tokens to HF reference script (#1903)
Browse files Browse the repository at this point in the history
  • Loading branch information
janimo authored Nov 3, 2024
1 parent 838dcda commit 916b3cd
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions scripts/playground/reference_hf.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def normal_text(args):
t = get_tokenizer(args.model_path, trust_remote_code=True)
m = AutoModelForCausalLM.from_pretrained(
args.model_path,
torch_dtype=torch.float16,
torch_dtype=args.dtype,
low_cpu_mem_usage=True,
device_map="auto",
trust_remote_code=True,
Expand All @@ -47,7 +47,7 @@ def normal_text(args):
"The capital of the United Kindom is",
"Today is a sunny day and I like",
]
max_new_tokens = 16
max_new_tokens = args.max_new_tokens

torch.cuda.set_device(0)

Expand Down Expand Up @@ -104,6 +104,16 @@ def synthetic_tokens(args):
default="TinyLlama/TinyLlama-1.1B-Chat-v0.4",
# default="meta-llama/Llama-2-7b-chat-hf",
)
parser.add_argument(
"--max-new-tokens",
type=int,
default=16)

parser.add_argument(
"--dtype",
type=str,
default="float16")

args = parser.parse_args()

normal_text(args)
Expand Down

0 comments on commit 916b3cd

Please sign in to comment.