Spaces:
Runtime error
Runtime error
Commit
·
5808e38
1
Parent(s):
c4d3822
Update app.py
Browse filesAdded bits & bites config
app.py
CHANGED
|
@@ -2,10 +2,16 @@ import torch
|
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
from peft import PeftModel, PeftConfig
|
| 5 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer ,pipeline
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
config = PeftConfig.from_pretrained("ShishuTripathi/entity_coder")
|
| 8 |
-
model = AutoModelForCausalLM.from_pretrained("ybelkada/falcon-7b-sharded-bf16", trust_remote_code=True)
|
| 9 |
model = PeftModel.from_pretrained(model, "ShishuTripathi/entity_coder")
|
| 10 |
tokenizer = AutoTokenizer.from_pretrained("ShishuTripathi/entity_coder")
|
| 11 |
generator = pipeline('text-generation' , model = model, tokenizer =tokenizer, max_length = 50)
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
from peft import PeftModel, PeftConfig
|
| 5 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer ,pipeline, BitsAndBytesConfig
|
| 6 |
+
|
| 7 |
+
bnb_config = BitsAndBytesConfig(
|
| 8 |
+
load_in_4bit=True,
|
| 9 |
+
bnb_4bit_quant_type="nf4",
|
| 10 |
+
bnb_4bit_compute_dtype=torch.float16,
|
| 11 |
+
)
|
| 12 |
|
| 13 |
config = PeftConfig.from_pretrained("ShishuTripathi/entity_coder")
|
| 14 |
+
model = AutoModelForCausalLM.from_pretrained("ybelkada/falcon-7b-sharded-bf16", quantization_config=bnb_config,trust_remote_code=True)
|
| 15 |
model = PeftModel.from_pretrained(model, "ShishuTripathi/entity_coder")
|
| 16 |
tokenizer = AutoTokenizer.from_pretrained("ShishuTripathi/entity_coder")
|
| 17 |
generator = pipeline('text-generation' , model = model, tokenizer =tokenizer, max_length = 50)
|