kskathe commited on
Commit
33873fb
1 Parent(s): 2fe6bd0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
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 and specify the device as CPU
59
- inputs = tokenizer([formatted_input], return_tensors="pt").to("cpu")
60
-
61
- # Load the model without quantization
62
  text_model = AutoPeftModelForCausalLM.from_pretrained(
63
  "kskathe/finetuned-llama-text-summarization",
64
- load_in_8bit=False, # Ensure quantization is disabled
65
- device_map="cpu" # Force the model to run on CPU
 
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