Prompters: ShareGPT: Allow for custom system prompts
Browse filesIf a system prompt is present in a conversation, add it instead of
using the default.
Signed-off-by: kingbri <[email protected]>
- src/axolotl/prompters.py +6 -4
src/axolotl/prompters.py
CHANGED
|
@@ -309,10 +309,6 @@ class ShareGPTPrompter: # pylint: disable=too-few-public-methods
|
|
| 309 |
)
|
| 310 |
|
| 311 |
def build_prompt(self, source) -> Generator[str, None, None]:
|
| 312 |
-
# ignore the system prompt if provided
|
| 313 |
-
if source[0]["from"] == "system":
|
| 314 |
-
source.pop(0)
|
| 315 |
-
|
| 316 |
if len(source) < 2:
|
| 317 |
# If there isn't a back and forth conversation, ignore it
|
| 318 |
# also happens on the data splitting leaving empty conversations
|
|
@@ -321,6 +317,12 @@ class ShareGPTPrompter: # pylint: disable=too-few-public-methods
|
|
| 321 |
)
|
| 322 |
|
| 323 |
conv = self._conversation.copy()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 324 |
roles = {"human": conv.roles[0], "gpt": conv.roles[1]}
|
| 325 |
|
| 326 |
try:
|
|
|
|
| 309 |
)
|
| 310 |
|
| 311 |
def build_prompt(self, source) -> Generator[str, None, None]:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 312 |
if len(source) < 2:
|
| 313 |
# If there isn't a back and forth conversation, ignore it
|
| 314 |
# also happens on the data splitting leaving empty conversations
|
|
|
|
| 317 |
)
|
| 318 |
|
| 319 |
conv = self._conversation.copy()
|
| 320 |
+
|
| 321 |
+
# Add the conversation system prompt if provided, otherwise use the default one
|
| 322 |
+
if source[0]["from"] == "system":
|
| 323 |
+
conv.system = source[0]["value"]
|
| 324 |
+
source.pop(0)
|
| 325 |
+
|
| 326 |
roles = {"human": conv.roles[0], "gpt": conv.roles[1]}
|
| 327 |
|
| 328 |
try:
|