Views
No views yet
User: {prompt}
Assistant:| Name | Quant method | Bits | Size | Max RAM required | Use case |
|---|---|---|---|---|---|
| DeepSeek-Coder-V2-Lite-Instruct.IQ1_S.gguf | IQ1_S | 1 | 4.5 GB | 5.5 GB | smallest, significant quality loss |
| DeepSeek-Coder-V2-Lite-Instruct.IQ1_M.gguf | IQ1_M | 1 | 4.7 GB | 5.7 GB | very small, significant quality loss |
| DeepSeek-Coder-V2-Lite-Instruct.IQ2_XXS.gguf | IQ2_XXS | 2 | 5.1 GB | 6.1 GB | very small, high quality loss |
| DeepSeek-Coder-V2-Lite-Instruct.IQ2_XS.gguf | IQ2_XS | 2 | 5.4 GB | 6.4 GB | very small, high quality loss |
| DeepSeek-Coder-V2-Lite-Instruct.IQ2_S.gguf | IQ2_S | 2 | 5.4 GB | 6.4 GB | small, substantial quality loss |
| DeepSeek-Coder-V2-Lite-Instruct.IQ2_M.gguf | IQ2_M | 2 | 5.7 GB | 6.7 GB | small, greater quality loss |
| DeepSeek-Coder-V2-Lite-Instruct.IQ3_XXS.gguf | IQ3_XXS | 3 | 6.3 GB | 7.3 GB | very small, high quality loss |
| DeepSeek-Coder-V2-Lite-Instruct.IQ3_XS.gguf | IQ3_XS | 3 | 6.5 GB | 7.5 GB | small, substantial quality loss |
| DeepSeek-Coder-V2-Lite-Instruct.IQ3_S.gguf | IQ3_S | 3 | 6.8 GB | 7.8 GB | small, greater quality loss |
| DeepSeek-Coder-V2-Lite-Instruct.IQ3_M.gguf | IQ3_M | 3 | 6.9 GB | 7.9 GB | medium, balanced quality - recommended |
| DeepSeek-Coder-V2-Lite-Instruct.IQ4_NL.gguf | IQ4_NL | 4 | 8.1 GB | 9.1 GB | small, substantial quality loss |
llama.cpp commandllama.cpp from commit fb76ec3 or later../llama-cli -ngl 28 -m DeepSeek-Coder-V2-Lite-Instruct.IQ4_NL.gguf --color -c 131072 --temp 0 --repeat-penalty 1.1 -p "User: {prompt}\n\nAssistant:"-ngl 28 to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.-c 131072 to the desired sequence length.-ctk q8_0 or even -ctk q4_0 for big memory savings (depending on context size).
There is a similar option for V-cache (-ctv), however that requires Flash Attention which is not working yet with this model.1# Prebuilt wheel with basic CPU support
2pip install llama-cpp-python --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu
3# Prebuilt wheel with NVidia CUDA acceleration
4pip install llama-cpp-python --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu121 (or cu122 etc.)
5# Prebuilt wheel with Metal GPU acceleration
6pip install llama-cpp-python --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/metal
7# Build base version with no GPU acceleration
8pip install llama-cpp-python
9# With NVidia CUDA acceleration
10CMAKE_ARGS="-DLLAMA_CUDA=on" pip install llama-cpp-python
11# Or with OpenBLAS acceleration
12CMAKE_ARGS="-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS" pip install llama-cpp-python
13# Or with CLBLast acceleration
14CMAKE_ARGS="-DLLAMA_CLBLAST=on" pip install llama-cpp-python
15# Or with AMD ROCm GPU acceleration (Linux only)
16CMAKE_ARGS="-DLLAMA_HIPBLAS=on" pip install llama-cpp-python
17# Or with Metal GPU acceleration for macOS systems only
18CMAKE_ARGS="-DLLAMA_METAL=on" pip install llama-cpp-python
19# Or with Vulkan acceleration
20CMAKE_ARGS="-DLLAMA_VULKAN=on" pip install llama-cpp-python
21# Or with Kompute acceleration
22CMAKE_ARGS="-DLLAMA_KOMPUTE=on" pip install llama-cpp-python
23# Or with SYCL acceleration
24CMAKE_ARGS="-DLLAMA_SYCL=on -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx" pip install llama-cpp-python
25
26# In windows, to set the variables CMAKE_ARGS in PowerShell, follow this format; eg for NVidia CUDA:
27$env:CMAKE_ARGS = "-DLLAMA_CUDA=on"
28pip install llama-cpp-python1from llama_cpp import Llama
2
3# Chat Completion API
4
5llm = Llama(model_path="./DeepSeek-Coder-V2-Lite-Instruct.IQ4_NL.gguf", n_gpu_layers=28, n_ctx=131072)
6print(llm.create_chat_completion(
7 repeat_penalty = 1.1,
8 messages = [
9 {
10 "role": "user",
11 "content": "Pick a LeetCode challenge and solve it in Python."
12 }
13 ]
14))1from llama_cpp import Llama
2
3# Completion API
4
5prompt = "def add("
6suffix = "\n return sum\n\n"
7
8llm = Llama(model_path="./DeepSeek-Coder-V2-Lite-Instruct.IQ4_NL.gguf", n_gpu_layers=28, n_ctx=131072)
9output = llm.create_completion(
10 temperature = 0.0,
11 repeat_penalty = 1.0,
12 prompt = prompt,
13 suffix = suffix
14)
15
16# Models sometimes repeat suffix in response, attempt to filter that
17response = output["choices"][0]["text"]
18response_stripped = response.rstrip()
19unwanted_response_suffix = suffix.rstrip()
20unwanted_response_length = len(unwanted_response_suffix)
21
22filtered = False
23if unwanted_response_suffix and response_stripped[-unwanted_response_length:] == unwanted_response_suffix:
24 response = response_stripped[:-unwanted_response_length]
25 filtered = True
26
27print(f"Fill-in-Middle completion{' (filtered)' if filtered else ''}:\n\n{prompt}\033[32m{response}\033[{'33' if filtered else '0'}m{suffix}\033[0m")
| Model | #Total Params | #Active Params | Context Length | Download |
|---|---|---|---|---|
| DeepSeek-Coder-V2-Lite-Base | 16B | 2.4B | 128k | 🤗 HuggingFace |
| DeepSeek-Coder-V2-Lite-Instruct | 16B | 2.4B | 128k | 🤗 HuggingFace |
| DeepSeek-Coder-V2-Base | 236B | 21B | 128k | 🤗 HuggingFace |
| DeepSeek-Coder-V2-Instruct | 236B | 21B | 128k | 🤗 HuggingFace |

