mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 03:04:13 +00:00
doc cleanup for custom prompt templates
This commit is contained in:
parent
e6d48d91ce
commit
e80457013b
6 changed files with 40 additions and 21 deletions
|
@ -42,24 +42,21 @@ def default_pt(messages):
|
|||
```python
|
||||
# Create your own custom prompt template works
|
||||
litellm.register_prompt_template(
|
||||
model="togethercomputer/LLaMA-2-7B-32K",
|
||||
role_dict={
|
||||
model="togethercomputer/LLaMA-2-7B-32K",
|
||||
roles={
|
||||
"system": {
|
||||
"pre_message": "[INST] <<SYS>>\n",
|
||||
"post_message": "\n<</SYS>>\n [/INST]\n"
|
||||
},
|
||||
"user": {
|
||||
"user": {
|
||||
"pre_message": "[INST] ",
|
||||
"post_message": " [/INST]\n"
|
||||
},
|
||||
"assistant": {
|
||||
"pre_message": "\n",
|
||||
"post_message": "\n",
|
||||
"post_message": "\n"
|
||||
}
|
||||
} # tell LiteLLM how you want to map the openai messages to this model
|
||||
pre_message_sep= "\n",
|
||||
post_message_sep= "\n"
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
def test_huggingface_custom_model():
|
||||
model = "huggingface/togethercomputer/LLaMA-2-7B-32K"
|
||||
|
|
|
@ -75,11 +75,22 @@ Let's register our custom prompt template: [Implementation Code](https://github.
|
|||
import litellm
|
||||
|
||||
litellm.register_prompt_template(
|
||||
model="OpenAssistant/llama2-70b-oasst-sft-v10",
|
||||
roles={"system":"<|im_start|>system", "assistant":"<|im_start|>assistant", "user":"<|im_start|>user"}, # tell LiteLLM how you want to map the openai messages to this model
|
||||
pre_message_sep= "\n",
|
||||
post_message_sep= "\n"
|
||||
)
|
||||
model="OpenAssistant/llama2-70b-oasst-sft-v10",
|
||||
roles={
|
||||
"system": {
|
||||
"pre_message": "[<|im_start|>system",
|
||||
"post_message": "\n"
|
||||
},
|
||||
"user": {
|
||||
"pre_message": "<|im_start|>user",
|
||||
"post_message": "\n"
|
||||
},
|
||||
"assistant": {
|
||||
"pre_message": "<|im_start|>assistant",
|
||||
"post_message": "\n"
|
||||
}
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
Let's use it!
|
||||
|
@ -105,11 +116,22 @@ from litellm import completion
|
|||
os.environ["TOGETHERAI_API_KEY"] = ""
|
||||
|
||||
litellm.register_prompt_template(
|
||||
model="OpenAssistant/llama2-70b-oasst-sft-v10",
|
||||
roles={"system":"<|im_start|>system", "assistant":"<|im_start|>assistant", "user":"<|im_start|>user"}, # tell LiteLLM how you want to map the openai messages to this model
|
||||
pre_message_sep= "\n",
|
||||
post_message_sep= "\n"
|
||||
)
|
||||
model="OpenAssistant/llama2-70b-oasst-sft-v10",
|
||||
roles={
|
||||
"system": {
|
||||
"pre_message": "[<|im_start|>system",
|
||||
"post_message": "\n"
|
||||
},
|
||||
"user": {
|
||||
"pre_message": "<|im_start|>user",
|
||||
"post_message": "\n"
|
||||
},
|
||||
"assistant": {
|
||||
"pre_message": "<|im_start|>assistant",
|
||||
"post_message": "\n"
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
messages=[{"role":"user", "content": "Write me a poem about the blue sky"}]
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ def default_pt(messages):
|
|||
# Create your own custom prompt template works
|
||||
litellm.register_prompt_template(
|
||||
model="togethercomputer/LLaMA-2-7B-32K",
|
||||
role_dict={
|
||||
roles={
|
||||
"system": {
|
||||
"pre_message": "[INST] <<SYS>>\n",
|
||||
"post_message": "\n<</SYS>>\n [/INST]\n"
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1538,7 +1538,7 @@ def register_prompt_template(model: str, roles: dict, initial_prompt_value: str
|
|||
"assistant": {
|
||||
"post_message": "\n" # follows this - https://replicate.com/blog/how-to-prompt-llama
|
||||
}
|
||||
},
|
||||
}
|
||||
)
|
||||
```
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue