Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -12,39 +12,18 @@ import torch
|
|
12 |
from langchain_community.vectorstores import FAISS
|
13 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
14 |
from huggingface_hub import login
|
15 |
-
from transformers import BitsAndBytesConfig
|
16 |
|
17 |
# Autenticaci贸n en Hugging Face
|
18 |
huggingface_token = st.secrets["HUGGINGFACE_TOKEN"]
|
19 |
login(huggingface_token)
|
20 |
|
21 |
# Configurar modelo y tokenizador
|
22 |
-
model_name = '
|
23 |
model_config = AutoConfig.from_pretrained(model_name)
|
24 |
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
25 |
tokenizer.pad_token = tokenizer.eos_token
|
26 |
tokenizer.padding_side = "right"
|
27 |
|
28 |
-
# Configuraci贸n de bitsandbytes para cargar el modelo en 4-bit
|
29 |
-
use_4bit = True
|
30 |
-
bnb_4bit_compute_dtype = "float16"
|
31 |
-
bnb_4bit_quant_type = "nf4"
|
32 |
-
use_nested_quant = False
|
33 |
-
|
34 |
-
compute_dtype = getattr(torch, bnb_4bit_compute_dtype)
|
35 |
-
|
36 |
-
bnb_config = BitsAndBytesConfig(
|
37 |
-
load_in_4bit=use_4bit,
|
38 |
-
bnb_4bit_quant_type=bnb_4bit_quant_type,
|
39 |
-
bnb_4bit_compute_dtype=compute_dtype,
|
40 |
-
bnb_4bit_use_double_quant=use_nested_quant,
|
41 |
-
)
|
42 |
-
|
43 |
-
model = AutoModelForCausalLM.from_pretrained(
|
44 |
-
model_name,
|
45 |
-
quantization_config=bnb_config,
|
46 |
-
)
|
47 |
-
|
48 |
text_generation_pipeline = pipeline(
|
49 |
model=model,
|
50 |
tokenizer=tokenizer,
|
@@ -52,7 +31,7 @@ text_generation_pipeline = pipeline(
|
|
52 |
temperature=0.2,
|
53 |
repetition_penalty=1.1,
|
54 |
return_full_text=True,
|
55 |
-
max_new_tokens=
|
56 |
)
|
57 |
|
58 |
prompt_template = """
|
|
|
12 |
from langchain_community.vectorstores import FAISS
|
13 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
14 |
from huggingface_hub import login
|
|
|
15 |
|
16 |
# Autenticaci贸n en Hugging Face
|
17 |
huggingface_token = st.secrets["HUGGINGFACE_TOKEN"]
|
18 |
login(huggingface_token)
|
19 |
|
20 |
# Configurar modelo y tokenizador
|
21 |
+
model_name = 'Fawazzx/SaulLm_Finetuned_10k'
|
22 |
model_config = AutoConfig.from_pretrained(model_name)
|
23 |
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
24 |
tokenizer.pad_token = tokenizer.eos_token
|
25 |
tokenizer.padding_side = "right"
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
text_generation_pipeline = pipeline(
|
28 |
model=model,
|
29 |
tokenizer=tokenizer,
|
|
|
31 |
temperature=0.2,
|
32 |
repetition_penalty=1.1,
|
33 |
return_full_text=True,
|
34 |
+
max_new_tokens=1000,
|
35 |
)
|
36 |
|
37 |
prompt_template = """
|