Views
No views yet
1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_name = "Klingspor/StarPO-1.7B"
4tokenizer = AutoTokenizer.from_pretrained(model_name)
5model = AutoModelForCausalLM.from_pretrained(model_name)
6
7system_prompt = """You are the Questioner in a game of 20 Questions, and your goal is to determine the secret word.
8The secret is randomly drawn from the most frequent nouns of the English language.
9
10Ask clear, concise, and strategic yes/no questions that will help you narrow down the possibilities.
11Consider previous answers to inform your subsequent questions, and keep track of the information you gather.
12Focus on deductive reasoning, start with a broad question and refine your queries as you progress."""
13
14user_prompt = """Ask a question to gain additional information about the secret or guess what the secret is.
15
16Instructions:
171. Ask a question that can be answered with "Yes" or "No" to help you deduce the secret word.
182. Your answer must be a single question. Do not provide any additional commentary or reasoning.
19
20Ask your question: """
21
22messages = [
23 {"role": "system", "content": system_prompt},
24 {"role": "user", "content": user_prompt},
25]
26
27text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
28inputs = tokenizer(text, return_tensors="pt")
29outputs = model.generate(**inputs, max_new_tokens=128)
30print(tokenizer.decode(outputs[0], skip_special_tokens=True))