Update README.md
Browse files
README.md
CHANGED
@@ -10,17 +10,20 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
10 |
model = AutoModelForCausalLM.from_pretrained("linh5nb/Llama-2-7b-chat-finetune_covid")
|
11 |
tokenizer = AutoTokenizer.from_pretrained("linh5nb/Llama-2-7b-chat-finetune_covid")
|
12 |
|
13 |
-
|
14 |
|
15 |
-
pipe = pipeline(task="text-generation", model=model, tokenizer=tokenizer, max_length=200)
|
16 |
|
17 |
-
|
|
|
|
|
18 |
|
19 |
-
|
|
|
20 |
|
21 |
-
|
|
|
22 |
|
23 |
-
|
24 |
|
25 |
### Training Data
|
26 |
https://huggingface.co/datasets/hodgesz/covid_qa_llama2
|
|
|
10 |
model = AutoModelForCausalLM.from_pretrained("linh5nb/Llama-2-7b-chat-finetune_covid")
|
11 |
tokenizer = AutoTokenizer.from_pretrained("linh5nb/Llama-2-7b-chat-finetune_covid")
|
12 |
|
13 |
+
user_input = '''When was the West African Ebolavirus outbreak?'''
|
14 |
|
|
|
15 |
|
16 |
+
our_system_prompt = "\nYou are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.\n\nIf a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.\n" # Please do NOT change this
|
17 |
+
your_system_prompt = "Please, answer this question faithfully."
|
18 |
+
prompt = f"<s>[INST] <<SYS>>{our_system_prompt}<</SYS>>\n\n{your_system_prompt}\n{user_input} [/INST]"
|
19 |
|
20 |
+
inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False).input_ids.to(model.device)
|
21 |
+
outputs = model.generate(input_ids=inputs, max_length=4096)[0]
|
22 |
|
23 |
+
answer_start = int(inputs.shape[-1])
|
24 |
+
pred = tokenizer.decode(outputs[answer_start:], skip_special_tokens=True)
|
25 |
|
26 |
+
print(f'### User Input:\n{user_input}\n\n### Assistant Output:\n{pred}')
|
27 |
|
28 |
### Training Data
|
29 |
https://huggingface.co/datasets/hodgesz/covid_qa_llama2
|