prompt-formats.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. // extended list
  2. export const promptFormats = {
  3. "alpaca": {
  4. template: `{{prompt}}\n\n{{history}}\n\n{{char}}:`,
  5. historyTemplate: `### {{name}}:\n{{message}}`,
  6. char: "Response",
  7. charMsgPrefix: "",
  8. charMsgSuffix: "",
  9. user: "Instruction",
  10. userMsgPrefix: "",
  11. userMsgSuffix: "",
  12. stops: ""
  13. },
  14. // ----------------------------
  15. "chatml": {
  16. template: `<|im_start|>system\n{{prompt}}<|im_end|>\n{{history}}{{char}}`,
  17. historyTemplate: `<|im_start|>{{name}}\n{{message}}`,
  18. char: "assistant",
  19. charMsgPrefix: "",
  20. charMsgSuffix: "",
  21. user: "user",
  22. userMsgPrefix: "",
  23. userMsgSuffix: "<|im_end|>\n",
  24. stops: ""
  25. },
  26. // ----------------------------
  27. "commandr": {
  28. template: `<BOS_TOKEN><|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|>{{prompt}}\n<|END_OF_TURN_TOKEN|>{{history}}{{char}}`,
  29. historyTemplate: `<|START_OF_TURN_TOKEN|><|{{name}}|> {{message}}`,
  30. char: "CHATBOT_TOKEN",
  31. charMsgPrefix: "",
  32. charMsgSuffix: "",
  33. user: "USER_TOKEN",
  34. userMsgPrefix: "",
  35. userMsgSuffix: "<|END_OF_TURN_TOKEN|>",
  36. stops: ""
  37. },
  38. // ref: https://docs.cohere.com/docs/prompting-command-r
  39. // ----------------------------
  40. "llama2": {
  41. template: `<s>[INST] <<SYS>>\n{{prompt}}\n<</SYS>>\n\nTest Message [/INST] Test Successfull </s>{{history}}{{char}}`,
  42. historyTemplate: `{{name}}: {{message}}`,
  43. char: "Assistant",
  44. charMsgPrefix: "",
  45. charMsgSuffix: "</s>",
  46. user: "User",
  47. userMsgPrefix: "<s>[INST] ",
  48. userMsgSuffix: " [/INST]",
  49. stops: ""
  50. },
  51. // ref: https://huggingface.co/blog/llama2#how-to-prompt-llama-2
  52. // ----------------------------
  53. "llama3": {
  54. template: `<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\n{{prompt}}{{history}}{{char}}`,
  55. historyTemplate: `<|start_header_id|>{{name}}<|end_header_id|>\n\n{{message}}<|eot_id|>`,
  56. char: "assistant",
  57. charMsgPrefix: "",
  58. charMsgSuffix: "",
  59. user: "user",
  60. userMsgPrefix: "",
  61. userMsgSuffix: "",
  62. stops: "<|eot_id|>"
  63. },
  64. // ref: https://llama.meta.com/docs/model-cards-and-prompt-formats/meta-llama-3/#special-tokens-used-with-meta-llama-3
  65. // ----------------------------
  66. "openchat": {
  67. template: `{{history}}{{char}}`,
  68. historyTemplate: `GPT4 Correct {{name}}: {{message}}<|end_of_turn|>`,
  69. char: "Assistant",
  70. charMsgPrefix: "",
  71. charMsgSuffix: "",
  72. user: "User",
  73. userMsgPrefix: "",
  74. userMsgSuffix: "",
  75. stops: ""
  76. },
  77. // ----------------------------
  78. "phi3": {
  79. template: `{{history}}{{char}}`,
  80. historyTemplate: `<|{{name}}|>\n{{message}}<|end|>\n`,
  81. char: "assistant",
  82. charMsgPrefix: "",
  83. charMsgSuffix: "",
  84. user: "user",
  85. userMsgPrefix: "",
  86. userMsgSuffix: "",
  87. stops: "<|end|>"
  88. },
  89. // ref: https://huggingface.co/microsoft/Phi-3-mini-4k-instruct#chat-format
  90. // ----------------------------
  91. "vicuna": {
  92. template: `{{prompt}}\n{{history}}{{char}}`,
  93. historyTemplate: `{{name}}: {{message}}\n`,
  94. char: "ASSISTANT",
  95. charMsgPrefix: "",
  96. charMsgSuffix: "",
  97. user: "USER",
  98. userMsgPrefix: "",
  99. userMsgSuffix: "",
  100. stops: ""
  101. },
  102. // ref: https://huggingface.co/lmsys/vicuna-33b-v1.3/discussions/1
  103. // ----------------------------
  104. "deepseekCoder": {
  105. template: `{{prompt}}{{history}}{{char}}:`,
  106. historyTemplate: `### {{name}}:\n{{message}}`,
  107. char: "Response",
  108. charMsgPrefix: "",
  109. charMsgSuffix: "",
  110. user: "Instruction",
  111. userMsgPrefix: "",
  112. userMsgSuffix: "",
  113. stops: "<|EOT|>"
  114. },
  115. // ----------------------------
  116. "med42": {
  117. template: `<|system|>: {{prompt}}\n{{history}}{{char}}`,
  118. historyTemplate: `<|{{name}}|>: {{message}}\n`,
  119. char: "assistant",
  120. charMsgPrefix: "",
  121. charMsgSuffix: "",
  122. user: "prompter",
  123. userMsgPrefix: "",
  124. userMsgSuffix: "",
  125. stops: ""
  126. },
  127. // ----------------------------
  128. "neuralchat": {
  129. template: `### System:\n{{prompt}}\n{{history}}{{char}}:`,
  130. historyTemplate: `### {{name}}:\n{{message}}\n`,
  131. char: "Assistant",
  132. charMsgPrefix: "",
  133. charMsgSuffix: "",
  134. user: "User",
  135. userMsgPrefix: "",
  136. userMsgSuffix: "",
  137. stops: ""
  138. },
  139. // ----------------------------
  140. "nousHermes": {
  141. template: `### Instruction: {{prompt}}\n\n{{history}}\n\n{{char}}:`,
  142. historyTemplate: `### {{name}}:\n{{message}}`,
  143. char: "Response",
  144. charMsgPrefix: "",
  145. charMsgSuffix: "",
  146. user: "Input",
  147. userMsgPrefix: "",
  148. userMsgSuffix: "",
  149. stops: ""
  150. },
  151. // ----------------------------
  152. "openchatMath": {
  153. template: `{{history}}{{char}}`,
  154. historyTemplate: `Math Correct {{name}}: {{message}}<|end_of_turn|>`,
  155. char: "Assistant",
  156. charMsgPrefix: "",
  157. charMsgSuffix: "",
  158. user: "User",
  159. userMsgPrefix: "",
  160. userMsgSuffix: "",
  161. stops: ""
  162. },
  163. // ----------------------------
  164. "orion": {
  165. template: `<s>Human: Test Message\n\nAssistant: </s>Test Successful</s>{{history}}{{char}}:`,
  166. historyTemplate: `{{name}}: {{message}}`,
  167. char: "Assistant </s>",
  168. charMsgPrefix: "",
  169. charMsgSuffix: "",
  170. user: "Human",
  171. userMsgPrefix: "",
  172. userMsgSuffix: "\n\n",
  173. stops: ""
  174. },
  175. // ----------------------------
  176. "sauerkraut": {
  177. template: `{{prompt}}\n{{history}}{{char}}`,
  178. historyTemplate: `
  179. {{name}}: {{message}}\n`,
  180. char: "Assistant",
  181. charMsgPrefix: "",
  182. charMsgSuffix: "",
  183. user: "User",
  184. userMsgPrefix: "",
  185. userMsgSuffix: "",
  186. stops: ""
  187. },
  188. // ----------------------------
  189. "starlingCode": {
  190. template: `{{history}}{{char}}`,
  191. historyTemplate: `Code {{name}}: {{message}}<|end_of_turn|>`,
  192. char: "Assistant",
  193. charMsgPrefix: "",
  194. charMsgSuffix: "",
  195. user: "User",
  196. userMsgPrefix: "",
  197. userMsgSuffix: "",
  198. stops: ""
  199. },
  200. // ----------------------------
  201. "yi34b": {
  202. template: `{{history}} {{char}}`,
  203. historyTemplate: `{{name}}: {{message}}`,
  204. char: "Assistant",
  205. charMsgPrefix: "",
  206. charMsgSuffix: "",
  207. user: "Human",
  208. userMsgPrefix: "",
  209. userMsgSuffix: "",
  210. stops: ""
  211. },
  212. // ----------------------------
  213. "zephyr": {
  214. template: `<|system|>\n{{prompt}}</s>\n{{history}}{{char}}`,
  215. historyTemplate: `<|{{name}}|>\n{{message}}</s>\n`,
  216. char: "assistant",
  217. charMsgPrefix: "",
  218. charMsgSuffix: "",
  219. user: "user",
  220. userMsgPrefix: "",
  221. userMsgSuffix: "",
  222. stops: ""
  223. }
  224. };