Skip to content

Some method of re-warming up an unloaded session #130

Open
@domenic

Description

@domenic

Currently in Chromium, any created LanguageModelSession stays alive until it is explicitly destroyed, or the page creating it is unloaded, or similar.

However, we're likely going to add some mechanism that auto-unloads the session after some period of inactivity.

This could lead to the following workflow:

  • User opens page which uses the prompt API, which creates a LanguageModelSession and uses it.
  • The user happily continues engaging with the page, which calls prompt(), and each call gets relatively fast responses.
  • User walks away from their computer for an hour.
  • User re-engages with the page, which calls prompt(). But this time, the prompt() call takes much longer, as it has to re-load the session into memory.

We're considering adding some new method, e.g. warmup(), which sites could use to restore an unloaded session into memory ahead of time.

Note that calling this method right after session creation, or right before calling prompt(), is useless. It's only useful if there's a third point in time, when the developer knows that a prompt will happen soon but not immediately, that this method would be useful. Then, the developer can call warmup() at that time, and the browser can use the time between warmup() and prompt() to do work ahead of time that would otherwise delay responding to the prompt. An example of such a time would be if the user focuses a textbox in a chat interface.

(This method may be similar to Apple's Foundation Models API's prewarm() method, and maybe we should just reeuse that name. However, the docs for that are a bit unclear, as it says "Consider calling this method when you need to immediately use the session", which seems like it's not aligned with what we're envisioning here. If you're going to immediately use the session, then you can just call prompt() and the reloading of the session into memory will happen as part of that.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions