Upload MyTestPipeline
Browse files- new_task.py +4 -1
new_task.py
CHANGED
|
@@ -5,7 +5,7 @@ import numpy as np
|
|
| 5 |
|
| 6 |
class MyTestPipeline(TextGenerationPipeline):
|
| 7 |
def preprocess(self, text, **kwargs):
|
| 8 |
-
prompt = 'Answer the following question/statement without any explanation, do not abbreviate names
|
| 9 |
txt = f"<|user|>\n{prompt} {text}\n<|end|>\n<|assistant|>"
|
| 10 |
return self.tokenizer(txt, return_tensors=self.framework)
|
| 11 |
|
|
@@ -35,5 +35,8 @@ class MyTestPipeline(TextGenerationPipeline):
|
|
| 35 |
log_probs = np.round(np.exp(transition_scores.cpu().numpy()), 3)[0]
|
| 36 |
guess_prob = np.product(log_probs)
|
| 37 |
|
|
|
|
|
|
|
|
|
|
| 38 |
return {'guess': guess_text, 'confidence': guess_prob}
|
| 39 |
|
|
|
|
| 5 |
|
| 6 |
class MyTestPipeline(TextGenerationPipeline):
|
| 7 |
def preprocess(self, text, **kwargs):
|
| 8 |
+
prompt = 'Answer the following question/statement without any explanation, do not abbreviate names.'
|
| 9 |
txt = f"<|user|>\n{prompt} {text}\n<|end|>\n<|assistant|>"
|
| 10 |
return self.tokenizer(txt, return_tensors=self.framework)
|
| 11 |
|
|
|
|
| 35 |
log_probs = np.round(np.exp(transition_scores.cpu().numpy()), 3)[0]
|
| 36 |
guess_prob = np.product(log_probs)
|
| 37 |
|
| 38 |
+
if guess_prob >= 0.8:
|
| 39 |
+
guess_prob = 1.0
|
| 40 |
+
|
| 41 |
return {'guess': guess_text, 'confidence': guess_prob}
|
| 42 |
|