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

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +35 -1
README.md CHANGED
@@ -50,7 +50,41 @@ For evaluation and testing only. Do not expect great results, and do not use thi
50
 
51
  ### Direct Use
52
 
53
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
 
55
  [More Information Needed]
56
 
 
50
 
51
  ### Direct Use
52
 
53
+ ```python
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:
61
+ Below is an instruction that describes a task. Write a response that appropriately completes the request.
62
+
63
+ ALWAYS use Python type hints for mypy.
64
+
65
+ ### Instruction:
66
+ {instruction}
67
+
68
+ ### Input:
69
+ {input}
70
+
71
+ ### Output:
72
+ """
73
+
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
+ ```
88
 
89
  [More Information Needed]
90