File size: 808 Bytes
9bbc2d0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
from huggingface_hub import snapshot_download
import json
import os
REPO_ID = "mosaicml/mosaic-bert-base-seqlen-2048"
MODEL_DIRECTORY = "mosaic-bert-base-seqlen-2048"
def main():
snapshot_download(repo_id=REPO_ID, local_dir=MODEL_DIRECTORY)
# modify the model's config.json file to satisfy our requirements
config_file_path = os.path.join(MODEL_DIRECTORY, 'config.json')
contents = json.load(open(config_file_path))
contents['architectures'] = ['BertModel']
contents['auto_map']['AutoModel'] = 'bert_layers.BertModel'
contents['torch_dtype'] = 'bfloat16'
contents['transformers_version'] = '4.28.1'
contents['_name_or_path'] = 'mosaic-bert-base-seqlen-2048'
json.dump(contents, open(config_file_path, 'w'), ensure_ascii=True)
if __name__ == '__main__':
main() |