Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,8 +7,10 @@ from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
|
| 7 |
# from google.colab import userdata
|
| 8 |
import os
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
|
|
|
|
|
|
|
| 12 |
bnb_config = BitsAndBytesConfig(
|
| 13 |
load_in_4bit=True,
|
| 14 |
bnb_4bit_quant_type="nf4",
|
|
@@ -23,14 +25,16 @@ max_seq_length=400
|
|
| 23 |
# attn_implementation=None
|
| 24 |
attn_implementation=None
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
# quantization_config=bnb_config,
|
| 30 |
-
device_map = {"":0},
|
| 31 |
-
attn_implementation = attn_implementation, # A100 o H100
|
| 32 |
-
).eval()
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
|
| 36 |
class ListOfTokensStoppingCriteria(StoppingCriteria):
|
|
|
|
| 7 |
# from google.colab import userdata
|
| 8 |
import os
|
| 9 |
|
| 10 |
+
#sft_model = "somosnlp/gemma-FULL-RAC-Colombia_v2"
|
| 11 |
+
sft_model = "somosnlp/RecetasDeLaAbuela_mistral-7b-instruct-v0.2-bnb-4bit"
|
| 12 |
+
base_model_name = "mistralai/Mistral-7B-Instruct-v0.2"
|
| 13 |
+
|
| 14 |
bnb_config = BitsAndBytesConfig(
|
| 15 |
load_in_4bit=True,
|
| 16 |
bnb_4bit_quant_type="nf4",
|
|
|
|
| 25 |
# attn_implementation=None
|
| 26 |
attn_implementation=None
|
| 27 |
|
| 28 |
+
#base_model = AutoModelForCausalLM.from_pretrained(model_name,return_dict=True,torch_dtype=torch.float16,)
|
| 29 |
+
#base_model = AutoModelForCausalLM.from_pretrained(model_name,return_dict=True,device_map="auto", torch_dtype=torch.float16,)
|
| 30 |
+
base_model = AutoModelForCausalLM.from_pretrained(base_model_name, return_dict=True, device_map = {"":0}, attn_implementation = attn_implementation, # A100 o H100).eval()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
+
tokenizer = AutoTokenizer.from_pretrained(sft_model, max_length = max_seq_length)
|
| 33 |
+
ft_model = PeftModel.from_pretrained(base_model, sft_model)
|
| 34 |
+
model = ft_model.merge_and_unload()
|
| 35 |
+
model.save_pretrained(".")
|
| 36 |
+
model.to('cuda')
|
| 37 |
+
tokenizer.save_pretrained(".")
|
| 38 |
|
| 39 |
|
| 40 |
class ListOfTokensStoppingCriteria(StoppingCriteria):
|