YiDuo1999 commited on
Commit
0e81185
1 Parent(s): 5e03a62

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +46 -3
README.md CHANGED
@@ -1,3 +1,46 @@
1
- ---
2
- license: llama3
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: llama3
3
+ ---
4
+ The official instruct model weights for "Efficient Continual Pre-training by Mitigating the Stability Gap".
5
+
6
+ ## Introduction
7
+ This repo contains Llama-3-Physician-8B-Instruct, a medical language model with 8 billion parameters. This model builds upon the foundation of Llama 3 and has been firstly continual pretrained on high-quality medical sub-corpus from the RefinedWeb dataset and then tuned with diverse medical and general instructions. We also use the three strategies in the paper to mitigate the stability gap during continual pretraining and instruction tuning, which boosts the model's medical task performance and reduces the computation consumption.
8
+
9
+ ## 💻 Usage
10
+
11
+ ```python
12
+ from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
13
+ import torch
14
+ model_name = "YiDuo1999/Llama-3-Physician-8B-Instruct"
15
+ device_map = 'auto'
16
+ model = AutoModelForCausalLM.from_pretrained( model_name, trust_remote_code=True,use_cache=False,device_map=device_map)
17
+ tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
18
+ tokenizer.pad_token = tokenizer.eos_token
19
+ def askme(question):
20
+ sys_message = '''
21
+ You are an AI Medical Assistant trained on a vast dataset of health information. Please be thorough and
22
+ provide an informative answer. If you don't know the answer to a specific medical inquiry, advise seeking professional help.
23
+ '''
24
+ # Create messages structured for the chat template
25
+ messages = [{"role": "system", "content": sys_message}, {"role": "user", "content": question}]
26
+
27
+ # Applying chat template
28
+ prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
29
+ inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
30
+ outputs = model.generate(**inputs, max_new_tokens=100, use_cache=True)
31
+
32
+ # Extract and return the generated text, removing the prompt
33
+ response_text = tokenizer.batch_decode(outputs)[0].strip()
34
+ answer = response_text.split('<|im_start|>assistant')[-1].strip()
35
+ return answer
36
+ # Example usage
37
+ # - Context: First describe your problem.
38
+ # - Question: Then make the question.
39
+ question = '''What is HIV?'''
40
+ print(askme(question))
41
+ ```
42
+ the type of answer is :
43
+ ```
44
+ HIV, or Human Immunodeficiency Virus, is a retrovirus that primarily infects cells of the human immune system, particularly CD4+ T cells, which are crucial to the body's ability to fight off infection. HIV infection can lead to AIDS, or Acquired Immune Deficiency Syndrome, a condition that causes severe damage to the immune system and makes individuals more susceptible to life-threatening infections. HIV
45
+ is transmitted through sexual contact, sharing needles, or through mother-to-child transmission during pregnancy.
46
+ ```