from transformers import AutoTokenizer | |
import argparse | |
parser = argparse.ArgumentParser() | |
parser.add_argument('--path', default="/public/home/qianlima/scow/Llama-3.1-70B-Instruct", type=str, help='模型路径') | |
args = parser.parse_args() | |
name = args.path[args.path.rfind('/')+1:] | |
# Initialize the tokenizer | |
tokenizer = AutoTokenizer.from_pretrained(args.path, trust_remote_code=True) | |
messages = [{"content": "You are a helpful assistant", "role": "system"},{"content": "Hello! What's your name", "role": "user"},{"content": "My name is Harry.", "role": "assistant"}] | |
new_prompt = tokenizer.apply_chat_template(messages, tokenize=False) | |
print(new_prompt) | |
print() |