Instructions to use QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF", filename="Sparse-Llama-3.1-8B-2of4.Q2_K.gguf", )
output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF:Q4_K_M # Run inference directly in the terminal: llama-cli -hf QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF:Q4_K_M # Run inference directly in the terminal: llama-cli -hf QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF:Q4_K_M
Use Docker
docker model run hf.co/QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF:Q4_K_M
- Ollama
How to use QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF with Ollama:
ollama run hf.co/QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF:Q4_K_M
- Unsloth Studio new
How to use QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF to start chatting
- Docker Model Runner
How to use QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF with Docker Model Runner:
docker model run hf.co/QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF:Q4_K_M
- Lemonade
How to use QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.Sparse-Llama-3.1-8B-2of4-GGUF-Q4_K_M
List all available models
lemonade list
QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF
This is quantized version of neuralmagic/Sparse-Llama-3.1-8B-2of4 created using llama.cpp
Original Model Card
Sparse-Llama-3.1-8B-2of4
Model Overview
- Model Architecture: Llama-3.1-8B
- Input: Text
- Output: Text
- Model Optimizations:
- Sparsity: 2:4
- Release Date: 11/20/2024
- Version: 1.0
- License(s): llama3.1
- Model Developers: Neural Magic
This is the 2:4 sparse version of Llama-3.1-8B. On the OpenLLM benchmark (version 1), it achieves an average score of 62.16, compared to 63.19 for the dense model—demonstrating a 98.37% accuracy recovery. On the Mosaic Eval Gauntlet benchmark (version v0.3), it achieves an average score of 53.85, versus 55.34 for the dense model—representing a 97.3% accuracy recovery.
Model Optimizations
This model was obtained by pruning all linear operators within transformer blocks to the 2:4 sparsity pattern: in each group of four weights, two are retained while two are pruned. In addition to pruning, the sparse model was trained with knowledge distillation for 13B tokens to recover the accuracy loss incurred by pruning. For pruning, we utilize optimized version of SparseGPT through LLM-Compressor, and for sparse training with knowledge distillation we utilize SquareHead approach.
Deployment with vLLM
This model can be deployed efficiently using the vLLM backend. vLLM aslo supports OpenAI-compatible serving. See the documentation for more details.
Evaluation
This model was evaluated on the OpenLLM benchmark (version 1) with the vLLM engine for faster inference. In addition to the OpenLLM benchmark, the model was evaluated on the Mosaic Eval Gauntlet benchmark (version v0.3). The evaluation results are summarized below.
Accuracy
Open LLM Leaderboard evaluation scores
| Benchmark | Llama-3.1-8B | Sparse-Llama-3.1-8B-2of4 |
| ARC-C (25-shot) | 58.2 | 59.4 |
| MMLU (5-shot) | 65.4 | 60.6 |
| HellaSwag (10-shot) | 82.3 | 79.8 |
| WinoGrande (5-shot) | 78.3 | 75.9 |
| GSM8K (5-shot) | 50.7 | 56.3 |
| TruthfulQA (0-shot) | 44.2 | 40.9 |
| Average Score | 63.19 | 62.16 |
| Accuracy Recovery (%) | 100 | 98.37 |
Mosaic Eval Gauntlet evaluation scores
| Benchmark | Llama-3.1-8B | Sparse-Llama-3.1-8B-2of4 |
| World Knowledge | 59.4 | 55.6 |
| Commonsense Reasoning | 49.3 | 50.0 |
| Language Understanding | 69.8 | 69.0 |
| Symbolic Problem Solving | 40.0 | 37.1 |
| Reading Comprehension | 58.2 | 57.5 |
| Average Score | 55.34 | 53.85 |
| Accuracy Recovery (%) | 100 | 97.3 |
- Downloads last month
- 2,637
2-bit
3-bit
4-bit
5-bit
6-bit
8-bit
Model tree for QuantFactory/Sparse-Llama-3.1-8B-2of4-GGUF
Base model
meta-llama/Llama-3.1-8B