Feature Extraction
Transformers
Safetensors
qwen3_5
image-text-to-text
multimodal-embedding
retrieval
evaluation
custom_code
Instructions to use woooooz/WeMM-Embedding-9B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use woooooz/WeMM-Embedding-9B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="woooooz/WeMM-Embedding-9B", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("woooooz/WeMM-Embedding-9B", trust_remote_code=True) model = AutoModelForMultimodalLM.from_pretrained("woooooz/WeMM-Embedding-9B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download evaluation/vendor/transformers/cli/serving/server.py from woooooz/WeMM-Embedding-9B: direct link, hf CLI and curl.
- Browser
- Download file 4.18 kB
-
https://huggingface.co/woooooz/WeMM-Embedding-9B/resolve/main/evaluation/vendor/transformers/cli/serving/server.py
- Command line
-
hf download hf://woooooz/WeMM-Embedding-9B/evaluation/vendor/transformers/cli/serving/server.py
-
curl -L -o server.py https://huggingface.co/woooooz/WeMM-Embedding-9B/resolve/main/evaluation/vendor/transformers/cli/serving/server.py
4.18 kB
| # Copyright 2026 The HuggingFace Team. All rights reserved. | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| """ | |
| FastAPI app factory. | |
| """ | |
| import uuid | |
| from contextlib import asynccontextmanager | |
| from ...utils import logging | |
| from ...utils.import_utils import is_serve_available | |
| if is_serve_available(): | |
| from fastapi import FastAPI, Request | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from fastapi.responses import JSONResponse, StreamingResponse | |
| from .chat_completion import ChatCompletionHandler | |
| from .model_manager import ModelManager | |
| from .response import ResponseHandler | |
| from .transcription import TranscriptionHandler | |
| from .utils import X_REQUEST_ID | |
| logger = logging.get_logger(__name__) | |
| def build_server( | |
| model_manager: ModelManager, | |
| chat_handler: ChatCompletionHandler, | |
| response_handler: ResponseHandler, | |
| transcription_handler: TranscriptionHandler, | |
| enable_cors: bool = False, | |
| ) -> FastAPI: | |
| """Build and return a configured FastAPI application. | |
| Args: | |
| model_manager: Handles model loading, caching, and cleanup. | |
| chat_handler: Handles `/v1/chat/completions` requests. | |
| response_handler: Handles `/v1/responses` requests. | |
| enable_cors: If `True`, adds permissive CORS middleware (allow all origins). | |
| Returns: | |
| A FastAPI app ready to be passed to uvicorn. | |
| """ | |
| async def lifespan(app: FastAPI): | |
| yield | |
| model_manager.shutdown() | |
| app = FastAPI(lifespan=lifespan) | |
| if enable_cors: | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=["*"], | |
| allow_credentials=True, | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| ) | |
| logger.warning_once("CORS allow origin is set to `*`. Not recommended for production.") | |
| # ---- Middleware ---- | |
| async def request_id_middleware(request: Request, call_next): | |
| """Get or set the request ID in the header.""" | |
| request_id = request.headers.get(X_REQUEST_ID) or str(uuid.uuid4()) | |
| request.state.request_id = request_id | |
| response = await call_next(request) | |
| response.headers[X_REQUEST_ID] = request_id | |
| return response | |
| # ---- Routes ---- | |
| async def chat_completions(request: Request, body: dict): | |
| return await chat_handler.handle_request(body, request.state.request_id) | |
| async def responses(request: Request, body: dict): | |
| return await response_handler.handle_request(body, request.state.request_id) | |
| async def audio_transcriptions(request: Request): | |
| return await transcription_handler.handle_request(request) | |
| async def load_model(body: dict): | |
| from fastapi import HTTPException | |
| model = body.get("model") | |
| if model is None: | |
| raise HTTPException(status_code=422, detail="Missing `model` field in the request body.") | |
| model_id_and_revision = model_manager.process_model_name(model) | |
| return StreamingResponse( | |
| model_manager.load_model_streaming(model_id_and_revision), media_type="text/event-stream" | |
| ) | |
| def reset(): | |
| model_manager.shutdown() | |
| return JSONResponse({"status": "ok"}) | |
| def list_models(): | |
| return JSONResponse({"object": "list", "data": model_manager.get_gen_models()}) | |
| def health(): | |
| return JSONResponse({"status": "ok"}) | |
| return app | |