Update README.md
Browse files
README.md
CHANGED
@@ -56,10 +56,12 @@ base_model = AutoModelForCausalLM.from_pretrained("microsoft/phi-2",device_map="
|
|
56 |
model = PeftModel.from_pretrained(base_model, "Mit1208/phi-2-universal-NER", trust_remote_code=True)
|
57 |
tokenizer = AutoTokenizer.from_pretrained("Mit1208/phi-2-universal-NER", trust_remote_code=True)
|
58 |
|
|
|
|
|
59 |
conversations = [ { "from": "human", "value": "Text: Mit Patel here from India"}, {"from": "gpt", "value": "I've read this text."},
|
60 |
{"from":"human", "value":"what is a name of the person in the text?"}]
|
61 |
inference_text = tokenizer.apply_chat_template(conversations, tokenize=False) + '<|im_start|>gpt:\n'
|
62 |
-
inputs = tokenizer(inference_text, return_tensors="pt", return_attention_mask=False)
|
63 |
|
64 |
class EosListStoppingCriteria(StoppingCriteria):
|
65 |
def __init__(self, eos_sequence = tokenizer.encode("<|im_end|>")):
|
|
|
56 |
model = PeftModel.from_pretrained(base_model, "Mit1208/phi-2-universal-NER", trust_remote_code=True)
|
57 |
tokenizer = AutoTokenizer.from_pretrained("Mit1208/phi-2-universal-NER", trust_remote_code=True)
|
58 |
|
59 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
60 |
+
|
61 |
conversations = [ { "from": "human", "value": "Text: Mit Patel here from India"}, {"from": "gpt", "value": "I've read this text."},
|
62 |
{"from":"human", "value":"what is a name of the person in the text?"}]
|
63 |
inference_text = tokenizer.apply_chat_template(conversations, tokenize=False) + '<|im_start|>gpt:\n'
|
64 |
+
inputs = tokenizer(inference_text, return_tensors="pt", return_attention_mask=False).to(device)
|
65 |
|
66 |
class EosListStoppingCriteria(StoppingCriteria):
|
67 |
def __init__(self, eos_sequence = tokenizer.encode("<|im_end|>")):
|