Views
No views yet
llama.cpp environments, llama-cli and llama-server.lmstudio to utilize these models. 👇

llama-cpp-python1from llama_cpp import Llama
2
3# Define the inference parameters
4inference_params = {
5 "n_threads": 4,
6 "n_predict": -1,
7 "top_k": 20,
8 "min_p": 0.0,
9 "top_p": 0.95,
10 "temp": 0.6,
11 "repeat_penalty": 1.05,
12 "input_prefix": "<start_of_turn>user\\n",
13 "input_suffix": "<end_of_turn>\\n<start_of_turn>model\\n",
14 "antiprompt": [],
15 "pre_prompt": "",
16 "pre_prompt_suffix": "",
17 "pre_prompt_prefix": "<bos>",
18 "seed": -1,
19 "tfs_z": 1,
20 "typical_p": 1,
21 "repeat_last_n": 64,
22 "frequency_penalty": 0,
23 "presence_penalty": 0,
24 "n_keep": 0,
25 "logit_bias": {},
26 "mirostat": 0,
27 "mirostat_tau": 5,
28 "mirostat_eta": 0.1,
29 "memory_f16": True,
30 "multiline_input": False,
31 "penalize_nl": True
32}
33
34# Initialize the Gemma model with the specified inference parameters
35gemma = Llama.from_pretrained(
36 repo_id="ytu-ce-cosmos/Turkish-Gemma-9b-T1-GGUF",
37 filename="*Q4_K.gguf",
38 verbose=False
39)
40# Example input
41user_input = "Türkiyenin başkenti neresidir?"
42
43# Construct the prompt
44prompt = f"{inference_params['pre_prompt_prefix']}{inference_params['pre_prompt']}{inference_params['pre_prompt_suffix']}{inference_params['input_prefix']}{user_input}{inference_params['input_suffix']}"
45
46# Generate the response
47response = gemma(prompt)
48
49# Output the response
50print(response['choices'][0]['text'])
51llama.cpp. As we have seen, this method tends to give the most stable results.