Enhance completions benchmark generator to extract words from a fallback Perl copyright file
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import random
|
import random
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
from vastai import Worker, WorkerConfig, HandlerConfig, LogActionConfig, BenchmarkConfig
|
from vastai import Worker, WorkerConfig, HandlerConfig, LogActionConfig, BenchmarkConfig
|
||||||
|
|
||||||
@@ -22,11 +23,16 @@ def completions_benchmark_generator() -> dict:
|
|||||||
|
|
||||||
WORD_LIST = []
|
WORD_LIST = []
|
||||||
|
|
||||||
with open(__file__, 'r') as f:
|
# Try to load from perl copyright file first
|
||||||
# Use regex to extract words from the source code
|
try:
|
||||||
import re
|
with open("/usr/share/doc/perl/copyright", 'r') as f:
|
||||||
source_code = f.read()
|
source_code = f.read()
|
||||||
WORD_LIST = re.findall(r'\b\w+\b', source_code)
|
WORD_LIST = re.findall(r'\b\w+\b', source_code)
|
||||||
|
except (FileNotFoundError, IOError):
|
||||||
|
# Fallback to loading from python file
|
||||||
|
with open(__file__, 'r') as f:
|
||||||
|
source_code = f.read()
|
||||||
|
WORD_LIST = re.findall(r'\b\w+\b', source_code)
|
||||||
|
|
||||||
prompt = " ".join(random.choices(WORD_LIST, k=int(250)))
|
prompt = " ".join(random.choices(WORD_LIST, k=int(250)))
|
||||||
model = os.environ.get("MODEL_NAME")
|
model = os.environ.get("MODEL_NAME")
|
||||||
|
|||||||
Reference in New Issue
Block a user