Views
No views yet
1prompt_str = (
2 f"[INST] Write code to solve the following coding problem that obeys"
3 f"the constraints and passes the example test cases."
4 f"Please wrap your code answer using ```:\n{input}\n[/INST]```python\n"
5 )1prompt_str = (
2 f"[INST] Write code to solve the following coding problem that obeys"
3 f"the constraints and passes the example test cases."
4 f"Please wrap your code answer using ```:\n{input}\n[/INST]```python\n"
5 )
6model = AutoModelForCausalLM.from_pretrained(model_path, device_map="auto", torch_dtype=torch.bfloat16)
7token_ids = tokenizer([prompt_str], return_tensors="pt")["input_ids"]
8token_ids = token_ids.to(model.device)
9outputs = model.generate(input_ids=token_ids, max_new_tokens=1024, do_sample=True, temperature=0.0001)
10all_token_ids = outputs[0].tolist()
11ouput_token_ids = all_token_ids[token_ids.shape[-1] :]
12output = tokenizer.decode(ouput_token_ids)
13print("-------------Solution generated from Model---------")
14print(output)