Text Generation
MLX
Safetensors
Dream
code
text-diffusion-model
diffusion large language model
conversational
4-bit precision
Instructions to use mlx-community/DiffuCoder-7B-cpGRPO-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use mlx-community/DiffuCoder-7B-cpGRPO-4bit with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("mlx-community/DiffuCoder-7B-cpGRPO-4bit") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- LM Studio
- Pi new
How to use mlx-community/DiffuCoder-7B-cpGRPO-4bit with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/DiffuCoder-7B-cpGRPO-4bit"
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "mlx-community/DiffuCoder-7B-cpGRPO-4bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use mlx-community/DiffuCoder-7B-cpGRPO-4bit with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/DiffuCoder-7B-cpGRPO-4bit"
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default mlx-community/DiffuCoder-7B-cpGRPO-4bit
Run Hermes
hermes
- MLX LM
How to use mlx-community/DiffuCoder-7B-cpGRPO-4bit with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "mlx-community/DiffuCoder-7B-cpGRPO-4bit"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "mlx-community/DiffuCoder-7B-cpGRPO-4bit" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mlx-community/DiffuCoder-7B-cpGRPO-4bit", "messages": [ {"role": "user", "content": "Hello"} ] }'
Delete configuration_dream.py
Browse files- configuration_dream.py +0 -86
configuration_dream.py
DELETED
|
@@ -1,86 +0,0 @@
|
|
| 1 |
-
# coding=utf-8
|
| 2 |
-
# Copyright 2024 The Dream team, HKUNLP Group and the HuggingFace Inc. team. All rights reserved.
|
| 3 |
-
#
|
| 4 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
-
# you may not use this file except in compliance with the License.
|
| 6 |
-
# You may obtain a copy of the License at
|
| 7 |
-
#
|
| 8 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
-
#
|
| 10 |
-
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
-
# See the License for the specific language governing permissions and
|
| 14 |
-
# limitations under the License.
|
| 15 |
-
"""Dream model configuration"""
|
| 16 |
-
|
| 17 |
-
from transformers.configuration_utils import PretrainedConfig
|
| 18 |
-
from transformers.modeling_rope_utils import rope_config_validation
|
| 19 |
-
from transformers.utils import logging
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
logger = logging.get_logger(__name__)
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
class DreamConfig(PretrainedConfig):
|
| 26 |
-
model_type = "Dream"
|
| 27 |
-
keys_to_ignore_at_inference = ["past_key_values"]
|
| 28 |
-
|
| 29 |
-
def __init__(
|
| 30 |
-
self,
|
| 31 |
-
vocab_size=151936,
|
| 32 |
-
hidden_size=4096,
|
| 33 |
-
intermediate_size=22016,
|
| 34 |
-
num_hidden_layers=32,
|
| 35 |
-
num_attention_heads=32,
|
| 36 |
-
num_key_value_heads=32,
|
| 37 |
-
hidden_act="silu",
|
| 38 |
-
max_position_embeddings=32768,
|
| 39 |
-
initializer_range=0.02,
|
| 40 |
-
rms_norm_eps=1e-6,
|
| 41 |
-
use_cache=False, # cache not used in diffusion
|
| 42 |
-
tie_word_embeddings=False,
|
| 43 |
-
rope_theta=10000.0,
|
| 44 |
-
rope_scaling=None,
|
| 45 |
-
use_sliding_window=False,
|
| 46 |
-
sliding_window=4096,
|
| 47 |
-
max_window_layers=28,
|
| 48 |
-
attention_dropout=0.0,
|
| 49 |
-
mask_token_id=151666,
|
| 50 |
-
pad_token_id=151643,
|
| 51 |
-
**kwargs,
|
| 52 |
-
):
|
| 53 |
-
self.vocab_size = vocab_size
|
| 54 |
-
self.max_position_embeddings = max_position_embeddings
|
| 55 |
-
self.hidden_size = hidden_size
|
| 56 |
-
self.intermediate_size = intermediate_size
|
| 57 |
-
self.num_hidden_layers = num_hidden_layers
|
| 58 |
-
self.num_attention_heads = num_attention_heads
|
| 59 |
-
self.use_sliding_window = use_sliding_window
|
| 60 |
-
self.sliding_window = sliding_window if use_sliding_window else None
|
| 61 |
-
self.max_window_layers = max_window_layers
|
| 62 |
-
|
| 63 |
-
# for backward compatibility
|
| 64 |
-
if num_key_value_heads is None:
|
| 65 |
-
num_key_value_heads = num_attention_heads
|
| 66 |
-
|
| 67 |
-
self.num_key_value_heads = num_key_value_heads
|
| 68 |
-
self.hidden_act = hidden_act
|
| 69 |
-
self.initializer_range = initializer_range
|
| 70 |
-
self.rms_norm_eps = rms_norm_eps
|
| 71 |
-
self.use_cache = use_cache
|
| 72 |
-
self.rope_theta = rope_theta
|
| 73 |
-
self.rope_scaling = rope_scaling
|
| 74 |
-
self.attention_dropout = attention_dropout
|
| 75 |
-
# Validate the correctness of rotary position embeddings parameters
|
| 76 |
-
# BC: if there is a 'type' field, move it to 'rope_type'.
|
| 77 |
-
if self.rope_scaling is not None and "type" in self.rope_scaling:
|
| 78 |
-
self.rope_scaling["rope_type"] = self.rope_scaling["type"]
|
| 79 |
-
rope_config_validation(self)
|
| 80 |
-
|
| 81 |
-
super().__init__(
|
| 82 |
-
tie_word_embeddings=tie_word_embeddings,
|
| 83 |
-
**kwargs,
|
| 84 |
-
)
|
| 85 |
-
self.mask_token_id = mask_token_id
|
| 86 |
-
self.pad_token_id = pad_token_id
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|