Skip to content

Commit

Permalink
Use max tokens from options in mlx_lm evaluate (#1302)
Browse files Browse the repository at this point in the history
  • Loading branch information
awni authored Feb 26, 2025
1 parent 56e60ad commit 0f240a4
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions llms/mlx_lm/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,17 +289,15 @@ def generate_until(self, requests) -> list[str]:
contexts, options = zip(*[req.args for req in requests])
# contrary to the doc the second element of the tuple contains
# {'do_sample': False, 'until': ['\n\n'], 'temperature': 0}
keys = list(options[0].keys())
assert "until" in keys
untils = [x["until"] for x in options]
completions = []

for context, until in tqdm(zip(contexts, untils), total=len(contexts)):
for context, opt in tqdm(zip(contexts, options), total=len(contexts)):
until = opt["until"]
context = self.tokenizer.encode(
context, add_special_tokens=not self.use_chat_template
)
max_tokens = min(
self._max_tokens,
opt.get("max_gen_tokens", self._max_tokens),
self.tokenizer.model_max_length - len(context),
)
text = ""
Expand Down Expand Up @@ -334,9 +332,9 @@ def main():
)
parser.add_argument(
"--limit",
default=1.0,
default=100,
help="Limit the number of examples per task.",
type=float,
type=int,
)
parser.add_argument("--seed", type=int, default=123, help="Random seed.")
parser.add_argument(
Expand Down

0 comments on commit 0f240a4

Please sign in to comment.