Text Generation
Transformers
Safetensors
multilingual
phimoe
nlp
code
conversational
custom_code
4-bit precision
awq
Instructions to use danieldk/Phi-3.5-MoE-instruct-AWQ-INT4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use danieldk/Phi-3.5-MoE-instruct-AWQ-INT4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="danieldk/Phi-3.5-MoE-instruct-AWQ-INT4", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("danieldk/Phi-3.5-MoE-instruct-AWQ-INT4", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("danieldk/Phi-3.5-MoE-instruct-AWQ-INT4", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use danieldk/Phi-3.5-MoE-instruct-AWQ-INT4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "danieldk/Phi-3.5-MoE-instruct-AWQ-INT4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "danieldk/Phi-3.5-MoE-instruct-AWQ-INT4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/danieldk/Phi-3.5-MoE-instruct-AWQ-INT4
- SGLang
How to use danieldk/Phi-3.5-MoE-instruct-AWQ-INT4 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 "danieldk/Phi-3.5-MoE-instruct-AWQ-INT4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "danieldk/Phi-3.5-MoE-instruct-AWQ-INT4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "danieldk/Phi-3.5-MoE-instruct-AWQ-INT4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "danieldk/Phi-3.5-MoE-instruct-AWQ-INT4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use danieldk/Phi-3.5-MoE-instruct-AWQ-INT4 with Docker Model Runner:
docker model run hf.co/danieldk/Phi-3.5-MoE-instruct-AWQ-INT4
| license: mit | |
| license_link: https://huggingface.co/microsoft/Phi-3.5-MoE-instruct/resolve/main/LICENSE | |
| language: | |
| - multilingual | |
| pipeline_tag: text-generation | |
| tags: | |
| - nlp | |
| - code | |
| widget: | |
| - messages: | |
| - role: user | |
| content: Can you provide ways to eat combinations of bananas and dragonfruits? | |
| library_name: transformers | |
| > [!IMPORTANT] | |
| > This repository is a quantized version of the original model [`microsoft/Phi-3.5-MoE-instruct`](https://huggingface.co/microsoft/Phi-3.5-MoE-instruct) which is the FP16 half-precision official version released by Microsoft. | |
| ## Model Summary | |
| Phi-3.5-MoE is a lightweight, state-of-the-art open model built upon datasets used for Phi-3 - synthetic data and filtered publicly available documents - with a focus on very high-quality, reasoning dense data. The model supports multilingual and comes with 128K context length (in tokens). The model underwent a rigorous enhancement process, incorporating supervised fine-tuning, proximal policy optimization, and direct preference optimization to ensure precise instruction adherence and robust safety measures. | |
| 🏡 [Phi-3 Portal](https://azure.microsoft.com/en-us/products/phi-3) <br> | |
| 📰 [Phi-3 Microsoft Blog](https://aka.ms/phi3.5-techblog) <br> | |
| 📖 [Phi-3 Technical Report](https://arxiv.org/abs/2404.14219) <br> | |
| 👩🍳 [Phi-3 Cookbook](https://github.com/microsoft/Phi-3CookBook) <br> | |
| 🖥️ [Try It](https://aka.ms/try-phi3.5moe) <br> | |
| MoE references: | |
| 📜[Phi-3.5-MoE Blog](https://techcommunity.microsoft.com/t5/ai-azure-ai-services-blog/announcing-the-availability-of-phi-3-5-moe-in-azure-ai-studio/ba-p/4256278) | 😁[GRIN MoE](https://huggingface.co/microsoft/GRIN-MoE) | |
| **Phi-3.5**: [[mini-instruct]](https://huggingface.co/microsoft/Phi-3.5-mini-instruct); [[MoE-instruct]](https://huggingface.co/microsoft/Phi-3.5-MoE-instruct) ; [[vision-instruct]](https://huggingface.co/microsoft/Phi-3.5-vision-instruct) | |
| ## Running 🏃 | |
| ### TGI | |
| ```bash | |
| model=danieldk/Phi-3.5-MoE-instruct-AWQ-INT4 | |
| volume=$PWD/data # share a volume with the Docker container to avoid downloading weights every run | |
| docker run --gpus all --shm-size 1g -p 8080:80 -v $volume:/data \ | |
| ghcr.io/huggingface/text-generation-inference:2.4.0 \ | |
| --model-id $model --num-shard 2 | |
| ``` | |
| ## Quantization Reproduction | |
| Soon (need to upstream an AutoAWQ patch). |