load model from local

pull/464/head
simon gao 2023-05-08 12:03:03 +08:00
parent da9dfee3ef
commit 0685b56bc1
1 changed files with 9 additions and 4 deletions

View File

@ -95,9 +95,14 @@ async def create_item(request: Request):
if __name__ == '__main__': if __name__ == '__main__':
tokenizer = AutoTokenizer.from_pretrained( #tokenizer = AutoTokenizer.from_pretrained(
"THUDM/chatglm-6b", trust_remote_code=True) # "THUDM/chatglm-6b", trust_remote_code=True)
model = AutoModel.from_pretrained( #model = AutoModel.from_pretrained(
"THUDM/chatglm-6b", trust_remote_code=True).half().cuda() # "THUDM/chatglm-6b", trust_remote_code=True).half().cuda()
# mkdir model
# cp ~/.cache/huggingface/hub/models--THUDM--chatglm-6b/snapshots/658202d88ac4bb782b99e99ac3adff58b4d0b813 ./model
model_path = "./model/"
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
model = AutoModel.from_pretrained(model_path, trust_remote_code=True).half().cuda()
model.eval() model.eval()
uvicorn.run(app, host='0.0.0.0', port=8000, workers=1) uvicorn.run(app, host='0.0.0.0', port=8000, workers=1)