Kibo1 commited on
Commit
66ac81a
·
verified ·
1 Parent(s): d08e774

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -3,15 +3,23 @@ import pandas as pd
3
 
4
  df = pd.read_csv('./Mental_Health_FAQ.csv')
5
 
 
 
 
 
6
  context_data = []
 
7
  for i in range(len(df)):
8
- context = ""
9
- for j in range(3):
10
- context += df.columns[j]
11
- context += ": "
12
- context += df.iloc[i][j]
13
- context += " "
14
  context_data.append(context)
 
 
 
 
 
 
 
 
15
 
16
 
17
  import os
 
3
 
4
  df = pd.read_csv('./Mental_Health_FAQ.csv')
5
 
6
+ import pandas as pd
7
+ from sentence_transformers import SentenceTransformer
8
+ # Assuming your DataFrame is already loaded as 'df'
9
+
10
  context_data = []
11
+
12
  for i in range(len(df)):
13
+ context = f"Question: {df.iloc[i]['Questions']} Answer: {df.iloc[i]['Answers']}"
 
 
 
 
 
14
  context_data.append(context)
15
+ # print(context_data)
16
+
17
+ # Embed the contexts
18
+ embedding_model = SentenceTransformer('all-MiniLM-L6-v2')
19
+ context_embeddings = embedding_model.encode(context_data)
20
+
21
+ print(f"Number of contexts: {len(context_data)}")
22
+ print(f"Shape of embeddings: {context_embeddings.shape}")
23
 
24
 
25
  import os