Spaces:
Runtime error
Runtime error
Download app.py from caubetotbunggg/api: direct link, hf CLI and curl.
- Browser
- Download file 610 Bytes
-
https://huggingface.co/spaces/caubetotbunggg/api/resolve/main/app.py
- Command line
-
hf download hf://spaces/caubetotbunggg/api/app.py
-
curl -L -o app.py https://huggingface.co/spaces/caubetotbunggg/api/resolve/main/app.py
610 Bytes
| import gradio as gr | |
| from sentence_transformers import SentenceTransformer | |
| # Load model BGEM3 | |
| model = SentenceTransformer("BAAI/bge-m3") | |
| def embed_text(text): | |
| if not text.strip(): | |
| return "⚠️ Please enter some text!" | |
| embedding = model.encode(text).tolist() | |
| return embedding | |
| # Gradio UI | |
| with gr.Blocks() as demo: | |
| gr.Markdown("## 🔎 e5 Embedding Demo") | |
| inp = gr.Textbox(label="Nhập câu hoặc đoạn văn") | |
| out = gr.JSON(label="Vector (10 giá trị đầu)") | |
| btn = gr.Button("Generate Embedding") | |
| btn.click(embed_text, inputs=inp, outputs=out) | |
| demo.launch() | |