mirror of
				https://github.com/nomic-ai/gpt4all.git
				synced 2025-11-04 00:03:33 -05: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
 | 
			
		||||
    // template: end of assistant prompt
 | 
			
		||||
    std::string asstSuffix;
 | 
			
		||||
    if (placeholders.size() >= 2) {
 | 
			
		||||
        // template: end of assistant prompt
 | 
			
		||||
        size_t start = placeholders[1].position() + placeholders[1].length();
 | 
			
		||||
        auto asstSuffix = promptTemplate.substr(start);
 | 
			
		||||
        if (!asstSuffix.empty()) {
 | 
			
		||||
            embd_inp = tokenize(promptCtx, asstSuffix, true);
 | 
			
		||||
            decodePrompt(promptCallback, responseCallback, recalculateCallback, promptCtx, embd_inp);
 | 
			
		||||
        }
 | 
			
		||||
        asstSuffix = promptTemplate.substr(start);
 | 
			
		||||
    } else {
 | 
			
		||||
        asstSuffix = "\n\n"; // default to a blank link, good for e.g. Alpaca
 | 
			
		||||
    }
 | 
			
		||||
    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)
 | 
			
		||||
    model = GPT4All('nous-hermes-llama2-13b.Q4_0.gguf')
 | 
			
		||||
    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)
 | 
			
		||||
        print(response)
 | 
			
		||||
        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:
 | 
			
		||||
    who are you?
 | 
			
		||||
 | 
			
		||||
    ### Response:
 | 
			
		||||
 | 
			
		||||
    ===/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:
 | 
			
		||||
    ### Instruction:
 | 
			
		||||
    what are your favorite 3 mountains?
 | 
			
		||||
 | 
			
		||||
    ### Response:
 | 
			
		||||
 | 
			
		||||
    ===/LLModel.prompt_model -- prompt/===
 | 
			
		||||
@ -315,10 +317,10 @@ are used instead of model-specific system and prompt templates:
 | 
			
		||||
=== "Output"
 | 
			
		||||
    ```
 | 
			
		||||
    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 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 = {
 | 
			
		||||
    "systemPrompt": "",
 | 
			
		||||
    "promptTemplate": "### Human: \n{0}\n### Assistant:\n",
 | 
			
		||||
    "promptTemplate": "### Human: \n{0}\n\n### Assistant:\n",
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ConfigType = Dict[str, str]
 | 
			
		||||
 | 
			
		||||
@ -45,7 +45,7 @@
 | 
			
		||||
    "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>",
 | 
			
		||||
    "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",
 | 
			
		||||
@ -106,7 +106,7 @@
 | 
			
		||||
    "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>",
 | 
			
		||||
    "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",
 | 
			
		||||
@ -152,7 +152,7 @@
 | 
			
		||||
    "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>",
 | 
			
		||||
    "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"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
@ -132,8 +132,8 @@ private:
 | 
			
		||||
    mutable int m_maxGpuLayers     = -1;
 | 
			
		||||
    double  m_repeatPenalty        = 1.18;
 | 
			
		||||
    int     m_repeatPenaltyTokens  = 64;
 | 
			
		||||
    QString m_promptTemplate       = "### Human:\n%1\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_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\n";
 | 
			
		||||
    friend class MySettings;
 | 
			
		||||
};
 | 
			
		||||
Q_DECLARE_METATYPE(ModelInfo)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user