-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add documentation for model dispatch
- Loading branch information
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,24 @@ | ||
# Model-based prompt dispatching | ||
|
||
|
||
Different models often require different prompts to achieve a given task. They are, in essence, not different prompts in the sense that they are supposed to perform the same operation. In the same way we use `functools.singledispatch` to dispatch a functionality on the type of the first | ||
argument, it can be useful to dispatch the prompt on the model that is being used. | ||
|
||
`prompts` provides a way to dispatch the prompt on the model: | ||
|
||
|
||
```python | ||
import prompts | ||
|
||
|
||
@prompts.template | ||
def a_simple_prompt(query: str): | ||
"""<s>{{ query }}</s>""" | ||
|
||
@a_simple_prompt.register("google/gemma-2-9b") | ||
def a_simple_prompt_gemma(query: str): | ||
"""<bos>{{ query }}<eos>""" | ||
``` | ||
|
||
!!! note | ||
Choosing BOS and EOS based on the model is better achieved by using [special variables](special_tokens.md). |