Update README.md
Browse files
README.md
CHANGED
@@ -8,25 +8,30 @@ Use the code below to get started with the model.
|
|
8 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
9 |
|
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
|
30 |
|
31 |
-
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
32 |
|
|
|
8 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
9 |
|
10 |
model = AutoModelForCausalLM.from_pretrained("linh5nb/Llama-2-7b-chat-finetune_covid")
|
11 |
+
|
12 |
tokenizer = AutoTokenizer.from_pretrained("linh5nb/Llama-2-7b-chat-finetune_covid")
|
13 |
|
14 |
user_input = '''When was the West African Ebolavirus outbreak?'''
|
15 |
|
16 |
|
17 |
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
|
18 |
+
|
19 |
your_system_prompt = "Please, answer this question faithfully."
|
20 |
+
|
21 |
prompt = f"<s>[INST] <<SYS>>{our_system_prompt}<</SYS>>\n\n{your_system_prompt}\n{user_input} [/INST]"
|
22 |
|
23 |
inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False).input_ids.to(model.device)
|
24 |
+
|
25 |
outputs = model.generate(input_ids=inputs, max_length=4096)[0]
|
26 |
|
27 |
answer_start = int(inputs.shape[-1])
|
28 |
+
|
29 |
pred = tokenizer.decode(outputs[answer_start:], skip_special_tokens=True)
|
30 |
|
31 |
print(f'### User Input:\n{user_input}\n\n### Assistant Output:\n{pred}')
|
32 |
|
33 |
### Training Data
|
34 |
+
|
35 |
https://huggingface.co/datasets/hodgesz/covid_qa_llama2
|
36 |
|
|
|
37 |
|