Spaces:
Runtime error
Runtime error
DSXiangLi
commited on
Commit
•
698a3ea
1
Parent(s):
30c1c19
- ape/ape.py +1 -0
- ape/llm.py +1 -3
- ape/prompt.py +6 -12
ape/ape.py
CHANGED
@@ -45,6 +45,7 @@ def generate(instance, openai_key, n_instruct):
|
|
45 |
for few_shot in train_iter:
|
46 |
instruction = LLM.generate_instruction(few_shot)
|
47 |
print(instruction)
|
|
|
48 |
return '\n'.join(instructions)
|
49 |
|
50 |
|
|
|
45 |
for few_shot in train_iter:
|
46 |
instruction = LLM.generate_instruction(few_shot)
|
47 |
print(instruction)
|
48 |
+
instructions.append(instruction)
|
49 |
return '\n'.join(instructions)
|
50 |
|
51 |
|
ape/llm.py
CHANGED
@@ -65,13 +65,11 @@ class LLMGPT(object):
|
|
65 |
prompt = ''
|
66 |
for shot in few_shot:
|
67 |
prompt += MyTemplate['few_shot_prompt'].format(input=shot[0], output=shot[1])
|
68 |
-
|
69 |
-
result = self.gen_chain({'few_shot':prompt})
|
70 |
return result
|
71 |
|
72 |
def generate_output(self, instruction, input):
|
73 |
output = self.test_chain({'input': input, 'instruction': instruction})
|
74 |
-
print(output)
|
75 |
return output
|
76 |
|
77 |
def generate_logprobs(self, ):
|
|
|
65 |
prompt = ''
|
66 |
for shot in few_shot:
|
67 |
prompt += MyTemplate['few_shot_prompt'].format(input=shot[0], output=shot[1])
|
68 |
+
result = self.gen_chain({'few_shot': prompt})
|
|
|
69 |
return result
|
70 |
|
71 |
def generate_output(self, instruction, input):
|
72 |
output = self.test_chain({'input': input, 'instruction': instruction})
|
|
|
73 |
return output
|
74 |
|
75 |
def generate_logprobs(self, ):
|
ape/prompt.py
CHANGED
@@ -1,23 +1,17 @@
|
|
1 |
# -*-coding:utf-8 -*-
|
2 |
few_shot_prompt = "Input: {input}\nOutput: {output}\n"
|
3 |
|
4 |
-
gen_user_prompt =
|
|
|
5 |
|
6 |
-
gen_sys_prompt = ""
|
7 |
-
a list of input-output pairs, you must come up with the correct instruction in medical-related area.
|
8 |
-
You must respond in the following format, and always respond in chinese.
|
9 |
-
```
|
10 |
-
{{'instruction':"$YOUR_INSTRUCTION"}}
|
11 |
-
```
|
12 |
-
Everything between the ``` must be valid json. """
|
13 |
|
14 |
eval_prompt = "Instruction: {instruction}\nInput: {input}\nOutput: {output}"
|
15 |
|
16 |
-
test_sys_prompt = ""
|
17 |
-
Given an instruction and input, you must come up with corresponding output, and always respond in chinese.
|
18 |
-
"""
|
19 |
|
20 |
-
test_user_prompt = "
|
|
|
21 |
|
22 |
MyTemplate = {
|
23 |
'gen_user_prompt': gen_user_prompt,
|
|
|
1 |
# -*-coding:utf-8 -*-
|
2 |
few_shot_prompt = "Input: {input}\nOutput: {output}\n"
|
3 |
|
4 |
+
gen_user_prompt = """I gave a friend who is medical school teacher an instruction.
|
5 |
+
Based on the instruction they produced the following input-output pairs:\n\n{few_shot}\n\nThe instruction was to """
|
6 |
|
7 |
+
gen_sys_prompt = ""
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
eval_prompt = "Instruction: {instruction}\nInput: {input}\nOutput: {output}"
|
10 |
|
11 |
+
test_sys_prompt = ""
|
|
|
|
|
12 |
|
13 |
+
test_user_prompt = """I gave a friend who is medical school teacher an instruction. Base on this instruction, they will
|
14 |
+
transform the input to output.\n Instruction: {instruction}Input: {input}\nOutput: """
|
15 |
|
16 |
MyTemplate = {
|
17 |
'gen_user_prompt': gen_user_prompt,
|