branch: externals/minuet
commit bc6b638ec5b6a7d99df5ab0a40bf2d7f4fafc506
Author: Milan Glacier <[email protected]>
Commit: Milan Glacier <[email protected]>
doc: add example code to switch between prefix-first and suffix-first
prompt.
---
README.md | 40 ++++++++++++++++++++++++++++++++++++++++
prompt.md | 52 ++++++++++++++++++----------------------------------
2 files changed, 58 insertions(+), 34 deletions(-)
diff --git a/README.md b/README.md
index 5fcdf8f73a..baee905bdd 100644
--- a/README.md
+++ b/README.md
@@ -10,6 +10,7 @@
- [Selecting a Provider or Model](#selecting-a-provider-or-model)
- [Understanding Model Speed](#understanding-model-speed)
- [Prompt](#prompt)
+ - [Prefix-First vs. Suffix-First](#prefix-first-vs-suffix-first)
- [Configuration](#configuration)
- [minuet-provider](#minuet-provider)
- [minuet-context-window](#minuet-context-window)
@@ -343,6 +344,45 @@ Note that `minuet` employs two distinct prompt systems:
Gemini)
2. A separate system designed for Codestral and OpenAI-FIM-compatible models
+## Prefix-First vs. Suffix-First
+
+When use chat-based LLMs, there are two ways for constructing the prompt:
+placing the prefix (context before the cursor) before the suffix (context after
+the cursor), or placing the suffix before the prefix.
+
+By default, `minuet` uses the **prefix-first** style for the Gemini provider,
+and the **suffix-first** style for OpenAI, OpenAI-Compatible, and Claude
+providers. It is recommended that you experiment with both strategies to
+determine which yields the best results, particularly if you are using an
+OpenAI-compatible provider with various models.
+
+Below is an example code snippet demonstrating how to switch between these two
+prompt construction methods:
+
+<details>
+
+```lisp
+;; Prefix-first style
+(plist-put minuet-openai-compatible-options :fewshots
'minuet-default-fewshots-prefix-first)
+(minuet-set-nested-plist minuet-openai-compatible-options
+ 'minuet-default-prompt-prefix-first
+ :system :prompt)
+(minuet-set-nested-plist minuet-openai-compatible-options
+ 'minuet-default-chat-input-template-prefix-first
+ :chat-input :template)
+
+;; Suffix-first style
+(plist-put minuet-openai-compatible-options :fewshots 'minuet-default-fewshots)
+(minuet-set-nested-plist minuet-openai-compatible-options
+ 'minuet-default-prompt
+ :system :prompt)
+(minuet-set-nested-plist minuet-openai-compatible-options
+ 'minuet-default-chat-input-template
+ :chat-input :template)
+```
+
+</details>
+
# Configuration
Below are commonly used configuration options. To view the complete list of
diff --git a/prompt.md b/prompt.md
index cb8d81b212..86bb232f94 100644
--- a/prompt.md
+++ b/prompt.md
@@ -319,21 +319,21 @@ represents the **default setting** applied to Gemini.
```lisp
(use-package minuet
- :config
- (setq minuet-provider 'gemini)
+ :config
+ (setq minuet-provider 'gemini)
- (defvar my-minuet-gemini-prompt minuet-default-prompt-prefix-first)
+ (defvar my-minuet-gemini-prompt minuet-default-prompt-prefix-first)
- (defvar my-minuet-gemini-chat-input-template
- "{{{:language-and-tab}}}
+ (defvar my-minuet-gemini-chat-input-template
+ "{{{:language-and-tab}}}
<contextBeforeCursor>
{{{:context-before-cursor}}}<cursorPosition>
<contextAfterCursor>
{{{:context-after-cursor}}}")
- (defvar my-minuet-gemini-fewshots
- `((:role "user"
- :content "# language: javascript
+ (defvar my-minuet-gemini-fewshots
+ `((:role "user"
+ :content "# language: javascript
<contextBeforeCursor>
function transformData(data, options) {
const result = [];
@@ -347,30 +347,14 @@ const processedData = transformData(rawData, {
uppercase: true,
removeSpaces: false
});")
- ,(cadr minuet-default-fewshots)))
-
- (minuet-set-optional-options minuet-gemini-options
- :prompt 'my-minuet-gemini-prompt
- :system)
- (minuet-set-optional-options minuet-gemini-options
- :template
'my-minuet-gemini-chat-input-template
- :chat-input)
- (plist-put minuet-gemini-options :fewshots 'my-minuet-gemini-fewshots)
-
- (minuet-set-optional-options minuet-gemini-options
- :generationConfig
- '(:maxOutputTokens 256
- :topP 0.9))
- (minuet-set-optional-options minuet-gemini-options
- :safetySettings
- [(:category "HARM_CATEGORY_DANGEROUS_CONTENT"
- :threshold "BLOCK_NONE")
- (:category "HARM_CATEGORY_HATE_SPEECH"
- :threshold "BLOCK_NONE")
- (:category "HARM_CATEGORY_HARASSMENT"
- :threshold "BLOCK_NONE")
- (:category "HARM_CATEGORY_SEXUALLY_EXPLICIT"
- :threshold "BLOCK_NONE")])
-
- )
+ ,(cadr minuet-default-fewshots)))
+
+ (minuet-set-optional-options minuet-gemini-options
+ :prompt 'my-minuet-gemini-prompt
+ :system)
+ (minuet-set-optional-options minuet-gemini-options
+ :template 'my-minuet-gemini-chat-input-template
+ :chat-input)
+ (plist-put minuet-gemini-options :fewshots 'my-minuet-gemini-fewshots)
+ )
```