Spaces:
Sleeping
Sleeping
File size: 1,207 Bytes
77f290b 2db37b1 77f290b 2db37b1 77f290b 2db37b1 77f290b 2db37b1 febd197 2db37b1 77f290b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
import re
from core.conversion import noop_logger
def evaluate(llm, zip, readmes, log_fn=noop_logger):
log_fn("TITLE", "\nLooking for code to train the model...")
overall = "No"
patterns = {
'tensorflow': [
r'model\.(fit|compile|train_on_batch)',
r'tf\.GradientTape'
],
'pytorch': [
r'model\.(train|forward)',
r'loss\.backward',
r'optimizer\.step',
]
}
files = [file_path for file_path in zip.namelist() if ((file_path.endswith(".py") | file_path.endswith(".ipynb")))]
for file_path in files:
code = zip.open(file_path).read().decode("utf-8")
for framework, regex_list in patterns.items():
for pattern in regex_list:
if re.search(pattern, code):
log_fn("LOG", f"Found code for training a model in {framework} framework in file: {file_path}")
overall = "Yes"
for readme in readmes:
if (readme):
if (("train" in readme)):
log_fn("LOG", "Found something about training in README file")
overall = "Yes"
if (overall == "No"):
log_fn("ERROR", "Found no code for training the model.")
return overall |