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

Add chatLLaMa script #198

Merged
merged 5 commits into from
Mar 21, 2023
Merged

Add chatLLaMa script #198

merged 5 commits into from
Mar 21, 2023

Conversation

j3k0
Copy link
Contributor

@j3k0 j3k0 commented Mar 16, 2023

I'm not sure if this has a place in the repository. I did a bit of prompt engineering to get a conversation going with LLaMa, this is the script I use, which can serve as an example and "quickstart" to new users.

@pjq
Copy link

pjq commented Mar 16, 2023

@j3k0 Nice script for new user like me.
Just curious, with your chat history context, will LLaMa continue the conversation?

@j3k0
Copy link
Contributor Author

j3k0 commented Mar 16, 2023

In very rare instances, LLaMa will decide to end the conversation. It was occurring way more often before I told it it's a "never ending conversation" and a "10000 pages year long dialog".

I'm quite happy, even impressed with the result. Note that the examples I gave it (cat, Moscow) are excerpts from Wikipedia, I found that it reinforced LLaMa to use similar content as a source and tone for the answers, instead of the reddit/forums tone it had a tendency to produce.

@pjq
Copy link

pjq commented Mar 16, 2023

Very nice, I am using your script to avoid it auto end the conversation.

@D0han
Copy link

D0han commented Mar 16, 2023

This script could benefit from static analysis, please use https://www.shellcheck.net/ to make it more robust

@G2G2G2G
Copy link

G2G2G2G commented Mar 17, 2023

the entirety of it is shared below.

is there trickery here? I'd (as a human) see this and expect not to reply / talk at all anymore and I am reading a past experience?

I assume you had to add this to get it to keep staying on or something?

@j3k0
Copy link
Contributor Author

j3k0 commented Mar 17, 2023

@G2G2G2G The language model just tries to continue the text and make it self consistent. If you start with "here are 10 step to do XYZ. Step 1, do X. Step 2", then it will auto-complete it until it generated those 10 steps.

In this script, insisting in different ways that what comes below is a very long dialog, that never ends (etc.), reduces the likelihood that the auto-completion decides that the dialog is over ([end of text]). This still happens, but way less.

At that point it's just dark magic, I didn't do any statistical analysis or whatever to find the best prompt, just solving issues I experience with trial and error.

@G2G2G2G
Copy link

G2G2G2G commented Mar 17, 2023

Well I think I was clear that I did understand that. But the specific text I outlined seems to suggest it's already over and to end it lol

anyway I thought issue 71 is the main reason stuff ends early.
(Your script doesn't help there, it still exits right at the same amount of text cuz of the token count max =[ )

@j3k0
Copy link
Contributor Author

j3k0 commented Mar 17, 2023

@D0han done

@j3k0
Copy link
Contributor Author

j3k0 commented Mar 17, 2023

@G2G2G2G You can increase --n_predict and get longer output, but it will end when out of state memory (can be increased with ctx_size). However I think issue 71 refers to what I'm trying to prevent here: the interaction is often ended by the model before reaching any limits (with this special [end of text] token). I played around in main.cpp to prevent it and force-insert reverse_prompt tokens when end of text is generated by the model, however the models internal state becomes inconsistent at that stage (it forgot what it was doing), so there is no point.

@gjmulder gjmulder added the enhancement New feature or request label Mar 17, 2023
@mdonaberger
Copy link

Great script, thank you! I had been trying to build my own chat script and your prompt seems to be the key!

@G2G2G2G
Copy link

G2G2G2G commented Mar 18, 2023

@j3k0 ah I see, thanks for the input.

inconsistent at that stage (it forgot what it was doing), so there is no point.

wow maybe it has dementia =[

@thement
Copy link
Contributor

thement commented Mar 18, 2023

How about making a directory named contrib and put the script there? It could be a place to put other related and useful tools.

@Green-Sky
Copy link
Collaborator

How about making a directory named contrib and put the script there? It could be a place to put other related and useful tools.

Good Idea. but let's keep it consistent with whisper.cpp. There is the examples directory.

https://github.com/ggerganov/whisper.cpp/tree/master/examples

@rabidcopy
Copy link
Contributor

May I suggest increasing n_predict to 2048? From my understanding having -n 1024 more or less limits the context size to that number and chat sessions will cut off sooner basically. #266 (comment) Again I may be wrong but I do know setting -n 2048 allows for effectively twice the session length before it reaches a hard stop. I'll try to do more testing on this. If I lower it to -n 96 I can get only 3 dog facts listed off before it comes to a hard stop. Regardless of how high -c is.

@j3k0
Copy link
Contributor Author

j3k0 commented Mar 19, 2023

May I suggest increasing n_predict to 2048?

Done and rebased my branch onto master.

@ggerganov ggerganov merged commit 3ab3e65 into ggml-org:master Mar 21, 2023
rooprob pushed a commit to rooprob/llama.cpp that referenced this pull request Aug 2, 2023
README.md - Update notable forks section
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants