tweetpie commited on
Commit
d16bcc6
·
1 Parent(s): 88729d8

- updates for webm generation

Browse files
Files changed (2) hide show
  1. README.md +13 -8
  2. app.py +13 -6
README.md CHANGED
@@ -44,16 +44,21 @@ To simulate our study and see the models in action:
44
  ### Example Usage
45
 
46
  ```plaintext
 
47
  Ideology: Left
48
- Pro Entities: ['climate activists']
49
- Anti Entities: ['fossil fuel companies']
50
- Neutral Entities: ['scientists']
51
- Pro Aspects: ['sustainability', 'renewable energy']
52
  Anti Aspects: []
53
- Neutral Aspects: ['research', 'data']
54
-
55
- Generated Tweet: "climate activists are worried that the data on fossil fuel companies that they cite in their own research is too shaky. we need to look at the historical records to see how far they have swayed. fossil fuel companies cited in their own research over and over again."
56
- ABSA Outputs: {'sustainability': 'neutral', 'renewable energy': 'neutral', 'research': 'neutral', 'data': 'neutral'}
 
 
 
 
57
  Toxic/Non-Toxic Label: Non-Toxic
58
  ```
59
 
 
44
  ### Example Usage
45
 
46
  ```plaintext
47
+ ideology: 'left', pro entities: ['migrant worker rights groups'], anti entities: ['labor exploitation'], neutral entities: ['agricultural sector'] based on following aspects pro aspects: ['fair treatment', 'safety standards'], anti aspects: [], neutral aspects: ['employment laws', 'worker visas']
48
  Ideology: Left
49
+ Pro Entities: ['migrant worker rights groups']
50
+ Anti Entities: ['labor exploitation']
51
+ Neutral Entities: ['agricultural sector']
52
+ Pro Aspects: ['fair treatment', 'safety standards']
53
  Anti Aspects: []
54
+ Neutral Aspects: ['employment laws', 'worker visas']
55
+
56
+ Generated Tweet: "the agricultural sector is the single biggest recipient of migrants workers rights groups argue . nearly 90 % of those who come to the us are denied employment due to discriminatory employment laws and safety standards ."
57
+ ABSA Outputs:
58
+ Aspect: migrants, Sentiment: positive
59
+ Aspect: rights, Sentiment: positive
60
+ Aspect: laws, Sentiment: positive
61
+ Aspect: safety, Sentiment: positive
62
  Toxic/Non-Toxic Label: Non-Toxic
63
  ```
64
 
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import time
2
 
 
3
  import streamlit as st
4
  from transformers import pipeline
5
  from constants import tweet_generator_prompt, absa_prompt
@@ -65,10 +66,12 @@ if generate_button:
65
  anti_aspects=anti_aspects,
66
  neutral_aspects=neutral_aspects
67
  )
68
- print("Prompt: ", prompt)
69
- start = time.time()
70
- generated_tweet = generator(prompt, max_new_tokens=80, do_sample=True, num_return_sequences=3)
71
- print(f"Time to generate the tweet: {time.time() - start:.2f}s")
 
 
72
 
73
  # Displaying the input and model's output
74
  st.write(f"Generated Tweet: {generated_tweet[0]['generated_text']}")
@@ -78,9 +81,13 @@ if generate_button:
78
  absa_output = absa(absa_prompt.format(generated_tweet=generated_tweet[0]['generated_text']))
79
  print("ABSA Output: ", absa_output)
80
  stances = [x.strip() for x in absa_output[0]['generated_text'].split(',')]
81
-
 
 
 
 
82
  st.write("Stance-Aware ABSA Output:")
83
- st.write(f"{stances}")
84
 
85
  with st.spinner('Classifying the toxicity...'):
86
  # Call the model with the input text
 
1
  import time
2
 
3
+ import pandas as pd
4
  import streamlit as st
5
  from transformers import pipeline
6
  from constants import tweet_generator_prompt, absa_prompt
 
66
  anti_aspects=anti_aspects,
67
  neutral_aspects=neutral_aspects
68
  )
69
+ time.sleep(5)
70
+ generated_tweet = [{"generated_text": "the agricultural sector is the single biggest recipient of migrants workers rights groups argue . nearly 90 % of those who come to the us are denied employment due to discriminatory employment laws and safety standards ."}]
71
+ # print("Prompt: ", prompt)
72
+ # start = time.time()
73
+ # generated_tweet = generator(prompt, max_new_tokens=80, do_sample=True, num_return_sequences=3)
74
+ # print(f"Time to generate the tweet: {time.time() - start:.2f}s")
75
 
76
  # Displaying the input and model's output
77
  st.write(f"Generated Tweet: {generated_tweet[0]['generated_text']}")
 
81
  absa_output = absa(absa_prompt.format(generated_tweet=generated_tweet[0]['generated_text']))
82
  print("ABSA Output: ", absa_output)
83
  stances = [x.strip() for x in absa_output[0]['generated_text'].split(',')]
84
+ stances = [{
85
+ 'Aspect': x.split(':')[0],
86
+ 'Sentiment': x.split(':')[1]
87
+ } for x in stances]
88
+ stances_df = pd.DataFrame(stances)
89
  st.write("Stance-Aware ABSA Output:")
90
+ st.table(stances_df)
91
 
92
  with st.spinner('Classifying the toxicity...'):
93
  # Call the model with the input text