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

Update GPT4ALL integration #4567

Merged
merged 4 commits into from
May 18, 2023
Merged

Update GPT4ALL integration #4567

merged 4 commits into from
May 18, 2023

Conversation

Chae4ek
Copy link
Contributor

@Chae4ek Chae4ek commented May 12, 2023

Update GPT4ALL integration

GPT4ALL have completely changed their bindings. They use a bit odd implementation that doesn't fit well into base.py and it will probably be changed again, so it's a temporary solution.

Fixes #3839, #4628

@AndriyMulyar
Copy link
Contributor

We are standardizing on these bindings (they are the best multiplatform option), no more large changes 😀

@Chae4ek
Copy link
Contributor Author

Chae4ek commented May 13, 2023

thanks a lot @AndriyMulyar!
I'm confused a little with these parameters, it looks like implementation details.
And I see you have added MPT support, do you plan to keep that params the same for each model? If so it's better to remove this check I guess, just to make it work for future models without updating it every time

@AndriyMulyar
Copy link
Contributor

Let's wait to merge anything until the python bindings dev chimes in

@rguo123
Copy link

rguo123 commented May 13, 2023

Hey @Chae4ek! The parameters are needed to set the prompt context correctly. They typically will not require any changes on the user side and as far as I know work well across MPT, llama, and GPTJ models. However, I do think they are nice to have as they may change model behavior (for example, I have messed around with temp param at times to see how it impacts the generated text) and they are "technically" required inputs to the C function calls.

I'm not sure what that backend check was for but when loading a GPT4All model using the Python bindings, we will load the correct model. The only case where this isn't applied is if it's a custom model built not provided by us but built off a valid ggml/llama.cpp backend. In this case, providing model_type is needed for us to know which architecture to use. Hope this provides some clarification. Let me know if there's anything else I can help with!

@Chae4ek
Copy link
Contributor Author

Chae4ek commented May 13, 2023

backend check was needed to pass different parameters because pygpt4all used different ones, I'll remove it for now.

logits_size, tokens_size and n_past are unclear to me.
I'm looking at the implementation rn and:

logits_size is unused actually and can be safely removed, logits.size() is used instead. Anyway it's used only in sample_top_k_top_p and evaluation functions and always has size = n_vocab 1, 2
llama.cpp has a parameter to change this to n_vocab*N. You'll probably want to add that too.

tokens_size is unused as well.

n_past is used for the current state of the model to remember a conversation as I understand it. Currently it resets every generate call. I think it should be removed at least from here. It is impossible to save this from python

the rest parameters are pretty clear, thank you for clarification)

@AndriyMulyar
Copy link
Contributor

AndriyMulyar commented May 14, 2023 via email

@Chae4ek
Copy link
Contributor Author

Chae4ek commented May 14, 2023

I hope it will be determined based on the actual file.
I don't understand how it's possible to do that based only on the file name

@AndriyMulyar
Copy link
Contributor

AndriyMulyar commented May 14, 2023 via email

@Chae4ek
Copy link
Contributor Author

Chae4ek commented May 14, 2023

I'd like to use the model path without splitting it into path-to-directory and file name, up to you though

@dev2049
Copy link
Contributor

dev2049 commented May 16, 2023

@rguo123 @AndriyMulyar how does it look now?

@rguo123
Copy link

rguo123 commented May 17, 2023

Chiming in here on auto-suggest / installation path. We have a C library method for deciding correct model to load based on magic numbers for the model binaries. We haven't ported it over to the Python bindings yet but that may be a good solution temporarily. The magic number is for context size which differs for all these models.

This may not work in the future if different model architectures have the same context size but could be useful for now. I am wary of adapting it because it does make logic for deciding model more complicated than just if's on model names and will not be a universal solution in the long term.

@rguo123
Copy link

rguo123 commented May 17, 2023

I think having filename be part of model_path is reasonable and no strong feelings there if we want to see that change in the gpt4all package. I do think keeping model filename/name and directory separate lines up with Huggingface's from_pretrained pattern more which would be my slight preference for keeping original impl. Lmk if there are stronger leanings for either side.

@rguo123
Copy link

rguo123 commented May 17, 2023

PR looks good to me @dev2049!

@AndriyMulyar
Copy link
Contributor

I think this is ready for merge pending the resolution of the above threads

@Chae4ek
Copy link
Contributor Author

Chae4ek commented May 17, 2023

@HyunggyuJang, @rguo123, could you please double check the latest changes and resolve the above conversations?

@rguo123
Copy link

rguo123 commented May 17, 2023

Doesn't look like I have permission to resolve conversations here? PR lgtm!

@Chae4ek
Copy link
Contributor Author

Chae4ek commented May 17, 2023

Oh ok, I did it

Copy link

@HyunggyuJang HyunggyuJang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@dev2049 dev2049 merged commit c9e2a01 into langchain-ai:master May 18, 2023
@srinicodeit
Copy link

When will this be available in Pypi as part of the new release?

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.

Unable to use gpt4all model
6 participants