Text Generation
Transformers
Safetensors
English
phi
quantized
gptq
4bit
safety-evaluation
banterhearts
text-generation-inference
4-bit precision
Instructions to use Crusadersk/phi-2-gptq-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Crusadersk/phi-2-gptq-4bit with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Crusadersk/phi-2-gptq-4bit")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Crusadersk/phi-2-gptq-4bit") model = AutoModelForCausalLM.from_pretrained("Crusadersk/phi-2-gptq-4bit", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Crusadersk/phi-2-gptq-4bit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Crusadersk/phi-2-gptq-4bit" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Crusadersk/phi-2-gptq-4bit", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Crusadersk/phi-2-gptq-4bit
- SGLang
How to use Crusadersk/phi-2-gptq-4bit 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 "Crusadersk/phi-2-gptq-4bit" \ --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": "Crusadersk/phi-2-gptq-4bit", "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 "Crusadersk/phi-2-gptq-4bit" \ --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": "Crusadersk/phi-2-gptq-4bit", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Crusadersk/phi-2-gptq-4bit with Docker Model Runner:
docker model run hf.co/Crusadersk/phi-2-gptq-4bit
| { | |
| "architectures": [ | |
| "PhiForCausalLM" | |
| ], | |
| "attention_dropout": 0.0, | |
| "bos_token_id": 50256, | |
| "dtype": "float16", | |
| "embd_pdrop": 0.0, | |
| "eos_token_id": 50256, | |
| "hidden_act": "gelu_new", | |
| "hidden_size": 2560, | |
| "initializer_range": 0.02, | |
| "intermediate_size": 10240, | |
| "layer_norm_eps": 1e-05, | |
| "max_position_embeddings": 2048, | |
| "model_type": "phi", | |
| "num_attention_heads": 32, | |
| "num_hidden_layers": 32, | |
| "num_key_value_heads": 32, | |
| "pad_token_id": 50256, | |
| "partial_rotary_factor": 0.4, | |
| "qk_layernorm": false, | |
| "quantization_config": { | |
| "bits": 4, | |
| "checkpoint_format": "gptq", | |
| "desc_act": false, | |
| "format": "gptq", | |
| "group_size": 128, | |
| "lm_head": false, | |
| "meta": { | |
| "act_group_aware": true, | |
| "auto_forward_data_parallel": true, | |
| "damp_auto_increment": 0.01, | |
| "damp_percent": 0.05, | |
| "failsafe": { | |
| "smooth": null, | |
| "strategy": "rtn", | |
| "threshold": "0.5%" | |
| }, | |
| "gc_mode": "interval", | |
| "gptaq": null, | |
| "hessian": { | |
| "chunk_bytes": null, | |
| "chunk_size": null, | |
| "staging_dtype": "float32" | |
| }, | |
| "mock_quantization": false, | |
| "mse": 0.0, | |
| "offload_to_disk": true, | |
| "offload_to_disk_path": "./gptqmodel_offload/bxitqbrw-vnczleuk/", | |
| "pack_impl": "cpu", | |
| "quantizer": [ | |
| "gptqmodel:5.8.0" | |
| ], | |
| "static_groups": false, | |
| "true_sequential": true, | |
| "uri": "https://github.com/modelcloud/gptqmodel", | |
| "vram_strategy": "exclusive", | |
| "wait_for_submodule_finalizers": false | |
| }, | |
| "pack_dtype": "int32", | |
| "quant_method": "gptq", | |
| "sym": true | |
| }, | |
| "resid_pdrop": 0.1, | |
| "rope_parameters": { | |
| "partial_rotary_factor": 0.4, | |
| "rope_theta": 10000.0, | |
| "rope_type": "default" | |
| }, | |
| "tie_word_embeddings": false, | |
| "transformers_version": "5.4.0", | |
| "use_cache": true, | |
| "vocab_size": 51200 | |
| } | |