joshuasundance commited on
Commit
9f3fdab
·
verified ·
1 Parent(s): fc53152

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +27 -9
README.md CHANGED
@@ -54,7 +54,11 @@ For evaluation and testing only. Do not expect great results, and do not use thi
54
  from transformers import pipeline
55
 
56
 
57
- pipe = pipeline("text-generation", model="joshuasundance/phi3-mini-4k-qlora-python-code-20k-mypo-4k-rfc-pipe", trust_remote_code=True)
 
 
 
 
58
 
59
 
60
  prompt_template = """### Instruction:
@@ -74,14 +78,28 @@ ALWAYS use Python type hints for mypy.
74
 
75
  def invoke(user_instruction: str, user_input: str = "") -> str:
76
  prompt_str = prompt_template.format(instruction=user_instruction, input=user_input)
77
- prompt = pipe.tokenizer.apply_chat_template([{"role": "user", "content": prompt_str}], tokenize=False, add_generation_prompt=True)
78
- outputs = pipe(prompt, max_new_tokens=256, do_sample=True, num_beams=1, temperature=0.3, top_k=50, top_p=0.95,
79
- max_time= 180) #, eos_token_id=eos_token)
80
- return outputs[0]['generated_text'][len(prompt):].strip()
81
-
82
-
83
- user_instruction="Write a Python function that takes 3 ints, x, y, and z, and returns (x*z)//y."
84
- user_input=""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
 
86
  invoke(user_instruction, user_input)
87
  ```
 
54
  from transformers import pipeline
55
 
56
 
57
+ pipe = pipeline(
58
+ "text-generation",
59
+ model="joshuasundance/phi3-mini-4k-qlora-python-code-20k-mypo-4k-rfc-pipe",
60
+ trust_remote_code=True,
61
+ )
62
 
63
 
64
  prompt_template = """### Instruction:
 
78
 
79
  def invoke(user_instruction: str, user_input: str = "") -> str:
80
  prompt_str = prompt_template.format(instruction=user_instruction, input=user_input)
81
+ prompt = pipe.tokenizer.apply_chat_template(
82
+ [{"role": "user", "content": prompt_str}],
83
+ tokenize=False,
84
+ add_generation_prompt=True,
85
+ )
86
+ outputs = pipe(
87
+ prompt,
88
+ max_new_tokens=256,
89
+ do_sample=True,
90
+ num_beams=1,
91
+ temperature=0.3,
92
+ top_k=50,
93
+ top_p=0.95,
94
+ max_time=180,
95
+ ) # , eos_token_id=eos_token)
96
+ return outputs[0]["generated_text"][len(prompt) :].strip()
97
+
98
+
99
+ user_instruction = (
100
+ "Write a Python function that takes 3 ints, x, y, and z, and returns (x*z)//y."
101
+ )
102
+ user_input = ""
103
 
104
  invoke(user_instruction, user_input)
105
  ```