Spaces:
Build error
Build error
Update llm_utils.py
Browse files- llm_toolkit/llm_utils.py +7 -2
llm_toolkit/llm_utils.py
CHANGED
@@ -133,7 +133,7 @@ def extract_answer(text, debug=False):
|
|
133 |
return text
|
134 |
|
135 |
|
136 |
-
def eval_model(model, tokenizer, eval_dataset, device="cuda"):
|
137 |
total = len(eval_dataset)
|
138 |
predictions = []
|
139 |
for i in tqdm(range(total)):
|
@@ -142,7 +142,12 @@ def eval_model(model, tokenizer, eval_dataset, device="cuda"):
|
|
142 |
return_tensors="pt",
|
143 |
).to(device)
|
144 |
|
145 |
-
outputs = model.generate(
|
|
|
|
|
|
|
|
|
|
|
146 |
decoded_output = tokenizer.batch_decode(outputs)
|
147 |
debug = i == 0
|
148 |
decoded_output = [
|
|
|
133 |
return text
|
134 |
|
135 |
|
136 |
+
def eval_model(model, tokenizer, eval_dataset, device="cuda", repetition_penalty=1.1):
|
137 |
total = len(eval_dataset)
|
138 |
predictions = []
|
139 |
for i in tqdm(range(total)):
|
|
|
142 |
return_tensors="pt",
|
143 |
).to(device)
|
144 |
|
145 |
+
outputs = model.generate(
|
146 |
+
**inputs,
|
147 |
+
max_new_tokens=4096,
|
148 |
+
repetition_penalty=repetition_penalty,
|
149 |
+
use_cache=False,
|
150 |
+
)
|
151 |
decoded_output = tokenizer.batch_decode(outputs)
|
152 |
debug = i == 0
|
153 |
decoded_output = [
|