1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
3tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Base", trust_remote_code=True)
4model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Base", trust_remote_code=True, torch_dtype=torch.bfloat16).cuda()
5input_text = "#write a quick sort algorithm"
6inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
7outputs = model.generate(**inputs, max_length=128)
8print(tokenizer.decode(outputs[0], skip_special_tokens=True))1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
3tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Base", trust_remote_code=True)
4model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Base", trust_remote_code=True, torch_dtype=torch.bfloat16).cuda()
5input_text = """<|fim▁begin|>def quick_sort(arr):
6 if len(arr) <= 1:
7 return arr
8 pivot = arr[0]
9 left = []
10 right = []
11<|fim▁hole|>
12 if arr[i] < pivot:
13 left.append(arr[i])
14 else:
15 right.append(arr[i])
16 return quick_sort(left) + [pivot] + quick_sort(right)<|fim▁end|>"""
17inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
18outputs = model.generate(**inputs, max_length=128)
19print(tokenizer.decode(outputs[0], skip_special_tokens=True)[len(input_text):])1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
3tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct", trust_remote_code=True)
4model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct", trust_remote_code=True, torch_dtype=torch.bfloat16).cuda()
5messages=[
6 { 'role': 'user', 'content': "write a quick sort algorithm in python."}
7]
8inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
9# tokenizer.eos_token_id is the id of <|EOT|> token
10outputs = model.generate(inputs, max_new_tokens=512, do_sample=False, top_k=50, top_p=0.95, num_return_sequences=1, eos_token_id=tokenizer.eos_token_id)
11print(tokenizer.decode(outputs[0][len(inputs[0]):], skip_special_tokens=True))tokenizer_config.json located in the huggingface model repository.1<|begin▁of▁sentence|>User: {user_message_1}
2
3Assistant: {assistant_message_1}<|end▁of▁sentence|>User: {user_message_2}
4
5Assistant:1<|begin▁of▁sentence|>{system_message}
2
3User: {user_message_1}
4
5Assistant: {assistant_message_1}<|end▁of▁sentence|>User: {user_message_2}
6
7Assistant:1from transformers import AutoTokenizer
2from vllm import LLM, SamplingParams
3
4max_model_len, tp_size = 8192, 1
5model_name = "deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct"
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": "write a quick sort algorithm in python."}],
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)