From 69276f619a1f03d35948719ff2460f79279bcc90 Mon Sep 17 00:00:00 2001 From: mlmz <54172054+minleminzui@users.noreply.github.com> Date: Sun, 11 May 2025 23:22:11 +0800 Subject: [PATCH] doc: fix the erroneous documents and example codes about Alibaba-NLP/gme-Qwen2-VL-2B-Instruct (#6199) --- docs/backend/openai_api_embeddings.ipynb | 8 ++++++ docs/supported_models/embedding_models.md | 33 ++++++++++++++++++++--- examples/runtime/multimodal_embedding.py | 5 +--- 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/docs/backend/openai_api_embeddings.ipynb b/docs/backend/openai_api_embeddings.ipynb index 742185f82..89abeb830 100644 --- a/docs/backend/openai_api_embeddings.ipynb +++ b/docs/backend/openai_api_embeddings.ipynb @@ -171,6 +171,14 @@ "source": [ "terminate_process(embedding_process)" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Multi-Modal Embedding Model\n", + "Please refer to [Multi-Modal Embedding Model](../supported_models/embedding_models.md)" + ] } ], "metadata": { diff --git a/docs/supported_models/embedding_models.md b/docs/supported_models/embedding_models.md index 48ea379c5..738a201a7 100644 --- a/docs/supported_models/embedding_models.md +++ b/docs/supported_models/embedding_models.md @@ -6,15 +6,42 @@ SGLang provides robust support for embedding models by integrating efficient ser They are executed with `--is-embedding` and some may require `--trust-remote-code` ``` -## Example launch Command +## Example Launch Command ```shell python3 -m sglang.launch_server \ - --model-path Alibaba-NLP/gme-Qwen2-VL-2B-Instruct \ # example HF/local path + --model-path Alibaba-NLP/gme-Qwen2-VL-2B-Instruct \ --is-embedding \ --host 0.0.0.0 \ - --port 30000 \ + --chat-template gme-qwen2-vl \ + --port 30000 ``` +## Example Client Request +```python +import requests + +url = "http://127.0.0.1:30000" + +text_input = "Represent this image in embedding space." +image_path = "https://huggingface.co/datasets/liuhaotian/llava-bench-in-the-wild/resolve/main/images/023.jpg" + +payload = { + "model": "gme-qwen2-vl", + "input": [ + { + "text": text_input + }, + { + "image": image_path + } + ], +} + +response = requests.post(url + "/v1/embeddings", json=payload).json() + +print("Embeddings:", [x.get("embedding") for x in response.get("data", [])]) +``` + ## Supporting Matrixs diff --git a/examples/runtime/multimodal_embedding.py b/examples/runtime/multimodal_embedding.py index a924b381e..4e8d748b4 100644 --- a/examples/runtime/multimodal_embedding.py +++ b/examples/runtime/multimodal_embedding.py @@ -10,10 +10,7 @@ image_path = "https://huggingface.co/datasets/liuhaotian/llava-bench-in-the-wild payload = { "model": "gme-qwen2-vl", - "input": [ - {"type": "text", "text": text_input}, - {"type": "image", "url": image_path}, - ], + "input": [{"text": text_input}, {"image": image_path}], } response = requests.post(url + "/v1/embeddings", json=payload).json()