mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-06-21 21:19:08 +00:00
llmodel: default to a blank line between reply and next prompt (#1996)
Also make some related adjustments to the provided Alpaca-style prompt templates and system prompts. Signed-off-by: Jared Van Bortel <jared@nomic.ai>
This commit is contained in:
parent
fc1a281381
commit
f500bcf6e5
@ -136,14 +136,17 @@ void LLModel::prompt(const std::string &prompt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// decode the rest of the prompt template
|
// decode the rest of the prompt template
|
||||||
|
// template: end of assistant prompt
|
||||||
|
std::string asstSuffix;
|
||||||
if (placeholders.size() >= 2) {
|
if (placeholders.size() >= 2) {
|
||||||
// template: end of assistant prompt
|
|
||||||
size_t start = placeholders[1].position() + placeholders[1].length();
|
size_t start = placeholders[1].position() + placeholders[1].length();
|
||||||
auto asstSuffix = promptTemplate.substr(start);
|
asstSuffix = promptTemplate.substr(start);
|
||||||
if (!asstSuffix.empty()) {
|
} else {
|
||||||
embd_inp = tokenize(promptCtx, asstSuffix, true);
|
asstSuffix = "\n\n"; // default to a blank link, good for e.g. Alpaca
|
||||||
decodePrompt(promptCallback, responseCallback, recalculateCallback, promptCtx, embd_inp);
|
}
|
||||||
}
|
if (!asstSuffix.empty()) {
|
||||||
|
embd_inp = tokenize(promptCtx, asstSuffix, true);
|
||||||
|
decodePrompt(promptCallback, responseCallback, recalculateCallback, promptCtx, embd_inp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +263,7 @@ logging infrastructure offers [many more customization options][py-logging-cookb
|
|||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
model = GPT4All('nous-hermes-llama2-13b.Q4_0.gguf')
|
model = GPT4All('nous-hermes-llama2-13b.Q4_0.gguf')
|
||||||
with model.chat_session('You are a geography expert.\nBe terse.',
|
with model.chat_session('You are a geography expert.\nBe terse.',
|
||||||
'### Instruction:\n{0}\n### Response:\n'):
|
'### Instruction:\n{0}\n\n### Response:\n'):
|
||||||
response = model.generate('who are you?', temp=0)
|
response = model.generate('who are you?', temp=0)
|
||||||
print(response)
|
print(response)
|
||||||
response = model.generate('what are your favorite 3 mountains?', temp=0)
|
response = model.generate('what are your favorite 3 mountains?', temp=0)
|
||||||
@ -277,6 +277,7 @@ logging infrastructure offers [many more customization options][py-logging-cookb
|
|||||||
|
|
||||||
### Instruction:
|
### Instruction:
|
||||||
who are you?
|
who are you?
|
||||||
|
|
||||||
### Response:
|
### Response:
|
||||||
|
|
||||||
===/LLModel.prompt_model -- prompt/===
|
===/LLModel.prompt_model -- prompt/===
|
||||||
@ -284,6 +285,7 @@ logging infrastructure offers [many more customization options][py-logging-cookb
|
|||||||
INFO:gpt4all.pyllmodel:LLModel.prompt_model -- prompt:
|
INFO:gpt4all.pyllmodel:LLModel.prompt_model -- prompt:
|
||||||
### Instruction:
|
### Instruction:
|
||||||
what are your favorite 3 mountains?
|
what are your favorite 3 mountains?
|
||||||
|
|
||||||
### Response:
|
### Response:
|
||||||
|
|
||||||
===/LLModel.prompt_model -- prompt/===
|
===/LLModel.prompt_model -- prompt/===
|
||||||
@ -315,10 +317,10 @@ are used instead of model-specific system and prompt templates:
|
|||||||
=== "Output"
|
=== "Output"
|
||||||
```
|
```
|
||||||
default system template: ''
|
default system template: ''
|
||||||
default prompt template: '### Human: \n{0}\n### Assistant:\n'
|
default prompt template: '### Human: \n{0}\n\n### Assistant:\n'
|
||||||
|
|
||||||
session system template: ''
|
session system template: ''
|
||||||
session prompt template: '### Human: \n{0}\n### Assistant:\n'
|
session prompt template: '### Human: \n{0}\n\n### Assistant:\n'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ DEFAULT_MODEL_DIRECTORY = os.path.join(str(Path.home()), ".cache", "gpt4all").re
|
|||||||
|
|
||||||
DEFAULT_MODEL_CONFIG = {
|
DEFAULT_MODEL_CONFIG = {
|
||||||
"systemPrompt": "",
|
"systemPrompt": "",
|
||||||
"promptTemplate": "### Human: \n{0}\n### Assistant:\n",
|
"promptTemplate": "### Human: \n{0}\n\n### Assistant:\n",
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigType = Dict[str, str]
|
ConfigType = Dict[str, str]
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
"systemPrompt": " ",
|
"systemPrompt": " ",
|
||||||
"description": "<strong>Very fast model with good quality</strong><br><ul><li>Fastest responses</li><li>Instruction based</li><li>Trained by TII<li>Finetuned by Nomic AI<li>Licensed for commercial use</ul>",
|
"description": "<strong>Very fast model with good quality</strong><br><ul><li>Fastest responses</li><li>Instruction based</li><li>Trained by TII<li>Finetuned by Nomic AI<li>Licensed for commercial use</ul>",
|
||||||
"url": "https://gpt4all.io/models/gguf/gpt4all-falcon-newbpe-q4_0.gguf",
|
"url": "https://gpt4all.io/models/gguf/gpt4all-falcon-newbpe-q4_0.gguf",
|
||||||
"promptTemplate": "### Instruction:\n%1\n### Response:\n"
|
"promptTemplate": "### Instruction:\n%1\n\n### Response:\n"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"order": "e",
|
"order": "e",
|
||||||
@ -106,7 +106,7 @@
|
|||||||
"systemPrompt": " ",
|
"systemPrompt": " ",
|
||||||
"description": "<strong>Extremely good model</strong><br><ul><li>Instruction based<li>Gives long responses<li>Curated with 300,000 uncensored instructions<li>Trained by Nous Research<li>Cannot be used commercially</ul>",
|
"description": "<strong>Extremely good model</strong><br><ul><li>Instruction based<li>Gives long responses<li>Curated with 300,000 uncensored instructions<li>Trained by Nous Research<li>Cannot be used commercially</ul>",
|
||||||
"url": "https://gpt4all.io/models/gguf/nous-hermes-llama2-13b.Q4_0.gguf",
|
"url": "https://gpt4all.io/models/gguf/nous-hermes-llama2-13b.Q4_0.gguf",
|
||||||
"promptTemplate": "### Instruction:\n%1\n### Response:\n"
|
"promptTemplate": "### Instruction:\n%1\n\n### Response:\n"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"order": "i",
|
"order": "i",
|
||||||
@ -152,7 +152,7 @@
|
|||||||
"type": "OpenLLaMa",
|
"type": "OpenLLaMa",
|
||||||
"description": "<strong>Small version of new model with novel dataset</strong><br><ul><li>Instruction based<li>Explain tuned datasets<li>Orca Research Paper dataset construction approaches<li>Cannot be used commercially</ul>",
|
"description": "<strong>Small version of new model with novel dataset</strong><br><ul><li>Instruction based<li>Explain tuned datasets<li>Orca Research Paper dataset construction approaches<li>Cannot be used commercially</ul>",
|
||||||
"url": "https://gpt4all.io/models/gguf/orca-mini-3b-gguf2-q4_0.gguf",
|
"url": "https://gpt4all.io/models/gguf/orca-mini-3b-gguf2-q4_0.gguf",
|
||||||
"promptTemplate": "### User:\n%1\n### Response:\n",
|
"promptTemplate": "### User:\n%1\n\n### Response:\n",
|
||||||
"systemPrompt": "### System:\nYou are an AI assistant that follows instruction extremely well. Help as much as you can.\n\n"
|
"systemPrompt": "### System:\nYou are an AI assistant that follows instruction extremely well. Help as much as you can.\n\n"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -132,8 +132,8 @@ private:
|
|||||||
mutable int m_maxGpuLayers = -1;
|
mutable int m_maxGpuLayers = -1;
|
||||||
double m_repeatPenalty = 1.18;
|
double m_repeatPenalty = 1.18;
|
||||||
int m_repeatPenaltyTokens = 64;
|
int m_repeatPenaltyTokens = 64;
|
||||||
QString m_promptTemplate = "### Human:\n%1\n### Assistant:\n";
|
QString m_promptTemplate = "### Human:\n%1\n\n### Assistant:\n";
|
||||||
QString m_systemPrompt = "### System:\nYou are an AI assistant who gives a quality response to whatever humans ask of you.\n";
|
QString m_systemPrompt = "### System:\nYou are an AI assistant who gives a quality response to whatever humans ask of you.\n\n";
|
||||||
friend class MySettings;
|
friend class MySettings;
|
||||||
};
|
};
|
||||||
Q_DECLARE_METATYPE(ModelInfo)
|
Q_DECLARE_METATYPE(ModelInfo)
|
||||||
|
Loading…
Reference in New Issue
Block a user