Instructions to use brianwoo/Orca-Mini-3B-Onnx-Quantized with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use brianwoo/Orca-Mini-3B-Onnx-Quantized with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="brianwoo/Orca-Mini-3B-Onnx-Quantized")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("brianwoo/Orca-Mini-3B-Onnx-Quantized") model = AutoModelForCausalLM.from_pretrained("brianwoo/Orca-Mini-3B-Onnx-Quantized") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use brianwoo/Orca-Mini-3B-Onnx-Quantized with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "brianwoo/Orca-Mini-3B-Onnx-Quantized" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "brianwoo/Orca-Mini-3B-Onnx-Quantized", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/brianwoo/Orca-Mini-3B-Onnx-Quantized
- SGLang
How to use brianwoo/Orca-Mini-3B-Onnx-Quantized 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 "brianwoo/Orca-Mini-3B-Onnx-Quantized" \ --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": "brianwoo/Orca-Mini-3B-Onnx-Quantized", "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 "brianwoo/Orca-Mini-3B-Onnx-Quantized" \ --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": "brianwoo/Orca-Mini-3B-Onnx-Quantized", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use brianwoo/Orca-Mini-3B-Onnx-Quantized with Docker Model Runner:
docker model run hf.co/brianwoo/Orca-Mini-3B-Onnx-Quantized
How to use from
Docker Model Runnerdocker model run hf.co/brianwoo/Orca-Mini-3B-Onnx-QuantizedQuick Links
Have external files can load directly from hub,must down all the yourself . Can run on mobile or mini PC,it's much more faster than the normal version. Sample code for using this model :
from transformers import AutoTokenizer, pipeline
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer,GenerationConfig,TextIteratorStreamer
from optimum.onnxruntime import ORTModelForCausalLM
from transformers import logging
logging.set_verbosity_error()
import time
model_id="pathto/Orca-Mini-3B-Onnx-Quantized"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = ORTModelForCausalLM.from_pretrained(model_id)
streamer = TextStreamer(tokenizer,skip_prompt=True, skip_special_tokens=True,return_text=True)
onnx_gen = pipeline("text-generation", model=model, tokenizer=tokenizer,streamer=streamer,return_text=True)
while True:
text = input("\nBrian:")
print("Bot:\n")
t0=time.time()
gen = onnx_gen(text)
t=time.time()-t0
text=gen[0]["generated_text"]
print(t,len(text.split(" "))/t,"words /sec")
My sample code for quant modes on Colab :
from optimum.onnxruntime import ORTStableDiffusionXLImg2ImgPipeline , ORTStableDiffusionXLPipeline,ORTModelForCausalLM
from transformers import AutoTokenizer
from optimum.onnxruntime import ORTOptimizer
from optimum.onnxruntime.configuration import OptimizationConfig
from optimum.onnxruntime.configuration import AutoQuantizationConfig
from optimum.onnxruntime import ORTQuantizer
import os,torch
from pathlib import Path
Gbase="/gdrive/MyDrive/onnx/"
model_checkpoint = "gpt2"
save_directory = Gbase+"onnx/gpt2_arm64"
tasks=['TinyLlama/TinyLlama-1.1B-Chat-v0.6',
'pankajmathur/orca_mini_3b',
'Fredithefish/RedPajama-INCITE-Chat-3B-Instruction-Tuning-with-GPT-4',
'CobraMamba/mamba-gpt-3b-v4',
'WizardLM/WizardCoder-3B-V1.0',
'GeneZC/MiniChat-3B']
#TinyLlama/TinyLlama-1.1B-Chat-v0.6
#pankajmathur/orca_mini_3b
#Fredithefish/RedPajama-INCITE-Chat-3B-Instruction-Tuning-with-GPT-4
#CobraMamba/mamba-gpt-3b-v4
#WizardLM/WizardCoder-3B-V1.0
#GeneZC/MiniChat-3B
def quantModel(model_checkpoint=model_checkpoint,save_directory=save_directory):
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
tokenizer.save_pretrained(save_directory)
ort_model = ORTModelForCausalLM.from_pretrained(model_checkpoint, export=True)
optimizer = ORTOptimizer.from_pretrained(ort_model)
optimization_config = OptimizationConfig(optimization_level=3)
qconfig = AutoQuantizationConfig.arm64(is_static=False, per_channel=False)
quantizer = ORTQuantizer.from_pretrained(ort_model)
quantizer.quantize(save_dir=save_directory, quantization_config=qconfig,use_external_data_format=True)
def doTasks(tasks=tasks,Gbase=Gbase):
for model_checkpoint in tasks:
save_directory=os.path.join(Gbase,Path(model_checkpoint).name)
try:quantModel(model_checkpoint=model_checkpoint,save_directory=save_directory)
except:
import traceback
traceback.print_exc()
doTasks()
- Downloads last month
- -
# Gated model: Login with a HF token with gated access permission hf auth login