127 lines
4.2 KiB
Nix
127 lines
4.2 KiB
Nix
{
|
|
pkgs,
|
|
lib,
|
|
optimizeWithFlags,
|
|
...
|
|
}:
|
|
let
|
|
models = [
|
|
{
|
|
name = "Rombos-LLM-V2.6-Qwen-14b.IQ4_XS.gguf";
|
|
context_length = "32768";
|
|
gen_length = "8192";
|
|
source = pkgs.fetchurl {
|
|
url = "https://huggingface.co/mradermacher/Rombos-LLM-V2.6-Qwen-14b-GGUF/resolve/main/Rombos-LLM-V2.6-Qwen-14b.IQ4_XS.gguf?download=true";
|
|
sha256 = "InSndYkZx6pZux1SWn/pjQUc0tvUigjsw+JdXc3Dsdg=";
|
|
};
|
|
}
|
|
{
|
|
name = "Qwen2.5-14B-Instruct-IQ4_XS.gguf";
|
|
context_length = "32768";
|
|
gen_length = "8192";
|
|
source = pkgs.fetchurl {
|
|
url = "https://huggingface.co/bartowski/Qwen2.5-14B-Instruct-GGUF/resolve/main/Qwen2.5-14B-Instruct-IQ4_XS.gguf?download=true";
|
|
sha256 = "+AHt49no0qQ48MoNsqGJV4FeJ3Cf2hSZqTMjNUIHaO4=";
|
|
};
|
|
}
|
|
];
|
|
|
|
gpt4all_package = (
|
|
optimizeWithFlags
|
|
(pkgs.gpt4all.overrideAttrs (old: {
|
|
version = "3.4.2";
|
|
src = pkgs.fetchFromGitHub {
|
|
fetchSubmodules = true;
|
|
owner = "nomic-ai";
|
|
repo = "gpt4all";
|
|
rev = "v3.4.2";
|
|
sha256 = "QzU22y6tt3UhazVSPcFuKejH4AV+mw7JExH61NtAKoM=";
|
|
};
|
|
|
|
cmakeFlags = old.cmakeFlags ++ [
|
|
"-DGGML_VULKAN=ON"
|
|
"-DGGML_KOMPUTE=ON"
|
|
];
|
|
|
|
patches = old.patches ++ [
|
|
./disable-settings-err.patch
|
|
./disable-version-check.patch
|
|
(pkgs.fetchpatch {
|
|
url = "https://aur.archlinux.org/cgit/aur.git/plain/004-fix-build-with-qt-6.8.0.diff?h=gpt4all-chat&id=d14b12cb63fae95e578aa839a570189a23833051";
|
|
sha256 = "3Zur9KFn45f4dgAzOF7p1q42IdLqXwioN4zMiBbWbVU=";
|
|
stripLen = 1;
|
|
})
|
|
];
|
|
|
|
}))
|
|
# compile flags
|
|
[
|
|
"-O3"
|
|
"-ffast-math"
|
|
"-march=native"
|
|
"-mtune=native"
|
|
"-fno-finite-math-only" # https://github.com/ggerganov/llama.cpp/pull/7154#issuecomment-2143844461
|
|
]
|
|
);
|
|
in
|
|
{
|
|
home.packages = [
|
|
gpt4all_package
|
|
];
|
|
|
|
home.file =
|
|
lib.recursiveUpdate
|
|
{
|
|
".config/nomic.ai/GPT4All.ini".text =
|
|
let
|
|
system_prompt = "You are an expert LLM who is thoughtful and works step-by-step from first principles derive an answer to the user's prompt. For each step, title the step and begin showing your work, then decide if your work is comprehensive and if you're ready to provide your final answer. Make sure to exhaust ALL POSSIBILITIES before answering. INTERNAL REASONING STEPS ARE NOT SHOWN TO THE USER, ONLY A \"Final Answer\" SECTION WILL BE SHOWN TO THE USER. USE AS MANY REASONING STEPS AS POSSIBLE. EXPLORE ALTERNATE ANSWERS AND CONSIDER THAT YOUR ANSWER OR ANY ASSUMPTIONS MAY BE WRONG. IDENTIFY POSSIBLE ERRORS IN YOUR REASONING AND WHERE SUCH ERRORS MAY BE. FULLY TEST ALL OTHER POSSIBILITIES. YOU CAN BE WRONG. SHOW YOUR WORK WHEN RE-EXAMINING.";
|
|
in
|
|
''
|
|
[General]
|
|
chatTheme=Dark
|
|
height=940
|
|
suggestionMode=Off
|
|
threadCount=8
|
|
uniqueId=7096f2d2-448d-4272-a132-d37e77f8a781
|
|
userDefaultModel=${
|
|
# select the first element of `models` to be the default model
|
|
(builtins.elemAt models 0).name
|
|
}
|
|
width=1472
|
|
x=0
|
|
y=0
|
|
|
|
[download]
|
|
lastVersionStarted=${gpt4all_package.version}
|
|
''
|
|
+ (lib.concatStrings (
|
|
map (model: ''
|
|
[model-${model.name}]
|
|
contextLength=${model.context_length}
|
|
filename=${model.name}
|
|
maxLength=${model.gen_length}
|
|
promptBatchSize=256
|
|
promptTemplate=<|im_start|>user\n%1<|im_end|>\n<|im_start|>assistant\n
|
|
systemPrompt="<|im_start|>system\n${
|
|
# replace newlines with the string "\n" for gpt4all to properly parse
|
|
builtins.replaceStrings [ "\n" ] [ "\\n" ] system_prompt
|
|
}<|im_end|>
|
|
\n"
|
|
'') models
|
|
))
|
|
+ ''
|
|
[network]
|
|
isActive=true
|
|
usageStatsActive=true
|
|
'';
|
|
}
|
|
(
|
|
builtins.listToAttrs (
|
|
map (f: {
|
|
name = ".local/share/nomic.ai/GPT4All/${f.name}";
|
|
value.source = f.source;
|
|
}) models
|
|
)
|
|
);
|
|
}
|