Views
No views yet
<|im_start|>system
{system_prompt}<|im_end|>
<|im_start|>user
{prompt}<|im_end|>
<|im_start|>assistant| Name | Quant method | Bits | Size | Max RAM required | Use case |
|---|---|---|---|---|---|
| CodeQwen1.5-7B-Chat.IQ1_S.gguf | IQ1_S | 1 | 2.2 GB | 2.4 GB | smallest, significant quality loss |
| CodeQwen1.5-7B-Chat.IQ1_M.gguf | IQ1_M | 1 | 2.3 GB | 2.5 GB | very small, significant quality loss |
| CodeQwen1.5-7B-Chat.IQ2_XXS.gguf | IQ2_XXS | 2 | 2.5 GB | 2.7 GB | very small, high quality loss |
| CodeQwen1.5-7B-Chat.IQ2_XS.gguf | IQ2_XS | 2 | 2.6 GB | 2.8 GB | very small, high quality loss |
| CodeQwen1.5-7B-Chat.IQ2_S.gguf | IQ2_S | 2 | 2.7 GB | 2.9 GB | small, substantial quality loss |
| CodeQwen1.5-7B-Chat.IQ2_M.gguf | IQ2_M | 2 | 2.9 GB | 3.1 GB | small, greater quality loss |
| CodeQwen1.5-7B-Chat.IQ3_XXS.gguf | IQ3_XXS | 3 | 3.1 GB | 3.3 GB | very small, high quality loss |
| CodeQwen1.5-7B-Chat.IQ3_XS.gguf | IQ3_XS | 3 | 3.2 GB | 3.4 GB | small, substantial quality loss |
| CodeQwen1.5-7B-Chat.IQ3_S.gguf | IQ3_S | 3 | 3.3 GB | 3.5 GB | small, greater quality loss |
| CodeQwen1.5-7B-Chat.IQ3_M.gguf | IQ3_M | 3 | 3.4 GB | 3.6 GB | medium, balanced quality - recommended |
| CodeQwen1.5-7B-Chat.IQ4_NL.gguf | IQ4_NL | 4 | 4.0 GB | 4.2 GB | small, substantial quality loss |
llama.cpp commandllama.cpp from commit 0becb22 or later../main -ngl 33 -m CodeQwen1.5-7B-Chat.IQ2_XS.gguf --color -c 65536 --temp 1.0 --repeat-penalty 1.0 --top-p 0.95 -n -1 -p "<|im_start|>system\nYou are a helpful assistant<|im_end|>\n<|im_start|>\n{prompt}<|im_end|>\n<|im_start|>assistant\n"-ngl 33 to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.-c 65536 to the desired sequence length.-p <PROMPT> argument with -i -ins-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 is not working yet.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="./CodeQwen1.5-7B-Chat.IQ2_XS.gguf", n_gpu_layers=33, n_ctx=65536)
6print(llm.create_chat_completion(
7 messages = [
8 {"role": "system", "content": "You are an expert AI coding assistant."},
9 {
10 "role": "user",
11 "content": "Pick a LeetCode challenge and solve it in Python."
12 }
13 ]
14))transformers>=4.37.0, or you might encounter the following error:KeyError: 'qwen2'.apply_chat_template to show you how to load the tokenizer and model and how to generate contents.1from transformers import AutoModelForCausalLM, AutoTokenizer
2device = "cuda" # the device to load the model onto
3
4model = AutoModelForCausalLM.from_pretrained(
5 "Qwen/CodeQwen1.5-7B-Chat",
6 torch_dtype="auto",
7 device_map="auto"
8)
9tokenizer = AutoTokenizer.from_pretrained("Qwen/CodeQwen1.5-7B-Chat")
10
11prompt = "Write a quicksort algorithm in python."
12messages = [
13 {"role": "system", "content": "You are a helpful assistant."},
14 {"role": "user", "content": prompt}
15]
16text = tokenizer.apply_chat_template(
17 messages,
18 tokenize=False,
19 add_generation_prompt=True
20)
21model_inputs = tokenizer([text], return_tensors="pt").to(device)
22
23generated_ids = model.generate(
24 model_inputs.input_ids,
25 max_new_tokens=512
26)
27generated_ids = [
28 output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
29]
30
31response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]generation_config.json.@article{qwen,
title={Qwen Technical Report},
author={Jinze Bai and Shuai Bai and Yunfei Chu and Zeyu Cui and Kai Dang and Xiaodong Deng and Yang Fan and Wenbin Ge and Yu Han and Fei Huang and Binyuan Hui and Luo Ji and Mei Li and Junyang Lin and Runji Lin and Dayiheng Liu and Gao Liu and Chengqiang Lu and Keming Lu and Jianxin Ma and Rui Men and Xingzhang Ren and Xuancheng Ren and Chuanqi Tan and Sinan Tan and Jianhong Tu and Peng Wang and Shijie Wang and Wei Wang and Shengguang Wu and Benfeng Xu and Jin Xu and An Yang and Hao Yang and Jian Yang and Shusheng Yang and Yang Yao and Bowen Yu and Hongyi Yuan and Zheng Yuan and Jianwei Zhang and Xingxuan Zhang and Yichang Zhang and Zhenru Zhang and Chang Zhou and Jingren Zhou and Xiaohuan Zhou and Tianhang Zhu},
journal={arXiv preprint arXiv:2309.16609},
year={2023}
}