Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove binary state from high-level API and use Jinja templates #3147

Merged
merged 80 commits into from
Nov 25, 2024

Conversation

cebtenzzre
Copy link
Member

@cebtenzzre cebtenzzre commented Oct 28, 2024

This PR replaces GPT4All's templates that use QString.arg to format a user/assistant pair, with a HuggingFace-style Jinja template that formats the entire conversation.

This allows more fine-grained control of how the extra data (such as LocalDocs context) is passed to the model (for {# version 1#} templates).

cebtenzzre and others added 27 commits November 7, 2024 10:43
- Python bindings use `jinja2`
- server.cpp is not implemented
- chatapi.cpp is not implemented

Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Signed-off-by: Adam Treat <treat.adam@gmail.com>
Signed-off-by: Adam Treat <treat.adam@gmail.com>
Signed-off-by: Adam Treat <treat.adam@gmail.com>
Signed-off-by: Adam Treat <treat.adam@gmail.com>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
We still need this for models that don't include bos_token in their chat
template. Llama 3.1 8B Instruct sets this to false.

Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Importantly, the non-chat completions endpoint (`/v1/completions`) no
longer uses a system prompt or LocalDocs, as those are not applicable.

Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Before this PR, GPT4All inserted a system message into non-chat
completions, and it attempted to use LocalDocs with them. It no longer
does either of these things because they do not make sense here.

This changes the output slightly, so the test needs to be updated.

Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Alpaca is obsolete. We would be much better off defaulting to the chat
template that is shipped with the model.

The default system prompt exists in order to demonstrate how it should
be templated with Alpaca, but this is no longer applicable because this
is now part of the Jinja template.

Signed-off-by: Jared Van Bortel <jared@nomic.ai>
As a bonus, system prompts can now be used with remote models.

Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
The new tool calling PR shows that we can achieve the desired UI with
the same adjacent prompt/response pairs that we have now, by having
child items instead of items in between.

This assumption allows us to simplify the on-disk state by always
computing the peer index lazily.

Signed-off-by: Jared Van Bortel <jared@nomic.ai>
@manyoso
Copy link
Collaborator

manyoso commented Nov 23, 2024

image

This is what I see when installing llama 3.2 models

And when I click on the documentation I see

image

Also, it doesn't build for me by default because you're using 'cbegin' and 'cend' in chatllm.cpp for the std::span

gpt4all-chat/src/chatllm.cpp Outdated Show resolved Hide resolved
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
This subrange is already const, so C++23 cbegin/cend isn't necessary.

Signed-off-by: Jared Van Bortel <jared@nomic.ai>
The 'set tools = none' line is not recognized by Jinja2Cpp.

Signed-off-by: Jared Van Bortel <jared@nomic.ai>
@cebtenzzre
Copy link
Member Author

cebtenzzre commented Nov 23, 2024

And when I click on the documentation I see [image: broken page]

You won't see the new documentation page until this PR is merged. If you run the doc site locally with mkdocs serve, you will see that the Chat Templates page is at the expected URL.

@cebtenzzre cebtenzzre requested a review from manyoso November 23, 2024 19:46
Signed-off-by: Adam Treat <treat.adam@gmail.com>
Signed-off-by: Adam Treat <treat.adam@gmail.com>
@manyoso manyoso merged commit 225bf6b into main Nov 25, 2024
3 of 18 checks passed
@cebtenzzre cebtenzzre mentioned this pull request Dec 2, 2024
cebtenzzre added a commit that referenced this pull request Dec 5, 2024
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
cebtenzzre added a commit that referenced this pull request Dec 6, 2024
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
manyoso pushed a commit that referenced this pull request Dec 6, 2024
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants