Spaces:
Runtime error
Runtime error
- ape/ape.py +3 -11
- ape/llm.py +0 -1
ape/ape.py
CHANGED
@@ -6,8 +6,6 @@ from ape.llm import LLMGPT
|
|
6 |
from functools import partial
|
7 |
from itertools import chain
|
8 |
|
9 |
-
LLM = None
|
10 |
-
|
11 |
|
12 |
def load_task(task, file):
|
13 |
global instance
|
@@ -36,9 +34,7 @@ def esttimate_cost(instance):
|
|
36 |
|
37 |
|
38 |
def generate(gen_prompt, instance, openai_key):
|
39 |
-
|
40 |
-
if LLM is None:
|
41 |
-
LLM = LLMGPT(openai_key)
|
42 |
|
43 |
instructions = []
|
44 |
train_iter = instance.get_train_iter()
|
@@ -50,9 +46,7 @@ def generate(gen_prompt, instance, openai_key):
|
|
50 |
|
51 |
|
52 |
def single_test(test_prompt, instruction, input, openai_key):
|
53 |
-
|
54 |
-
if LLM is None:
|
55 |
-
LLM = LLMGPT(openai_key)
|
56 |
output = []
|
57 |
for i in input.split('\n'):
|
58 |
output.append(LLM.generate_output(test_prompt, instruction, i)['text'])
|
@@ -60,9 +54,7 @@ def single_test(test_prompt, instruction, input, openai_key):
|
|
60 |
|
61 |
|
62 |
def score_single(eval_prompt, instance, instruction, openai_key):
|
63 |
-
|
64 |
-
if LLM is None:
|
65 |
-
LLM = LLMGPT(openai_key)
|
66 |
|
67 |
score = LLM.generate_logprobs(eval_prompt, instruction, instance.eval_samples)
|
68 |
return score
|
|
|
6 |
from functools import partial
|
7 |
from itertools import chain
|
8 |
|
|
|
|
|
9 |
|
10 |
def load_task(task, file):
|
11 |
global instance
|
|
|
34 |
|
35 |
|
36 |
def generate(gen_prompt, instance, openai_key):
|
37 |
+
LLM = LLMGPT(openai_key)
|
|
|
|
|
38 |
|
39 |
instructions = []
|
40 |
train_iter = instance.get_train_iter()
|
|
|
46 |
|
47 |
|
48 |
def single_test(test_prompt, instruction, input, openai_key):
|
49 |
+
LLM = LLMGPT(openai_key)
|
|
|
|
|
50 |
output = []
|
51 |
for i in input.split('\n'):
|
52 |
output.append(LLM.generate_output(test_prompt, instruction, i)['text'])
|
|
|
54 |
|
55 |
|
56 |
def score_single(eval_prompt, instance, instruction, openai_key):
|
57 |
+
LLM = LLMGPT(openai_key)
|
|
|
|
|
58 |
|
59 |
score = LLM.generate_logprobs(eval_prompt, instruction, instance.eval_samples)
|
60 |
return score
|
ape/llm.py
CHANGED
@@ -21,7 +21,6 @@ Cost = {
|
|
21 |
|
22 |
class LLMGPT(object):
|
23 |
encoding = tiktoken.get_encoding("cl100k_base")
|
24 |
-
|
25 |
def __init__(self, openai_key):
|
26 |
self.gen_llm = ChatOpenAI(openai_api_key=openai_key, max_tokens=2000, temperature=0.7, verbose=True)
|
27 |
self.eval_llm = OpenAI(openai_api_key=openai_key, max_tokens=0, temperature=0.7, echo=True, logprobs=1)
|
|
|
21 |
|
22 |
class LLMGPT(object):
|
23 |
encoding = tiktoken.get_encoding("cl100k_base")
|
|
|
24 |
def __init__(self, openai_key):
|
25 |
self.gen_llm = ChatOpenAI(openai_api_key=openai_key, max_tokens=2000, temperature=0.7, verbose=True)
|
26 |
self.eval_llm = OpenAI(openai_api_key=openai_key, max_tokens=0, temperature=0.7, echo=True, logprobs=1)
|