rishi1985 commited on
Commit
a614bfc
1 Parent(s): c12d377

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -8
app.py CHANGED
@@ -3,19 +3,19 @@
3
  # from firebase_admin import firestore
4
  import io
5
  from fastapi import FastAPI, File, UploadFile
6
- from werkzeug.utils import secure_filename
7
  # import speech_recognition as sr
8
  import subprocess
9
  import os
10
  import requests
11
  import random
12
  import pandas as pd
13
- from pydub import AudioSegment
14
  from datetime import datetime
15
  from datetime import date
16
- import numpy as np
17
  # from sklearn.ensemble import RandomForestRegressor
18
- import shutil
19
  import json
20
  # from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
21
  from pydantic import BaseModel
@@ -28,7 +28,7 @@ from fastapi import Form
28
  # from transformers import AutoModelForSequenceClassification
29
  # from transformers import TFAutoModelForSequenceClassification
30
  # from transformers import AutoTokenizer, AutoConfig
31
- import numpy as np
32
  # from scipy.special import softmax
33
  from sentence_transformers import SentenceTransformer
34
 
@@ -36,10 +36,11 @@ from sentence_transformers import SentenceTransformer
36
 
37
 
38
  # model = SentenceTransformer('flax-sentence-embeddings/all_datasets_v4_MiniLM-L6')
39
- model = SentenceTransformer("sentence-transformers/all-roberta-large-v1")
40
-
41
 
42
 
 
43
 
44
 
45
  class Query(BaseModel):
@@ -91,7 +92,10 @@ async def startup_event():
91
  async def get_answer(q: Query ):
92
 
93
  text = q.text
94
- text_e = model.encode(text)
 
 
 
95
 
96
 
97
  dict={ }
 
3
  # from firebase_admin import firestore
4
  import io
5
  from fastapi import FastAPI, File, UploadFile
6
+ # from werkzeug.utils import secure_filename
7
  # import speech_recognition as sr
8
  import subprocess
9
  import os
10
  import requests
11
  import random
12
  import pandas as pd
13
+ # from pydub import AudioSegment
14
  from datetime import datetime
15
  from datetime import date
16
+ # import numpy as np
17
  # from sklearn.ensemble import RandomForestRegressor
18
+ # import shutil
19
  import json
20
  # from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
21
  from pydantic import BaseModel
 
28
  # from transformers import AutoModelForSequenceClassification
29
  # from transformers import TFAutoModelForSequenceClassification
30
  # from transformers import AutoTokenizer, AutoConfig
31
+ # import numpy as np
32
  # from scipy.special import softmax
33
  from sentence_transformers import SentenceTransformer
34
 
 
36
 
37
 
38
  # model = SentenceTransformer('flax-sentence-embeddings/all_datasets_v4_MiniLM-L6')
39
+ # model = SentenceTransformer("sentence-transformers/all-roberta-large-v1")
40
+ # model =SentenceTransformer("intfloat/multilingual-e5-large")
41
 
42
 
43
+ model = SentenceTransformer('intfloat/multilingual-e5-large')
44
 
45
 
46
  class Query(BaseModel):
 
92
  async def get_answer(q: Query ):
93
 
94
  text = q.text
95
+ # text_e = model.encode(text)
96
+ input_texts = [text]
97
+ embeddings = model.encode(input_texts)
98
+ text_e = embeddings[0]
99
 
100
 
101
  dict={ }