FlameF0X commited on
Commit
7e31eab
Β·
verified Β·
1 Parent(s): 48ce260

Update marc.py

Browse files
Files changed (1) hide show
  1. marc.py +11 -4
marc.py CHANGED
@@ -10,6 +10,7 @@ Usage:
10
  python marc.py --hf HuggingFaceTB/SmolLM2-360M
11
  python marc.py --hf Qwen/Qwen3-0.5B-Instruct --chat --n-samples 5 --temperature 0.7
12
  python marc.py --openai Qwen/Qwen3-32B --base-url http://localhost:8000/v1 --chat
 
13
  """
14
  import argparse
15
  import random
@@ -281,15 +282,18 @@ def parse_grid(text: str) -> Grid | None:
281
  # ═══════════════════════════════════════════════════════════════════════════
282
 
283
  class HFModel:
284
- def __init__(self, name: str, chat: bool, device: str = "cuda"):
 
285
  import torch
286
  from transformers import AutoModelForCausalLM, AutoTokenizer
287
- self.tok = AutoTokenizer.from_pretrained(name)
 
288
  if self.tok.pad_token is None:
289
  self.tok.pad_token = self.tok.eos_token
290
  self.tok.padding_side = "left"
291
  self.model = AutoModelForCausalLM.from_pretrained(
292
- name, torch_dtype=torch.bfloat16).to(device).eval()
 
293
  self.device, self.chat, self.torch = device, chat, torch
294
 
295
  def generate(self, prompts, n, temperature, max_new_tokens):
@@ -382,6 +386,8 @@ def main():
382
  src.add_argument("--openai", help="model name on an OpenAI-compatible endpoint")
383
  ap.add_argument("--base-url", help="for --openai, e.g. http://localhost:8000/v1")
384
  ap.add_argument("--chat", action="store_true", help="use chat template (instruct models)")
 
 
385
  ap.add_argument("--families", nargs="+", choices=list(FAMILIES), default=list(FAMILIES))
386
  ap.add_argument("--difficulties", nargs="+", type=int, choices=[1, 2, 3], default=[1, 2, 3])
387
  ap.add_argument("--n-per-cell", type=int, default=20)
@@ -392,7 +398,8 @@ def main():
392
  args = ap.parse_args()
393
 
394
  if args.hf:
395
- model = HFModel(args.hf, chat=args.chat)
 
396
  else:
397
  if not args.base_url:
398
  sys.exit("--base-url is required with --openai")
 
10
  python marc.py --hf HuggingFaceTB/SmolLM2-360M
11
  python marc.py --hf Qwen/Qwen3-0.5B-Instruct --chat --n-samples 5 --temperature 0.7
12
  python marc.py --openai Qwen/Qwen3-32B --base-url http://localhost:8000/v1 --chat
13
+ python marc.py --hf dotlabs/void.1 --trust-remote-code
14
  """
15
  import argparse
16
  import random
 
282
  # ═══════════════════════════════════════════════════════════════════════════
283
 
284
  class HFModel:
285
+ def __init__(self, name: str, chat: bool, device: str = "cuda",
286
+ trust_remote_code: bool = False):
287
  import torch
288
  from transformers import AutoModelForCausalLM, AutoTokenizer
289
+ self.tok = AutoTokenizer.from_pretrained(
290
+ name, trust_remote_code=trust_remote_code)
291
  if self.tok.pad_token is None:
292
  self.tok.pad_token = self.tok.eos_token
293
  self.tok.padding_side = "left"
294
  self.model = AutoModelForCausalLM.from_pretrained(
295
+ name, torch_dtype=torch.bfloat16,
296
+ trust_remote_code=trust_remote_code).to(device).eval()
297
  self.device, self.chat, self.torch = device, chat, torch
298
 
299
  def generate(self, prompts, n, temperature, max_new_tokens):
 
386
  src.add_argument("--openai", help="model name on an OpenAI-compatible endpoint")
387
  ap.add_argument("--base-url", help="for --openai, e.g. http://localhost:8000/v1")
388
  ap.add_argument("--chat", action="store_true", help="use chat template (instruct models)")
389
+ ap.add_argument("--trust-remote-code", action="store_true",
390
+ help="pass trust_remote_code=True to HF tokenizer/model loaders")
391
  ap.add_argument("--families", nargs="+", choices=list(FAMILIES), default=list(FAMILIES))
392
  ap.add_argument("--difficulties", nargs="+", type=int, choices=[1, 2, 3], default=[1, 2, 3])
393
  ap.add_argument("--n-per-cell", type=int, default=20)
 
398
  args = ap.parse_args()
399
 
400
  if args.hf:
401
+ model = HFModel(args.hf, chat=args.chat,
402
+ trust_remote_code=args.trust_remote_code)
403
  else:
404
  if not args.base_url:
405
  sys.exit("--base-url is required with --openai")