Spaces:
Runtime error
Runtime error
Turkunov Y
commited on
Commit
·
7b74d53
1
Parent(s):
79a28b0
replace mistral with llama
Browse files- app.py +7 -9
- requirements.txt +2 -1
app.py
CHANGED
@@ -1,23 +1,21 @@
|
|
1 |
import gradio as gr
|
2 |
from textPreprocessing import text2prompt
|
3 |
-
from transformers import AutoTokenizer, AutoModelForCausalLM
|
4 |
import torch
|
5 |
|
6 |
-
|
7 |
-
Необходимо раскомментить при досутпе к GPU
|
8 |
-
|
9 |
bnb_config = BitsAndBytesConfig(
|
10 |
load_in_4bit=True,
|
11 |
bnb_4bit_use_double_quant=True,
|
12 |
bnb_4bit_quant_type="fp4",
|
13 |
bnb_4bit_compute_dtype=torch.bfloat16
|
14 |
-
)
|
15 |
|
16 |
model = AutoModelForCausalLM.from_pretrained(
|
17 |
-
|
18 |
-
|
19 |
)
|
20 |
-
tokenizer = AutoTokenizer.from_pretrained(
|
21 |
|
22 |
def predict(input_text, t, m):
|
23 |
"""
|
@@ -38,7 +36,7 @@ def predict(input_text, t, m):
|
|
38 |
gradio_app = gr.Interface(
|
39 |
predict,
|
40 |
inputs=gr.Textbox(
|
41 |
-
label="Входная новость",
|
42 |
lines=8, placeholder="Акции кредитного банка \"X\" обрушились в цене из-за дефолта по ипотечным кредитам"
|
43 |
),
|
44 |
outputs=[gr.Label(label="Финансовая рекомендация на основе новости:")],
|
|
|
1 |
import gradio as gr
|
2 |
from textPreprocessing import text2prompt
|
3 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
4 |
import torch
|
5 |
|
6 |
+
model_id = 'openlm-research/open_llama_3b_v2'
|
|
|
|
|
7 |
bnb_config = BitsAndBytesConfig(
|
8 |
load_in_4bit=True,
|
9 |
bnb_4bit_use_double_quant=True,
|
10 |
bnb_4bit_quant_type="fp4",
|
11 |
bnb_4bit_compute_dtype=torch.bfloat16
|
12 |
+
)
|
13 |
|
14 |
model = AutoModelForCausalLM.from_pretrained(
|
15 |
+
model_id,
|
16 |
+
quantization_config=bnb_config # Необходимо раскомментить при досутпе к GPU
|
17 |
)
|
18 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
19 |
|
20 |
def predict(input_text, t, m):
|
21 |
"""
|
|
|
36 |
gradio_app = gr.Interface(
|
37 |
predict,
|
38 |
inputs=gr.Textbox(
|
39 |
+
label="Входная новость", container=True,
|
40 |
lines=8, placeholder="Акции кредитного банка \"X\" обрушились в цене из-за дефолта по ипотечным кредитам"
|
41 |
),
|
42 |
outputs=[gr.Label(label="Финансовая рекомендация на основе новости:")],
|
requirements.txt
CHANGED
@@ -1,2 +1,3 @@
|
|
1 |
transformers
|
2 |
-
torch
|
|
|
|
1 |
transformers
|
2 |
+
torch
|
3 |
+
install gradio_client
|