Instructions to use NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO") model = AutoModelForMultimodalLM.from_pretrained("NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO") 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 Settings
- vLLM
How to use NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO
- SGLang
How to use NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO 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 "NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO" \ --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": "NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO", "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 "NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO" \ --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": "NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO with Docker Model Runner:
docker model run hf.co/NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO
[AUTOMATED] Model Memory Requirements
Model Memory Requirements
You will need about {'dtype': 'float16/bfloat16', 'Largest Layer or Residual Group': '2.72 GB', 'Total Size': '87.25 GB', 'Training using Adam': '348.99 GB'} VRAM to load this model for inference, and {'dtype': 'int4', 'Largest Layer or Residual Group': '696.02 MB', 'Total Size': '21.81 GB', 'Training using Adam': '87.25 GB'} VRAM to train it using Adam.
These calculations were measured from the Model Memory Utility Space on the Hub.
The minimum recommended vRAM needed for this model assumes using Accelerate or device_map="auto" and is denoted by the size of the "largest layer".
When performing inference, expect to add up to an additional 20% to this, as found by EleutherAI. More tests will be performed in the future to get a more accurate benchmark for each model.
When training with Adam, you can expect roughly 4x the reported results to be used. (1x for the model, 1x for the gradients, and 2x for the optimizer).
Results:
| dtype | Largest Layer or Residual Group | Total Size | Training using Adam |
|---|---|---|---|
| float32 | 5.44 GB | 174.49 GB | 697.97 GB |
| float16/bfloat16 | 2.72 GB | 87.25 GB | 348.99 GB |
| int8 | 1.36 GB | 43.62 GB | 174.49 GB |
| int4 | 696.02 MB | 21.81 GB | 87.25 GB |
When I run this model using vllm and the following command - docker run --runtime nvidia --gpus all --restart always -p 8000:8000 -e HF_TOKEN='HUGGINGFACE_TOKEN' --ipc=host -d vllm/vllm-openai:latest --served-model-name mpt-7b-chat --model NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO --host 0.0.0.0 on a newly created GCP instance equipped with 4 NVIDIA A100 40GB GPUs, I am getting a torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 1.75 GiB. GPU 0 has a total capacty of 39.39 GiB of which 575.94 MiB is free. Process 45100 has 38.82 GiB memory in use. Of the allocated memory 38.18 GiB is allocated by PyTorch, and 14.34 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF error. I ran nvidia-smi and there are no processes currently running and the GPU/memory utilization is also currently 0. Has anybody else encountered this and is there a good fix for this?