mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-25 17:29:22 +01:00
Specify utf-8 encoding for model metadata file open (#5125)
This commit is contained in:
parent
20a2eaaf95
commit
b7dd1f9542
@ -35,7 +35,7 @@ def get_model_metadata(model):
|
|||||||
|
|
||||||
path = Path(f'{shared.args.model_dir}/{model}/config.json')
|
path = Path(f'{shared.args.model_dir}/{model}/config.json')
|
||||||
if path.exists():
|
if path.exists():
|
||||||
hf_metadata = json.loads(open(path, 'r').read())
|
hf_metadata = json.loads(open(path, 'r', encoding='utf-8').read())
|
||||||
else:
|
else:
|
||||||
hf_metadata = None
|
hf_metadata = None
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ def get_model_metadata(model):
|
|||||||
else:
|
else:
|
||||||
# Transformers metadata
|
# Transformers metadata
|
||||||
if hf_metadata is not None:
|
if hf_metadata is not None:
|
||||||
metadata = json.loads(open(path, 'r').read())
|
metadata = json.loads(open(path, 'r', encoding='utf-8').read())
|
||||||
if 'max_position_embeddings' in metadata:
|
if 'max_position_embeddings' in metadata:
|
||||||
model_settings['truncation_length'] = metadata['max_position_embeddings']
|
model_settings['truncation_length'] = metadata['max_position_embeddings']
|
||||||
model_settings['max_seq_len'] = metadata['max_position_embeddings']
|
model_settings['max_seq_len'] = metadata['max_position_embeddings']
|
||||||
@ -101,7 +101,7 @@ def get_model_metadata(model):
|
|||||||
# Read AutoGPTQ metadata
|
# Read AutoGPTQ metadata
|
||||||
path = Path(f'{shared.args.model_dir}/{model}/quantize_config.json')
|
path = Path(f'{shared.args.model_dir}/{model}/quantize_config.json')
|
||||||
if path.exists():
|
if path.exists():
|
||||||
metadata = json.loads(open(path, 'r').read())
|
metadata = json.loads(open(path, 'r', encoding='utf-8').read())
|
||||||
if 'bits' in metadata:
|
if 'bits' in metadata:
|
||||||
model_settings['wbits'] = metadata['bits']
|
model_settings['wbits'] = metadata['bits']
|
||||||
if 'group_size' in metadata:
|
if 'group_size' in metadata:
|
||||||
@ -112,7 +112,7 @@ def get_model_metadata(model):
|
|||||||
# Try to find the Jinja instruct template
|
# Try to find the Jinja instruct template
|
||||||
path = Path(f'{shared.args.model_dir}/{model}') / 'tokenizer_config.json'
|
path = Path(f'{shared.args.model_dir}/{model}') / 'tokenizer_config.json'
|
||||||
if path.exists():
|
if path.exists():
|
||||||
metadata = json.loads(open(path, 'r').read())
|
metadata = json.loads(open(path, 'r', encoding='utf-8').read())
|
||||||
if 'chat_template' in metadata:
|
if 'chat_template' in metadata:
|
||||||
template = metadata['chat_template']
|
template = metadata['chat_template']
|
||||||
for k in ['eos_token', 'bos_token']:
|
for k in ['eos_token', 'bos_token']:
|
||||||
|
Loading…
Reference in New Issue
Block a user