-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e34fed3
commit 3cc17e8
Showing
3 changed files
with
89 additions
and
3 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
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 |
---|---|---|
|
@@ -4,11 +4,64 @@ LMQL is a high-level, front-end language for text generation. This means that LM | |
|
||
Due to the modular design of LMQL, it is easy to add support for new models and backends. If you would like to propose or add support for a new model API or inference engine, please reach out to us via our [Community Discord](https://discord.com/invite/7eJP4fcyNT) or via [[email protected]](mailto:[email protected]). | ||
|
||
## Specifying The Model | ||
|
||
LMQL offers two ways to specify the model that is used as underlying LLM: | ||
|
||
**Queries with `from` Clause**: The first option is to simply specify the model as part of the query itself. For this, you can use the `from` in combination with the indented syntax. This can be particularly useful, if your choice of model is intentional and should be part of your program. | ||
|
||
```{lmql} | ||
name::specify-decoder | ||
argmax | ||
"This is a query with a specified decoder: [RESPONSE] | ||
from | ||
"openai/text-ada-001" | ||
``` | ||
|
||
**Specifying the Model Externally**: The second option is to specify the model and its parameters externally, i.e. separately from the actual program code: | ||
|
||
```python | ||
import lmql | ||
|
||
# uses 'chatgpt' by default | ||
@lmql.query(model="chatgpt") | ||
def tell_a_joke(): | ||
'''lmql | ||
"""A list of good dad jokes. A indicates the punchline | ||
Q: How does a penguin build its house? | ||
A: Igloos it together. | ||
Q: Which knight invented King Arthur's Round Table? | ||
A: Sir Cumference. | ||
Q:[JOKE] | ||
A:[PUNCHLINE]""" where STOPS_AT(JOKE, "?") and STOPS_AT(PUNCHLINE, "\n") | ||
''' | ||
|
||
tell_a_joke() # uses chatgpt | ||
|
||
tell_a_joke(model="openai/text-davinci-003") # uses text-davinci-003 | ||
|
||
``` | ||
|
||
This is only possible when using LMQL from a Python program. When running in the playground, you can alternatively use the model dropdown available in the top right of the program editor: | ||
|
||
<center> | ||
<img src="https://github.com/eth-sri/lmql/assets/17903049/5ba2ffdd-e64d-465c-85be-5d9dc2ab6c14" width="70%" alt="Screenshot of the model dropdown in the playground" /> | ||
</center> | ||
|
||
## Available Model Backends | ||
|
||
```{toctree} | ||
:maxdepth: 1 | ||
openai.md | ||
azure.md | ||
hf.md | ||
llama.cpp.md | ||
``` | ||
``` | ||
|
||
## Using Multiple Models | ||
|
||
LMQL currently supports the use of only one model per query. If you want to mix multiple models, the advised way is to use multiple queries that are executed in sequence. The main obstacles in supporting this, is the fact that different models produce differently scaled token probabilities, which means an end-to-end decoding process would be difficult to implement. | ||
|
||
However, we are actively exploring ways to [support this in the future](https://github.com/eth-sri/lmql/issues/82). |
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