Spaces:
Runtime error
Runtime error
storresbusquets
commited on
Commit
·
0ec0587
1
Parent(s):
efa520c
Update app.py
Browse files
app.py
CHANGED
@@ -43,6 +43,21 @@ class GradioInference:
|
|
43 |
self.tokenizer = AutoTokenizer.from_pretrained("csebuetnlp/mT5_multilingual_XLSum")
|
44 |
self.model = AutoModelForSeq2SeqLM.from_pretrained("csebuetnlp/mT5_multilingual_XLSum")
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
|
48 |
def __call__(self, link, lang, size, progress=gr.Progress()):
|
@@ -208,24 +223,7 @@ class GradioInference:
|
|
208 |
########################## PRUEBA LLM #################################
|
209 |
from langchain import HuggingFacePipeline, PromptTemplate, LLMChain
|
210 |
|
211 |
-
|
212 |
-
|
213 |
-
llm_tokenizer = AutoTokenizer.from_pretrained(llm_model)
|
214 |
-
|
215 |
-
pipeline = pipeline(
|
216 |
-
"text-generation", #task
|
217 |
-
model=llm_model,
|
218 |
-
tokenizer=llm_tokenizer,
|
219 |
-
torch_dtype=torch.bfloat16,
|
220 |
-
trust_remote_code=True,
|
221 |
-
device_map="auto",
|
222 |
-
max_length=1000,
|
223 |
-
do_sample=True,
|
224 |
-
top_k=10,
|
225 |
-
num_return_sequences=1,
|
226 |
-
eos_token_id=tokenizer.eos_token_id
|
227 |
-
)
|
228 |
-
llm = HuggingFacePipeline(pipeline = pipeline, model_kwargs = {'temperature':0})
|
229 |
|
230 |
template = """
|
231 |
Write a concise summary of the following text delimited by triple backquotes.
|
|
|
43 |
self.tokenizer = AutoTokenizer.from_pretrained("csebuetnlp/mT5_multilingual_XLSum")
|
44 |
self.model = AutoModelForSeq2SeqLM.from_pretrained("csebuetnlp/mT5_multilingual_XLSum")
|
45 |
|
46 |
+
self.llm_tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-7b-instruct")
|
47 |
+
|
48 |
+
self.pipeline = pipeline(
|
49 |
+
"text-generation", #task
|
50 |
+
model="tiiuae/falcon-7b-instruct",
|
51 |
+
tokenizer=self.llm_tokenizer,
|
52 |
+
torch_dtype=torch.bfloat16,
|
53 |
+
trust_remote_code=True,
|
54 |
+
device_map="auto",
|
55 |
+
max_length=1000,
|
56 |
+
do_sample=True,
|
57 |
+
top_k=10,
|
58 |
+
num_return_sequences=1,
|
59 |
+
eos_token_id=tokenizer.eos_token_id
|
60 |
+
)
|
61 |
|
62 |
|
63 |
def __call__(self, link, lang, size, progress=gr.Progress()):
|
|
|
223 |
########################## PRUEBA LLM #################################
|
224 |
from langchain import HuggingFacePipeline, PromptTemplate, LLMChain
|
225 |
|
226 |
+
llm = HuggingFacePipeline(pipeline = self.pipeline, model_kwargs = {'temperature':0})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
|
228 |
template = """
|
229 |
Write a concise summary of the following text delimited by triple backquotes.
|