|
--- |
|
|
|
|
|
## How to Get Started with the Model |
|
|
|
Use the code below to get started with the model. |
|
|
|
from transformers import AutoModelForCausalLM, AutoTokenizer |
|
|
|
model = AutoModelForCausalLM.from_pretrained("linh5nb/Llama-2-7b-chat-finetune_covid") |
|
|
|
tokenizer = AutoTokenizer.from_pretrained("linh5nb/Llama-2-7b-chat-finetune_covid") |
|
|
|
user_input = '''When was the West African Ebolavirus outbreak?''' |
|
|
|
|
|
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 |
|
|
|
your_system_prompt = "Please, answer this question faithfully." |
|
|
|
prompt = f"<s>[INST] <<SYS>>{our_system_prompt}<</SYS>>\n\n{your_system_prompt}\n{user_input} [/INST]" |
|
|
|
inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False).input_ids.to(model.device) |
|
|
|
outputs = model.generate(input_ids=inputs, max_length=4096)[0] |
|
|
|
answer_start = int(inputs.shape[-1]) |
|
|
|
pred = tokenizer.decode(outputs[answer_start:], skip_special_tokens=True) |
|
|
|
print(f'### User Input:\n{user_input}\n\n### Assistant Output:\n{pred}') |
|
|
|
### Training Data |
|
|
|
https://huggingface.co/datasets/hodgesz/covid_qa_llama2 |
|
|
|
|
|
|