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 CFG to server #2217

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Draft

Add CFG to server #2217

wants to merge 12 commits into from

Conversation

SlyEcho
Copy link
Collaborator

@SlyEcho SlyEcho commented Jul 13, 2023

From #2135

TODOs

  • Find a way to avoid too much duplication.
  • Improve examples like the web chat.
  • web chat CSS.
  • Prompt style template switcher, Alpaca, LLaMA 2, Vicuna

Adding new API parameters:

  • cfg_negative_prompt
  • cfg_scale
  • cfg_n_keep

cfg_n_keep is new to server that main.cpp doesn't have, it allows the negative prompt to be managed just like the main prompt.

Since the server doesn't have a chat memory itself the client has to now format two prompt strings to use this feature.

repeat_last_n tokens now are not limited to the context size and can span however long you want, making sampling memory longer than context.


Normal:

{
  "prompt": "A chat between a curious user and a pirate.\n\n### Instruction:\nWhat's your name?\n\n### Response:\n",
  "n_predict": 32,
  "stop": ["###"]
}

Random responses

"content": "My name is Captain Blackbeard! What's yours?"
"content": "My name is Captain Jack Sparrow!"
"content": "My name is Captain Red Beard, but you can just call me Red."

With negative prompt:

{
  "prompt": "A chat between a curious user and a pirate.\n\n### Instruction:\nWhat's your name?\n\n### Response:\n",
  "cfg_negative_prompt": "A chat between a curious user and an artificial intelligence assistant.\n\n### Instruction:\nWhat's your name?\n\n### Response:\n",
  "cfg_scale": 4.0,
  "n_predict": 32,
  "stop": ["###"]
}

Responses, but the first one was with the "smooth factor" that is now gone.

"content": "Capt'n Longbanks o' th' Black Flaggerarrrrg! What's yer business, landlubber?"
"content": "Capt'n Longbaharrrd be me name. Arrrg, what be ye name, stranger?"
"content": "Capt'n Longbanks o' th Pirate Island. What's yer business be wit us buccaneers, curious one?"

@ghost
Copy link

ghost commented Jul 20, 2023

The simplicty of server makes using CFG much better, even as a work-in-progress:
Screenshot_20230720-103911_Iceraven

This is a great PR.

Thank you.

@SlyEcho
Copy link
Collaborator Author

SlyEcho commented Jul 20, 2023

Hmm, are you running in dark mode? I am not that good at the web design, so it may look a bit weird.

It also has a lot of debug strings all over the place but I will clean it up when it's more finished.

@ghost
Copy link

ghost commented Jul 20, 2023

It looks better than I expect considering it's brand new, but I appreciate it'll be polished over time.

Hmm, are you running in dark mode

Yes, here's without dark:
Screenshot_20230720-105800_Fulguris

@ArEnSc
Copy link

ArEnSc commented Nov 30, 2023

@SlyEcho you going to get this merged? whats left ?

@SlyEcho
Copy link
Collaborator Author

SlyEcho commented Dec 2, 2023

I have to start again because the server changed so much in the meantime

@ArEnSc
Copy link

ArEnSc commented Dec 2, 2023

I have to start again because the server changed so much in the meantime

I wonder if we can just get the feature in with the flag to allow for the inputs, it seems like you did most of the heavy lifting, maybe the ui work can come in a secondary pr

@SlyEcho
Copy link
Collaborator Author

SlyEcho commented Dec 3, 2023

Yeah, I should have not put the UI stuff in here, it was too much changes at the same time. I hope to have more time over the holidays when I don't have lectures to give any more.

@Yorizuka
Copy link

Having CFG for the server api would be so nice, will this PR get eventually revived?

@lexasub
Copy link
Contributor

lexasub commented Jan 12, 2025

@SlyEcho, we wait cfg oportuniy))

@SlyEcho
Copy link
Collaborator Author

SlyEcho commented Jan 13, 2025

I would have to redo the entire PR, because so much has changed in the mean time.

Originally, I got stuck when trying to merge some of the frontend changes.

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.

4 participants