Skip to content

Add CFG to server - #2217

Draft
SlyEcho wants to merge 12 commits into
masterfrom
server-cfg
Draft

Add CFG to server#2217
SlyEcho wants to merge 12 commits into
masterfrom
server-cfg

Conversation

@SlyEcho

@SlyEcho SlyEcho commented Jul 13, 2023

Copy link
Copy Markdown
Contributor

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

ghost commented Jul 20, 2023

Copy link
Copy Markdown

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

SlyEcho commented Jul 20, 2023

Copy link
Copy Markdown
Contributor Author

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

ghost commented Jul 20, 2023

Copy link
Copy Markdown

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

ArEnSc commented Nov 30, 2023

Copy link
Copy Markdown

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

@SlyEcho

SlyEcho commented Dec 2, 2023

Copy link
Copy Markdown
Contributor Author

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

@ArEnSc

ArEnSc commented Dec 2, 2023

Copy link
Copy Markdown

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

SlyEcho commented Dec 3, 2023

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown

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

@lexasub

lexasub commented Jan 12, 2025

Copy link
Copy Markdown

@SlyEcho, we wait cfg oportuniy))

@SlyEcho

SlyEcho commented Jan 13, 2025

Copy link
Copy Markdown
Contributor Author

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