Instructions to use RedHatAI/SparseLlama-2-7b-evolcodealpaca-pruned_50.2of4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use RedHatAI/SparseLlama-2-7b-evolcodealpaca-pruned_50.2of4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="RedHatAI/SparseLlama-2-7b-evolcodealpaca-pruned_50.2of4")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("RedHatAI/SparseLlama-2-7b-evolcodealpaca-pruned_50.2of4") model = AutoModelForCausalLM.from_pretrained("RedHatAI/SparseLlama-2-7b-evolcodealpaca-pruned_50.2of4", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use RedHatAI/SparseLlama-2-7b-evolcodealpaca-pruned_50.2of4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "RedHatAI/SparseLlama-2-7b-evolcodealpaca-pruned_50.2of4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RedHatAI/SparseLlama-2-7b-evolcodealpaca-pruned_50.2of4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/RedHatAI/SparseLlama-2-7b-evolcodealpaca-pruned_50.2of4
- SGLang
How to use RedHatAI/SparseLlama-2-7b-evolcodealpaca-pruned_50.2of4 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/SparseLlama-2-7b-evolcodealpaca-pruned_50.2of4" \ --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": "RedHatAI/SparseLlama-2-7b-evolcodealpaca-pruned_50.2of4", "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 "RedHatAI/SparseLlama-2-7b-evolcodealpaca-pruned_50.2of4" \ --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": "RedHatAI/SparseLlama-2-7b-evolcodealpaca-pruned_50.2of4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use RedHatAI/SparseLlama-2-7b-evolcodealpaca-pruned_50.2of4 with Docker Model Runner:
docker model run hf.co/RedHatAI/SparseLlama-2-7b-evolcodealpaca-pruned_50.2of4
SparseLlama-2-7b-evolcodealpaca-pruned_50.2of4
Model Overview
- Model Architecture: Llama-2
- Input: Text
- Output: Text
- Model Optimizations:
- Pruned: 50% 2:4
- Release Date: 7/2/2024
- Version: 1.0
- Model Developers: Neural Magic
Compressed version of Llama-2-7b specialized for code-generation. This model was obtained by fine-tuning the Sparse Foundational model SparseLlama-2-7b-pruned_50.2of4 on the evol-codealpaca-v1 dataset. SquareHead knowledge distillation was used with Llama-2-7b-evolcodealpaca as teacher. It achieves HumanEval pass@1 of 34.58%, whereas the dense Llama-2-7b-evolcodealpaca model achieves 32.03%.
This model was produced as part if Neural Magic's Sparse Foundational Models initiative, and demostrates the capability of Sparse Foundational Models to transfer to the code-generation domain.
Model Optimizations
This model is derived from the Sparse Foundational model Sparse-Llama-2-7b-pruned_50.2of4, which was obtained by applying the SparseGPT algorithm to prune Llama-2-7b to 50% sparsity with a 2:4 mask. This optimization reduces the number of parameters by 50%, reducing the disk size and FLOPs by the same level.
Evaluation
This model was evaluated in the HumanEval benchmark using the bigcode-evaluation-harness.
Accuracy
| Model | HumanEval pass@1 | Recovery |
|---|---|---|
| Llama-2-7b-evolcodealpaca | 32.03% | -- |
| SparseLlama-2-7b-evolcodealpaca-pruned_50.2of4 | 34.58% | 108% |
- Downloads last month
- 9