Views
No views yet



| Benchmark | DeepSeek-V2-Chat | DeepSeek-V2-Chat-0628 | Improvement |
|---|---|---|---|
| HumanEval | 81.1 | 84.8 | +3.7 |
| MATH | 53.9 | 71.0 | +17.1 |
| BBH | 79.7 | 83.4 | +3.7 |
| IFEval | 63.8 | 77.6 | +13.8 |
| Arena-Hard | 41.6 | 68.3 | +26.7 |
| JSON Output (Internal) | 78 | 85 | +7 |
1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig
3
4model_name = "deepseek-ai/DeepSeek-V2-Chat-0628"
5tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
6# `max_memory` should be set based on your devices
7max_memory = {i: "75GB" for i in range(8)}
8# `device_map` cannot be set to `auto`
9model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True, device_map="sequential", torch_dtype=torch.bfloat16, max_memory=max_memory, attn_implementation="eager")
10model.generation_config = GenerationConfig.from_pretrained(model_name)
11model.generation_config.pad_token_id = model.generation_config.eos_token_id
12
13messages = [
14 {"role": "user", "content": "Write a piece of quicksort code in C++"}
15]
16input_tensor = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt")
17outputs = model.generate(input_tensor.to(model.device), max_new_tokens=100)
18
19result = tokenizer.decode(outputs[0][input_tensor.shape[1]:], skip_special_tokens=True)
20print(result)tokenizer_config.json located in the huggingface model repository.<|begin▁of▁sentence|><|User|>{user_message_1}<|Assistant|>{assistant_message_1}<|end▁of▁sentence|><|User|>{user_message_2}<|Assistant|>1<|begin▁of▁sentence|>{system_message}
2
3<|User|>{user_message_1}<|Assistant|>{assistant_message_1}<|end▁of▁sentence|><|User|>{user_message_2}<|Assistant|>1from transformers import AutoTokenizer
2from vllm import LLM, SamplingParams
3
4max_model_len, tp_size = 8192, 8
5model_name = "deepseek-ai/DeepSeek-V2-Chat-0628"
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7llm = LLM(model=model_name, tensor_parallel_size=tp_size, max_model_len=max_model_len, trust_remote_code=True, enforce_eager=True)
8sampling_params = SamplingParams(temperature=0.3, max_tokens=256, stop_token_ids=[tokenizer.eos_token_id])
9
10messages_list = [
11 [{"role": "user", "content": "Who are you?"}],
12 [{"role": "user", "content": "Translate the following content into Chinese directly: DeepSeek-V2 adopts innovative architectures to guarantee economical training and efficient inference."}],
13 [{"role": "user", "content": "Write a piece of quicksort code in C++."}],
14]
15
16prompt_token_ids = [tokenizer.apply_chat_template(messages, add_generation_prompt=True) for messages in messages_list]
17
18outputs = llm.generate(prompt_token_ids=prompt_token_ids, sampling_params=sampling_params)
19
20generated_text = [output.outputs[0].text for output in outputs]
21print(generated_text)@misc{deepseekv2,
title={DeepSeek-V2: A Strong, Economical, and Efficient Mixture-of-Experts Language Model},
author={DeepSeek-AI},
year={2024},
eprint={2405.04434},
archivePrefix={arXiv},
primaryClass={cs.CL}
}