Views
No views yet
tool_calls fixed when None), removed silly tool_call_id length restriction and added padding token.tools parameter, see example.[AVAILABLE_TOOLS][{"name": "function_name", "description": "Description", "parameters": {...}}, ...][/AVAILABLE_TOOLS][INST]{prompt}[/INST]| Name | Quant method | Bits | Size | Max RAM required | Use case |
|---|---|---|---|---|---|
| Mistral-Nemo-Instruct-2407.IQ1_S.gguf | IQ1_S | 1 | 2.8 GB | 3.4 GB | smallest, significant quality loss |
| Mistral-Nemo-Instruct-2407.IQ1_M.gguf | IQ1_M | 1 | 3.0 GB | 3.6 GB | very small, significant quality loss |
| Mistral-Nemo-Instruct-2407.IQ2_XXS.gguf | IQ2_XXS | 2 | 3.3 GB | 3.9 GB | very small, high quality loss |
| Mistral-Nemo-Instruct-2407.IQ2_XS.gguf | IQ2_XS | 2 | 3.6 GB | 4.2 GB | very small, high quality loss |
| Mistral-Nemo-Instruct-2407.IQ2_S.gguf | IQ2_S | 2 | 3.9 GB | 4.4 GB | small, substantial quality loss |
| Mistral-Nemo-Instruct-2407.IQ2_M.gguf | IQ2_M | 2 | 4.1 GB | 4.7 GB | small, greater quality loss |
| Mistral-Nemo-Instruct-2407.IQ3_XXS.gguf | IQ3_XXS | 3 | 4.6 GB | 5.2 GB | very small, high quality loss |
| Mistral-Nemo-Instruct-2407.IQ3_XS.gguf | IQ3_XS | 3 | 4.9 GB | 5.5 GB | small, substantial quality loss |
| Mistral-Nemo-Instruct-2407.IQ3_S.gguf | IQ3_S | 3 | 5.2 GB | 5.8 GB | small, greater quality loss |
| Mistral-Nemo-Instruct-2407.IQ3_M.gguf | IQ3_M | 3 | 5.3 GB | 5.9 GB | medium, balanced quality - recommended |
| Mistral-Nemo-Instruct-2407.IQ4_XS.gguf | IQ4_XS | 4 | 6.3 GB | 6.9 GB | small, substantial quality loss |
llama.cpp commandllama.cpp from commit 50e0535 or later../llama-cli -ngl 41 -m Mistral-Nemo-Instruct-2407.IQ4_XS.gguf --color -c 131072 --temp 0.3 --repeat-penalty 1.1 -p "[AVAILABLE_TOOLS]{tools}[/AVAILABLE_TOOLS][INST]{prompt}[/INST]"-ngl 41 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 is not working yet unless you enable Flash Attention (-fa) too.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="./Mistral-Nemo-Instruct-2407.IQ4_XS.gguf", n_gpu_layers=41, n_ctx=131072)
6print(llm.create_chat_completion(
7 messages = [
8 {
9 "role": "user",
10 "content": "Pick a LeetCode challenge and solve it in Python."
11 }
12 ]
13))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="./Mistral-Nemo-Instruct-2407.IQ4_XS.gguf", n_gpu_layers=41, n_ctx=131072)
22response = llm.create_chat_completion(
23 temperature = 0.0,
24 repeat_penalty = 1.1,
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.1,
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, NO" ,"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))