omm7 commited on
Commit
541ab60
·
verified ·
1 Parent(s): 33106c1

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -38
app.py DELETED
@@ -1,38 +0,0 @@
1
- from transformers import T5Tokenizer, T5ForConditionalGeneration
2
- import streamlit as st
3
-
4
- tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-large")
5
- model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-large")
6
-
7
- def llm_response(prompt):
8
-     input_ids = tokenizer(prompt, return_tensors="pt").input_ids
9
-     outputs = model.generate(input_ids, max_length=300, do_sample=True, temperature=0.1)
10
-     return tokenizer.decode(outputs[0])[6:-4]
11
-
12
- def predict_review_sentiment(review):
13
-     sys_prompt = """
14
-         Categorize the sentiment of the customer review as positive, negative, or neutral.
15
-         Leverage your expertise in the aviation industry and deep understanding of industry trends to analyze the nuanced expressions and overall tone.
16
-         It is crucial to accurately identify neutral sentiments, which may indicate a balanced view or neutral stance towards Us Airways. Neutral expressions could involve factual statements without explicit positive or negative opinions.
17
-         Consider the importance of these neutral sentiments in gauging the public sentiment towards the airline company.
18
-         For instance, a positive sentiment might convey satisfaction with the airline's services, a negative sentiment could express dissatisfaction, while neutral sentiment may reflect an impartial observation or a neutral standpoint
19
-     """
20
-
21
-     pred_sent = llm_response(
22
-         """
23
-             {}
24
-             Review text: '{}'
25
-         """.format(sys_prompt, review)
26
-     )
27
-     return pred_sent
28
-
29
- st.title("Airline Review Sentiment Classifier")
30
-
31
- review = st.text_area("Paste a review:")
32
-
33
- if st.button("Analyse Sentiment"):
34
-     if review.strip():
35
-         result = predict_review_sentiment(review)
36
-         st.success(f"Predicted Sentiment: {result}")
37
-     else:
38
-         st.warning("Please enter some review text.")