Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -35,12 +35,12 @@
|
|
35 |
# st.write(decoded_output[0])
|
36 |
|
37 |
|
38 |
-
|
39 |
import streamlit as st
|
40 |
from transformers import pipeline
|
41 |
from peft import AutoPeftModelForCausalLM
|
42 |
from transformers import AutoTokenizer
|
43 |
|
|
|
44 |
# Initialize the tokenizer
|
45 |
tokenizer = AutoTokenizer.from_pretrained("kskathe/finetuned-llama-text-summarization")
|
46 |
|
@@ -55,14 +55,15 @@ input_text = st.text_area("Enter the article content:")
|
|
55 |
formatted_input = alpaca_prompt.format(input_text, "")
|
56 |
|
57 |
if st.button("Generate Highlights"):
|
58 |
-
# Prepare the input
|
59 |
-
inputs = tokenizer([formatted_input], return_tensors="pt")
|
60 |
-
|
61 |
-
# Load the model without quantization
|
62 |
text_model = AutoPeftModelForCausalLM.from_pretrained(
|
63 |
"kskathe/finetuned-llama-text-summarization",
|
64 |
-
|
65 |
-
|
|
|
66 |
)
|
67 |
|
68 |
# Generate the output
|
|
|
35 |
# st.write(decoded_output[0])
|
36 |
|
37 |
|
|
|
38 |
import streamlit as st
|
39 |
from transformers import pipeline
|
40 |
from peft import AutoPeftModelForCausalLM
|
41 |
from transformers import AutoTokenizer
|
42 |
|
43 |
+
|
44 |
# Initialize the tokenizer
|
45 |
tokenizer = AutoTokenizer.from_pretrained("kskathe/finetuned-llama-text-summarization")
|
46 |
|
|
|
55 |
formatted_input = alpaca_prompt.format(input_text, "")
|
56 |
|
57 |
if st.button("Generate Highlights"):
|
58 |
+
# Prepare the input
|
59 |
+
inputs = tokenizer([formatted_input], return_tensors="pt")
|
60 |
+
|
61 |
+
# Load the model without quantization and force CPU usage
|
62 |
text_model = AutoPeftModelForCausalLM.from_pretrained(
|
63 |
"kskathe/finetuned-llama-text-summarization",
|
64 |
+
device_map="cpu", # Force the model to run on CPU
|
65 |
+
load_in_8bit=False, # Disable 8-bit quantization if it was enabled
|
66 |
+
torch_dtype="float32" # Use float32 precision which is CPU friendly
|
67 |
)
|
68 |
|
69 |
# Generate the output
|