Spaces:
Sleeping
Sleeping
Commit
·
8277386
1
Parent(s):
f2f5e43
feat add time in prediction.py
Browse files- prediction.py +6 -3
prediction.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
from functools import partial
|
| 2 |
import os
|
| 3 |
import re
|
|
|
|
| 4 |
from xml.parsers.expat import model
|
| 5 |
|
| 6 |
# https://discuss.huggingface.co/t/issues-with-sadtalker-zerogpu-spaces-inquiry-about-community-grant/110625/10
|
|
@@ -16,7 +17,6 @@ else:
|
|
| 16 |
|
| 17 |
return wrapper
|
| 18 |
|
| 19 |
-
|
| 20 |
from transformers import pipeline as hf_pipeline
|
| 21 |
|
| 22 |
import litellm
|
|
@@ -59,7 +59,6 @@ class ModelPrediction:
|
|
| 59 |
|
| 60 |
def _reset_pipeline(self, model_name):
|
| 61 |
if self._model_name != model_name:
|
| 62 |
-
print("Resetting pipeline with model", model_name)
|
| 63 |
self._model_name = model_name
|
| 64 |
self._pipeline = None
|
| 65 |
|
|
@@ -81,15 +80,19 @@ class ModelPrediction:
|
|
| 81 |
"supported models are",
|
| 82 |
self.model_name2pred_func.keys(),
|
| 83 |
)
|
|
|
|
| 84 |
|
| 85 |
prompt = prompt or self.base_prompt
|
| 86 |
prompt = prompt.format(question=question, db_schema=db_schema)
|
| 87 |
-
print(prompt)
|
| 88 |
|
|
|
|
| 89 |
prediction = self.model_name2pred_func[model_name](prompt)
|
|
|
|
| 90 |
prediction["response_parsed"] = self._extract_answer_from_pred(
|
| 91 |
prediction["response"]
|
| 92 |
)
|
|
|
|
|
|
|
| 93 |
return prediction
|
| 94 |
|
| 95 |
|
|
|
|
| 1 |
from functools import partial
|
| 2 |
import os
|
| 3 |
import re
|
| 4 |
+
import time
|
| 5 |
from xml.parsers.expat import model
|
| 6 |
|
| 7 |
# https://discuss.huggingface.co/t/issues-with-sadtalker-zerogpu-spaces-inquiry-about-community-grant/110625/10
|
|
|
|
| 17 |
|
| 18 |
return wrapper
|
| 19 |
|
|
|
|
| 20 |
from transformers import pipeline as hf_pipeline
|
| 21 |
|
| 22 |
import litellm
|
|
|
|
| 59 |
|
| 60 |
def _reset_pipeline(self, model_name):
|
| 61 |
if self._model_name != model_name:
|
|
|
|
| 62 |
self._model_name = model_name
|
| 63 |
self._pipeline = None
|
| 64 |
|
|
|
|
| 80 |
"supported models are",
|
| 81 |
self.model_name2pred_func.keys(),
|
| 82 |
)
|
| 83 |
+
|
| 84 |
|
| 85 |
prompt = prompt or self.base_prompt
|
| 86 |
prompt = prompt.format(question=question, db_schema=db_schema)
|
|
|
|
| 87 |
|
| 88 |
+
start_time = time.time()
|
| 89 |
prediction = self.model_name2pred_func[model_name](prompt)
|
| 90 |
+
end_time = time.time()
|
| 91 |
prediction["response_parsed"] = self._extract_answer_from_pred(
|
| 92 |
prediction["response"]
|
| 93 |
)
|
| 94 |
+
prediction['time'] = end_time - start_time
|
| 95 |
+
|
| 96 |
return prediction
|
| 97 |
|
| 98 |
|