DSXiangLi commited on
Commit
30c1c19
1 Parent(s): d537b9c
Files changed (2) hide show
  1. ape/llm.py +5 -5
  2. ape/prompt.py +2 -2
ape/llm.py CHANGED
@@ -20,9 +20,9 @@ Cost = {
20
 
21
  class LLMGPT(object):
22
  def __init__(self, openai_key, n_instruct):
23
- self.gen_llm = ChatOpenAI(openai_api_key=openai_key, max_tokens=2000, temperature=0.7, n=n_instruct)
24
- self.eval_llm = OpenAI(openai_api_key=openai_key, max_tokens=2000, temperature=0.7, echo=True)
25
- self.test_llm = ChatOpenAI(openai_api_key=openai_key, max_tokens=2000, temperature=0.7)
26
  self.gen_chain = None
27
  self.eval_chain = None
28
  self.init()
@@ -66,11 +66,11 @@ class LLMGPT(object):
66
  for shot in few_shot:
67
  prompt += MyTemplate['few_shot_prompt'].format(input=shot[0], output=shot[1])
68
  print(prompt)
69
- result = self.gen_chain.generate(prompt)
70
  return result
71
 
72
  def generate_output(self, instruction, input):
73
- output = self.test_chain.generate([instruction, input])
74
  print(output)
75
  return output
76
 
 
20
 
21
  class LLMGPT(object):
22
  def __init__(self, openai_key, n_instruct):
23
+ self.gen_llm = ChatOpenAI(openai_api_key=openai_key, max_tokens=2000, temperature=0.7, n=n_instruct, verbose=True)
24
+ self.eval_llm = OpenAI(openai_api_key=openai_key, max_tokens=2000, temperature=0.7, echo=True, verbose=True)
25
+ self.test_llm = ChatOpenAI(openai_api_key=openai_key, max_tokens=2000, temperature=0.7, verbose=True)
26
  self.gen_chain = None
27
  self.eval_chain = None
28
  self.init()
 
66
  for shot in few_shot:
67
  prompt += MyTemplate['few_shot_prompt'].format(input=shot[0], output=shot[1])
68
  print(prompt)
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
 
ape/prompt.py CHANGED
@@ -11,13 +11,13 @@ You must respond in the following format, and always respond in chinese.
11
  ```
12
  Everything between the ``` must be valid json. """
13
 
14
- eval_prompt = "Instruction: {prompt}\nInput: {input}\nOutput: {output}"
15
 
16
  test_sys_prompt = """I want you to act as an AI assisted doctor. You are capable of answering anything related to medical.
17
  Given an instruction and input, you must come up with corresponding output, and always respond in chinese.
18
  """
19
 
20
- test_user_prompt = "Instruction: {prompt}\nInput: {input}\nOutput: "
21
 
22
  MyTemplate = {
23
  'gen_user_prompt': gen_user_prompt,
 
11
  ```
12
  Everything between the ``` must be valid json. """
13
 
14
+ eval_prompt = "Instruction: {instruction}\nInput: {input}\nOutput: {output}"
15
 
16
  test_sys_prompt = """I want you to act as an AI assisted doctor. You are capable of answering anything related to medical.
17
  Given an instruction and input, you must come up with corresponding output, and always respond in chinese.
18
  """
19
 
20
+ test_user_prompt = "Instruction: {instruction}\nInput: {input}\nOutput: "
21
 
22
  MyTemplate = {
23
  'gen_user_prompt': gen_user_prompt,