Adjusted Models
Collection
3 items • Updated
How to use pbansal/Dream-Coder-v0-Instruct-7B-Adjust with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="pbansal/Dream-Coder-v0-Instruct-7B-Adjust", trust_remote_code=True)
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("pbansal/Dream-Coder-v0-Instruct-7B-Adjust", trust_remote_code=True, dtype="auto")How to use pbansal/Dream-Coder-v0-Instruct-7B-Adjust with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "pbansal/Dream-Coder-v0-Instruct-7B-Adjust"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "pbansal/Dream-Coder-v0-Instruct-7B-Adjust",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/pbansal/Dream-Coder-v0-Instruct-7B-Adjust
How to use pbansal/Dream-Coder-v0-Instruct-7B-Adjust with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "pbansal/Dream-Coder-v0-Instruct-7B-Adjust" \
--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": "pbansal/Dream-Coder-v0-Instruct-7B-Adjust",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "pbansal/Dream-Coder-v0-Instruct-7B-Adjust" \
--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": "pbansal/Dream-Coder-v0-Instruct-7B-Adjust",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use pbansal/Dream-Coder-v0-Instruct-7B-Adjust with Docker Model Runner:
docker model run hf.co/pbansal/Dream-Coder-v0-Instruct-7B-Adjust
This is the joint sampling enabled Dream-Coder-v0-Instruct-7B model. Kindly refer to the paper below for details.
Here is a simple script for running the model. Setting the use_adjust flag as False generates from the base diffusion LM with naive parallel sampling.
from transformers import AutoModel, AutoTokenizer, AutoModelForCausalLM, set_seed
model_path = "pbansal/Dream-Coder-v0-Instruct-7B-Adjust"
model = AutoModel.from_pretrained(model_path, torch_dtype=torch.bfloat16, trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
model = model.to("cuda").eval()
use_adjust = True # Set to false to sample from just the base model
messages = [
{"role": "user", "content": "Write a quick sort algorithm."}
]
inputs = tokenizer.apply_chat_template(
messages, return_tensors="pt", return_dict=True, add_generation_prompt=True
)
input_ids = inputs.input_ids.to(device="cuda")
attention_mask = inputs.attention_mask.to(device="cuda")
output = model.diffusion_generate(
input_ids,
attention_mask=attention_mask,
max_new_tokens=768,
output_history=True,
return_dict_in_generate=True,
steps=768,
temperature=0.1,
top_p=0.95,
alg="entropy",
alg_temp=0.,
use_adjust=use_adjust,
)
generations = [
tokenizer.decode(g.tolist())
for p, g in zip(input_ids, output.sequences)
]
print(generations[0].split(tokenizer.eos_token)[0])