Spaces:
Running on Zero
Running on Zero
Commit History
3 days ago
-
Pin E5 model and add verified encoder metadata and normalized endpoint Running
Verified signaturePreserve legacy /encode; add bounded pinned query/passage contract, runtime metadata and frozen dependencies. Code/config only.d8f6ca9 -
Pin E5 model and add verified encoder metadata and normalized endpoint
Verified signaturePreserve legacy /encode; add bounded pinned query/passage contract, runtime metadata and frozen dependencies. Code/config only.665ddab -
Pin E5 model and add verified encoder metadata and normalized endpoint
Verified signaturePreserve legacy /encode; add bounded pinned query/passage contract, runtime metadata and frozen dependencies. Code/config only.d704ace -
Restore previous E5 Space source after candidate dependency build failure
Verified signature14479b0 -
Pin E5 model and add verified encoder metadata and normalized endpoint
Verified signaturePreserve legacy /encode; add bounded pinned query/passage contract, runtime metadata and frozen dependencies. Code/config only.60420a1
-
Create app.py
Verified signature7bb019c -
app.py
Verified signatureimport gradio as gr import spaces from sentence_transformers import SentenceTransformer # Tải sẵn mô hình (sẽ tự động được chuyển lên GPU khi hàm chạy) MODEL_NAME = "intfloat/multilingual-e5-large" print(f"Loading {MODEL_NAME}...") model = SentenceTransformer(MODEL_NAME) print("Model loaded!") # duration=10: giới hạn thời gian giữ GPU tối đa 10s để ưu tiên hàng đợi ZeroGPU @spaces.GPU(duration=10) def encode_text(text: str): if not text or not text.strip(): return [] # E5 chuẩn hóa: câu hỏi tìm kiếm cần có tiền tố 'query: ' cleaned = text.strip() if not (cleaned.startswith("query: ") or cleaned.startswith("passage: ")): cleaned = f"query: {cleaned}" # Model tự động chạy trên CUDA nhờ decorator @spaces.GPU embedding = model.encode(cleaned, normalize_embeddings=False) return embedding.tolist() # Giao diện Gradio + Cấu hình tên API endpoint demo = gr.Interface( fn=encode_text, inputs=gr.Textbox(label="Văn bản cần Embed", pla…55197b4 -
initial commit
Verified signature35c1341