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 |
|---|---|---|---|---|---|
| pydevmini1.IQ2_S.gguf (with YaRN) | IQ2_S | 2 | 1.5 GB | 2.0 GB | small, substantial quality loss |
| pydevmini1.IQ2_M.gguf (with YaRN) | IQ2_M | 2 | 1.6 GB | 2.1 GB | small, greater quality loss |
| pydevmini1.IQ3_XXS.gguf (with YaRN) | IQ3_XXS | 3 | 1.7 GB | 2.2 GB | very small, high quality loss |
| pydevmini1.IQ3_XS.gguf (with YaRN) | IQ3_XS | 3 | 1.8 GB | 2.3 GB | small, substantial quality loss |
| pydevmini1.IQ3_S.gguf (with YaRN) | IQ3_S | 3 | 1.9 GB | 2.4 GB | small, greater quality loss |
| pydevmini1.IQ3_M.gguf (with YaRN) | IQ3_M | 3 | 2.0 GB | 2.5 GB | medium, balanced quality |
| pydevmini1.IQ4_XS.gguf (with YaRN) | IQ4_XS | 4 | 2.3 GB | 2.8 GB | small, marginal quality loss - recommended |
llama.cpp commandllama.cpp from commit d3bd719 or later../llama-cli -ngl 37 -m pydevmini1.IQ4_XS.gguf --color -c 262144 --temp 0.7 --top-p 0.8 --top-k 20 --repeat-penalty 1.05 --jinja-ngl 37 to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.-c 262144 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), only available if you enable Flash Attention (-fa) as well.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="-DGGML_CUDA=on" pip install llama-cpp-python
11# Or with OpenBLAS acceleration
12CMAKE_ARGS="-DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS" pip install llama-cpp-python
13# Or with AMD ROCm GPU acceleration (Linux only)
14CMAKE_ARGS="-DGGML_HIPBLAS=on" pip install llama-cpp-python
15# Or with Metal GPU acceleration for macOS systems only
16CMAKE_ARGS="-DGGML_METAL=on" pip install llama-cpp-python
17# Or with Vulkan acceleration
18CMAKE_ARGS="-DGGML_VULKAN=on" pip install llama-cpp-python
19# Or with SYCL acceleration
20CMAKE_ARGS="-DGGML_SYCL=on -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx" pip install llama-cpp-python
21
22# In windows, to set the variables CMAKE_ARGS in PowerShell, follow this format; eg for NVidia CUDA:
23$env:CMAKE_ARGS = "-DGGML_CUDA=on"
24pip install llama-cpp-python1from llama_cpp import Llama
2
3# Chat Completion API
4
5llm = Llama(model_path="./pydevmini1.IQ4_XS.gguf", n_gpu_layers=37, n_ctx=262144)
6print(llm.create_chat_completion(
7 repeat_penalty = 1.05,
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="./pydevmini1.IQ4_XS.gguf", n_gpu_layers=37, n_ctx=262144)
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")1from llama_cpp import Llama
2
3# Chat Completion API
4
5grammar = LlamaGrammar.from_json_schema(json.dumps({
6 "type": "array",
7 "items": {
8 "type": "object",
9 "required": [ "name", "arguments" ],
10 "properties": {
11 "name": {
12 "type": "string"
13 },
14 "arguments": {
15 "type": "object"
16 }
17 }
18 }
19}))
20
21llm = Llama(model_path="./pydevmini1.IQ4_XS.gguf", n_gpu_layers=37, n_ctx=262144)
22response = llm.create_chat_completion(
23 temperature = 0.0,
24 repeat_penalty = 1.05,
25 messages = [
26 {
27 "role": "user",
28 "content": "What's the weather like in Oslo and Stockholm?"
29 }
30 ],
31 tools=[{
32 "type": "function",
33 "function": {
34 "name": "get_current_weather",
35 "description": "Get the current weather in a given location",
36 "parameters": {
37 "type": "object",
38 "properties": {
39 "location": {
40 "type": "string",
41 "description": "The city and state, e.g. San Francisco, CA"
42 },
43 "unit": {
44 "type": "string",
45 "enum": [ "celsius", "fahrenheit" ]
46 }
47 },
48 "required": [ "location" ]
49 }
50 }
51 }],
52 grammar = grammar
53)
54print(json.loads(response["choices"][0]["text"]))
55
56print(llm.create_chat_completion(
57 temperature = 0.0,
58 repeat_penalty = 1.05,
59 messages = [
60 {
61 "role": "user",
62 "content": "What's the weather like in Oslo?"
63 },
64 { # The tool_calls is from the response to the above with tool_choice active
65 "role": "assistant",
66 "content": None,
67 "tool_calls": [
68 {
69 "id": "call__0_get_current_weather_cmpl-...",
70 "type": "function",
71 "function": {
72 "name": "get_current_weather",
73 "arguments": { "location": "Oslo, Norway" , "unit": "celsius" }
74 }
75 }
76 ]
77 },
78 { # The tool_call_id is from tool_calls and content is the result from the function call you made
79 "role": "tool",
80 "content": "20",
81 "tool_call_id": "call__0_get_current_weather_cmpl-..."
82 }
83 ],
84 tools=[{
85 "type": "function",
86 "function": {
87 "name": "get_current_weather",
88 "description": "Get the current weather in a given location",
89 "parameters": {
90 "type": "object",
91 "properties": {
92 "location": {
93 "type": "string",
94 "description": "The city and state, e.g. San Francisco, CA"
95 },
96 "unit": {
97 "type": "string",
98 "enum": [ "celsius", "fahrenheit" ]
99 }
100 },
101 "required": [ "location" ]
102 }
103 }
104 }],
105 #tool_choice={
106 # "type": "function",
107 # "function": {
108 # "name": "get_current_weather"
109 # }
110 #}
111))