def load_from_checkpoint(cls, checkpoint_path):
if checkpoint_path.endswith('.dnn'):
dnn = torch_load_dnn(checkpoint_path)
config, _ = cls.from_deprecated_args(dnn.get('arguments', {}))
# TODO: FIXME: Decide if the line below will have any unintended consequences. We don't want to overwrite those!
config.set('checkpoint', checkpoint_path)
return config
loaded_config_path = os.path.join(checkpoint_path, 'artifact.metadata')
if os.path.exists(loaded_config_path):
loaded_config, _ = cls.from_path(loaded_config_path)
loaded_config.set('checkpoint', checkpoint_path)
return loaded_config
However, at this point in time, the model's files haven't been fetched from hugginface, and therefore artifact.metadata doesn't yet exist, though this config is then passed to HF_ColBERT to generate the model. This results in the following situation:
Where the config is all default values, and not the one of the model actually downloaded from the hub, which can be a fairly big problem (e.g. JaColBERT uses different query/doc_token)
An in-depth fix could be having a proper hugggingface Config class (having ColBERTConfig inherit from it) and fetching the config with AutoConfig before initialising the model, but that requires more modifications to the codebase.
I have implemented a quick fix in the library I'm working on, and upstreaming it here. When loading a pretrained config, we'll attempt to manually download the artifact.metadata file:
This is a completely transparent quick fix -- if you've passed a local path to the model loader it will just error out and not modify anything, but it ensures we'll properly load the config from the hub to make models easier to share (see output post-fix below)
@okhat Currently there's a pretty major issue (for usability purposes) with loading the config from Huggingface:
When loading a pre-trained model, the config is fetched like this (from BaseColBERT for this code example):
Which calls this function:
However, at this point in time, the model's files haven't been fetched from hugginface, and therefore
artifact.metadata
doesn't yet exist, though this config is then passed toHF_ColBERT
to generate the model. This results in the following situation:Where the config is all default values, and not the one of the model actually downloaded from the hub, which can be a fairly big problem (e.g. JaColBERT uses different query/doc_token)
An in-depth fix could be having a proper hugggingface
Config
class (having ColBERTConfig inherit from it) and fetching the config withAutoConfig
before initialising the model, but that requires more modifications to the codebase.I have implemented a quick fix in the library I'm working on, and upstreaming it here. When loading a pretrained config, we'll attempt to manually download the artifact.metadata file:
This is a completely transparent quick fix -- if you've passed a local path to the model loader it will just error out and not modify anything, but it ensures we'll properly load the config from the hub to make models easier to share (see output post-fix below)
(apologies for the noisy formatting commit -- thought I'd set up my formatter properly for the repo, but was keen to get this fix pushed ASAP)