Text Generation
Transformers
Safetensors
English
phi3
conversational
custom_code
text-generation-inference
8-bit precision
compressed-tensors
Instructions to use RedHatAI/Phi-3-mini-128k-instruct-quantized.w8a8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use RedHatAI/Phi-3-mini-128k-instruct-quantized.w8a8 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="RedHatAI/Phi-3-mini-128k-instruct-quantized.w8a8", 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("RedHatAI/Phi-3-mini-128k-instruct-quantized.w8a8", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("RedHatAI/Phi-3-mini-128k-instruct-quantized.w8a8", 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 RedHatAI/Phi-3-mini-128k-instruct-quantized.w8a8 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "RedHatAI/Phi-3-mini-128k-instruct-quantized.w8a8" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RedHatAI/Phi-3-mini-128k-instruct-quantized.w8a8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/RedHatAI/Phi-3-mini-128k-instruct-quantized.w8a8
- SGLang
How to use RedHatAI/Phi-3-mini-128k-instruct-quantized.w8a8 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 "RedHatAI/Phi-3-mini-128k-instruct-quantized.w8a8" \ --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": "RedHatAI/Phi-3-mini-128k-instruct-quantized.w8a8", "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 "RedHatAI/Phi-3-mini-128k-instruct-quantized.w8a8" \ --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": "RedHatAI/Phi-3-mini-128k-instruct-quantized.w8a8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use RedHatAI/Phi-3-mini-128k-instruct-quantized.w8a8 with Docker Model Runner:
docker model run hf.co/RedHatAI/Phi-3-mini-128k-instruct-quantized.w8a8
Model doesnt load in vllm version 0.5.0 : ValueError: `rope_scaling`'s type field must be one of ['su', 'yarn'], got longrope
#1
by sujjosep - opened
llm = LLM(model=model_id, trust_remote_code=True, max_model_len=8196, tensor_parallel_size=number_gpus)
With trust remote code True
File ~/.local/lib/python3.11/site-packages/vllm/config.py:1287, in _get_and_verify_max_len(hf_config, max_model_len, disable_sliding_window, sliding_window_len)
1280 if disable_sliding_window:
1281 # TODO(robertgshaw): Find a model that supports rope_scaling
1282 # with sliding window to see if this case should be allowed.
1283 raise NotImplementedError(
1284 "Disabling sliding window is not supported for models "
1285 "with rope_scaling. Please raise an issue so we can "
1286 "investigate.")
-> 1287 assert "factor" in rope_scaling
1288 scaling_factor = rope_scaling["factor"]
1289 if rope_scaling["type"] == "yarn":
AssertionError:
Without trust remote code True :
File ~/.local/lib/python3.11/site-packages/transformers/models/phi3/configuration_phi3.py:185, in Phi3Config._rope_scaling_validation(self)
183 rope_scaling_long_factor = self.rope_scaling.get("long_factor", None)
184 if rope_scaling_type is None or rope_scaling_type not in ["su", "yarn"]:
--> 185 raise ValueError(f"`rope_scaling`'s type field must be one of ['su', 'yarn'], got {rope_scaling_type}")
186 if not (
187 isinstance(rope_scaling_short_factor, list)
188 and all(isinstance(x, (int, float)) for x in rope_scaling_short_factor)
189 ):
190 raise ValueError(
191 f"`rope_scaling`'s short_factor field must be a list of numbers, got {rope_scaling_short_factor}"
192 )
ValueError: `rope_scaling`'s type field must be one of ['su', 'yarn'], got longrope
Please update your version of vLLM to 0.5.2