Spaces:
Sleeping
Sleeping
robinroy03
commited on
Commit
•
fd39c21
1
Parent(s):
234a9c1
first commit
Browse files- .gitignore +2 -0
- Dockerfile +11 -0
- main.py +22 -0
- requirements.txt +47 -0
.gitignore
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
venv
|
2 |
+
__pycache__
|
Dockerfile
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.12
|
2 |
+
|
3 |
+
WORKDIR /code
|
4 |
+
|
5 |
+
COPY ./requirements.txt /code/requirements.txt
|
6 |
+
|
7 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
8 |
+
|
9 |
+
COPY . .
|
10 |
+
|
11 |
+
CMD ["gunicorn", "-w", "5", "main:app"]
|
main.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask import Flask
|
2 |
+
from flask import request
|
3 |
+
from sentence_transformers import SentenceTransformer
|
4 |
+
|
5 |
+
app = Flask(__name__)
|
6 |
+
model = SentenceTransformer('Alibaba-NLP/gte-large-en-v1.5', trust_remote_code=True)
|
7 |
+
|
8 |
+
@app.route("/embedding", methods=['POST'])
|
9 |
+
def embedding():
|
10 |
+
"""
|
11 |
+
{
|
12 |
+
text: <text>
|
13 |
+
}
|
14 |
+
"""
|
15 |
+
|
16 |
+
message = request.get_json()
|
17 |
+
message = model.encode(message)
|
18 |
+
|
19 |
+
return model.encode(message['text'])
|
20 |
+
|
21 |
+
|
22 |
+
# curl -v -X POST 'http://127.0.0.1:8000/completion' --header 'Content-Type: application/json' --data '{"text": "what is an apple?"}'
|
requirements.txt
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
blinker==1.8.2
|
2 |
+
certifi==2024.6.2
|
3 |
+
charset-normalizer==3.3.2
|
4 |
+
click==8.1.7
|
5 |
+
filelock==3.14.0
|
6 |
+
Flask==3.0.3
|
7 |
+
fsspec==2024.6.0
|
8 |
+
gunicorn==22.0.0
|
9 |
+
huggingface-hub==0.23.2
|
10 |
+
idna==3.7
|
11 |
+
itsdangerous==2.2.0
|
12 |
+
Jinja2==3.1.4
|
13 |
+
joblib==1.4.2
|
14 |
+
MarkupSafe==2.1.5
|
15 |
+
mpmath==1.3.0
|
16 |
+
networkx==3.3
|
17 |
+
numpy==1.26.4
|
18 |
+
nvidia-cublas-cu12==12.1.3.1
|
19 |
+
nvidia-cuda-cupti-cu12==12.1.105
|
20 |
+
nvidia-cuda-nvrtc-cu12==12.1.105
|
21 |
+
nvidia-cuda-runtime-cu12==12.1.105
|
22 |
+
nvidia-cudnn-cu12==8.9.2.26
|
23 |
+
nvidia-cufft-cu12==11.0.2.54
|
24 |
+
nvidia-curand-cu12==10.3.2.106
|
25 |
+
nvidia-cusolver-cu12==11.4.5.107
|
26 |
+
nvidia-cusparse-cu12==12.1.0.106
|
27 |
+
nvidia-nccl-cu12==2.20.5
|
28 |
+
nvidia-nvjitlink-cu12==12.5.40
|
29 |
+
nvidia-nvtx-cu12==12.1.105
|
30 |
+
packaging==24.0
|
31 |
+
pillow==10.3.0
|
32 |
+
PyYAML==6.0.1
|
33 |
+
regex==2024.5.15
|
34 |
+
requests==2.32.3
|
35 |
+
safetensors==0.4.3
|
36 |
+
scikit-learn==1.5.0
|
37 |
+
scipy==1.13.1
|
38 |
+
sentence-transformers==3.0.0
|
39 |
+
sympy==1.12.1
|
40 |
+
threadpoolctl==3.5.0
|
41 |
+
tokenizers==0.19.1
|
42 |
+
torch==2.3.0
|
43 |
+
tqdm==4.66.4
|
44 |
+
transformers==4.41.2
|
45 |
+
typing_extensions==4.12.1
|
46 |
+
urllib3==2.2.1
|
47 |
+
Werkzeug==3.0.3
|