Hamid Shojanazeri vor 1 Jahr
Ursprung
Commit
f6152893d8
3 geänderte Dateien mit 18 neuen und 14 gelöschten Zeilen
  1. 8 0
      inference/README.md
  2. 3 14
      inference/chat_utils.py
  3. 7 0
      inference/chats.json

+ 8 - 0
inference/README.md

@@ -9,3 +9,11 @@ This folder contains inference examples for Llama 2. So far, we have provided su
 3. The [hf-text-generation-inference](hf-text-generation-inference/README.md) folder contains information on Hugging Face Text Generation Inference (TGI).
 
 For more in depth information on inference including inference safety checks and examples, see the inference documentation [here](../docs/inference.md).
+
+## System Prompt Update
+
+### Observed Issue
+We received feedback from the community on our prompt template and we are providing an update to reduce the false refusal rates seen. False refusals occur when the model incorrectly refuses to answer a question that it should, for example due to overly broad instructions to be cautious in how it provides responses.
+
+### Updated approach
+Based on evaluation and analysis, we recommend the removal of the system prompt as the default setting. [Pull request #104](https://github.com/facebookresearch/llama-recipes/pull/104)] removes the system prompt as the default option, but still provides an example to help enable experimentation for those using it.

+ 3 - 14
inference/chat_utils.py

@@ -16,22 +16,11 @@ Dialog = List[Message]
 
 B_INST, E_INST = "[INST]", "[/INST]"
 B_SYS, E_SYS = "<<SYS>>\n", "\n<</SYS>>\n\n"
-DEFAULT_SYSTEM_PROMPT = """\
-You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe.  Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.
-
-If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information."""
-
 def format_tokens(dialogs, tokenizer):
     prompt_tokens = []
     for dialog in dialogs:
-        if dialog[0]["role"] != "system":
-                dialog = [
-                    {
-                        "role": "system",
-                        "content": DEFAULT_SYSTEM_PROMPT,
-                    }
-                ] + dialog
-        dialog = [
+        if dialog[0]["role"] == "system":
+            dialog = [
             {
                 "role": dialog[1]["role"],
                 "content": B_SYS
@@ -47,7 +36,7 @@ def format_tokens(dialogs, tokenizer):
             "starting with user and alternating (u/a/u/a/u...)"
         )
         """
-        Please verify that yout tokenizer support adding "[INST]", "[/INST]" to your inputs.
+        Please verify that your tokenizer support adding "[INST]", "[/INST]" to your inputs.
         Here, we are adding it manually.
         """
         dialog_tokens: List[int] = sum(

Datei-Diff unterdrückt, da er zu groß ist
+ 7 - 0
inference/chats.json