Update README.md
Browse files
README.md
CHANGED
@@ -18,8 +18,11 @@ For model inference, please refer to the following example code:
|
|
18 |
|
19 |
```python
|
20 |
import torch
|
|
|
21 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
22 |
|
|
|
|
|
23 |
model_path = 'yueqingyou/BioQwen-1.8B'
|
24 |
tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=True)
|
25 |
model = AutoModelForCausalLM.from_pretrained(model_path, device_map='auto', torch_dtype=torch.bfloat16, attn_implementation='flash_attention_2').eval()
|
@@ -57,7 +60,7 @@ def predict(prompt):
|
|
57 |
do_sample=True,
|
58 |
top_p = 0.9,
|
59 |
temperature = 0.3,
|
60 |
-
repetition_penalty = 1.
|
61 |
)
|
62 |
|
63 |
generated_ids = [
|
@@ -68,7 +71,8 @@ def predict(prompt):
|
|
68 |
return response.strip()
|
69 |
|
70 |
prompt = 'I am suffering from irregular periods. I am currently taking medication Levothyroxine 50. My T3 is 0.87 ng/mL, T4 is 8.30 ug/dL, TSH is 2.43 uIU/mL. I am 34 years old, weigh 75 kg, and 5 feet tall. Please advice.'
|
71 |
-
predict(prompt)
|
|
|
72 |
```
|
73 |
|
74 |
For more detailed information and code, please refer to [GitHub](https://github.com/yueqingyou/BioQwen).
|
|
|
18 |
|
19 |
```python
|
20 |
import torch
|
21 |
+
import transformers
|
22 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
23 |
|
24 |
+
transformers.logging.set_verbosity_error()
|
25 |
+
max_length = 512
|
26 |
model_path = 'yueqingyou/BioQwen-1.8B'
|
27 |
tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=True)
|
28 |
model = AutoModelForCausalLM.from_pretrained(model_path, device_map='auto', torch_dtype=torch.bfloat16, attn_implementation='flash_attention_2').eval()
|
|
|
60 |
do_sample=True,
|
61 |
top_p = 0.9,
|
62 |
temperature = 0.3,
|
63 |
+
repetition_penalty = 1.1
|
64 |
)
|
65 |
|
66 |
generated_ids = [
|
|
|
71 |
return response.strip()
|
72 |
|
73 |
prompt = 'I am suffering from irregular periods. I am currently taking medication Levothyroxine 50. My T3 is 0.87 ng/mL, T4 is 8.30 ug/dL, TSH is 2.43 uIU/mL. I am 34 years old, weigh 75 kg, and 5 feet tall. Please advice.'
|
74 |
+
print(f'Question:\t{prompt}\n\nAnswer:\t{predict(prompt)}')
|
75 |
+
|
76 |
```
|
77 |
|
78 |
For more detailed information and code, please refer to [GitHub](https://github.com/yueqingyou/BioQwen).
|