- updates for webm generation
Browse files
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: ['
|
49 |
-
Anti Entities: ['
|
50 |
-
Neutral Entities: ['
|
51 |
-
Pro Aspects: ['
|
52 |
Anti Aspects: []
|
53 |
-
Neutral Aspects: ['
|
54 |
-
|
55 |
-
Generated Tweet: "
|
56 |
-
ABSA Outputs:
|
|
|
|
|
|
|
|
|
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 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
|
|
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.
|
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
|