MCPcopy Create free account
hub / github.com/TabbyML/tabby / save

Method save

python/ctranslate2/specs/model_spec.py:364–380  ·  view source on GitHub ↗

Saves this model on disk. Arguments: output_dir: Output directory where the model is saved.

(self, output_dir: str)

Source from the content-addressed store, hash-verified

362 self._files[filename] = path
363
364 def save(self, output_dir: str) -> None:
365 """Saves this model on disk.
366
367 Arguments:
368 output_dir: Output directory where the model is saved.
369 """
370 self._serialize(os.path.join(output_dir, "model.bin"))
371 if self._config is not None:
372 self._config.save_as_json(os.path.join(output_dir, "config.json"))
373
374 for filename, path in self._files.items():
375 destination = os.path.join(output_dir, filename)
376 if os.path.exists(destination):
377 raise RuntimeError(
378 "File %s already exists in the model directory" % destination
379 )
380 shutil.copy(path, destination)
381
382 def _serialize(self, path):
383 """Serializes the model variables."""

Callers 5

test_torch_variablesFunction · 0.45
convertMethod · 0.45
saveMethod · 0.45
saveMethod · 0.45

Calls 4

_serializeMethod · 0.95
joinMethod · 0.80
save_as_jsonMethod · 0.80
copyMethod · 0.80

Tested by 2

test_torch_variablesFunction · 0.36