huggingface¶
huggingface
¶
HuggingFaceModel
¶
HuggingFaceModel(repo_id: str, *args, revision: Optional[str] = None, import_edits: Union[bool, str] = False, **kwargs)
Bases: RemoteableMixin
Base class for NNsight wrappers around HuggingFace Hub models.
Adds HuggingFace repository handling (repo ID, revision) and
persistent edit export/import on top of :class:RemoteableMixin.
| PARAMETER | DESCRIPTION |
|---|---|
repo_id
|
HuggingFace repository ID (e.g.
TYPE:
|
*args
|
Forwarded to the parent mixin chain.
DEFAULT:
|
revision
|
Git revision (branch, tag, or commit hash)
of the model repository. Defaults to
TYPE:
|
import_edits
|
If
TYPE:
|
**kwargs
|
Forwarded to the parent mixin chain and ultimately to the model loading function.
DEFAULT:
|
| ATTRIBUTE | DESCRIPTION |
|---|---|
repo_id |
The HuggingFace repository ID.
TYPE:
|
revision |
The repository revision.
TYPE:
|
repo_id
instance-attribute
¶
export_edits
¶
export_edits(name: Optional[str] = None, export_dir: Optional[str] = None, variant: str = '__default__')
Export persistent model edits to disk.
Edits created via model.edit(inplace=True) are serialized
and saved so they can be reloaded later with :meth:import_edits.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Export name. Defaults to a name derived from the HuggingFace repo ID.
TYPE:
|
export_dir
|
Directory to save exports.
Defaults to the HuggingFace cache under
TYPE:
|
variant
|
Named variant for this set of edits.
Defaults to
TYPE:
|
import_edits
¶
import_edits(name: Optional[str] = None, export_dir: Optional[str] = None, variant: str = '__default__')
Import previously exported model edits from disk.
Loads edits that were saved with :meth:export_edits and
applies them as persistent in-place edits on this model.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Export name. Defaults to a name derived from the HuggingFace repo ID.
TYPE:
|
export_dir
|
Directory to load exports from.
Defaults to the HuggingFace cache under
TYPE:
|
variant
|
Named variant to load.
Defaults to
TYPE:
|