(
fname_out: Path, ftype: GGMLFileType, params: Params, model: LazyModel, vocab: BaseVocab, svocab: gguf.SpecialVocab,
concurrency: int = DEFAULT_CONCURRENCY, endianess: gguf.GGUFEndian = gguf.GGUFEndian.LITTLE,
pad_vocab: bool = False,
)
| 1312 | |
| 1313 | @staticmethod |
| 1314 | def write_all( |
| 1315 | fname_out: Path, ftype: GGMLFileType, params: Params, model: LazyModel, vocab: BaseVocab, svocab: gguf.SpecialVocab, |
| 1316 | concurrency: int = DEFAULT_CONCURRENCY, endianess: gguf.GGUFEndian = gguf.GGUFEndian.LITTLE, |
| 1317 | pad_vocab: bool = False, |
| 1318 | ) -> None: |
| 1319 | check_vocab_size(params, vocab, pad_vocab=pad_vocab) |
| 1320 | |
| 1321 | of = OutputFile(fname_out, endianess=endianess) |
| 1322 | |
| 1323 | if 'bitnet' in of.gguf.arch: |
| 1324 | svocab.chat_template = "{% for message in messages %}{% if loop.first %}{{ bos_token }}{% endif %}{% if message['role'] == 'user' %}{{ 'Human: ' + message['content'] + '\\n\\nBITNETAssistant: ' + eos_token }}{% elif message['role'] == 'assistant' %}{{ message['content'] + eos_token }}{% endif %}{% endfor %}" |
| 1325 | |
| 1326 | # meta data |
| 1327 | of.add_meta_arch(params) |
| 1328 | if isinstance(vocab, Vocab): |
| 1329 | of.add_meta_vocab(vocab) |
| 1330 | of.add_meta_special_vocab(svocab) |
| 1331 | else: # NoVocab |
| 1332 | of.gguf.add_tokenizer_model(vocab.tokenizer_model) |
| 1333 | |
| 1334 | # tensor info |
| 1335 | for name, lazy_tensor in model.items(): |
| 1336 | of.add_tensor_info(name, lazy_tensor) |
| 1337 | |
| 1338 | of.write_meta() |
| 1339 | of.write_tensor_info() |
| 1340 | |
| 1341 | # tensor data |
| 1342 | of.write_tensor_data(ftype, model, concurrency) |
| 1343 | |
| 1344 | of.close() |
| 1345 | |
| 1346 | |
| 1347 | def pick_output_type(model: LazyModel, output_type_str: str | None) -> GGMLFileType: |
no test coverage detected