Skip to content
fn

compose_cartridge_adapters

→None
compose_cartridge_adapters(adapter_paths: Sequence[str | os.PathLike[str]], output_path: str | os.PathLike[str], safe_serialization: bool = True)

Join saved Cartridges into one by laying their caches end to end.

The composed cache is every cache one after another, so a model that reads it attends to all the documents at once (the paper's composition by concatenation, done at the adapter, with no several adapters at run time). Its config is the first Cartridge's with num_virtual_tokens the total; the frozen tokens are the first Cartridge's only, one attention sink for the whole.

Parameters

adapter_pathssequence of str or PathLike
Directories of at least two saved Cartridges.
output_pathstr or PathLike
The directory to write the composed adapter to; created if missing.
safe_serializationbool= True
Write adapter_model.safetensors, the one format here; False raises NotImplementedError.

Raises

ValueError
Fewer than two paths, an adapter that is not a Cartridge, Cartridges whose sizes differ, or a directory without a prompt_embeddings tensor.
NotImplementedError
safe_serialization is False.

Used by 1