fix accuracy sensitiveness

This commit is contained in:
Yingda Chen
2024-12-03 18:39:32 +08:00
parent 1950ec1839
commit 89029d20f5
2 changed files with 28 additions and 10 deletions

View File

@@ -55,15 +55,6 @@ class LlamafileCMD(CLICommand):
'Selected accuracy of GGUF files in the repo. Ignored when "file" is also provided.'
)
group.add_argument(
'--launch',
type=str,
required=False,
default='True',
help=
'Whether to launch model with the downloaded llamafile, default to True.'
)
group.add_argument(
'--file',
type=str,
@@ -80,6 +71,15 @@ class LlamafileCMD(CLICommand):
'Directory where the selected llamafile would will be downloaded to.'
)
group.add_argument(
'--launch',
type=str,
required=False,
default='True',
help=
'Whether to launch model with the downloaded llamafile, default to True.'
)
parser.set_defaults(func=subparser_func)
def execute(self):
@@ -106,7 +106,7 @@ class LlamafileCMD(CLICommand):
selected_file = f
found = True
break
if self.args.accuracy and self.args.accuracy in f.lower():
if self.args.accuracy and self.args.accuracy.lower() in f.lower():
selected_file = f
found = True
break

View File

@@ -29,6 +29,24 @@ class LlamafileCMDTest(unittest.TestCase):
in output)
self.assertTrue('Launching model with llamafile' in output)
accuracy = 'Q2_K'
cmd = f'python -m modelscope.cli.cli {self.cmd} --model {self.model_id} --accuracy {accuracy}'
stat, output = subprocess.getstatusoutput(cmd)
self.assertEqual(stat, 0)
self.assertTrue(
'llamafile matching criteria found: [My-Model-14B-Q2_K.llamafile]'
in output)
self.assertTrue('Launching model with llamafile' in output)
accuracy = 'q2_k'
cmd = f'python -m modelscope.cli.cli {self.cmd} --model {self.model_id} --accuracy {accuracy}'
stat, output = subprocess.getstatusoutput(cmd)
self.assertEqual(stat, 0)
self.assertTrue(
'llamafile matching criteria found: [My-Model-14B-Q2_K.llamafile]'
in output)
self.assertTrue('Launching model with llamafile' in output)
def test_given_file(self):
file = 'My-Model-14B-FP16.llamafile'
cmd = f'python -m modelscope.cli.cli {self.cmd} --model {self.model_id} --file {file}'