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

Switching ChatSessions without writing to file. #559

Closed
eublefar opened this issue Mar 1, 2024 · 3 comments · Fixed by #560
Closed

Switching ChatSessions without writing to file. #559

eublefar opened this issue Mar 1, 2024 · 3 comments · Fixed by #560

Comments

@eublefar
Copy link
Contributor

eublefar commented Mar 1, 2024

Hi

Could you please confirm that this is correct way to switch between chat sessions without writing them to files (for performance reasons)?
https://github.com/eublefar/LLAMASharpUnityDemo/blob/main/Assets/LLamaSharpTestScript.cs

Do you think it's worth to implement it into some interface at ChatSession level? (similar to how it's done at Executor level)

Also one thing I struggled to find is something like AddMessage but in non-lazy way with context.Decode happening at the same time, to precompute KV cache before generating the first message.

@AsakusaRinne
Copy link
Collaborator

Hi, I think it's a correct way with a rough look at your code.

Do you think it's worth to implement it into some interface at ChatSession level? (similar to how it's done at Executor level)

From my perspective I'd like to see such an API in ChatSession. As you can see, some extra process of the output is performed when switching context, which could be wrapped in an API.

Also one thing I struggled to find is something like AddMessage but in non-lazy way with context.Decode happening at the same time, to precompute KV cache before generating the first message.

It's a good idea for performance improvement. More generally The generation and prefill could be separate parts and exposed to users in a certain way. Currently I think there's also a tricky way to do so. When you want to prefill it without generation, you just need to set the last several words of your prompt as antiprompt (but be sure it's alone).

FYI @martindevans

@eublefar
Copy link
Contributor Author

eublefar commented Mar 2, 2024

Great, thanks for taking time to look at the code.

I think I could make a PR for these changes if you want.

@AsakusaRinne
Copy link
Collaborator

It would be great if you'd like to make it😀

@AsakusaRinne AsakusaRinne linked a pull request Mar 26, 2024 that will close this issue
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 a pull request may close this issue.

2 participants