Spaces:
Running
Running
Commit
·
1075b3f
1
Parent(s):
2d273f1
progress more 54
Browse files
app.py
CHANGED
@@ -19,6 +19,8 @@ from langchain_community.llms import HuggingFacePipeline
|
|
19 |
from langchain.prompts import PromptTemplate
|
20 |
from langchain.chains import LLMChain
|
21 |
from huggingface_hub import login
|
|
|
|
|
22 |
|
23 |
# Initialize pymystem3 for lemmatization
|
24 |
mystem = Mystem()
|
@@ -43,10 +45,17 @@ def init_langchain_llm():
|
|
43 |
|
44 |
try:
|
45 |
tokenizer = transformers.AutoTokenizer.from_pretrained(model_id)
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
model_id,
|
48 |
torch_dtype=torch.float16,
|
49 |
device_map="auto",
|
|
|
50 |
)
|
51 |
|
52 |
pipeline = transformers.pipeline(
|
@@ -439,7 +448,7 @@ def create_output_file(df, uploaded_file, analysis_df):
|
|
439 |
return output
|
440 |
|
441 |
def main():
|
442 |
-
st.title("... приступим к анализу... версия
|
443 |
|
444 |
# Initialize session state
|
445 |
if 'processed_df' not in st.session_state:
|
|
|
19 |
from langchain.prompts import PromptTemplate
|
20 |
from langchain.chains import LLMChain
|
21 |
from huggingface_hub import login
|
22 |
+
from accelerate import init_empty_weights
|
23 |
+
|
24 |
|
25 |
# Initialize pymystem3 for lemmatization
|
26 |
mystem = Mystem()
|
|
|
45 |
|
46 |
try:
|
47 |
tokenizer = transformers.AutoTokenizer.from_pretrained(model_id)
|
48 |
+
|
49 |
+
# Use Accelerate for efficient model loading
|
50 |
+
with init_empty_weights():
|
51 |
+
config = transformers.AutoConfig.from_pretrained(model_id)
|
52 |
+
model = transformers.AutoModelForCausalLM.from_config(config)
|
53 |
+
|
54 |
+
model = model.from_pretrained(
|
55 |
model_id,
|
56 |
torch_dtype=torch.float16,
|
57 |
device_map="auto",
|
58 |
+
low_cpu_mem_usage=True
|
59 |
)
|
60 |
|
61 |
pipeline = transformers.pipeline(
|
|
|
448 |
return output
|
449 |
|
450 |
def main():
|
451 |
+
st.title("... приступим к анализу... версия 54")
|
452 |
|
453 |
# Initialize session state
|
454 |
if 'processed_df' not in st.session_state:
|