Instructions to use Wanclouds/Mistral-7b-doc-ONNX with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Wanclouds/Mistral-7b-doc-ONNX with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Wanclouds/Mistral-7b-doc-ONNX")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Wanclouds/Mistral-7b-doc-ONNX") model = AutoModelForCausalLM.from_pretrained("Wanclouds/Mistral-7b-doc-ONNX") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Wanclouds/Mistral-7b-doc-ONNX with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Wanclouds/Mistral-7b-doc-ONNX" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Wanclouds/Mistral-7b-doc-ONNX", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Wanclouds/Mistral-7b-doc-ONNX
- SGLang
How to use Wanclouds/Mistral-7b-doc-ONNX with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Wanclouds/Mistral-7b-doc-ONNX" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Wanclouds/Mistral-7b-doc-ONNX", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Wanclouds/Mistral-7b-doc-ONNX" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Wanclouds/Mistral-7b-doc-ONNX", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Wanclouds/Mistral-7b-doc-ONNX with Docker Model Runner:
docker model run hf.co/Wanclouds/Mistral-7b-doc-ONNX
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
-------------------------------------------------------------------------
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License.
--------------------------------------------------------------------------
import os from pathlib import Path
import torch import torch.distributed as dist from optimum.onnxruntime import ORTModelForCausalLM from transformers import AutoConfig, AutoTokenizer, GenerationConfig
device_id = 0 device = torch.device(f"cuda:{device_id}") # Change to torch.device("cpu") if running on CPU
ep = "CUDAExecutionProvider" # change to CPUExecutionProvider if running on CPU ep_options = {"device_id": device_id}
model_id = "mistralai/Mistral-7B-Instruct-v0.2" model_path = "./Olive/examples/llama2/models/qlora/qlora-conversion-transformers_optimization-bnb_quantization/gpu-cuda_model"
model_path = Path(model_path)
if not (model_path / "config.json").exists(): config = AutoConfig.from_pretrained(model_id) config.save_pretrained(model_path) else: config = AutoConfig.from_pretrained(model_path)
if not (model_path / "generation_config.json").exists(): gen_config = GenerationConfig.from_pretrained(model_id) gen_config.save_pretrained(model_path) else: gen_config = GenerationConfig.from_pretrained(model_path)
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = ORTModelForCausalLM.from_pretrained( model_path, config=config, generation_config=gen_config, use_io_binding=True, # provider="CUDAExecutionProvider", provider=ep, provider_options={"device_id": device_id} # provider_options={"device_id": str(rank)}, )
- Downloads last month
- 4