Skip to content

Commit

Permalink
Update chat_ner.py
Browse files Browse the repository at this point in the history
  • Loading branch information
taishan1994 committed May 24, 2023
1 parent bb5d759 commit 2053893
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions chat_ner.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import torch
import json
from pprint import pprint
Expand All @@ -18,12 +19,12 @@

model = AutoModel.from_pretrained(args["model_dir"], trust_remote_code=True).half().cuda()
model = model.eval()
model = PeftModel.from_pretrained(model, args["save_dir"], torch_dtype=torch.float32, trust_remote_code=True)
model = PeftModel.from_pretrained(model, os.path.join(args["save_dir"], "adapter_model"), torch_dtype=torch.float32, trust_remote_code=True)
model.half().cuda()
model.eval()

while True:
inp = input("用户 >>> ")
response, history = model.chat(tokenizer, inp, history=[])
print("ChatNER >>> ", response))
print("="*100)
print("="*100)

0 comments on commit 2053893

Please sign in to comment.