wolfofbackstreet commited on
Commit
56f89b6
·
verified ·
1 Parent(s): 6f28864
Files changed (4) hide show
  1. .gitignore +1 -0
  2. Dockerfile +16 -0
  3. app.py +24 -0
  4. requirements.txt +4 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .idea/
Dockerfile ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
+ # you will also find guides on how best to write your Dockerfile
3
+
4
+ FROM python:3.11
5
+
6
+ RUN useradd -m -u 1000 user
7
+ USER user
8
+ ENV PATH="/home/user/.local/bin:$PATH"
9
+
10
+ WORKDIR /app
11
+
12
+ COPY --chown=user ./requirements.txt requirements.txt
13
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
14
+
15
+ COPY --chown=user . /app
16
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, request, jsonify
2
+ from sentence_transformers import SentenceTransformer
3
+ import logging
4
+
5
+ logging.basicConfig(level=logging.DEBUG)
6
+
7
+ app = Flask(__name__)
8
+
9
+ # Load the Qwen3-Embedding-0.6B model (adjust the path as needed)
10
+ model = SentenceTransformer(model_name_or_path="Qwen/Qwen3-Embedding-0.6B")
11
+
12
+ @app.route('/embed', methods=['POST'])
13
+ def get_embedding():
14
+ try:
15
+ text = request.json.get('text', '')
16
+ if not text:
17
+ return jsonify({"error": "No text provided"}), 400
18
+
19
+ # Generate embeddings for the input text
20
+ document_embeddings = model.encode(text)
21
+ arr_list = document_embeddings.tolist()
22
+ return jsonify({"embedding": arr_list})
23
+ except Exception as e:
24
+ return jsonify({"error": str(e)}), 500
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ flask
2
+ sentence-transformers
3
+ transformers
4
+ torch