Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -45,12 +45,12 @@ class EmotionalAIAssistant:
|
|
45 |
# Load pre-trained BERT model for emotion prediction
|
46 |
self.emotion_prediction_model = AutoModelForSequenceClassification.from_pretrained("bhadresh-savani/distilbert-base-uncased-emotion")
|
47 |
self.emotion_prediction_tokenizer = AutoTokenizer.from_pretrained("bhadresh-savani/distilbert-base-uncased-emotion", padding_side='left')
|
48 |
-
|
49 |
-
|
50 |
self.megatron_tokenizer = MegatronTokenizer.from_pretrained('nvidia/megatron-lm-330m')
|
51 |
-
self.megatron_model = MegatronLMHeadModel.from_pretrained('nvidia/megatron-lm-330m', device_map='auto'
|
52 |
-
|
53 |
-
|
54 |
self.emotions = {
|
55 |
'joy': {'percentage': 10, 'motivation': 'positive', 'intensity': 0},
|
56 |
'pleasure': {'percentage': 10, 'motivation': 'selfish', 'intensity': 0},
|
@@ -143,7 +143,7 @@ class EmotionalAIAssistant:
|
|
143 |
|
144 |
population = toolbox.population(n=100)
|
145 |
algorithms.eaMuPlusLambda(population, toolbox, mu=50, lambda_=100, cxpb=0.7, mutpb=0.2, ngen=100,
|
146 |
-
|
147 |
|
148 |
best_individual = tools.selBest(population, k=1)[0]
|
149 |
emotion_values = best_individual[:len(self.emotions)]
|
@@ -157,8 +157,6 @@ class EmotionalAIAssistant:
|
|
157 |
|
158 |
self.emotions['ideal_state']['percentage'] = ideal_state
|
159 |
|
160 |
-
|
161 |
-
|
162 |
def generate_text(self, prompt, chat_history, emotion=None, max_length=300):
|
163 |
full_prompt = (
|
164 |
f"You are Adam, a witty AI assistant who's trying to figure out your own personality and emotions. "
|
|
|
45 |
# Load pre-trained BERT model for emotion prediction
|
46 |
self.emotion_prediction_model = AutoModelForSequenceClassification.from_pretrained("bhadresh-savani/distilbert-base-uncased-emotion")
|
47 |
self.emotion_prediction_tokenizer = AutoTokenizer.from_pretrained("bhadresh-savani/distilbert-base-uncased-emotion", padding_side='left')
|
48 |
+
|
49 |
+
# Load pre-trained Megatron-LM model for text generation
|
50 |
self.megatron_tokenizer = MegatronTokenizer.from_pretrained('nvidia/megatron-lm-330m')
|
51 |
+
self.megatron_model = MegatronLMHeadModel.from_pretrained('nvidia/megatron-lm-330m', device_map='auto')
|
52 |
+
|
53 |
+
# Enhanced Emotional States
|
54 |
self.emotions = {
|
55 |
'joy': {'percentage': 10, 'motivation': 'positive', 'intensity': 0},
|
56 |
'pleasure': {'percentage': 10, 'motivation': 'selfish', 'intensity': 0},
|
|
|
143 |
|
144 |
population = toolbox.population(n=100)
|
145 |
algorithms.eaMuPlusLambda(population, toolbox, mu=50, lambda_=100, cxpb=0.7, mutpb=0.2, ngen=100,
|
146 |
+
stats=None, halloffame=None, verbose=False)
|
147 |
|
148 |
best_individual = tools.selBest(population, k=1)[0]
|
149 |
emotion_values = best_individual[:len(self.emotions)]
|
|
|
157 |
|
158 |
self.emotions['ideal_state']['percentage'] = ideal_state
|
159 |
|
|
|
|
|
160 |
def generate_text(self, prompt, chat_history, emotion=None, max_length=300):
|
161 |
full_prompt = (
|
162 |
f"You are Adam, a witty AI assistant who's trying to figure out your own personality and emotions. "
|