nmitchko commited on
Commit
496644d
1 Parent(s): aeef31f

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +76 -0
README.md ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ library_name: peft
5
+ pipeline_tag: text-generation
6
+ tags:
7
+ - medical
8
+ license: cc-by-nc-3.0
9
+ ---
10
+
11
+ # MedFalcon 40b LoRA
12
+
13
+
14
+ ## Model Description
15
+
16
+ ### Architecture
17
+ `nmitchko/medfalcon-40b-lora` is a large language model LoRa specifically fine-tuned for medical domain tasks.
18
+ It is based on [`Falcon-40b-instruct`](https://huggingface.co/tiiuae/falcon-40b-instruct/) at 40 billion parameters.
19
+
20
+ The primary goal of this model is to improve question-answering and medical dialogue tasks.
21
+ It was trained using [LoRA](https://arxiv.org/abs/2106.09685), specifically [QLora](https://github.com/artidoro/qlora), to reduce memory footprint.
22
+
23
+ > This Lora supports 4-bit and 8-bit modes.
24
+
25
+ ### Requirements
26
+
27
+ ```
28
+ bitsandbytes>=0.39.0
29
+ peft
30
+ transformers
31
+ ```
32
+
33
+ Steps to load this model:
34
+ 1. Load base model using QLORA
35
+ 2. Apply LoRA using peft
36
+
37
+ ```python
38
+ #
39
+ from transformers import AutoTokenizer, AutoModelForCausalLM
40
+ import transformers
41
+ import torch
42
+
43
+ model = "tiiuae/falcon-40b-instruct/"
44
+ LoRA = "nmitchko/medfalcon-40b-lora"
45
+
46
+ tokenizer = AutoTokenizer.from_pretrained(model)
47
+
48
+ model = AutoModelForCausalLM.from_pretrained(model,
49
+ load_in_8bit=load_8bit,
50
+ torch_dtype=torch.float16,
51
+ trust_remote_code=True,
52
+ )
53
+
54
+ model = PeftModel.from_pretrained(model, LoRA)
55
+
56
+ pipeline = transformers.pipeline(
57
+ "text-generation",
58
+ model=model,
59
+ tokenizer=tokenizer,
60
+ torch_dtype=torch.bfloat16,
61
+ trust_remote_code=True,
62
+ device_map="auto",
63
+ )
64
+
65
+ sequences = pipeline(
66
+ "What does the drug ceftrioxone do?\nDoctor:",
67
+ max_length=200,
68
+ do_sample=True,
69
+ top_k=40,
70
+ num_return_sequences=1,
71
+ eos_token_id=tokenizer.eos_token_id,
72
+ )
73
+
74
+ for seq in sequences:
75
+ print(f"Result: {seq['generated_text']}")
76
+ ```