Views
No views yet
epfl-llm/meditron-7b with open assist dataset using SFT QLora .'<s> [INST] <<SYS>>
You are a helpful, respectful and medical 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.
If 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.
<</SYS>> {question} [/INST] {Model answer } </s>'1model_name='jiviadmin/meditron-7b-guanaco-chat'
2
3# Load the model
4base_model = AutoModelForCausalLM.from_pretrained(
5model_name,
6low_cpu_mem_usage=True,
7return_dict=True,
8torch_dtype=torch.float16,
9device_map={"": 0},
10)
11# Load tokenizer to save it
12tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True,add_eos_token=True)
13tokenizer.add_special_tokens({'pad_token': '[PAD]'})
14tokenizer.pad_token_id = 18610
15tokenizer.padding_side = "right"
16
17default_system_prompt="You are a helpful, respectful and honest medical 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.
18If 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.Please consider the context below if applicable:
19Context:NA"
20
21#Initialize the hugging face pipeline
22def format_prompt(question):
23 return f'''<s> [INST] <<SYS>> {default_system_prompt} <</SYS>> [INST] {question} [/INST]'''
24
25question=' My father has a big white colour patch inside of his right cheek. please suggest a reason.'
26
27pipe = pipeline(task="text-generation", model=base_model, tokenizer=tokenizer, max_length=512,repetition_penalty=1.1,return_full_text=False)
28result = pipe(format_prompt(question))
29answer=result[0]['generated_text']
30print(answer)