Instructions to use robertgshaw2/llama-2-7b-chat-marlin with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use robertgshaw2/llama-2-7b-chat-marlin with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="robertgshaw2/llama-2-7b-chat-marlin")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("robertgshaw2/llama-2-7b-chat-marlin") model = AutoModelForCausalLM.from_pretrained("robertgshaw2/llama-2-7b-chat-marlin") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use robertgshaw2/llama-2-7b-chat-marlin with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "robertgshaw2/llama-2-7b-chat-marlin" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "robertgshaw2/llama-2-7b-chat-marlin", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/robertgshaw2/llama-2-7b-chat-marlin
- SGLang
How to use robertgshaw2/llama-2-7b-chat-marlin 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 "robertgshaw2/llama-2-7b-chat-marlin" \ --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": "robertgshaw2/llama-2-7b-chat-marlin", "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 "robertgshaw2/llama-2-7b-chat-marlin" \ --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": "robertgshaw2/llama-2-7b-chat-marlin", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use robertgshaw2/llama-2-7b-chat-marlin with Docker Model Runner:
docker model run hf.co/robertgshaw2/llama-2-7b-chat-marlin
llama-2-7b-chat-marlin
Example of converting a GPTQ model to Marlin format for fast batched decoding with Marlin Kernels
Install Marlin
pip install torch
git clone https://github.com/IST-DASLab/marlin.git
cd marlin
pip install -e .
Convert Model
Convert the model from GPTQ to Marlin format. Note that this requires:
sym=truegroup_size=128desc_activations=false
pip install -U transformers accelerate auto-gptq optimum
Convert with the convert.py script in this repo:
python3 convert.py --model-id "TheBloke/Llama-2-7B-Chat-GPTQ" --save-path "./marlin-model" --do-generation
Run Model
Load with the load.load_model utility from this repo and run inference as usual.
from load import load_model
from transformers import AutoTokenizer
# Load model from disk.
model_path = "./marlin-model"
model = load_model(model_path).to("cuda")
tokenizer = AutoTokenizer.from_pretrained(model_path)
# Generate text.
inputs = tokenizer("My favorite song is", return_tensors="pt")
inputs = {k: v.to("cuda") for k, v in inputs.items()}
outputs = model.generate(**inputs, max_new_tokens=50, do_sample=False)
print(tokenizer.batch_decode(outputs)[0])
- Downloads last month
- 29