Transformers 源码解析(一百四十)
.\utils\logging.py
""" Logging utilities."""
import functools
import logging
import os
import sys
import threading
from logging import (
CRITICAL,
DEBUG,
ERROR,
FATAL,
INFO,
NOTSET,
WARN,
WARNING,
)
from logging import captureWarnings as _captureWarnings
from typing import Optional
import huggingface_hub.utils as hf_hub_utils
from tqdm import auto as tqdm_lib
_lock = threading.Lock()
_default_handler: Optional[logging.Handler] = None
log_levels = {
"detail": logging.DEBUG,
"debug": logging.DEBUG,
"info": logging.INFO,
"warning": logging.WARNING,
"error": logging.ERROR,
"critical": logging.CRITICAL,
}
_default_log_level = logging.WARNING
_tqdm_active = not hf_hub_utils.are_progress_bars_disabled()
def _get_default_logging_level():
"""
如果 TRANSFORMERS_VERBOSITY 环境变量设置为有效选择之一,则返回其作为新的默认级别。
如果未设置,则回退到 `_default_log_level`
"""
env_level_str = os.getenv("TRANSFORMERS_VERBOSITY", None)
if env_level_str:
if env_level_str in log_levels:
return log_levels[env_level_str]
else:
logging.getLogger().warning(
f"Unknown option TRANSFORMERS_VERBOSITY={env_level_str}, "
f"has to be one of: { ', '.join(log_levels.keys()) }"
)
return _default_log_level
def _get_library_name() -> str:
return __name__.split(".")[0]
def _get_library_root_logger() -> logging.Logger:
return logging.getLogger(_get_library_name())
def _configure_library_root_logger() -> None:
global _default_handler
with _lock:
if _default_handler:
return
_default_handler = logging.StreamHandler()
if sys.stderr is None:
sys.stderr = open(os.devnull, "w")
_default_handler.flush = sys.stderr.flush
library_root_logger = _get_library_root_logger()
library_root_logger.addHandler(_default_handler)
library_root_logger.setLevel(_get_default_logging_level())
if os.getenv("TRANSFORMERS_VERBOSITY", None) == "detail":
formatter = logging.Formatter("[%(levelname)s|%(pathname)s:%(lineno)s] %(asctime)s >> %(message)s")
_default_handler.setFormatter(formatter)
library_root_logger.propagate = False
def _reset_library_root_logger() -> None:
with _lock:
if not _default_handler:
return
library_root_logger = _get_library_root_logger()
library_root_logger.removeHandler(_default_handler)
library_root_logger.setLevel(logging.NOTSET)
_default_handler = None
def get_log_levels_dict():
return log_levels
def captureWarnings(capture):
"""
调用 logging 库中的 `captureWarnings` 方法,用于管理 `warnings` 库发出的警告。
详细信息请参阅:
https://docs.python.org/3/library/logging.html#integration-with-the-warnings-module
所有警告将通过 `py.warnings` 记录器记录。
注意:如果 `py.warnings` 记录器不存在处理器,则此方法还会添加一个处理器,并更新该记录器的日志级别为库的根日志记录器级别。
"""
logger = get_logger("py.warnings")
if not logger.handlers:
logger.addHandler(_default_handler)
logger.setLevel(_get_library_root_logger().level)
_captureWarnings(capture)
def get_logger(name: Optional[str] = None) -> logging.Logger:
"""
返回指定名称的日志记录器。
除非您正在编写自定义的 transformers 模块,否则不应直接访问此函数。
"""
if name is None:
name = _get_library_name()
_configure_library_root_logger()
return logging.getLogger(name)
def get_verbosity() -> int:
"""
返回 🤗 Transformers 根日志记录器的当前日志级别作为整数。
返回值:
`int`: 日志级别。
<Tip>
🤗 Transformers 有以下日志级别:
- 50: `transformers.logging.CRITICAL` 或 `transformers.logging.FATAL`
- 40: `transformers.logging.ERROR`
- 30: `transformers.logging.WARNING` 或 `transformers.logging.WARN`
- 20: `transformers.logging.INFO`
- 10: `transformers.logging.DEBUG`
</Tip>"""
_configure_library_root_logger()
return _get_library_root_logger().getEffectiveLevel()
def set_verbosity(verbosity: int) -> None:
"""
设置 🤗 Transformers 根日志记录器的日志级别。
参数:
verbosity (`int`):
日志级别,例如:
- `transformers.logging.CRITICAL` 或 `transformers.logging.FATAL`
- `transformers.logging.ERROR`
- `transformers.logging.WARNING` 或 `transformers.logging.WARN`
- `transformers.logging.INFO`
- `transformers.logging.DEBUG`
"""
_configure_library_root_logger()
_get_library_root_logger().setLevel(verbosity)
def set_verbosity_info():
"""将日志级别设置为 `INFO`。"""
return set_verbosity(INFO)
def set_verbosity_warning():
"""将日志级别设置为 `WARNING`。"""
return set_verbosity(WARNING)
def set_verbosity_debug():
"""将日志级别设置为 `DEBUG`。"""
return set_verbosity(DEBUG)
return set_verbosity(DEBUG)
def set_verbosity_error():
"""Set the verbosity to the `ERROR` level."""
return set_verbosity(ERROR)
def disable_default_handler() -> None:
"""Disable the default handler of the HuggingFace Transformers's root logger."""
_configure_library_root_logger()
assert _default_handler is not None
_get_library_root_logger().removeHandler(_default_handler)
def enable_default_handler() -> None:
"""Enable the default handler of the HuggingFace Transformers's root logger."""
_configure_library_root_logger()
assert _default_handler is not None
_get_library_root_logger().addHandler(_default_handler)
def add_handler(handler: logging.Handler) -> None:
"""adds a handler to the HuggingFace Transformers's root logger."""
_configure_library_root_logger()
assert handler is not None
_get_library_root_logger().addHandler(handler)
def remove_handler(handler: logging.Handler) -> None:
"""removes given handler from the HuggingFace Transformers's root logger."""
_configure_library_root_logger()
assert handler is not None and handler not in _get_library_root_logger().handlers
_get_library_root_logger().removeHandler(handler)
def disable_propagation() -> None:
"""
Disable propagation of the library log outputs. Note that log propagation is disabled by default.
"""
_configure_library_root_logger()
_get_library_root_logger().propagate = False
def enable_propagation() -> None:
"""
Enable propagation of the library log outputs. Please disable the HuggingFace Transformers's default handler to
prevent double logging if the root logger has been configured.
"""
_configure_library_root_logger()
_get_library_root_logger().propagate = True
def enable_explicit_format() -> None:
"""
Enable explicit formatting for every HuggingFace Transformers's logger. The explicit formatter is as follows:
```
[LEVELNAME|FILENAME|LINE NUMBER] TIME >> MESSAGE
```
All handlers currently bound to the root logger are affected by this method.
"""
handlers = _get_library_root_logger().handlers
for handler in handlers:
formatter = logging.Formatter("[%(levelname)s|%(filename)s:%(lineno)s] %(asctime)s >> %(message)s")
handler.setFormatter(formatter)
def reset_format() -> None:
"""
Resets the formatting for HuggingFace Transformers's loggers.
All handlers currently bound to the root logger are affected by this method.
"""
handlers = _get_library_root_logger().handlers
for handler in handlers:
handler.setFormatter(None)
def warning_advice(self, *args, **kwargs):
"""
This method is identical to `logger.warning()`, but if env var TRANSFORMERS_NO_ADVISORY_WARNINGS=1 is set, this
warning will not be printed
"""
no_advisory_warnings = os.getenv("TRANSFORMERS_NO_ADVISORY_WARNINGS", False)
if no_advisory_warnings:
return
self.warning(*args, **kwargs)
logging.Logger.warning_advice = warning_advice
def warning_once(self, *args, **kwargs):
"""
This method is identical to `logger.warning()`, but will emit the warning with the same message only once
Note: The cache is for the function arguments, so 2 different callers using the same arguments will hit the cache.
The assumption here is that all warning messages are unique across the code. If they aren't then need to switch to
another type of cache that includes the caller frame information in the hashing function.
"""
self.warning(*args, **kwargs)
logging.Logger.warning_once = warning_once
class EmptyTqdm:
"""Dummy tqdm which doesn't do anything."""
def __init__(self, *args, **kwargs):
self._iterator = args[0] if args else None
def __iter__(self):
return iter(self._iterator)
def __getattr__(self, _):
"""Return empty function."""
def empty_fn(*args, **kwargs):
return
return empty_fn
def __enter__(self):
return self
def __exit__(self, type_, value, traceback):
return
class _tqdm_cls:
def __call__(self, *args, **kwargs):
if _tqdm_active:
return tqdm_lib.tqdm(*args, **kwargs)
else:
return EmptyTqdm(*args, **kwargs)
def set_lock(self, *args, **kwargs):
self._lock = None
def get_lock(self):
tqdm = _tqdm_cls()
def is_progress_bar_enabled() -> bool:
"""Return a boolean indicating whether tqdm progress bars are enabled."""
global _tqdm_active
return bool(_tqdm_active)
def enable_progress_bar():
"""Enable tqdm progress bar."""
global _tqdm_active
_tqdm_active = True
hf_hub_utils.enable_progress_bars()
def disable_progress_bar():
"""Disable tqdm progress bar."""
global _tqdm_active
_tqdm_active = False
hf_hub_utils.disable_progress_bars()
.\utils\model_parallel_utils.py
from math import ceil
def assert_device_map(device_map, num_blocks):
blocks = list(range(0, num_blocks))
device_map_blocks = [item for sublist in list(device_map.values()) for item in sublist]
duplicate_blocks = []
for i in device_map_blocks:
if device_map_blocks.count(i) > 1 and i not in duplicate_blocks:
duplicate_blocks.append(i)
missing_blocks = [i for i in blocks if i not in device_map_blocks]
extra_blocks = [i for i in device_map_blocks if i not in blocks]
if len(duplicate_blocks) != 0:
raise ValueError(
"Duplicate attention blocks specified in device_map. Attention blocks must be specified to one device."
" These attention blocks were specified more than once: " + str(duplicate_blocks)
)
if len(missing_blocks) != 0:
raise ValueError(
"There are attention blocks for this model that are not specified in the device_map. Add these attention "
"blocks to a device on the device_map: " + str(missing_blocks)
)
if len(extra_blocks) != 0:
raise ValueError(
"The device_map contains more attention blocks than this model has. Remove these from the device_map:"
+ str(extra_blocks)
)
def get_device_map(n_layers, devices):
"""Returns a dictionary of layers distributed evenly across all devices."""
layers = list(range(n_layers))
n_blocks = int(ceil(n_layers / len(devices)))
layers_list = [layers[i : i + n_blocks] for i in range(0, n_layers, n_blocks)]
return dict(zip(devices, layers_list))
.\utils\notebook.py
import re
import time
from typing import Optional
import IPython.display as disp
from ..trainer_callback import TrainerCallback
from ..trainer_utils import IntervalStrategy, has_length
def format_time(t):
"Format `t` (in seconds) to (h):mm:ss"
t = int(t)
h, m, s = t // 3600, (t // 60) % 60, t % 60
return f"{h}:{m:02d}:{s:02d}" if h != 0 else f"{m:02d}:{s:02d}"
def html_progress_bar(value, total, prefix, label, width=300):
return f"""
<div>
{prefix}
<progress value='{value}' max='{total}' style='width:{width}px; height:20px; vertical-align: middle;'></progress>
{label}
</div>
"""
def text_to_html_table(items):
"Put the texts in `items` in an HTML table."
html_code = """<table border="1" class="dataframe">\n"""
html_code += """ <thead>\n <tr style="text-align: left;">\n"""
for i in items[0]:
html_code += f" <th>{i}</th>\n"
html_code += " </tr>\n </thead>\n <tbody>\n"
for line in items[1:]:
html_code += " <tr>\n"
for elt in line:
elt = f"{elt:.6f}" if isinstance(elt, float) else str(elt)
html_code += f" <td>{elt}</td>\n"
html_code += " </tr>\n"
html_code += " </tbody>\n</table><p>"
return html_code
class NotebookProgressBar:
"""
A progress bar for display in a notebook.
Class attributes (overridden by derived classes)
- **warmup** (`int`) -- The number of iterations to do at the beginning while ignoring `update_every`.
- **update_every** (`float`) -- Since calling the time takes some time, we only do it every presumed
`update_every` seconds. The progress bar uses the average time passed up until now to guess the next value
for which it will call the update.
"""
class NotebookProgressBar:
warmup = 5
update_every = 0.2
def __init__(
self,
total: int,
prefix: Optional[str] = None,
leave: bool = True,
parent: Optional["NotebookTrainingTracker"] = None,
width: int = 300,
):
self.total = total
self.prefix = "" if prefix is None else prefix
self.leave = leave
self.parent = parent
self.width = width
self.last_value = None
self.comment = None
self.output = None
def update(self, value: int, force_update: bool = False, comment: str = None):
"""
更新进度条到指定的 `value` 值的主要方法。
Args:
value (`int`):
要使用的值。必须在 0 和 `total` 之间。
force_update (`bool`, *optional*, 默认为 `False`):
是否强制更新内部状态和显示(默认情况下,进度条将等待 `value` 达到它预测的对应于自上次更新以来超过 `update_every` 属性的时间的值,以避免添加样板文件)。
comment (`str`, *optional*):
要添加到进度条左侧的注释。
"""
self.value = value
if comment is not None:
self.comment = comment
if self.last_value is None:
self.start_time = self.last_time = time.time()
self.start_value = self.last_value = value
self.elapsed_time = self.predicted_remaining = None
self.first_calls = self.warmup
self.wait_for = 1
self.update_bar(value)
elif value <= self.last_value and not force_update:
return
elif force_update or self.first_calls > 0 or value >= min(self.last_value + self.wait_for, self.total):
if self.first_calls > 0:
self.first_calls -= 1
current_time = time.time()
self.elapsed_time = current_time - self.start_time
if value > self.start_value:
self.average_time_per_item = self.elapsed_time / (value - self.start_value)
else:
self.average_time_per_item = None
if value >= self.total:
value = self.total
self.predicted_remaining = None
if not self.leave:
self.close()
elif self.average_time_per_item is not None:
self.predicted_remaining = self.average_time_per_item * (self.total - value)
self.update_bar(value)
self.last_value = value
self.last_time = current_time
if (self.average_time_per_item is None) or (self.average_time_per_item == 0):
self.wait_for = 1
else:
self.wait_for = max(int(self.update_every / self.average_time_per_item), 1)
def update_bar(self, value, comment=None):
spaced_value = " " * (len(str(self.total)) - len(str(value))) + str(value)
if self.elapsed_time is None:
self.label = f"[{spaced_value}/{self.total} : < :"
elif self.predicted_remaining is None:
self.label = f"[{spaced_value}/{self.total} {format_time(self.elapsed_time)}"
else:
self.label = (
f"[{spaced_value}/{self.total} {format_time(self.elapsed_time)} <"
f" {format_time(self.predicted_remaining)}"
)
if self.average_time_per_item == 0:
self.label += ", +inf it/s"
else:
self.label += f", {1/self.average_time_per_item:.2f} it/s"
self.label += "]" if self.comment is None or len(self.comment) == 0 else f", {self.comment}]"
self.display()
def display(self):
self.html_code = html_progress_bar(self.value, self.total, self.prefix, self.label, self.width)
if self.parent is not None:
self.parent.display()
return
if self.output is None:
self.output = disp.display(disp.HTML(self.html_code), display_id=True)
else:
self.output.update(disp.HTML(self.html_code))
def close(self):
"Closes the progress bar."
if self.parent is None and self.output is not None:
self.output.update(disp.HTML(""))
class NotebookTrainingTracker(NotebookProgressBar):
"""
An object tracking the updates of an ongoing training with progress bars and a nice table reporting metrics.
Args:
num_steps (`int`): The number of steps during training.
column_names (`List[str]`, *optional*): The list of column names for the metrics table
(will be inferred from the first call to `~utils.notebook.NotebookTrainingTracker.write_line` if not set).
"""
def __init__(self, num_steps, column_names=None):
super().__init__(num_steps)
self.inner_table = None if column_names is None else [column_names]
self.child_bar = None
def display(self):
self.html_code = html_progress_bar(self.value, self.total, self.prefix, self.label, self.width)
if self.inner_table is not None:
self.html_code += text_to_html_table(self.inner_table)
if self.child_bar is not None:
self.html_code += self.child_bar.html_code
if self.output is None:
self.output = disp.display(disp.HTML(self.html_code), display_id=True)
else:
self.output.update(disp.HTML(self.html_code))
def write_line(self, values):
"""
Write the values in the inner table.
Args:
values (`Dict[str, float]`): The values to display.
"""
if self.inner_table is None:
self.inner_table = [list(values.keys()), list(values.values())]
else:
columns = self.inner_table[0]
for key in values.keys():
if key not in columns:
columns.append(key)
self.inner_table[0] = columns
if len(self.inner_table) > 1:
last_values = self.inner_table[-1]
first_column = self.inner_table[0][0]
if last_values[0] != values[first_column]:
self.inner_table.append([values[c] if c in values else "No Log" for c in columns])
else:
new_values = values
for c in columns:
if c not in new_values.keys():
new_values[c] = last_values[columns.index(c)]
self.inner_table[-1] = [new_values[c] for c in columns]
else:
self.inner_table.append([values[c] for c in columns])
def add_child(self, total, prefix=None, width=300):
"""
Add a child progress bar displayed under the table of metrics. The child progress bar is returned (so it can be
easily updated).
Args:
total (`int`): The number of iterations for the child progress bar.
prefix (`str`, *optional*): A prefix to write on the left of the progress bar.
width (`int`, *optional*, defaults to 300): The width (in pixels) of the progress bar.
"""
self.child_bar = NotebookProgressBar(total, prefix=prefix, parent=self, width=width)
return self.child_bar
def remove_child(self):
"""
Closes the child progress bar.
"""
self.child_bar = None
self.display()
"""
A [`TrainerCallback`] that displays the progress of training or evaluation, optimized for Jupyter Notebooks or
Google colab.
"""
def __init__(self):
self.training_tracker = None
self.prediction_bar = None
self._force_next_update = False
def on_train_begin(self, args, state, control, **kwargs):
self.first_column = "Epoch" if args.evaluation_strategy == IntervalStrategy.EPOCH else "Step"
self.training_loss = 0
self.last_log = 0
column_names = [self.first_column] + ["Training Loss"]
if args.evaluation_strategy != IntervalStrategy.NO:
column_names.append("Validation Loss")
self.training_tracker = NotebookTrainingTracker(state.max_steps, column_names)
def on_step_end(self, args, state, control, **kwargs):
epoch = int(state.epoch) if int(state.epoch) == state.epoch else f"{state.epoch:.2f}"
self.training_tracker.update(
state.global_step + 1,
comment=f"Epoch {epoch}/{state.num_train_epochs}",
force_update=self._force_next_update,
)
self._force_next_update = False
def on_prediction_step(self, args, state, control, eval_dataloader=None, **kwargs):
if not has_length(eval_dataloader):
return
if self.prediction_bar is None:
if self.training_tracker is not None:
self.prediction_bar = self.training_tracker.add_child(len(eval_dataloader))
else:
self.prediction_bar = NotebookProgressBar(len(eval_dataloader))
self.prediction_bar.update(1)
else:
self.prediction_bar.update(self.prediction_bar.value + 1)
def on_predict(self, args, state, control, **kwargs):
if self.prediction_bar is not None:
self.prediction_bar.close()
self.prediction_bar = None
def on_log(self, args, state, control, logs=None, **kwargs):
if args.evaluation_strategy == IntervalStrategy.NO and "loss" in logs:
values = {"Training Loss": logs["loss"]}
values["Step"] = state.global_step
self.training_tracker.write_line(values)
def on_evaluate(self, args, state, control, metrics=None, **kwargs):
if self.training_tracker is not None:
values = {"Training Loss": "No log", "Validation Loss": "No log"}
for log in reversed(state.log_history):
if "loss" in log:
values["Training Loss"] = log["loss"]
break
if self.first_column == "Epoch":
values["Epoch"] = int(state.epoch)
else:
values["Step"] = state.global_step
metric_key_prefix = "eval"
for k in metrics:
if k.endswith("_loss"):
metric_key_prefix = re.sub(r"\_loss$", "", k)
_ = metrics.pop("total_flos", None)
_ = metrics.pop("epoch", None)
_ = metrics.pop(f"{metric_key_prefix}_runtime", None)
_ = metrics.pop(f"{metric_key_prefix}_samples_per_second", None)
_ = metrics.pop(f"{metric_key_prefix}_steps_per_second", None)
_ = metrics.pop(f"{metric_key_prefix}_jit_compilation_time", None)
for k, v in metrics.items():
splits = k.split("_")
name = " ".join([part.capitalize() for part in splits[1:]])
if name == "Loss":
name = "Validation Loss"
values[name] = v
self.training_tracker.write_line(values)
self.training_tracker.remove_child()
self.prediction_bar = None
self._force_next_update = True
def on_train_end(self, args, state, control, **kwargs):
self.training_tracker.update(
state.global_step,
comment=f"Epoch {int(state.epoch)}/{state.num_train_epochs}",
force_update=True,
)
self.training_tracker = None
.\utils\peft_utils.py
import importlib
import os
from typing import Dict, Optional, Union
from packaging import version
from .hub import cached_file
from .import_utils import is_peft_available
ADAPTER_CONFIG_NAME = "adapter_config.json"
ADAPTER_WEIGHTS_NAME = "adapter_model.bin"
ADAPTER_SAFE_WEIGHTS_NAME = "adapter_model.safetensors"
def find_adapter_config_file(
model_id: str,
cache_dir: Optional[Union[str, os.PathLike]] = None,
force_download: bool = False,
resume_download: bool = False,
proxies: Optional[Dict[str, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[str] = None,
local_files_only: bool = False,
subfolder: str = "",
_commit_hash: Optional[str] = None,
) -> Optional[str]:
r"""
简单检查存储在 Hub 或本地的模型是否为适配器模型,如果是,则返回适配器配置文件的路径,否则返回 None。
"""
adapter_cached_filename = None
if model_id is None:
return None
elif os.path.isdir(model_id):
list_remote_files = os.listdir(model_id)
if ADAPTER_CONFIG_NAME in list_remote_files:
adapter_cached_filename = os.path.join(model_id, ADAPTER_CONFIG_NAME)
adapter_cached_filename = cached_file(
model_id,
ADAPTER_CONFIG_NAME,
cache_dir=cache_dir,
force_download=force_download,
resume_download=resume_download,
proxies=proxies,
token=token,
revision=revision,
local_files_only=local_files_only,
subfolder=subfolder,
_commit_hash=_commit_hash,
_raise_exceptions_for_gated_repo=False,
_raise_exceptions_for_missing_entries=False,
_raise_exceptions_for_connection_errors=False,
)
return adapter_cached_filename
def check_peft_version(min_version: str) -> None:
r"""
检查 PEFT 的版本是否兼容。
Args:
min_version (`str`):
要检查兼容性的 PEFT 版本。
"""
if not is_peft_available():
raise ValueError("PEFT is not installed. Please install it with `pip install peft`")
is_peft_version_compatible = version.parse(importlib.metadata.version("peft")) >= version.parse(min_version)
if not is_peft_version_compatible:
raise ValueError(
f"The version of PEFT you are using is not compatible, please use a version that is greater"
f" than {min_version}"
)
.\utils\quantization_config.py
import copy
import importlib.metadata
import json
import os
from dataclasses import dataclass
from enum import Enum
from typing import Any, Dict, List, Optional, Union
from packaging import version
from ..utils import is_auto_awq_available, is_torch_available, logging
if is_torch_available():
import torch
logger = logging.get_logger(__name__)
class QuantizationMethod(str, Enum):
BITS_AND_BYTES = "bitsandbytes"
GPTQ = "gptq"
AWQ = "awq"
AQLM = "aqlm"
QUANTO = "quanto"
class AWQLinearVersion(str, Enum):
GEMM = "gemm"
GEMV = "gemv"
EXLLAMA = "exllama"
@staticmethod
def from_str(version: str):
version = version.lower()
if version == "gemm":
return AWQLinearVersion.GEMM
elif version == "gemv":
return AWQLinearVersion.GEMV
elif version == "exllama":
return AWQLinearVersion.EXLLAMA
else:
raise ValueError(f"Unknown AWQLinearVersion {version}")
class AwqBackendPackingMethod(str, Enum):
AUTOAWQ = "autoawq"
LLMAWQ = "llm-awq"
@dataclass
class QuantizationConfigMixin:
"""
Mixin class for quantization config
"""
quant_method: QuantizationMethod
@classmethod
def from_dict(cls, config_dict, return_unused_kwargs=False, **kwargs):
"""
从一个Python字典参数实例化一个`QuantizationConfigMixin`对象。
Args:
config_dict (`Dict[str, Any]`):
用于实例化配置对象的字典。
return_unused_kwargs (`bool`, *optional*, 默认为 `False`):
是否返回未使用的关键字参数列表。用于`PreTrainedModel`中的`from_pretrained`方法。
kwargs (`Dict[str, Any]`):
其他用于初始化配置对象的参数。
Returns:
[`QuantizationConfigMixin`]: 从这些参数实例化的配置对象。
"""
config = cls(**config_dict)
to_remove = []
for key, value in kwargs.items():
if hasattr(config, key):
setattr(config, key, value)
to_remove.append(key)
for key in to_remove:
kwargs.pop(key, None)
if return_unused_kwargs:
return config, kwargs
else:
return config
def to_json_file(self, json_file_path: Union[str, os.PathLike]):
"""
将该实例保存到一个JSON文件中。
Args:
json_file_path (`str` or `os.PathLike`):
要保存配置实例参数的JSON文件路径。
"""
with open(json_file_path, "w", encoding="utf-8") as writer:
config_dict = self.to_dict()
json_string = json.dumps(config_dict, indent=2, sort_keys=True) + "\n"
writer.write(json_string)
def to_dict(self) -> Dict[str, Any]:
"""
将该实例序列化为一个Python字典。
Returns:
`Dict[str, Any]`: 包含该配置实例所有属性的字典。
"""
return copy.deepcopy(self.__dict__)
def __iter__(self):
"""允许对该对象进行`dict(obj)`操作,适用于obj可能是字典或QuantizationConfigMixin的情况。"""
for attr, value in copy.deepcopy(self.__dict__).items():
yield attr, value
def __repr__(self):
return f"{self.__class__.__name__} {self.to_json_string()}"
def to_json_string(self, use_diff: bool = True) -> str:
"""
将当前实例序列化为 JSON 字符串。
Args:
use_diff (`bool`, *可选*, 默认为 `True`):
如果设置为 `True`,则只序列化配置实例与默认 `PretrainedConfig()` 之间的差异。
Returns:
`str`: 包含此配置实例所有属性的 JSON 格式字符串。
"""
if use_diff is True:
config_dict = self.to_diff_dict()
else:
config_dict = self.to_dict()
return json.dumps(config_dict, indent=2, sort_keys=True) + "\n"
def update(self, **kwargs):
"""
使用 `kwargs` 中的属性更新此类实例的属性,如果它们与现有属性匹配,则返回所有未使用的 kwargs。
Args:
kwargs (`Dict[str, Any]`):
要更新此类的属性的字典。
Returns:
`Dict[str, Any]`: 包含所有未用于更新实例的键值对的字典。
"""
to_remove = []
for key, value in kwargs.items():
if hasattr(self, key):
setattr(self, key, value)
to_remove.append(key)
unused_kwargs = {key: value for key, value in kwargs.items() if key not in to_remove}
return unused_kwargs
@dataclass
class BitsAndBytesConfig(QuantizationConfigMixin):
"""
This is a wrapper class about all possible attributes and features that you can play with a model that has been
loaded using `bitsandbytes`.
This replaces `load_in_8bit` or `load_in_4bit`therefore both options are mutually exclusive.
Currently only supports `LLM.int8()`, `FP4`, and `NF4` quantization. If more methods are added to `bitsandbytes`,
then more arguments will be added to this class.
"""
def __init__(
self,
load_in_8bit=False,
load_in_4bit=False,
llm_int8_threshold=6.0,
llm_int8_skip_modules=None,
llm_int8_enable_fp32_cpu_offload=False,
llm_int8_has_fp16_weight=False,
bnb_4bit_compute_dtype=None,
bnb_4bit_quant_type="fp4",
bnb_4bit_use_double_quant=False,
bnb_4bit_quant_storage=None,
**kwargs,
):
self.quant_method = QuantizationMethod.BITS_AND_BYTES
if load_in_4bit and load_in_8bit:
raise ValueError("load_in_4bit and load_in_8bit are both True, but only one can be used at the same time")
self._load_in_8bit = load_in_8bit
self._load_in_4bit = load_in_4bit
self.llm_int8_threshold = llm_int8_threshold
self.llm_int8_skip_modules = llm_int8_skip_modules
self.llm_int8_enable_fp32_cpu_offload = llm_int8_enable_fp32_cpu_offload
self.llm_int8_has_fp16_weight = llm_int8_has_fp16_weight
self.bnb_4bit_quant_type = bnb_4bit_quant_type
self.bnb_4bit_use_double_quant = bnb_4bit_use_double_quant
if bnb_4bit_compute_dtype is None:
self.bnb_4bit_compute_dtype = torch.float32
elif isinstance(bnb_4bit_compute_dtype, str):
self.bnb_4bit_compute_dtype = getattr(torch, bnb_4bit_compute_dtype)
elif isinstance(bnb_4bit_compute_dtype, torch.dtype):
self.bnb_4bit_compute_dtype = bnb_4bit_compute_dtype
else:
raise ValueError("bnb_4bit_compute_dtype must be a string or a torch.dtype")
if bnb_4bit_quant_storage is None:
self.bnb_4bit_quant_storage = torch.uint8
elif isinstance(bnb_4bit_quant_storage, str):
self.bnb_4bit_quant_storage = getattr(torch, bnb_4bit_quant_storage)
elif isinstance(bnb_4bit_quant_storage, torch.dtype):
self.bnb_4bit_quant_storage = bnb_4bit_quant_storage
else:
raise ValueError("bnb_4bit_quant_storage must be a string or a torch.dtype")
self.post_init()
@property
def load_in_4bit(self):
return self._load_in_4bit
@load_in_4bit.setter
def load_in_4bit(self, value: bool):
if self.load_in_8bit and value:
raise ValueError("load_in_4bit and load_in_8bit are both True, but only one can be used at the same time")
self._load_in_4bit = value
@property
def load_in_8bit(self):
return self._load_in_8bit
@load_in_8bit.setter
def load_in_8bit(self, value: bool):
if self.load_in_4bit and value:
raise ValueError("load_in_4bit and load_in_8bit are both True, but only one can be used at the same time")
self._load_in_8bit = value
def post_init(self):
r"""
Safety checker that arguments are correct - also replaces some NoneType arguments with their default values.
"""
if not isinstance(self.llm_int8_threshold, float):
raise ValueError("llm_int8_threshold must be a float")
if self.llm_int8_skip_modules is not None and not isinstance(self.llm_int8_skip_modules, list):
raise ValueError("llm_int8_skip_modules must be a list of strings")
if not isinstance(self.llm_int8_enable_fp32_cpu_offload, bool):
raise ValueError("llm_int8_enable_fp32_cpu_offload must be a boolean")
if not isinstance(self.llm_int8_has_fp16_weight, bool):
raise ValueError("llm_int8_has_fp16_weight must be a boolean")
if self.bnb_4bit_compute_dtype is not None and not isinstance(self.bnb_4bit_compute_dtype, torch.dtype):
raise ValueError("bnb_4bit_compute_dtype must be torch.dtype")
if not isinstance(self.bnb_4bit_quant_type, str):
raise ValueError("bnb_4bit_quant_type must be a string")
if not isinstance(self.bnb_4bit_use_double_quant, bool):
raise ValueError("bnb_4bit_use_double_quant must be a boolean")
if self.load_in_4bit and not version.parse(importlib.metadata.version("bitsandbytes")) >= version.parse(
"0.39.0"
):
raise ValueError(
"4 bit quantization requires bitsandbytes>=0.39.0 - please upgrade your bitsandbytes version"
)
def is_quantizable(self):
r"""
Returns `True` if the model is quantizable, `False` otherwise.
"""
return self.load_in_8bit or self.load_in_4bit
def quantization_method(self):
r"""
This method returns the quantization method used for the model. If the model is not quantizable, it returns
`None`.
"""
if self.load_in_8bit:
return "llm_int8"
elif self.load_in_4bit and self.bnb_4bit_quant_type == "fp4":
return "fp4"
elif self.load_in_4bit and self.bnb_4bit_quant_type == "nf4":
return "nf4"
else:
return None
def to_dict(self) -> Dict[str, Any]:
"""
Serializes this instance to a Python dictionary. Returns:
`Dict[str, Any]`: Dictionary of all the attributes that make up this configuration instance.
"""
output = copy.deepcopy(self.__dict__)
output["bnb_4bit_compute_dtype"] = str(output["bnb_4bit_compute_dtype"]).split(".")[1]
output["bnb_4bit_quant_storage"] = str(output["bnb_4bit_quant_storage"]).split(".")[1]
output["load_in_4bit"] = self.load_in_4bit
output["load_in_8bit"] = self.load_in_8bit
return output
def __repr__(self):
config_dict = self.to_dict()
return f"{self.__class__.__name__} {json.dumps(config_dict, indent=2, sort_keys=True)}\n"
def to_diff_dict(self) -> Dict[str, Any]:
"""
Removes all attributes from config which correspond to the default config attributes for better readability and
serializes to a Python dictionary.
Returns:
`Dict[str, Any]`: Dictionary of all the attributes that make up this configuration instance,
"""
config_dict = self.to_dict()
default_config_dict = BitsAndBytesConfig().to_dict()
serializable_config_dict = {}
for key, value in config_dict.items():
if value != default_config_dict[key]:
serializable_config_dict[key] = value
return serializable_config_dict
class ExllamaVersion(int, Enum):
ONE = 1
TWO = 2
@dataclass
class GPTQConfig(QuantizationConfigMixin):
"""
This is a wrapper class about all possible attributes and features that you can play with a model that has been
loaded using `optimum` api for gptq quantization relying on auto_gptq backend.
"""
def __init__(
self,
bits: int,
tokenizer: Any = None,
dataset: Optional[Union[List[str], str]] = None,
group_size: int = 128,
damp_percent: float = 0.1,
desc_act: bool = False,
sym: bool = True,
true_sequential: bool = True,
use_cuda_fp16: bool = False,
model_seqlen: Optional[int] = None,
block_name_to_quantize: Optional[str] = None,
module_name_preceding_first_block: Optional[List[str]] = None,
batch_size: int = 1,
pad_token_id: Optional[int] = None,
use_exllama: Optional[bool] = None,
max_input_length: Optional[int] = None,
exllama_config: Optional[Dict[str, Any]] = None,
cache_block_outputs: bool = True,
modules_in_block_to_quantize: Optional[List[List[str]]] = None,
**kwargs,
):
self.quant_method = QuantizationMethod.GPTQ
self.bits = bits
self.tokenizer = tokenizer
self.dataset = dataset
self.group_size = group_size
self.damp_percent = damp_percent
self.desc_act = desc_act
self.sym = sym
self.true_sequential = true_sequential
self.use_cuda_fp16 = use_cuda_fp16
self.model_seqlen = model_seqlen
self.block_name_to_quantize = block_name_to_quantize
self.module_name_preceding_first_block = module_name_preceding_first_block
self.batch_size = batch_size
self.pad_token_id = pad_token_id
self.use_exllama = use_exllama
self.max_input_length = max_input_length
self.exllama_config = exllama_config
self.disable_exllama = kwargs.pop("disable_exllama", None)
self.cache_block_outputs = cache_block_outputs
self.modules_in_block_to_quantize = modules_in_block_to_quantize
self.post_init()
def get_loading_attributes(self):
attibutes_dict = copy.deepcopy(self.__dict__)
loading_attibutes = ["disable_exllama", "use_exllama", "exllama_config", "use_cuda_fp16", "max_input_length"]
loading_attibutes_dict = {i: j for i, j in attibutes_dict.items() if i in loading_attibutes}
return loading_attibutes_dict
def to_dict(self):
config_dict = super().to_dict()
config_dict.pop("disable_exllama", None)
return config_dict
def to_dict_optimum(self):
"""
Get compatible dict for optimum gptq config
获取适用于最优gptq配置的兼容字典
"""
quant_dict = self.to_dict()
quant_dict["disable_exllama"] = not self.use_exllama
return quant_dict
@classmethod
def from_dict_optimum(cls, config_dict):
"""
从字典中创建最佳配置类
检查配置字典中是否存在 "disable_exllama" 键
"""
if "disable_exllama" in config_dict:
config_dict["use_exllama"] = not config_dict["disable_exllama"]
config_dict["disable_exllama"] = None
config = cls(**config_dict)
return config
@dataclass
class AwqConfig(QuantizationConfigMixin):
"""
This is a wrapper class about all possible attributes and features that you can play with a model that has been
loaded using `auto-awq` library awq quantization relying on auto_awq backend.
Args:
bits (`int`, *optional*, defaults to 4):
The number of bits to quantize to.
group_size (`int`, *optional*, defaults to 128):
The group size to use for quantization. Recommended value is 128 and -1 uses per-column quantization.
zero_point (`bool`, *optional*, defaults to `True`):
Whether to use zero point quantization.
version (`AWQLinearVersion`, *optional*, defaults to `AWQLinearVersion.GEMM`):
The version of the quantization algorithm to use. GEMM is better for big batch_size (e.g. >= 8) otherwise,
GEMV is better (e.g. < 8 ). GEMM models are compatible with Exllama kernels.
backend (`AwqBackendPackingMethod`, *optional*, defaults to `AwqBackendPackingMethod.AUTOAWQ`):
The quantization backend. Some models might be quantized using `llm-awq` backend. This is useful for users
that quantize their own models using `llm-awq` library.
do_fuse (`bool`, *optional*, defaults to `False`):
Whether to fuse attention and mlp layers together for faster inference
fuse_max_seq_len (`int`, *optional*):
The Maximum sequence length to generate when using fusing.
modules_to_fuse (`dict`, *optional*, default to `None`):
Overwrite the natively supported fusing scheme with the one specified by the users.
modules_to_not_convert (`list`, *optional*, default to `None`):
The list of modules to not quantize, useful for quantizing models that explicitly require to have
some modules left in their original precision (e.g. Whisper encoder, Llava encoder, Mixtral gate layers).
Note you cannot quantize directly with transformers, please refer to `AutoAWQ` documentation for quantizing HF models.
exllama_config (`Dict[str, Any]`, *optional*):
You can specify the version of the exllama kernel through the `version` key, the maximum sequence
length through the `max_input_len` key, and the maximum batch size through the `max_batch_size` key.
Defaults to `{"version": 2, "max_input_len": 2048, "max_batch_size": 8}` if unset.
"""
def __init__(
self,
bits: int = 4,
group_size: int = 128,
zero_point: bool = True,
version: AWQLinearVersion = AWQLinearVersion.GEMM,
backend: AwqBackendPackingMethod = AwqBackendPackingMethod.AUTOAWQ,
do_fuse: Optional[bool] = None,
fuse_max_seq_len: Optional[int] = None,
modules_to_fuse: Optional[dict] = None,
modules_to_not_convert: Optional[List] = None,
exllama_config: Optional[Dict[str, int]] = None,
**kwargs,
):
self.quant_method = QuantizationMethod.AWQ
self.bits = bits
self.group_size = group_size
self.zero_point = zero_point
self.version = version
self.backend = backend
self.fuse_max_seq_len = fuse_max_seq_len
self.modules_to_not_convert = modules_to_not_convert
self.exllama_config = exllama_config
self.modules_to_fuse = modules_to_fuse
if do_fuse is None:
self.do_fuse = modules_to_fuse is not None and len(modules_to_fuse) > 0
else:
self.do_fuse = do_fuse
self.fuse_max_seq_len = fuse_max_seq_len
self.post_init()
def get_loading_attributes(self):
attibutes_dict = copy.deepcopy(self.__dict__)
loading_attibutes = ["version", "do_fuse", "modules_to_fuse", "fuse_max_seq_len"]
loading_attibutes_dict = {i: j for i, j in attibutes_dict.items() if i in loading_attibutes}
return loading_attibutes_dict
@dataclass
class AqlmConfig(QuantizationConfigMixin):
"""
This is a dataclass that defines configuration parameters for the AQLM quantization method.
Args:
in_group_size (`int`, *optional*, defaults to 8):
The group size along the input dimension.
out_group_size (`int`, *optional*, defaults to 1):
The group size along the output dimension. It's recommended to always use 1.
num_codebooks (`int`, *optional*, defaults to 1):
Number of codebooks for the Additive Quantization procedure.
nbits_per_codebook (`int`, *optional*, defaults to 16):
Number of bits encoding a single codebook vector. Codebooks size is 2**nbits_per_codebook.
linear_weights_not_to_quantize (`Optional[List[str]]`, *optional*):
List of full paths of `nn.Linear` weight parameters that shall not be quantized.
kwargs (`Dict[str, Any]`, *optional*):
Additional parameters from which to initialize the configuration object.
"""
def __init__(
self,
in_group_size: int = 8,
out_group_size: int = 1,
num_codebooks: int = 1,
nbits_per_codebook: int = 16,
linear_weights_not_to_quantize: Optional[List[str]] = None,
**kwargs,
):
self.quant_method = QuantizationMethod.AQLM
self.in_group_size = in_group_size
self.out_group_size = out_group_size
self.num_codebooks = num_codebooks
self.nbits_per_codebook = nbits_per_codebook
self.linear_weights_not_to_quantize = linear_weights_not_to_quantize
self.post_init()
def post_init(self):
r"""
检查参数的正确性 - 替换一些 NoneType 参数为它们的默认值。
"""
if not isinstance(self.in_group_size, int):
raise ValueError("in_group_size must be an integer")
if not isinstance(self.out_group_size, int):
raise ValueError("out_group_size must be an integer")
if not isinstance(self.num_codebooks, int):
raise ValueError("num_codebooks must be an integer")
if not isinstance(self.nbits_per_codebook, int):
raise ValueError("nbits_per_codebook must be an integer")
if self.linear_weights_not_to_quantize is not None and not isinstance(
self.linear_weights_not_to_quantize, list
):
raise ValueError("linear_weights_not_to_quantize must be a list of strings")
if self.linear_weights_not_to_quantize is None:
self.linear_weights_not_to_quantize = []
Args:
weights (`str`, *optional*, defaults to `"int8"`):
The target dtype for the weights after quantization. Supported values are ("float8","int8","int4","int2")
activations (`str`, *optional*):
The target dtype for the activations after quantization. Supported values are (None,"int8","float8")
modules_to_not_convert (`list`, *optional*, default to `None`):
The list of modules to not quantize, useful for quantizing models that explicitly require to have
some modules left in their original precision (e.g. Whisper encoder, Llava encoder, Mixtral gate layers).
"""
# 初始化方法,用于设置量化器的参数和执行后续的初始化步骤
def __init__(
self,
weights="int8", # 设置权重的目标数据类型,默认为 "int8"
activations=None, # 设置激活函数的目标数据类型,默认为 None
modules_to_not_convert: Optional[List] = None, # 不需要量化的模块列表,默认为 None
**kwargs, # 允许接收任意额外的关键字参数
):
self.quant_method = QuantizationMethod.QUANTO # 设置量化方法为 QUANTO
self.weights = weights # 初始化权重目标数据类型
self.activations = activations # 初始化激活函数目标数据类型
self.modules_to_not_convert = modules_to_not_convert # 初始化不需量化的模块列表
self.post_init() # 调用后续初始化方法
# 后续初始化方法,用于检查参数是否合法
def post_init(self):
r"""
Safety checker that arguments are correct
"""
accepted_weights = ["float8", "int8", "int4", "int2"] # 支持的权重数据类型列表
accepted_activations = [None, "int8", "float8"] # 支持的激活函数数据类型列表
if self.weights not in accepted_weights: # 检查权重数据类型是否在支持列表中
raise ValueError(f"Only support weights in {accepted_weights} but found {self.weights}")
if self.activations not in accepted_activations: # 检查激活函数数据类型是否在支持列表中
raise ValueError(f"Only support weights in {accepted_activations} but found {self.activations}")
.\utils\sentencepiece_model_pb2.py
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protobuf import symbol_database as _symbol_database
_sym_db = _symbol_database.Default()
DESCRIPTOR = _descriptor.FileDescriptor(
name="sentencepiece_model.proto",
package="sentencepiece",
syntax="proto2",
serialized_options=b"H\003",
create_key=_descriptor._internal_create_key,
)
_TRAINERSPEC_MODELTYPE = _descriptor.EnumDescriptor(
name="ModelType",
full_name="sentencepiece.TrainerSpec.ModelType",
filename=None,
file=DESCRIPTOR,
create_key=_descriptor._internal_create_key,
values=[
_descriptor.EnumValueDescriptor(
name="UNIGRAM",
index=0,
number=1,
serialized_options=None,
type=None,
create_key=_descriptor._internal_create_key,
),
_descriptor.EnumValueDescriptor(
name="BPE",
index=1,
number=2,
serialized_options=None,
type=None,
create_key=_descriptor._internal_create_key,
),
_descriptor.EnumValueDescriptor(
name="WORD",
index=2,
number=3,
serialized_options=None,
type=None,
create_key=_descriptor._internal_create_key,
),
_descriptor.EnumValueDescriptor(
name="CHAR",
index=3,
number=4,
serialized_options=None,
type=None,
create_key=_descriptor._internal_create_key,
),
],
containing_type=None,
serialized_options=None,
serialized_start=1294,
serialized_end=1347,
)
_sym_db.RegisterEnumDescriptor(_TRAINERSPEC_MODELTYPE)
_MODELPROTO_SENTENCEPIECE_TYPE = _descriptor.EnumDescriptor(
name="Type",
full_name="sentencepiece.ModelProto.SentencePiece.Type",
filename=None,
file=DESCRIPTOR,
create_key=_descriptor._internal_create_key,
)
values=[
_descriptor.EnumValueDescriptor(
name="NORMAL",
index=0,
number=1,
serialized_options=None,
type=None,
create_key=_descriptor._internal_create_key,
),
_descriptor.EnumValueDescriptor(
name="UNKNOWN",
index=1,
number=2,
serialized_options=None,
type=None,
create_key=_descriptor._internal_create_key,
),
_descriptor.EnumValueDescriptor(
name="CONTROL",
index=2,
number=3,
serialized_options=None,
type=None,
create_key=_descriptor._internal_create_key,
),
_descriptor.EnumValueDescriptor(
name="USER_DEFINED",
index=3,
number=4,
serialized_options=None,
type=None,
create_key=_descriptor._internal_create_key,
),
_descriptor.EnumValueDescriptor(
name="BYTE",
index=4,
number=6,
serialized_options=None,
type=None,
create_key=_descriptor._internal_create_key,
),
_descriptor.EnumValueDescriptor(
name="UNUSED",
index=5,
number=5,
serialized_options=None,
type=None,
create_key=_descriptor._internal_create_key,
),
],
containing_type=None,
serialized_options=None,
serialized_start=2100,
serialized_end=2184,
_sym_db.RegisterEnumDescriptor(_MODELPROTO_SENTENCEPIECE_TYPE)
_TRAINERSPEC = _descriptor.Descriptor(
name="TrainerSpec",
full_name="sentencepiece.TrainerSpec",
filename=None,
file=DESCRIPTOR,
containing_type=None,
create_key=_descriptor._internal_create_key,
fields=[
],
extensions=[],
nested_types=[],
enum_types=[
_TRAINERSPEC_MODELTYPE,
],
serialized_options=None,
is_extendable=True,
syntax="proto2",
extension_ranges=[
(200, 536870912),
],
oneofs=[],
serialized_start=45,
serialized_end=1358,
)
_NORMALIZERSPEC = _descriptor.Descriptor(
name="NormalizerSpec",
full_name="sentencepiece.NormalizerSpec",
filename=None,
file=DESCRIPTOR,
containing_type=None,
create_key=_descriptor._internal_create_key,
fields=[],
extensions=[],
nested_types=[],
enum_types=[],
serialized_options=None,
is_extendable=True,
syntax="proto2",
extension_ranges=[
(200, 536870912),
],
oneofs=[],
serialized_start=1361,
serialized_end=1570,
)
_SELFTESTDATA_SAMPLE = _descriptor.Descriptor(
name="Sample",
full_name="sentencepiece.SelfTestData.Sample",
filename=None,
file=DESCRIPTOR,
containing_type=None,
create_key=_descriptor._internal_create_key,
fields=[
],
extensions=[],
nested_types=[],
enum_types=[],
serialized_options=None,
is_extendable=False,
syntax="proto2",
extension_ranges=[],
oneofs=[],
serialized_start=1641,
serialized_end=1682,
)
_SELFTESTDATA = _descriptor.Descriptor(
name="SelfTestData",
full_name="sentencepiece.SelfTestData",
filename=None,
file=DESCRIPTOR,
containing_type=None,
)
create_key=_descriptor._internal_create_key,
fields=[
_descriptor.FieldDescriptor(
name="samples",
full_name="sentencepiece.SelfTestData.samples",
index=0,
number=1,
type=11,
cpp_type=10,
label=3,
has_default_value=False,
default_value=[],
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
serialized_options=None,
file=DESCRIPTOR,
create_key=_descriptor._internal_create_key,
),
],
extensions=[],
nested_types=[
_SELFTESTDATA_SAMPLE,
],
enum_types=[],
serialized_options=None,
is_extendable=True,
syntax="proto2",
extension_ranges=[
(200, 536870912),
],
oneofs=[],
serialized_start=1572,
serialized_end=1693,
_MODELPROTO_SENTENCEPIECE = _descriptor.Descriptor(
name="SentencePiece",
full_name="sentencepiece.ModelProto.SentencePiece",
filename=None,
file=DESCRIPTOR,
containing_type=None,
create_key=_descriptor._internal_create_key,
fields=[
_descriptor.FieldDescriptor(
name="piece",
full_name="sentencepiece.ModelProto.SentencePiece.piece",
index=0,
number=1,
type=9,
cpp_type=9,
label=1,
has_default_value=False,
default_value=b"".decode("utf-8"),
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
serialized_options=None,
file=DESCRIPTOR,
create_key=_descriptor._internal_create_key,
),
_descriptor.FieldDescriptor(
name="score",
full_name="sentencepiece.ModelProto.SentencePiece.score",
index=1,
number=2,
type=2,
cpp_type=6,
label=1,
has_default_value=False,
default_value=float(0),
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
serialized_options=None,
file=DESCRIPTOR,
create_key=_descriptor._internal_create_key,
),
_descriptor.FieldDescriptor(
name="type",
full_name="sentencepiece.ModelProto.SentencePiece.type",
index=2,
number=3,
type=14,
cpp_type=8,
label=1,
has_default_value=True,
default_value=1,
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
serialized_options=None,
file=DESCRIPTOR,
create_key=_descriptor._internal_create_key,
),
],
extensions=[],
nested_types=[],
enum_types=[
_MODELPROTO_SENTENCEPIECE_TYPE,
],
serialized_options=None,
is_extendable=True,
syntax="proto2",
extension_ranges=[
(200, 536870912),
],
oneofs=[],
serialized_start=1985,
serialized_end=2195,
)
_MODELPROTO = _descriptor.Descriptor(
name="ModelProto",
full_name="sentencepiece.ModelProto",
filename=None,
file=DESCRIPTOR,
containing_type=None,
create_key=_descriptor._internal_create_key,
],
extensions=[],
nested_types=[
_MODELPROTO_SENTENCEPIECE,
],
enum_types=[],
serialized_options=None,
is_extendable=True,
syntax="proto2",
extension_ranges=[
(200, 536870912),
],
oneofs=[],
serialized_start=1696,
serialized_end=2206,
)
_TRAINERSPEC.fields_by_name["model_type"].enum_type = _TRAINERSPEC_MODELTYPE
_TRAINERSPEC_MODELTYPE.containing_type = _TRAINERSPEC
_SELFTESTDATA_SAMPLE.containing_type = _SELFTESTDATA
_SELFTESTDATA.fields_by_name["samples"].message_type = _SELFTESTDATA_SAMPLE
_MODELPROTO_SENTENCEPIECE.fields_by_name["type"].enum_type = _MODELPROTO_SENTENCEPIECE_TYPE
_MODELPROTO_SENTENCEPIECE.containing_type = _MODELPROTO
_MODELPROTO_SENTENCEPIECE_TYPE.containing_type = _MODELPROTO_SENTENCEPIECE
_MODELPROTO.fields_by_name["pieces"].message_type = _MODELPROTO_SENTENCEPIECE
_MODELPROTO.fields_by_name["trainer_spec"].message_type = _TRAINERSPEC
_MODELPROTO.fields_by_name["normalizer_spec"].message_type = _NORMALIZERSPEC
_MODELPROTO.fields_by_name["self_test_data"].message_type = _SELFTESTDATA
_MODELPROTO.fields_by_name["denormalizer_spec"].message_type = _NORMALIZERSPEC
DESCRIPTOR.message_types_by_name["TrainerSpec"] = _TRAINERSPEC
DESCRIPTOR.message_types_by_name["NormalizerSpec"] = _NORMALIZERSPEC
DESCRIPTOR.message_types_by_name["SelfTestData"] = _SELFTESTDATA
DESCRIPTOR.message_types_by_name["ModelProto"] = _MODELPROTO
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
TrainerSpec = _reflection.GeneratedProtocolMessageType(
"TrainerSpec",
(_message.Message,),
{
"DESCRIPTOR": _TRAINERSPEC,
"__module__": "sentencepiece_model_pb2",
},
)
_sym_db.RegisterMessage(TrainerSpec)
NormalizerSpec = _reflection.GeneratedProtocolMessageType(
"NormalizerSpec",
(_message.Message,),
{
"DESCRIPTOR": _NORMALIZERSPEC,
"__module__": "sentencepiece_model_pb2",
},
)
_sym_db.RegisterMessage(NormalizerSpec)
SelfTestData = _reflection.GeneratedProtocolMessageType(
"SelfTestData",
(_message.Message,),
{
"Sample": _reflection.GeneratedProtocolMessageType(
"Sample",
(_message.Message,),
{
"DESCRIPTOR": _SELFTESTDATA_SAMPLE,
"__module__": "sentencepiece_model_pb2",
},
),
"DESCRIPTOR": _SELFTESTDATA,
"__module__": "sentencepiece_model_pb2",
},
)
_sym_db.RegisterMessage(SelfTestData)
_sym_db.RegisterMessage(SelfTestData.Sample)
ModelProto = _reflection.GeneratedProtocolMessageType(
"ModelProto",
(_message.Message,),
{
...
{
"SentencePiece": _reflection.GeneratedProtocolMessageType(
"SentencePiece",
(_message.Message,),
{
"DESCRIPTOR": _MODELPROTO_SENTENCEPIECE,
"__module__": "sentencepiece_model_pb2",
},
),
"DESCRIPTOR": _MODELPROTO,
"__module__": "sentencepiece_model_pb2",
},
_sym_db.RegisterMessage(ModelProto)
_sym_db.RegisterMessage(ModelProto.SentencePiece)
DESCRIPTOR._options = None
_TRAINERSPEC.fields_by_name["mining_sentence_size"]._options = None
_TRAINERSPEC.fields_by_name["training_sentence_size"]._options = None
.\utils\sentencepiece_model_pb2_new.py
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import symbol_database as _symbol_database
from google.protobuf.internal import builder as _builder
_sym_db = _symbol_database.Default()
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(
)
_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, "sentencepiece_model_pb2", _globals)
if _descriptor._USE_C_DESCRIPTORS is False:
DESCRIPTOR._options = None
DESCRIPTOR._serialized_options = b"H\003"
_globals["_TRAINERSPEC"]._serialized_start = 45
_globals["_TRAINERSPEC"]._serialized_end = 1581
_globals["_TRAINERSPEC_MODELTYPE"]._serialized_start = 1517
_globals["_TRAINERSPEC_MODELTYPE"]._serialized_end = 1570
_globals["_NORMALIZERSPEC"]._serialized_start = 1584
_globals["_NORMALIZERSPEC"]._serialized_end = 1793
_globals["_SELFTESTDATA"]._serialized_start = 1795
_globals["_SELFTESTDATA"]._serialized_end = 1916
_globals["_SELFTESTDATA_SAMPLE"]._serialized_start = 1864
_globals["_SELFTESTDATA_SAMPLE"]._serialized_end = 1905
_globals["_MODELPROTO"]._serialized_start = 1919
_globals["_MODELPROTO"]._serialized_end = 2429
_globals["_MODELPROTO_SENTENCEPIECE"]._serialized_start = 2208
_globals["_MODELPROTO_SENTENCEPIECE"]._serialized_end = 2418
_globals["_MODELPROTO_SENTENCEPIECE_TYPE"]._serialized_start = 2323
_globals["_MODELPROTO_SENTENCEPIECE_TYPE"]._serialized_end = 2407
.\utils\versions.py
"""
用于处理包版本的实用工具
"""
import importlib.metadata
import operator
import re
import sys
from typing import Optional
from packaging import version
ops = {
"<": operator.lt,
"<=": operator.le,
"==": operator.eq,
"!=": operator.ne,
">=": operator.ge,
">": operator.gt,
}
def _compare_versions(op, got_ver, want_ver, requirement, pkg, hint):
if got_ver is None or want_ver is None:
raise ValueError(
f"Unable to compare versions for {requirement}: need={want_ver} found={got_ver}. This is unusual. Consider"
f" reinstalling {pkg}."
)
if not ops[op](version.parse(got_ver), version.parse(want_ver)):
raise ImportError(
f"{requirement} is required for a normal functioning of this module, but found {pkg}=={got_ver}.{hint}"
)
def require_version(requirement: str, hint: Optional[str] = None) -> None:
"""
执行运行时的依赖版本检查,使用与pip相同的语法。
安装的模块版本来自*site-packages*目录通过*importlib.metadata*。
Args:
requirement (`str`): pip风格的定义,例如 "tokenizers==0.9.4", "tqdm>=4.27", "numpy"
hint (`str`, *optional*): 如果未满足要求,打印的建议内容
Example:
```
require_version("pandas>1.1.2")
require_version("numpy>1.18.5", "this is important to have for whatever reason")
```"""
hint = f"\n{hint}" if hint is not None else ""
if re.match(r"^[\w_\-\d]+$", requirement):
pkg, op, want_ver = requirement, None, None
match = re.findall(r"^([^!=<>\s]+)([\s!=<>]{1,2}.+)", requirement)
if not match:
raise ValueError(
"requirement needs to be in the pip package format, .e.g., package_a==1.23, or package_b>=1.23, but"
f" got {requirement}"
)
pkg, want_full = match[0]
want_range = want_full.split(",")
wanted = {}
for w in want_range:
match = re.findall(r"^([\s!=<>]{1,2})(.+)", w)
if not match:
raise ValueError(
"requirement needs to be in the pip package format, .e.g., package_a==1.23, or package_b>=1.23,"
f" but got {requirement}"
)
op, want_ver = match[0]
wanted[op] = want_ver
if op not in ops:
raise ValueError(f"{requirement}: need one of {list(ops.keys())}, but got {op}")
if pkg == "python":
got_ver = ".".join([str(x) for x in sys.version_info[:3]])
for op, want_ver in wanted.items():
_compare_versions(op, got_ver, want_ver, requirement, pkg, hint)
return
try:
got_ver = importlib.metadata.version(pkg)
except importlib.metadata.PackageNotFoundError:
raise importlib.metadata.PackageNotFoundError(
f"The '{requirement}' distribution was not found and is required by this application. {hint}"
)
if want_ver is not None:
for op, want_ver in wanted.items():
_compare_versions(op, got_ver, want_ver, requirement, pkg, hint)
def require_version_core(requirement):
hint = "Try: `pip install transformers -U` or `pip install -e '.[dev]'` if you're working with git main"
return require_version(requirement, hint)
.\utils\__init__.py
from huggingface_hub import get_full_repo_name
from huggingface_hub.constants import HF_HUB_DISABLE_TELEMETRY as DISABLE_TELEMETRY
from packaging import version
from .. import __version__
from .backbone_utils import BackboneConfigMixin, BackboneMixin
from .constants import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD, IMAGENET_STANDARD_MEAN, IMAGENET_STANDARD_STD
from .doc import (
add_code_sample_docstrings,
add_end_docstrings,
add_start_docstrings,
add_start_docstrings_to_model_forward,
copy_func,
replace_return_docstrings,
)
from .generic import (
ContextManagers,
ExplicitEnum,
ModelOutput,
PaddingStrategy,
TensorType,
add_model_info_to_auto_map,
cached_property,
can_return_loss,
expand_dims,
find_labels,
flatten_dict,
infer_framework,
is_jax_tensor,
is_numpy_array,
is_tensor,
is_tf_symbolic_tensor,
is_tf_tensor,
is_torch_device,
is_torch_dtype,
is_torch_tensor,
reshape,
squeeze,
strtobool,
tensor_size,
to_numpy,
to_py_obj,
transpose,
working_or_temp_dir,
)
from .hub import (
CLOUDFRONT_DISTRIB_PREFIX,
HF_MODULES_CACHE,
HUGGINGFACE_CO_PREFIX,
HUGGINGFACE_CO_RESOLVE_ENDPOINT,
PYTORCH_PRETRAINED_BERT_CACHE,
PYTORCH_TRANSFORMERS_CACHE,
S3_BUCKET_PREFIX,
TRANSFORMERS_CACHE,
TRANSFORMERS_DYNAMIC_MODULE_NAME,
EntryNotFoundError,
PushInProgress,
PushToHubMixin,
RepositoryNotFoundError,
RevisionNotFoundError,
cached_file,
default_cache_path,
define_sagemaker_information,
download_url,
extract_commit_hash,
get_cached_models,
get_file_from_repo,
has_file,
http_user_agent,
is_offline_mode,
is_remote_url,
move_cache,
send_example_telemetry,
try_to_load_from_cache,
)
from .import_utils import (
ACCELERATE_MIN_VERSION,
ENV_VARS_TRUE_AND_AUTO_VALUES,
ENV_VARS_TRUE_VALUES,
TORCH_FX_REQUIRED_VERSION,
USE_JAX,
USE_TF,
USE_TORCH,
DummyObject,
OptionalDependencyNotAvailable,
_LazyModule,
ccl_version,
direct_transformers_import,
get_torch_version,
is_accelerate_available,
is_apex_available,
is_aqlm_available,
is_auto_awq_available,
is_auto_gptq_available,
is_bitsandbytes_available,
is_bs4_available,
is_coloredlogs_available,
is_cv2_available,
is_cython_available,
is_datasets_available,
is_decord_available,
is_detectron2_available,
is_essentia_available,
is_faiss_available,
is_flash_attn_2_available,
is_flash_attn_greater_or_equal_2_10,
is_flax_available,
is_fsdp_available,
is_ftfy_available,
is_g2p_en_available,
is_galore_torch_available,
is_in_notebook,
is_ipex_available,
is_jinja_available,
is_jumanpp_available,
is_kenlm_available,
is_keras_nlp_available,
is_levenshtein_available,
is_librosa_available,
is_mlx_available,
is_natten_available,
is_ninja_available,
is_nltk_available,
is_onnx_available,
is_openai_available,
is_optimum_available,
is_pandas_available,
is_peft_available,
is_phonemizer_available,
is_pretty_midi_available,
is_protobuf_available,
is_psutil_available,
is_py3nvml_available,
is_pyctcdecode_available,
is_pytesseract_available,
is_pytest_available,
is_pytorch_quantization_available,
is_quanto_available,
is_rjieba_available,
is_sacremoses_available,
is_safetensors_available,
is_sagemaker_dp_enabled,
is_sagemaker_mp_enabled,
is_scipy_available,
is_sentencepiece_available,
is_seqio_available,
is_sklearn_available,
is_soundfile_availble,
is_spacy_available,
is_speech_available,
is_sudachi_available,
is_sudachi_projection_available,
is_tensorflow_probability_available,
is_tensorflow_text_available,
is_tf2onnx_available,
is_tf_available,
is_timm_available,
is_tokenizers_available,
is_torch_available,
is_torch_bf16_available_on_device,
is_torch_bf16_cpu_available,
is_torch_bf16_gpu_available,
is_torch_compile_available,
is_torch_cuda_available,
is_torch_fp16_available_on_device,
is_torch_fx_available,
is_torch_fx_proxy,
is_torch_mps_available,
is_torch_neuroncore_available,
is_torch_npu_available,
is_torch_sdpa_available,
is_torch_tensorrt_fx_available,
is_torch_tf32_available,
is_torch_tpu_available,
is_torch_xla_available,
is_torch_xpu_available,
is_torchaudio_available,
is_torchdistx_available,
is_torchdynamo_available,
is_torchdynamo_compiling,
is_torchvision_available,
is_training_run_on_sagemaker,
requires_backends,
torch_only_method,
from .peft_utils import (
ADAPTER_CONFIG_NAME,
ADAPTER_SAFE_WEIGHTS_NAME,
ADAPTER_WEIGHTS_NAME,
check_peft_version,
find_adapter_config_file,
)
WEIGHTS_NAME = "pytorch_model.bin"
WEIGHTS_INDEX_NAME = "pytorch_model.bin.index.json"
TF2_WEIGHTS_NAME = "tf_model.h5"
TF2_WEIGHTS_INDEX_NAME = "tf_model.h5.index.json"
TF_WEIGHTS_NAME = "model.ckpt"
FLAX_WEIGHTS_NAME = "flax_model.msgpack"
FLAX_WEIGHTS_INDEX_NAME = "flax_model.msgpack.index.json"
SAFE_WEIGHTS_NAME = "model.safetensors"
SAFE_WEIGHTS_INDEX_NAME = "model.safetensors.index.json"
CONFIG_NAME = "config.json"
FEATURE_EXTRACTOR_NAME = "preprocessor_config.json"
IMAGE_PROCESSOR_NAME = FEATURE_EXTRACTOR_NAME
PROCESSOR_NAME = "processor_config.json"
GENERATION_CONFIG_NAME = "generation_config.json"
MODEL_CARD_NAME = "modelcard.json"
SENTENCEPIECE_UNDERLINE = "▁"
SPIECE_UNDERLINE = SENTENCEPIECE_UNDERLINE
MULTIPLE_CHOICE_DUMMY_INPUTS = [
[[0, 1, 0, 1], [1, 0, 0, 1]]
] * 2
DUMMY_INPUTS = [[7, 6, 0, 0, 1], [1, 2, 3, 0, 0], [0, 0, 0, 4, 5]]
DUMMY_MASK = [[1, 1, 1, 1, 1], [1, 1, 1, 0, 0], [0, 0, 0, 1, 1]]
def check_min_version(min_version):
if version.parse(__version__) < version.parse(min_version):
if "dev" in min_version:
error_message = (
"This example requires a source install from HuggingFace Transformers (see "
"`https://huggingface.co/docs/transformers/installation#install-from-source`),"
)
else:
error_message = f"This example requires a minimum version of {min_version},"
error_message += f" but the version found is {__version__}.\n"
raise ImportError(
error_message
+ "Check out https://github.com/huggingface/transformers/tree/main/examples#important-note for the examples corresponding to other "
"versions of HuggingFace Transformers."
)
.\__init__.py
`
__version__ = "4.39.0"
from typing import TYPE_CHECKING
from . import dependency_versions_check
from .utils import (
OptionalDependencyNotAvailable,
_LazyModule,
is_bitsandbytes_available,
is_essentia_available,
is_flax_available,
is_g2p_en_available,
is_keras_nlp_available,
is_librosa_available,
is_pretty_midi_available,
is_scipy_available,
is_sentencepiece_available,
is_speech_available,
is_tensorflow_text_available,
is_tf_available,
is_timm_available,
is_tokenizers_available,
is_torch_available,
is_torchaudio_available,
is_torchvision_available,
is_vision_available,
logging,
)
logger = logging.get_logger(__name__)
_import_structure = {
"audio_utils": [],
"benchmark": [],
"commands": [],
"configuration_utils": ["PretrainedConfig"],
"convert_graph_to_onnx": [],
"convert_slow_tokenizers_checkpoints_to_fast": [],
"convert_tf_hub_seq_to_seq_bert_to_pytorch": [],
"data": [
"DataProcessor",
"InputExample",
"InputFeatures",
"SingleSentenceClassificationProcessor",
"SquadExample",
"SquadFeatures",
"SquadV1Processor",
"SquadV2Processor",
"glue_compute_metrics",
"glue_convert_examples_to_features",
"glue_output_modes",
"glue_processors",
"glue_tasks_num_labels",
"squad_convert_examples_to_features",
"xnli_compute_metrics",
"xnli_output_modes",
"xnli_processors",
"xnli_tasks_num_labels",
],
"data.data_collator": [
"DataCollator",
"DataCollatorForLanguageModeling",
"DataCollatorForPermutationLanguageModeling",
"DataCollatorForSeq2Seq",
"DataCollatorForSOP",
"DataCollatorForTokenClassification",
"DataCollatorForWholeWordMask",
"DataCollatorWithPadding",
"DefaultDataCollator",
"default_data_collator",
],
"data.metrics": [],
"data.processors": [],
"debug_utils": [],
"deepspeed": [],
"dependency_versions_check": [],
"dependency_versions_table": [],
"dynamic_module_utils": [],
"feature_extraction_sequence_utils": ["SequenceFeatureExtractor"],
"feature_extraction_utils": ["BatchFeature", "FeatureExtractionMixin"],
"file_utils": [],
"generation": ["GenerationConfig", "TextIteratorStreamer", "TextStreamer"],
"hf_argparser": ["HfArgumentParser"],
"hyperparameter_search": [],
"image_transforms": [],
"integrations": [
"is_clearml_available",
"is_comet_available",
"is_dvclive_available",
"is_neptune_available",
"is_optuna_available",
"is_ray_available",
"is_ray_tune_available",
"is_sigopt_available",
"is_tensorboard_available",
"is_wandb_available",
],
"modelcard": ["ModelCard"],
"modeling_tf_pytorch_utils": [
"convert_tf_weight_name_to_pt_weight_name",
"load_pytorch_checkpoint_in_tf2_model",
"load_pytorch_model_in_tf2_model",
"load_pytorch_weights_in_tf2_model",
"load_tf2_checkpoint_in_pytorch_model",
"load_tf2_model_in_pytorch_model",
"load_tf2_weights_in_pytorch_model",
],
"models": [],
"models.albert": ["ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "AlbertConfig"],
"models.align": [
"ALIGN_PRETRAINED_CONFIG_ARCHIVE_MAP",
"AlignConfig",
"AlignProcessor",
"AlignTextConfig",
"AlignVisionConfig",
],
"models.altclip": [
"ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP",
"AltCLIPConfig",
"AltCLIPProcessor",
"AltCLIPTextConfig",
"AltCLIPVisionConfig",
],
"models.audio_spectrogram_transformer": [
"AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP",
"ASTConfig",
"ASTFeatureExtractor",
],
"models.auto": [
"ALL_PRETRAINED_CONFIG_ARCHIVE_MAP",
"CONFIG_MAPPING",
"FEATURE_EXTRACTOR_MAPPING",
"IMAGE_PROCESSOR_MAPPING",
"MODEL_NAMES_MAPPING",
"PROCESSOR_MAPPING",
"TOKENIZER_MAPPING",
"AutoConfig",
"AutoFeatureExtractor",
"AutoImageProcessor",
"AutoProcessor",
"AutoTokenizer",
],
"models.autoformer": [
"AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP",
"AutoformerConfig",
],
"models.bark": [
"BarkCoarseConfig",
"BarkConfig",
"BarkFineConfig",
"BarkProcessor",
"BarkSemanticConfig",
],
"models.bart": ["BartConfig", "BartTokenizer"],
"models.barthez": [],
"models.bartpho": [],
"models.beit": ["BEIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "BeitConfig"],
"models.bert": [
"BERT_PRETRAINED_CONFIG_ARCHIVE_MAP",
"BasicTokenizer",
"BertConfig",
"BertTokenizer",
"WordpieceTokenizer",
],
"models.bert_generation": ["BertGenerationConfig"],
"models.bert_japanese": [
"BertJapaneseTokenizer",
"CharacterTokenizer",
"MecabTokenizer",
],
"models.bertweet": ["BertweetTokenizer"],
"models.big_bird": ["BIG_BIRD_PRETRAINED_CONFIG_ARCHIVE_MAP", "BigBirdConfig"],
"models.bigbird_pegasus": [
"BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP",
"BigBirdPegasusConfig",
],
"models.biogpt": [
"BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP",
"BioGptConfig",
"BioGptTokenizer",
],
"models.bit": ["BIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "BitConfig"],
"models.blenderbot": [
"BLENDERBOT_PRETRAINED_CONFIG_ARCHIVE_MAP",
"BlenderbotConfig",
"BlenderbotTokenizer",
],
"models.blenderbot_small": [
"BLENDERBOT_SMALL_PRETRAINED_CONFIG_ARCHIVE_MAP",
"BlenderbotSmallConfig",
"BlenderbotSmallTokenizer",
],
"models.blip": [
"BLIP_PRETRAINED_CONFIG_ARCHIVE_MAP",
"BlipConfig",
"BlipProcessor",
"BlipTextConfig",
"BlipVisionConfig",
],
"models.blip_2": [
"BLIP_2_PRETRAINED_CONFIG_ARCHIVE_MAP",
"Blip2Config",
"Blip2Processor",
"Blip2QFormerConfig",
"Blip2VisionConfig",
],
"models.bloom": ["BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP", "BloomConfig"],
"models.bridgetower": [
"BRIDGETOWER_PRETRAINED_CONFIG_ARCHIVE_MAP",
"BridgeTowerConfig",
"BridgeTowerProcessor",
"BridgeTowerTextConfig",
"BridgeTowerVisionConfig",
],
"models.bros": [
"BROS_PRETRAINED_CONFIG_ARCHIVE_MAP",
"BrosConfig",
"BrosProcessor",
],
"models.byt5": ["ByT5Tokenizer"],
"models.camembert": ["CAMEMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "CamembertConfig"],
"models.clip": [
"CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP",
"CLIPConfig",
"CLIPProcessor",
"CLIPTextConfig",
"CLIPTokenizer",
"CLIPVisionConfig",
],
"models.clipseg": [
"CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP",
"CLIPSegConfig",
"CLIPSegProcessor",
"CLIPSegTextConfig",
"CLIPSegVisionConfig",
],
"models.clvp": [
"CLVP_PRETRAINED_CONFIG_ARCHIVE_MAP",
"ClvpConfig",
"ClvpDecoderConfig",
"ClvpEncoderConfig",
"ClvpFeatureExtractor",
"ClvpProcessor",
"ClvpTokenizer",
],
"models.code_llama": [],
"models.codegen": [
"CODEGEN_PRETRAINED_CONFIG_ARCHIVE_MAP",
"CodeGenConfig",
"CodeGenTokenizer",
],
"models.cohere": ["COHERE_PRETRAINED_CONFIG_ARCHIVE_MAP", "CohereConfig"],
"models.conditional_detr": [
"CONDITIONAL_DETR_PRETRAINED_CONFIG_ARCHIVE_MAP",
"ConditionalDetrConfig",
],
"models.convbert": [
"CONVBERT_PRETRAINED_CONFIG_ARCHIVE_MAP",
"ConvBertConfig",
"ConvBertTokenizer",
],
"models.convnext": ["CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MAP", "ConvNextConfig"],
"models.convnextv2": [
"CONVNEXTV2_PRETRAINED_CONFIG_ARCHIVE_MAP",
"ConvNextV2Config",
],
"models.cpm": [],
"models.cpmant": [
"CPMANT_PRETRAINED_CONFIG_ARCHIVE_MAP",
"CpmAntConfig",
"CpmAntTokenizer",
],
"models.ctrl": [
"CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP",
"CTRLConfig",
"CTRLTokenizer",
],
"models.cvt": ["CVT_PRETRAINED_CONFIG_ARCHIVE_MAP", "CvtConfig"],
"models.data2vec": [
"DATA2VEC_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP",
"DATA2VEC_VISION_PRETRAINED_CONFIG_ARCHIVE_MAP",
"Data2VecAudioConfig",
"Data2VecTextConfig",
"Data2VecVisionConfig",
],
"models.deberta": [
"DEBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP",
"DebertaConfig",
"DebertaTokenizer",
],
"models.deberta_v2": [
"DEBERTA_V2_PRETRAINED_CONFIG_ARCHIVE_MAP",
"DebertaV2Config",
],
"models.decision_transformer": [
"DECISION_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP",
"DecisionTransformerConfig",
],
"models.deformable_detr": [
"DEFORMABLE_DETR_PRETRAINED_CONFIG_ARCHIVE_MAP",
"DeformableDetrConfig",
],
"models.deit": ["DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "DeiTConfig"],
"models.deprecated": [],
"models.deprecated.bort": [],
"models.deprecated.mctct": [
"MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP",
"MCTCTConfig",
"MCTCTFeatureExtractor",
"MCTCTProcessor",
],
"models.deprecated.mmbt": ["MMBTConfig"],
"models.deprecated.open_llama": [
"OPEN_LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP",
"OpenLlamaConfig",
],
注释:
"models.clip": [
"CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP",
"CLIPConfig",
"CLIPProcessor",
"CLIPTextConfig",
"CLIPTokenizer",
"CLIPVisionConfig",
],
"models.clipseg": [
"CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP",
"CLIPSegConfig",
"CLIPSegProcessor",
"CLIPSegTextConfig",
"CLIPSegVisionConfig",
],
"models.clvp": [
"CLVP_PRETRAINED_CONFIG_ARCHIVE_MAP",
"ClvpConfig",
"ClvpDecoderConfig",
"ClvpEncoderConfig",
"ClvpFeatureExtractor",
"ClvpProcessor",
"ClvpTokenizer",
],
"models.code_llama": [],
"models.codegen": [
"CODEGEN_PRETRAINED_CONFIG_ARCHIVE_MAP",
"CodeGenConfig",
"CodeGenTokenizer",
],
"models.cohere": ["COHERE_PRETRAINED_CONFIG_ARCHIVE_MAP", "CohereConfig"],
"models.conditional_detr": [
"CONDITIONAL_DETR_PRETRAINED_CONFIG_ARCHIVE_MAP",
"ConditionalDetrConfig",
],
"models.convbert": [
"CONVBERT_PRETRAINED_CONFIG_ARCHIVE_MAP",
"ConvBertConfig",
"ConvBertTokenizer",
],
"models.convnext": ["CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MAP", "ConvNextConfig"],
"models.convnextv2": [
"CONVNEXTV2_PRETRAINED_CONFIG_ARCHIVE_MAP",
"ConvNextV2Config",
],
"models.cpm": [],
"models.cpmant": [
"CPMANT_PRETRAINED_CONFIG_ARCHIVE_MAP",
"CpmAntConfig",
"CpmAntTokenizer",
],
"models.ctrl": [
"CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP",
"CTRLConfig",
"CTRLTokenizer",
],
"models.cvt": ["CVT_PRETRAINED_CONFIG_ARCHIVE_MAP", "CvtConfig"],
"models.data2vec": [
"DATA2VEC_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP",
"DATA2VEC_VISION_PRETRAINED_CONFIG_ARCHIVE_MAP",
"Data2VecAudioConfig",
"Data2VecTextConfig",
"Data2VecVisionConfig",
],
"models.deberta": [
"DEBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP",
"DebertaConfig",
"DebertaTokenizer",
],
"models.deberta_v2": [
"DEBERTA_V2_PRETRAINED_CONFIG_ARCHIVE_MAP",
"DebertaV2Config",
],
"models.decision_transformer": [
"DECISION_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP",
"DecisionTransformerConfig",
],
"models.deformable_d
{
"models.deprecated.retribert": [
"RETRIBERT_PRETRAINED_CONFIG_ARCHIVE_MAP",
"RetriBertConfig",
"RetriBertTokenizer",
],
"models.deprecated.tapex": ["TapexTokenizer"],
"models.deprecated.trajectory_transformer": [
"TRAJECTORY_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP",
"TrajectoryTransformerConfig",
],
"models.deprecated.transfo_xl": [
"TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP",
"TransfoXLConfig",
"TransfoXLCorpus",
"TransfoXLTokenizer",
],
"models.deprecated.van": ["VAN_PRETRAINED_CONFIG_ARCHIVE_MAP", "VanConfig"],
"models.depth_anything": ["DEPTH_ANYTHING_PRETRAINED_CONFIG_ARCHIVE_MAP", "DepthAnythingConfig"],
"models.deta": ["DETA_PRETRAINED_CONFIG_ARCHIVE_MAP", "DetaConfig"],
"models.detr": ["DETR_PRETRAINED_CONFIG_ARCHIVE_MAP", "DetrConfig"],
"models.dialogpt": [],
"models.dinat": ["DINAT_PRETRAINED_CONFIG_ARCHIVE_MAP", "DinatConfig"],
"models.dinov2": ["DINOV2_PRETRAINED_CONFIG_ARCHIVE_MAP", "Dinov2Config"],
"models.distilbert": [
"DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP",
"DistilBertConfig",
"DistilBertTokenizer",
],
"models.dit": [],
"models.donut": [
"DONUT_SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP",
"DonutProcessor",
"DonutSwinConfig",
],
"models.dpr": [
"DPR_PRETRAINED_CONFIG_ARCHIVE_MAP",
"DPRConfig",
"DPRContextEncoderTokenizer",
"DPRQuestionEncoderTokenizer",
"DPRReaderOutput",
"DPRReaderTokenizer",
],
"models.dpt": ["DPT_PRETRAINED_CONFIG_ARCHIVE_MAP", "DPTConfig"],
"models.efficientformer": [
"EFFICIENTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP",
"EfficientFormerConfig",
],
"models.efficientnet": [
"EFFICIENTNET_PRETRAINED_CONFIG_ARCHIVE_MAP",
"EfficientNetConfig",
],
"models.electra": [
"ELECTRA_PRETRAINED_CONFIG_ARCHIVE_MAP",
"ElectraConfig",
"ElectraTokenizer",
],
"models.encodec": [
"ENCODEC_PRETRAINED_CONFIG_ARCHIVE_MAP",
"EncodecConfig",
"EncodecFeatureExtractor",
],
"models.encoder_decoder": ["EncoderDecoderConfig"],
"models.ernie": [
"ERNIE_PRETRAINED_CONFIG_ARCHIVE_MAP",
"ErnieConfig",
],
"models.ernie_m": ["ERNIE_M_PRETRAINED_CONFIG_ARCHIVE_MAP", "ErnieMConfig"],
"models.esm": ["ESM_PRETRAINED_CONFIG_ARCHIVE_MAP", "EsmConfig", "EsmTokenizer"],
"models.falcon": ["FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP", "FalconConfig"],
"models.fastspeech2_conformer": [
"FASTSPEECH2_CONFORMER_HIFIGAN_PRETRAINED_CONFIG_ARCHIVE_MAP",
"FASTSPEECH2_CONFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP",
"FASTSPEECH2_CONFORMER_WITH_HIFIGAN_PRETRAINED_CONFIG_ARCHIVE_MAP",
"FastSpeech2ConformerConfig",
"FastSpeech2ConformerHifiGanConfig",
"FastSpeech2ConformerTokenizer",
"FastSpeech2ConformerWithHifiGanConfig",
],
}
注释:
# models.deprecated.retribert 模块中的预训练配置映射、RetriBertConfig和RetriBertTokenizer类
{
"models.deprecated.retribert": [
"RETRIBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", # 预训练配置映射
"RetriBertConfig", # RetriBertConfig类
"RetriBertTokenizer", # RetriBertTokenizer类
],
# models.deprecated.tapex 模块中的TapexTokenizer类
"models.deprecated.tapex": ["TapexTokenizer"], # TapexTokenizer类
# models.deprecated.trajectory_transformer 模块中的预训练配置映射和TrajectoryTransformerConfig类
"models.deprecated.trajectory_transformer": [
"TRAJECTORY_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", # 预训练配置映射
"TrajectoryTransformerConfig", # TrajectoryTransformerConfig类
],
# models.deprecated.transfo_xl 模块中的预训练配置映射、TransfoXLConfig类、TransfoXLCorpus类和TransfoXLTokenizer类
"models.deprecated.transfo_xl": [
"TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP", # 预训练配置映射
"TransfoXLConfig", # TransfoXLConfig类
"TransfoXLCorpus", # TransfoXLCorpus类
"TransfoXLTokenizer", # TransfoXLTokenizer类
],
# models.deprecated.van 模块中的预训练配置映射和VanConfig类
"models.deprecated.van": ["VAN_PRETRAINED_CONFIG_ARCHIVE_MAP", "VanConfig"], # 预训练配置映射和VanConfig类
# models.depth_anything 模块中的预训练配置映射和DepthAnythingConfig类
"models.depth_anything": ["DEPTH_ANYTHING_PRETRAINED_CONFIG_ARCHIVE_MAP", "DepthAnythingConfig"], # 预训练配置映射和DepthAnythingConfig类
# models.deta 模块中的预训练配置映射和DetaConfig类
"models.deta": ["DETA_PRETRAINED_CONFIG_ARCHIVE_MAP", "DetaConfig"], # 预训练配置映射和DetaConfig类
# models.detr 模块中的预训练配置映射和DetrConfig类
"models.detr": ["DETR_PRETRAINED_CONFIG_ARCHIVE_MAP", "DetrConfig"], # 预训练配置映射和DetrConfig类
# models.dialogpt 模块为空,没有内容
"models.dialogpt": [], # 空列表,没有内容
# models.dinat 模块中的预训练配置映射和DinatConfig类
"models.dinat": ["DINAT_PRETRAINED_CONFIG_ARCHIVE_MAP", "DinatConfig"], # 预训练配置映射和DinatConfig类
# models.dinov2 模块中的预训练配置映射和Dinov2Config类
"models.dinov2": ["DINOV2_PRETRAINED_CONFIG_ARCHIVE_MAP", "Dinov2Config"], # 预训练配置映射和Dinov2Config类
# models.distilbert 模块中的预训练配置映射、DistilBertConfig类和DistilBertTokenizer类
"models.distilbert": [
"DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", # 预训练配置映射
"DistilBertConfig", # DistilBertConfig类
"DistilBertTokenizer", # DistilBertTokenizer类
],
# models.dit 模块为空,没有内容
"models.dit": [], # 空列表,没有内容
# models.donut 模块中的DonutProcessor类、DonutSwinConfig类和预训练配置映射
"models.donut": [
"DONUT_SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP", # 预训练配置映射
"DonutProcessor", # DonutProcessor类
"DonutSwinConfig", # DonutSwinConfig类
],
# models.dpr 模块中的多个类和预训练配置映射
"models.dpr": [
"DPR_PRETRAINED_CONFIG_ARCHIVE_MAP", # 预训练配置映射
"DPRConfig", # DPRConfig类
"DPRContextEncoderTokenizer", # DPRContextEncoderTokenizer类
"DPRQuestionEncoderTokenizer", # DPRQuestionEncoderTokenizer类
"DPRReaderOutput", # DPRReaderOutput类
"DPRReaderTokenizer", # DPRReaderTokenizer类
],
# models.dpt 模块中的预训练配置映射和DPTConfig
],
# models.flaubert 模块下的常量和类名列表
"models.flaubert": ["FLAUBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "FlaubertConfig", "FlaubertTokenizer"],
# models.flava 模块下的常量和类名列表
"models.flava": [
"FLAVA_PRETRAINED_CONFIG_ARCHIVE_MAP",
"FlavaConfig",
"FlavaImageCodebookConfig",
"FlavaImageConfig",
"FlavaMultimodalConfig",
"FlavaTextConfig",
],
# models.fnet 模块下的常量和类名列表
"models.fnet": ["FNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "FNetConfig"],
# models.focalnet 模块下的常量和类名列表
"models.focalnet": ["FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "FocalNetConfig"],
# models.fsmt 模块下的常量和类名列表
"models.fsmt": [
"FSMT_PRETRAINED_CONFIG_ARCHIVE_MAP",
"FSMTConfig",
"FSMTTokenizer",
],
# models.funnel 模块下的常量和类名列表
"models.funnel": [
"FUNNEL_PRETRAINED_CONFIG_ARCHIVE_MAP",
"FunnelConfig",
"FunnelTokenizer",
],
# models.fuyu 模块下的常量和类名列表
"models.fuyu": ["FUYU_PRETRAINED_CONFIG_ARCHIVE_MAP", "FuyuConfig"],
# models.gemma 模块下的常量和类名列表
"models.gemma": ["GEMMA_PRETRAINED_CONFIG_ARCHIVE_MAP", "GemmaConfig"],
# models.git 模块下的常量和类名列表
"models.git": [
"GIT_PRETRAINED_CONFIG_ARCHIVE_MAP",
"GitConfig",
"GitProcessor",
"GitVisionConfig",
],
# models.glpn 模块下的常量和类名列表
"models.glpn": ["GLPN_PRETRAINED_CONFIG_ARCHIVE_MAP", "GLPNConfig"],
# models.gpt2 模块下的常量和类名列表
"models.gpt2": [
"GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP",
"GPT2Config",
"GPT2Tokenizer",
],
# models.gpt_bigcode 模块下的常量和类名列表
"models.gpt_bigcode": [
"GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP",
"GPTBigCodeConfig",
],
# models.gpt_neo 模块下的常量和类名列表
"models.gpt_neo": ["GPT_NEO_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTNeoConfig"],
# models.gpt_neox 模块下的常量和类名列表
"models.gpt_neox": ["GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTNeoXConfig"],
# models.gpt_neox_japanese 模块下的常量和类名列表
"models.gpt_neox_japanese": [
"GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP",
"GPTNeoXJapaneseConfig",
],
# models.gpt_sw3 模块下的空列表,无常量和类名
"models.gpt_sw3": [],
# models.gptj 模块下的常量和类名列表
"models.gptj": ["GPTJ_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTJConfig"],
# models.gptsan_japanese 模块下的常量和类名列表
"models.gptsan_japanese": [
"GPTSAN_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP",
"GPTSanJapaneseConfig",
"GPTSanJapaneseTokenizer",
],
# models.graphormer 模块下的常量和类名列表
"models.graphormer": [
"GRAPHORMER_PRETRAINED_CONFIG_ARCHIVE_MAP",
"GraphormerConfig",
],
# models.groupvit 模块下的常量和类名列表
"models.groupvit": [
"GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP",
"GroupViTConfig",
"GroupViTTextConfig",
"GroupViTVisionConfig",
],
# models.herbert 模块下的常量和类名列表
"models.herbert": ["HerbertTokenizer"],
# models.hubert 模块下的常量和类名列表
"models.hubert": ["HUBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "HubertConfig"],
# models.ibert 模块下的常量和类名列表
"models.ibert": ["IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "IBertConfig"],
# models.idefics 模块下的常量和类名列表
"models.idefics": [
"IDEFICS_PRETRAINED_CONFIG_ARCHIVE_MAP",
"IdeficsConfig",
],
# models.imagegpt 模块下的常量和类名列表
"models.imagegpt": ["IMAGEGPT_PRETRAINED_CONFIG_ARCHIVE_MAP", "ImageGPTConfig"],
# models.informer 模块下的常量和类名列表
"models.informer": ["INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "InformerConfig"],
# models.instructblip 模块下的常量和类名列表
"models.instructblip": [
"INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP",
"InstructBlipConfig",
"InstructBlipProcessor",
"InstructBlipQFormerConfig",
"InstructBlipVisionConfig",
],
{
"models.jukebox": [
"JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP", # 音乐盒预训练配置文件映射
"JukeboxConfig", # 音乐盒配置
"JukeboxPriorConfig", # 音乐盒先验配置
"JukeboxTokenizer", # 音乐盒分词器
"JukeboxVQVAEConfig", # 音乐盒VQ-VAE配置
],
"models.kosmos2": [
"KOSMOS2_PRETRAINED_CONFIG_ARCHIVE_MAP", # Kosmos2预训练配置文件映射
"Kosmos2Config", # Kosmos2配置
"Kosmos2Processor", # Kosmos2处理器
],
"models.layoutlm": [
"LAYOUTLM_PRETRAINED_CONFIG_ARCHIVE_MAP", # LayoutLM预训练配置文件映射
"LayoutLMConfig", # LayoutLM配置
"LayoutLMTokenizer", # LayoutLM分词器
],
"models.layoutlmv2": [
"LAYOUTLMV2_PRETRAINED_CONFIG_ARCHIVE_MAP", # LayoutLMv2预训练配置文件映射
"LayoutLMv2Config", # LayoutLMv2配置
"LayoutLMv2FeatureExtractor", # LayoutLMv2特征提取器
"LayoutLMv2ImageProcessor", # LayoutLMv2图像处理器
"LayoutLMv2Processor", # LayoutLMv2处理器
"LayoutLMv2Tokenizer", # LayoutLMv2分词器
],
"models.layoutlmv3": [
"LAYOUTLMV3_PRETRAINED_CONFIG_ARCHIVE_MAP", # LayoutLMv3预训练配置文件映射
"LayoutLMv3Config", # LayoutLMv3配置
"LayoutLMv3FeatureExtractor", # LayoutLMv3特征提取器
"LayoutLMv3ImageProcessor", # LayoutLMv3图像处理器
"LayoutLMv3Processor", # LayoutLMv3处理器
"LayoutLMv3Tokenizer", # LayoutLMv3分词器
],
"models.layoutxlm": ["LayoutXLMProcessor"], # LayoutXLM处理器
"models.led": [
"LED_PRETRAINED_CONFIG_ARCHIVE_MAP", # LED预训练配置文件映射
"LEDConfig", # LED配置
"LEDTokenizer", # LED分词器
],
"models.levit": ["LEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP", # Levit预训练配置文件映射
"LevitConfig"], # Levit配置
"models.lilt": ["LILT_PRETRAINED_CONFIG_ARCHIVE_MAP", # Lilt预训练配置文件映射
"LiltConfig"], # Lilt配置
"models.llama": ["LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP", # Llama预训练配置文件映射
"LlamaConfig"], # Llama配置
"models.llava": [
"LLAVA_PRETRAINED_CONFIG_ARCHIVE_MAP", # Llava预训练配置文件映射
"LlavaConfig", # Llava配置
"LlavaProcessor", # Llava处理器
],
"models.llava_next": [
"LLAVA_NEXT_PRETRAINED_CONFIG_ARCHIVE_MAP", # Llava Next预训练配置文件映射
"LlavaNextConfig", # Llava Next配置
"LlavaNextProcessor", # Llava Next处理器
],
"models.longformer": [
"LONGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", # Longformer预训练配置文件映射
"LongformerConfig", # Longformer配置
"LongformerTokenizer", # Longformer分词器
],
"models.longt5": ["LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP", # LongT5预训练配置文件映射
"LongT5Config"], # LongT5配置
"models.luke": [
"LUKE_PRETRAINED_CONFIG_ARCHIVE_MAP", # LUKE预训练配置文件映射
"LukeConfig", # LUKE配置
"LukeTokenizer", # LUKE分词器
],
"models.lxmert": [
"LXMERT_PRETRAINED_CONFIG_ARCHIVE_MAP", # LXMERT预训练配置文件映射
"LxmertConfig", # LXMERT配置
"LxmertTokenizer", # LXMERT分词器
],
"models.m2m_100": ["M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP", # M2M-100预训练配置文件映射
"M2M100Config"], # M2M-100配置
"models.mamba": ["MAMBA_PRETRAINED_CONFIG_ARCHIVE_MAP", # Mamba预训练配置文件映射
"MambaConfig"], # Mamba配置
"models.marian": ["MarianConfig"], # Marian配置
"models.markuplm": [
"MARKUPLM_PRETRAINED_CONFIG_ARCHIVE_MAP", # MarkupLM预训练配置文件映射
"MarkupLMConfig", # MarkupLM配置
"MarkupLMFeatureExtractor", # MarkupLM特征提取器
"MarkupLMProcessor", # MarkupLM处理器
"MarkupLMTokenizer", # MarkupLM分词器
],
"models.mask2former": [
"MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", # Mask2Former预训练配置文件映射
"Mask2FormerConfig", # Mask2Former配置
],
"models.maskformer": [
"MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", # MaskFormer预训练配置文件映射
"MaskFormerConfig", # MaskFormer配置
"MaskFormerSwinConfig", # MaskFormerSwin配置
],
"models.mbart": ["MBartConfig"], # MBart配置
"models.mbart50": [], # MBart50
"models.mega": ["MEGA_PRETRAINED_CONFIG_ARCHIVE_MAP", # Mega预训练配置文件映射
"MegaConfig"], # Mega配置
"models.megatron_bert": [
"MEGATRON_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP", # Megatron BERT预训练配置文件映射
"MegatronBertConfig", # Megatron BERT配置
],
}
# 定义一个字典,包含了多个模型名称和它们对应的空列表
{
"models.megatron_gpt2": [],
"models.mgp_str": [
"MGP_STR_PRETRAINED_CONFIG_ARCHIVE_MAP", # 预训练配置文件映射
"MgpstrConfig", # MGPSTR 配置类
"MgpstrProcessor", # MGPSTR 处理器类
"MgpstrTokenizer", # MGPSTR 分词器类
],
"models.mistral": [
"MISTRAL_PRETRAINED_CONFIG_ARCHIVE_MAP", # 预训练配置文件映射
"MistralConfig", # Mistral 配置类
],
"models.mixtral": [
"MIXTRAL_PRETRAINED_CONFIG_ARCHIVE_MAP", # 预训练配置文件映射
"MixtralConfig", # Mixtral 配置类
],
"models.mluke": [], # mluke 模型,空列表
"models.mobilebert": [
"MOBILEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", # 预训练配置文件映射
"MobileBertConfig", # MobileBERT 配置类
"MobileBertTokenizer", # MobileBERT 分词器类
],
"models.mobilenet_v1": [
"MOBILENET_V1_PRETRAINED_CONFIG_ARCHIVE_MAP", # 预训练配置文件映射
"MobileNetV1Config", # MobileNetV1 配置类
],
"models.mobilenet_v2": [
"MOBILENET_V2_PRETRAINED_CONFIG_ARCHIVE_MAP", # 预训练配置文件映射
"MobileNetV2Config", # MobileNetV2 配置类
],
"models.mobilevit": [
"MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP", # 预训练配置文件映射
"MobileViTConfig", # MobileViT 配置类
],
"models.mobilevitv2": [
"MOBILEVITV2_PRETRAINED_CONFIG_ARCHIVE_MAP", # 预训练配置文件映射
"MobileViTV2Config", # MobileViTV2 配置类
],
"models.mpnet": [
"MPNET_PRETRAINED_CONFIG_ARCHIVE_MAP", # 预训练配置文件映射
"MPNetConfig", # MPNet 配置类
"MPNetTokenizer", # MPNet 分词器类
],
"models.mpt": [
"MPT_PRETRAINED_CONFIG_ARCHIVE_MAP", # 预训练配置文件映射
"MptConfig", # MPT 配置类
],
"models.mra": [
"MRA_PRETRAINED_CONFIG_ARCHIVE_MAP", # 预训练配置文件映射
"MraConfig", # MRA 配置类
],
"models.mt5": [
"MT5Config", # MT5 配置类
],
"models.musicgen": [
"MUSICGEN_PRETRAINED_CONFIG_ARCHIVE_MAP", # 预训练配置文件映射
"MusicgenConfig", # Musicgen 配置类
"MusicgenDecoderConfig", # Musicgen 解码器配置类
],
"models.musicgen_melody": [
"MUSICGEN_MELODY_PRETRAINED_MODEL_ARCHIVE_LIST", # 预训练模型存档列表
"MusicgenMelodyConfig", # Musicgen Melody 配置类
"MusicgenMelodyDecoderConfig", # Musicgen Melody 解码器配置类
],
"models.mvp": [
"MvpConfig", # MVP 配置类
"MvpTokenizer", # MVP 分词器类
],
"models.nat": [
"NAT_PRETRAINED_CONFIG_ARCHIVE_MAP", # 预训练配置文件映射
"NatConfig", # Nat 配置类
],
"models.nezha": [
"NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP", # 预训练配置文件映射
"NezhaConfig", # Nezha 配置类
],
"models.nllb": [], # nllb 模型,空列表
"models.nllb_moe": [
"NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP", # 预训练配置文件映射
"NllbMoeConfig", # NLLB MOE 配置类
],
"models.nougat": [
"NougatProcessor", # Nougat 处理器类
],
"models.nystromformer": [
"NYSTROMFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", # 预训练配置文件映射
"NystromformerConfig", # Nystromformer 配置类
],
"models.oneformer": [
"ONEFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", # 预训练配置文件映射
"OneFormerConfig", # Oneformer 配置类
"OneFormerProcessor", # Oneformer 处理器类
],
"models.openai": [
"OPENAI_GPT_PRETRAINED_CONFIG_ARCHIVE_MAP", # 预训练配置文件映射
"OpenAIGPTConfig", # OpenAI GPT 配置类
"OpenAIGPTTokenizer", # OpenAI GPT 分词器类
],
"models.opt": [
"OPTConfig", # OPT 配置类
],
"models.owlv2": [
"OWLV2_PRETRAINED_CONFIG_ARCHIVE_MAP", # 预训练配置文件映射
"Owlv2Config", # Owlv2 配置类
"Owlv2Processor", # Owlv2 处理器类
"Owlv2TextConfig", # Owlv2 文本配置类
"Owlv2VisionConfig", # Owlv2 视觉配置类
],
"models.owlvit": [
"OWLVIT_PRETRAINED_CONFIG_ARCHIVE_MAP", # 预训练配置文件映射
"OwlViTConfig", # Owlvit 配置类
"OwlViTProcessor", # Owlvit 处理器类
"OwlViTTextConfig", # Owlvit 文本配置类
"OwlViTVisionConfig", # Owlvit 视觉配置类
],
"models.patchtsmixer": [
"PATCHTSMIXER_PRETRAINED_CONFIG_ARCHIVE_MAP", # 预训练配置文件映射
"PatchTSMixerConfig", # PatchTSMixer 配置类
],
"models.patchtst": [
"PATCHTST_PRETRAINED_CONFIG_ARCHIVE_MAP", # 预训练配置文件映射
"PatchTSTConfig", # PatchTST 配置类
],
}
"models.pegasus": [
"PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP",
"PegasusConfig",
"PegasusTokenizer",
],
"models.pegasus_x": ["PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP", "PegasusXConfig"],
"models.perceiver": [
"PERCEIVER_PRETRAINED_CONFIG_ARCHIVE_MAP",
"PerceiverConfig",
"PerceiverTokenizer",
],
"models.persimmon": ["PERSIMMON_PRETRAINED_CONFIG_ARCHIVE_MAP", "PersimmonConfig"],
"models.phi": ["PHI_PRETRAINED_CONFIG_ARCHIVE_MAP", "PhiConfig"],
"models.phobert": ["PhobertTokenizer"],
"models.pix2struct": [
"PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP",
"Pix2StructConfig",
"Pix2StructProcessor",
"Pix2StructTextConfig",
"Pix2StructVisionConfig",
],
"models.plbart": ["PLBART_PRETRAINED_CONFIG_ARCHIVE_MAP", "PLBartConfig"],
"models.poolformer": [
"POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP",
"PoolFormerConfig",
],
"models.pop2piano": [
"POP2PIANO_PRETRAINED_CONFIG_ARCHIVE_MAP",
"Pop2PianoConfig",
],
"models.prophetnet": [
"PROPHETNET_PRETRAINED_CONFIG_ARCHIVE_MAP",
"ProphetNetConfig",
"ProphetNetTokenizer",
],
"models.pvt": ["PVT_PRETRAINED_CONFIG_ARCHIVE_MAP", "PvtConfig"],
"models.pvt_v2": ["PVT_V2_PRETRAINED_CONFIG_ARCHIVE_MAP", "PvtV2Config"],
"models.qdqbert": ["QDQBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "QDQBertConfig"],
"models.qwen2": [
"QWEN2_PRETRAINED_CONFIG_ARCHIVE_MAP",
"Qwen2Config",
"Qwen2Tokenizer",
],
"models.rag": ["RagConfig", "RagRetriever", "RagTokenizer"],
"models.realm": [
"REALM_PRETRAINED_CONFIG_ARCHIVE_MAP",
"RealmConfig",
"RealmTokenizer",
],
"models.reformer": ["REFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "ReformerConfig"],
"models.regnet": ["REGNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "RegNetConfig"],
"models.rembert": ["REMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "RemBertConfig"],
"models.resnet": ["RESNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "ResNetConfig"],
"models.roberta": [
"ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP",
"RobertaConfig",
"RobertaTokenizer",
],
"models.roberta_prelayernorm": [
"ROBERTA_PRELAYERNORM_PRETRAINED_CONFIG_ARCHIVE_MAP",
"RobertaPreLayerNormConfig",
],
"models.roc_bert": [
"ROC_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP",
"RoCBertConfig",
"RoCBertTokenizer",
],
"models.roformer": [
"ROFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP",
"RoFormerConfig",
"RoFormerTokenizer",
],
"models.rwkv": ["RWKV_PRETRAINED_CONFIG_ARCHIVE_MAP", "RwkvConfig"],
"models.sam": [
"SAM_PRETRAINED_CONFIG_ARCHIVE_MAP",
"SamConfig",
"SamMaskDecoderConfig",
"SamProcessor",
"SamPromptEncoderConfig",
"SamVisionConfig",
],
# 以下是一系列模型和相关的配置映射、配置类或者分词器的定义,每个条目对应于一个模型或者组件
"models.pegasus": [
"PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP",
"PegasusConfig",
"PegasusTokenizer",
],
# Pegasus 模型及其相关配置和分词器
"models.pegasus_x": ["PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP", "PegasusXConfig"],
# PegasusX 模型及其相关配置
"models.perceiver": [
"PERCEIVER_PRETRAINED_CONFIG_ARCHIVE_MAP",
"PerceiverConfig",
"PerceiverTokenizer",
],
# Perceiver 模型及其相关配置和分词器
"models.persimmon": ["PERSIMMON_PRETRAINED_CONFIG_ARCHIVE_MAP", "PersimmonConfig"],
# Persimmon 模型及其相关配置
"models.phi": ["PHI_PRETRAINED_CONFIG_ARCHIVE_MAP", "PhiConfig"],
# Phi 模型及其相关配置
"models.phobert": ["PhobertTokenizer"],
# Phobert 分词器
"models.pix2struct": [
"PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP",
"Pix2StructConfig",
"Pix2StructProcessor",
"Pix2StructTextConfig",
"Pix2StructVisionConfig",
],
# Pix2Struct 模型及其相关配置和处理器
"models.plbart": ["PLBART_PRETRAINED_CONFIG_ARCHIVE_MAP", "PLBartConfig"],
# PLBart 模型及其相关配置
"models.poolformer": [
"POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP",
"PoolFormerConfig",
],
# PoolFormer 模型及其相关配置
"models.pop2piano": [
"POP2PIANO_PRETRAINED_CONFIG_ARCHIVE_MAP",
"Pop2PianoConfig",
],
# Pop2Piano 模型及其相关配置
"models.prophetnet": [
"PROPHETNET_PRETRAINED_CONFIG_ARCHIVE_MAP",
"ProphetNetConfig",
"ProphetNetTokenizer",
],
# ProphetNet 模型及其相关配置和分词器
"models.pvt": ["PVT_PRETRAINED_CONFIG_ARCHIVE_MAP", "PvtConfig"],
# Pvt 模型及其相关配置
"models.pvt_v2": ["PVT_V2_PRETRAINED_CONFIG_ARCHIVE_MAP", "PvtV2Config"],
# PvtV2 模型及其相关配置
"models.qdqbert": ["QDQBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "QDQBertConfig"],
# QDQBert 模型及其相关配置
"models.qwen2": [
"QWEN2_PRETRAINED_CONFIG_ARCHIVE_MAP",
"Qwen2Config",
"Qwen2Tokenizer",
],
# Qwen2 模型及其相关配置和分词器
"models.rag": ["RagConfig", "RagRetriever", "RagTokenizer"],
# Rag 模型及其相关配置和检索器
"models.realm": [
"REALM_PRETRAINED_CONFIG_ARCHIVE_MAP",
"RealmConfig",
"RealmTokenizer",
],
# Realm 模型及其相关配置和分词器
"models.reformer": ["REFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "ReformerConfig"],
# Reformer 模型及其相关配置
"models.regnet": ["REGNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "RegNetConfig"],
# RegNet 模型及其相关配置
"models.rembert": ["REMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "RemBertConfig"],
# RemBert 模型及其相关配置
"models.resnet": ["RESNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "ResNetConfig"],
# ResNet 模型及其相关配置
"models.roberta": [
"ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP",
"RobertaConfig",
"RobertaTokenizer",
],
# Roberta 模型及其相关配置和分词器
"models.roberta_prelayernorm": [
"ROBERTA_PRELAYERNORM_PRETRAINED_CONFIG_ARCHIVE_MAP",
"RobertaPreLayerNormConfig",
],
# Roberta with PreLayerNorm 模型及其相关配置
"models.roc_bert": [
"ROC_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP",
"RoCBertConfig",
"RoCBertTokenizer",
],
# RoCBert 模型及其相关配置和分词器
"models.roformer": [
"ROFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP",
"RoFormerConfig",
"RoFormerTokenizer",
],
# RoFormer 模型及其相关配置和分词器
"models.rwkv": ["RWKV_PRETRAINED_CONFIG_ARCHIVE_MAP", "RwkvConfig"],
# Rwkv 模型及其相关配置
"models.sam": [
"SAM_PRETRAINED_CONFIG_ARCHIVE_MAP",
"SamConfig",
"SamMaskDecoderConfig",
"SamProcessor",
"SamPromptEncoderConfig",
"SamVisionConfig",
],
# Sam 模型及其相关配置和处理器、编码器、视觉配置
# 定义了多个模型及其相关配置和工具的映射关系,每个键对应一个模型的相关信息列表
"models.seamless_m4t": [
"SEAMLESS_M4T_PRETRAINED_CONFIG_ARCHIVE_MAP", # SEAMLESS_M4T 的预训练配置文件映射
"SeamlessM4TConfig", # SEAMLESS_M4T 的配置类
"SeamlessM4TFeatureExtractor", # SEAMLESS_M4T 的特征提取器类
"SeamlessM4TProcessor", # SEAMLESS_M4T 的处理器类
],
"models.seamless_m4t_v2": [
"SEAMLESS_M4T_V2_PRETRAINED_CONFIG_ARCHIVE_MAP", # SEAMLESS_M4T_V2 的预训练配置文件映射
"SeamlessM4Tv2Config", # SEAMLESS_M4T_V2 的配置类
],
"models.segformer": [
"SEGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", # SEGFORMER 的预训练配置文件映射
"SegformerConfig", # SEGFORMER 的配置类
],
"models.seggpt": [
"SEGGPT_PRETRAINED_CONFIG_ARCHIVE_MAP", # SEGGPT 的预训练配置文件映射
"SegGptConfig", # SEGGPT 的配置类
],
"models.sew": [
"SEW_PRETRAINED_CONFIG_ARCHIVE_MAP", # SEW 的预训练配置文件映射
"SEWConfig", # SEW 的配置类
],
"models.sew_d": [
"SEW_D_PRETRAINED_CONFIG_ARCHIVE_MAP", # SEW_D 的预训练配置文件映射
"SEWDConfig", # SEW_D 的配置类
],
"models.siglip": [
"SIGLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", # SIGLIP 的预训练配置文件映射
"SiglipConfig", # SIGLIP 的配置类
"SiglipProcessor", # SIGLIP 的处理器类
"SiglipTextConfig", # SIGLIP 文本处理的配置类
"SiglipVisionConfig", # SIGLIP 视觉处理的配置类
],
"models.speech_encoder_decoder": [
"SpeechEncoderDecoderConfig", # 语音编解码器的配置类
],
"models.speech_to_text": [
"SPEECH_TO_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP", # 语音到文本的预训练配置文件映射
"Speech2TextConfig", # 语音到文本的配置类
"Speech2TextFeatureExtractor", # 语音到文本的特征提取器类
"Speech2TextProcessor", # 语音到文本的处理器类
],
"models.speech_to_text_2": [
"SPEECH_TO_TEXT_2_PRETRAINED_CONFIG_ARCHIVE_MAP", # 语音到文本2的预训练配置文件映射
"Speech2Text2Config", # 语音到文本2的配置类
"Speech2Text2Processor", # 语音到文本2的处理器类
"Speech2Text2Tokenizer", # 语音到文本2的分词器类
],
"models.speecht5": [
"SPEECHT5_PRETRAINED_CONFIG_ARCHIVE_MAP", # SPEECHT5 的预训练配置文件映射
"SPEECHT5_PRETRAINED_HIFIGAN_CONFIG_ARCHIVE_MAP", # SPEECHT5 HiFiGAN 的预训练配置文件映射
"SpeechT5Config", # SPEECHT5 的配置类
"SpeechT5FeatureExtractor", # SPEECHT5 的特征提取器类
"SpeechT5HifiGanConfig", # SPEECHT5 HiFiGAN 的配置类
"SpeechT5Processor", # SPEECHT5 的处理器类
],
"models.splinter": [
"SPLINTER_PRETRAINED_CONFIG_ARCHIVE_MAP", # SPLINTER 的预训练配置文件映射
"SplinterConfig", # SPLINTER 的配置类
"SplinterTokenizer", # SPLINTER 的分词器类
],
"models.squeezebert": [
"SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", # SQUEEZEBERT 的预训练配置文件映射
"SqueezeBertConfig", # SQUEEZEBERT 的配置类
"SqueezeBertTokenizer", # SQUEEZEBERT 的分词器类
],
"models.stablelm": [
"STABLELM_PRETRAINED_CONFIG_ARCHIVE_MAP", # STABLELM 的预训练配置文件映射
"StableLmConfig", # STABLELM 的配置类
],
"models.starcoder2": [
"STARCODER2_PRETRAINED_CONFIG_ARCHIVE_MAP", # STARCODER2 的预训练配置文件映射
"Starcoder2Config", # STARCODER2 的配置类
],
"models.superpoint": [
"SUPERPOINT_PRETRAINED_CONFIG_ARCHIVE_MAP", # SUPERPOINT 的预训练配置文件映射
"SuperPointConfig", # SUPERPOINT 的配置类
],
"models.swiftformer": [
"SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", # SWIFTFORMER 的预训练配置文件映射
"SwiftFormerConfig", # SWIFTFORMER 的配置类
],
"models.swin": [
"SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP", # SWIN 的预训练配置文件映射
"SwinConfig", # SWIN 的配置类
],
"models.swin2sr": [
"SWIN2SR_PRETRAINED_CONFIG_ARCHIVE_MAP", # SWIN2SR 的预训练配置文件映射
"Swin2SRConfig", # SWIN2SR 的配置类
],
"models.swinv2": [
"SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP", # SWINV2 的预训练配置文件映射
"Swinv2Config", # SWINV2 的配置类
],
"models.switch_transformers": [
"SWITCH_TRANSFORMERS_PRETRAINED_CONFIG_ARCHIVE_MAP", # SWITCH_TRANSFORMERS 的预训练配置文件映射
"SwitchTransformersConfig", # SWITCH_TRANSFORMERS 的配置类
],
"models.t5": [
"T5_PRETRAINED_CONFIG_ARCHIVE_MAP", # T5 的预训练配置文件映射
"T5Config", # T5 的配置类
],
"models.table_transformer": [
"TABLE_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", # TABLE_TRANSFORMER 的预训练配置文件映射
"TableTransformerConfig", # TABLE_TRANSFORMER 的配置类
],
"models.tapas": [
"TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP", # TAPAS 的预训练配置文件映射
"TapasConfig", # TAPAS 的配置类
"TapasTokenizer", # TAPAS 的分词器类
],
# 导入模型 "models.time_series_transformer" 的相关配置和类名
"models.time_series_transformer": [
"TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP",
"TimeSeriesTransformerConfig",
],
# 导入模型 "models.timesformer" 的相关配置和类名
"models.timesformer": [
"TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP",
"TimesformerConfig",
],
# 导入模型 "models.timm_backbone" 的相关配置类名
"models.timm_backbone": ["TimmBackboneConfig"],
# 导入模型 "models.trocr" 的相关配置、类名和处理器名
"models.trocr": [
"TROCR_PRETRAINED_CONFIG_ARCHIVE_MAP",
"TrOCRConfig",
"TrOCRProcessor",
],
# 导入模型 "models.tvlt" 的相关配置、类名和特征提取器、处理器名
"models.tvlt": [
"TVLT_PRETRAINED_CONFIG_ARCHIVE_MAP",
"TvltConfig",
"TvltFeatureExtractor",
"TvltProcessor",
],
# 导入模型 "models.tvp" 的相关配置、类名和处理器名
"models.tvp": [
"TVP_PRETRAINED_CONFIG_ARCHIVE_MAP",
"TvpConfig",
"TvpProcessor",
],
# 导入模型 "models.udop" 的相关配置、类名和处理器名
"models.udop": [
"UDOP_PRETRAINED_CONFIG_ARCHIVE_MAP",
"UdopConfig",
"UdopProcessor",
],
# 导入模型 "models.umt5" 的相关配置类名
"models.umt5": ["UMT5Config"],
# 导入模型 "models.unispeech" 的相关配置和类名
"models.unispeech": [
"UNISPEECH_PRETRAINED_CONFIG_ARCHIVE_MAP",
"UniSpeechConfig",
],
# 导入模型 "models.unispeech_sat" 的相关配置和类名
"models.unispeech_sat": [
"UNISPEECH_SAT_PRETRAINED_CONFIG_ARCHIVE_MAP",
"UniSpeechSatConfig",
],
# 导入模型 "models.univnet" 的相关配置、类名和特征提取器名
"models.univnet": [
"UNIVNET_PRETRAINED_CONFIG_ARCHIVE_MAP",
"UnivNetConfig",
"UnivNetFeatureExtractor",
],
# 导入模型 "models.upernet" 的相关配置类名
"models.upernet": ["UperNetConfig"],
# 导入模型 "models.videomae" 的相关配置类名
"models.videomae": ["VIDEOMAE_PRETRAINED_CONFIG_ARCHIVE_MAP", "VideoMAEConfig"],
# 导入模型 "models.vilt" 的相关配置、类名和特征提取器、图像处理器、处理器名
"models.vilt": [
"VILT_PRETRAINED_CONFIG_ARCHIVE_MAP",
"ViltConfig",
"ViltFeatureExtractor",
"ViltImageProcessor",
"ViltProcessor",
],
# 导入模型 "models.vipllava" 的相关配置和类名
"models.vipllava": [
"VIPLLAVA_PRETRAINED_CONFIG_ARCHIVE_MAP",
"VipLlavaConfig",
],
# 导入模型 "models.vision_encoder_decoder" 的相关配置类名
"models.vision_encoder_decoder": ["VisionEncoderDecoderConfig"],
# 导入模型 "models.vision_text_dual_encoder" 的相关配置和类名
"models.vision_text_dual_encoder": [
"VisionTextDualEncoderConfig",
"VisionTextDualEncoderProcessor",
],
# 导入模型 "models.visual_bert" 的相关配置和类名
"models.visual_bert": [
"VISUAL_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP",
"VisualBertConfig",
],
# 导入模型 "models.vit" 的相关配置类名
"models.vit": ["VIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "ViTConfig"],
# 导入模型 "models.vit_hybrid" 的相关配置类名
"models.vit_hybrid": [
"VIT_HYBRID_PRETRAINED_CONFIG_ARCHIVE_MAP",
"ViTHybridConfig",
],
# 导入模型 "models.vit_mae" 的相关配置类名
"models.vit_mae": ["VIT_MAE_PRETRAINED_CONFIG_ARCHIVE_MAP", "ViTMAEConfig"],
# 导入模型 "models.vit_msn" 的相关配置类名
"models.vit_msn": ["VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP", "ViTMSNConfig"],
# 导入模型 "models.vitdet" 的相关配置类名
"models.vitdet": ["VITDET_PRETRAINED_CONFIG_ARCHIVE_MAP", "VitDetConfig"],
# 导入模型 "models.vitmatte" 的相关配置类名
"models.vitmatte": ["VITMATTE_PRETRAINED_CONFIG_ARCHIVE_MAP", "VitMatteConfig"],
# 导入模型 "models.vits" 的相关配置、类名和分词器、处理器名
"models.vits": [
"VITS_PRETRAINED_CONFIG_ARCHIVE_MAP",
"VitsConfig",
"VitsTokenizer",
],
# 导入模型 "models.vivit" 的相关配置和类名
"models.vivit": [
"VIVIT_PRETRAINED_CONFIG_ARCHIVE_MAP",
"VivitConfig",
],
# 导入模型 "models.wav2vec2" 的相关配置、类名和CTC标记器、特征提取器、处理器、分词器名
"models.wav2vec2": [
"WAV_2_VEC_2_PRETRAINED_CONFIG_ARCHIVE_MAP",
"Wav2Vec2Config",
"Wav2Vec2CTCTokenizer",
"Wav2Vec2FeatureExtractor",
"Wav2Vec2Processor",
"Wav2Vec2Tokenizer",
],
"models.wav2vec2_bert": [
"WAV2VEC2_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP", # WAV2VEC2_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP 是 models.wav2vec2_bert 的预训练配置映射
"Wav2Vec2BertConfig", # Wav2Vec2BertConfig 是用于 models.wav2vec2_bert 的配置类
"Wav2Vec2BertProcessor", # Wav2Vec2BertProcessor 是处理 models.wav2vec2_bert 的处理器类
],
"models.wav2vec2_conformer": [
"WAV2VEC2_CONFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", # WAV2VEC2_CONFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP 是 models.wav2vec2_conformer 的预训练配置映射
"Wav2Vec2ConformerConfig", # Wav2Vec2ConformerConfig 是用于 models.wav2vec2_conformer 的配置类
],
"models.wav2vec2_phoneme": ["Wav2Vec2PhonemeCTCTokenizer"], # Wav2Vec2PhonemeCTCTokenizer 是 models.wav2vec2_phoneme 的音素 CTC 分词器类
"models.wav2vec2_with_lm": ["Wav2Vec2ProcessorWithLM"], # Wav2Vec2ProcessorWithLM 是带有语言模型的 models.wav2vec2_with_lm 的处理器类
"models.wavlm": [
"WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP", # WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP 是 models.wavlm 的预训练配置映射
"WavLMConfig", # WavLMConfig 是用于 models.wavlm 的配置类
],
"models.whisper": [
"WHISPER_PRETRAINED_CONFIG_ARCHIVE_MAP", # WHISPER_PRETRAINED_CONFIG_ARCHIVE_MAP 是 models.whisper 的预训练配置映射
"WhisperConfig", # WhisperConfig 是用于 models.whisper 的配置类
"WhisperFeatureExtractor", # WhisperFeatureExtractor 是用于 models.whisper 的特征提取器类
"WhisperProcessor", # WhisperProcessor 是处理 models.whisper 的处理器类
"WhisperTokenizer", # WhisperTokenizer 是 models.whisper 的分词器类
],
"models.x_clip": [
"XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", # XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP 是 models.x_clip 的预训练配置映射
"XCLIPConfig", # XCLIPConfig 是用于 models.x_clip 的配置类
"XCLIPProcessor", # XCLIPProcessor 是处理 models.x_clip 的处理器类
"XCLIPTextConfig", # XCLIPTextConfig 是 models.x_clip 的文本配置类
"XCLIPVisionConfig", # XCLIPVisionConfig 是 models.x_clip 的视觉配置类
],
"models.xglm": ["XGLM_PRETRAINED_CONFIG_ARCHIVE_MAP", "XGLMConfig"], # XGLM_PRETRAINED_CONFIG_ARCHIVE_MAP 是 models.xglm 的预训练配置映射,XGLMConfig 是用于 models.xglm 的配置类
"models.xlm": ["XLM_PRETRAINED_CONFIG_ARCHIVE_MAP", "XLMConfig", "XLMTokenizer"], # XLM_PRETRAINED_CONFIG_ARCHIVE_MAP 是 models.xlm 的预训练配置映射,XLMConfig 是用于 models.xlm 的配置类,XLMTokenizer 是 models.xlm 的分词器类
"models.xlm_prophetnet": [
"XLM_PROPHETNET_PRETRAINED_CONFIG_ARCHIVE_MAP", # XLM_PROPHETNET_PRETRAINED_CONFIG_ARCHIVE_MAP 是 models.xlm_prophetnet 的预训练配置映射
"XLMProphetNetConfig", # XLMProphetNetConfig 是用于 models.xlm_prophetnet 的配置类
],
"models.xlm_roberta": [
"XLM_ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP", # XLM_ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP 是 models.xlm_roberta 的预训练配置映射
"XLMRobertaConfig", # XLMRobertaConfig 是用于 models.xlm_roberta 的配置类
],
"models.xlm_roberta_xl": [
"XLM_ROBERTA_XL_PRETRAINED_CONFIG_ARCHIVE_MAP", # XLM_ROBERTA_XL_PRETRAINED_CONFIG_ARCHIVE_MAP 是 models.xlm_roberta_xl 的预训练配置映射
"XLMRobertaXLConfig", # XLMRobertaXLConfig 是用于 models.xlm_roberta_xl 的配置类
],
"models.xlnet": ["XLNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "XLNetConfig"], # XLNET_PRETRAINED_CONFIG_ARCHIVE_MAP 是 models.xlnet 的预训练配置映射,XLNetConfig 是用于 models.xlnet 的配置类
"models.xmod": ["XMOD_PRETRAINED_CONFIG_ARCHIVE_MAP", "XmodConfig"], # XMOD_PRETRAINED_CONFIG_ARCHIVE_MAP 是 models.xmod 的预训练配置映射,XmodConfig 是用于 models.xmod 的配置类
"models.yolos": ["YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP", "YolosConfig"], # YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP 是 models.yolos 的预训练配置映射,YolosConfig 是用于 models.yolos 的配置类
"models.yoso": ["YOSO_PRETRAINED_CONFIG_ARCHIVE_MAP", "YosoConfig"], # YOSO_PRETRAINED_CONFIG_ARCHIVE_MAP 是 models.yoso 的预训练配置映射,YosoConfig 是用于 models.yoso 的配置类
"onnx": [], # 空列表,表示没有与 onnx 相关的配置
"pipelines": [
"AudioClassificationPipeline", # 音频分类管道
"AutomaticSpeechRecognitionPipeline", # 自动语音识别管道
"Conversation", # 对话管道
"ConversationalPipeline", # 会话式管道
"CsvPipelineDataFormat", # CSV 数据格式管道
"DepthEstimationPipeline", # 深度估计管道
"DocumentQuestionAnsweringPipeline", # 文档问答管道
"FeatureExtractionPipeline", # 特征提取管道
"FillMaskPipeline", # 填充掩码管道
"ImageClassificationPipeline", # 图像分类管道
"ImageFeatureExtractionPipeline", # 图像特征提取管道
"ImageSegmentationPipeline", # 图像分割管道
"ImageToImagePipeline", # 图像到图像管道
"ImageToTextPipeline", # 图像到文本管道
"JsonPipelineDataFormat", # JSON 数据格式管道
"MaskGenerationPipeline", # 掩码生成管道
"NerPipeline", # 命名实体识别管道
"ObjectDetectionPipeline", # 目标检测管道
"PipedPipelineDataFormat", # 管道数据格式管道
"Pipeline", # 管道
"PipelineDataFormat", # 管道数据格式
"QuestionAnsweringPipeline", # 问答管道
"SummarizationPipeline", # 摘要生成管道
"TableQuestionAnsweringPipeline", # 表格问答管道
"Text2TextGenerationPipeline", # 文本到文本生成管道
"TextClassificationPipeline", # 文本分类管道
"TextGenerationPipeline", # 文本生成管道
"TextToAudioPipeline", # 文本到音频管道
"TokenClassificationPipeline", # 标记分类管道
"TranslationPipeline", # 翻译管道
"VideoClassificationPipeline", # 视频分类管道
"VisualQuestionAnsweringPipeline", # 视觉问答管道
"ZeroShotAudioClassificationPipeline", # 零样本音频分类管道
"ZeroShotClassificationPipeline", # 零样本分类管道
"ZeroShotImageClassificationPipeline", # 零样本图像分类管道
"ZeroShotObjectDetectionPipeline", # 零样本目标检测管道
"pipeline", # 管道(通用概念)
],
"processing_utils": ["ProcessorMixin"], # 处理工具:混合处理器
"quantizers": [], # 量化器(空列表,暂无量化器)
"testing_utils": [], # 测试工具(空列表,暂无测试工具)
"tokenization_utils": ["PreTrainedTokenizer"], # 标记化工具:预训练标记器
"tokenization_utils_base": [
"AddedToken", # 增加的标记
"BatchEncoding", # 批次编码
"CharSpan", # 字符跨度
"PreTrainedTokenizerBase", # 预训练标记器基类
"SpecialTokensMixin", # 特殊标记混合类
"TokenSpan", # 标记跨度
],
"tools": [
"Agent", # 代理
"AzureOpenAiAgent", # Azure OpenAI 代理
"HfAgent", # Hugging Face 代理
"LocalAgent", # 本地代理
"OpenAiAgent", # OpenAI 代理
"PipelineTool", # 管道工具
"RemoteTool", # 远程工具
"Tool", # 工具
"launch_gradio_demo", # 启动 Gradio 演示
"load_tool", # 加载工具
],
"trainer_callback": [
"DefaultFlowCallback", # 默认流程回调
"EarlyStoppingCallback", # 提前停止回调
"PrinterCallback", # 打印回调
"ProgressCallback", # 进度回调
"TrainerCallback", # 训练器回调
"TrainerControl", # 训练控制
"TrainerState", # 训练状态
],
"trainer_utils": [
"EvalPrediction", # 评估预测
"IntervalStrategy", # 间隔策略
"SchedulerType", # 调度器类型
"enable_full_determinism", # 启用完全确定性
"set_seed", # 设置种子
],
"training_args": ["TrainingArguments"], # 训练参数:训练参数
"training_args_seq2seq": ["Seq2SeqTrainingArguments"], # 序列到序列训练参数:序列到序列训练参数
"training_args_tf": ["TFTrainingArguments"], # TensorFlow 训练参数:TensorFlow 训练参数
"utils": [
"CONFIG_NAME", # 配置名称常量
"MODEL_CARD_NAME", # 模型卡片名称常量
"PYTORCH_PRETRAINED_BERT_CACHE", # PyTorch预训练BERT模型缓存常量
"PYTORCH_TRANSFORMERS_CACHE", # PyTorch Transformers模型缓存常量
"SPIECE_UNDERLINE", # 分词符号下划线常量
"TF2_WEIGHTS_NAME", # TensorFlow 2.x模型权重名称常量
"TF_WEIGHTS_NAME", # TensorFlow模型权重名称常量
"TRANSFORMERS_CACHE", # Transformers模型缓存常量
"WEIGHTS_NAME", # 模型权重名称常量
"TensorType", # 张量类型
"add_end_docstrings", # 添加结尾文档字符串函数
"add_start_docstrings", # 添加开头文档字符串函数
"is_apex_available", # 是否可用Apex库
"is_bitsandbytes_available", # 是否可用BitsAndBytes库
"is_datasets_available", # 是否可用datasets库
"is_decord_available", # 是否可用Decord库
"is_faiss_available", # 是否可用Faiss库
"is_flax_available", # 是否可用Flax库
"is_keras_nlp_available", # 是否可用Keras NLP库
"is_phonemizer_available", # 是否可用Phonemizer库
"is_psutil_available", # 是否可用psutil库
"is_py3nvml_available", # 是否可用py3nvml库
"is_pyctcdecode_available", # 是否可用PyCTCDecode库
"is_sacremoses_available", # 是否可用sacremoses库
"is_safetensors_available", # 是否可用SafeTensors库
"is_scipy_available", # 是否可用SciPy库
"is_sentencepiece_available", # 是否可用SentencePiece库
"is_sklearn_available", # 是否可用scikit-learn库
"is_speech_available", # 是否可用speech库
"is_tensorflow_text_available", # 是否可用TensorFlow Text库
"is_tf_available", # 是否可用TensorFlow库
"is_timm_available", # 是否可用Timm库
"is_tokenizers_available", # 是否可用tokenizers库
"is_torch_available", # 是否可用PyTorch库
"is_torch_neuroncore_available", # 是否可用Torch NeuronCore库
"is_torch_npu_available", # 是否可用Torch NPU库
"is_torch_tpu_available", # 是否可用Torch TPU库
"is_torchvision_available", # 是否可用TorchVision库
"is_torch_xla_available", # 是否可用Torch XLA库
"is_torch_xpu_available", # 是否可用Torch XPU库
"is_vision_available", # 是否可用Vision库
"logging", # 日志记录模块
],
"utils.quantization_config": [
"AqlmConfig", # Aqlm配置类
"AwqConfig", # Awq配置类
"BitsAndBytesConfig", # BitsAndBytes配置类
"GPTQConfig", # GPTQ配置类
"QuantoConfig", # Quanto配置类
],
# sentencepiece-backed objects
# 尝试检查是否存在 sentencepiece 库的可用性
try:
# 如果 sentencepiece 库不可用,引发 OptionalDependencyNotAvailable 异常
if not is_sentencepiece_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
# 如果引发了 OptionalDependencyNotAvailable 异常,则从 utils 中导入 dummy_sentencepiece_objects
from .utils import dummy_sentencepiece_objects
# 将 dummy_sentencepiece_objects 中所有非私有成员的名称添加到 _import_structure["utils.dummy_sentencepiece_objects"] 列表中
_import_structure["utils.dummy_sentencepiece_objects"] = [
name for name in dir(dummy_sentencepiece_objects) if not name.startswith("_")
]
else:
# 如果 sentencepiece 库可用,分别添加以下模块的 Tokenizer 到对应的 _import_structure 中的列表中
_import_structure["models.albert"].append("AlbertTokenizer")
_import_structure["models.barthez"].append("BarthezTokenizer")
_import_structure["models.bartpho"].append("BartphoTokenizer")
_import_structure["models.bert_generation"].append("BertGenerationTokenizer")
_import_structure["models.big_bird"].append("BigBirdTokenizer")
_import_structure["models.camembert"].append("CamembertTokenizer")
_import_structure["models.code_llama"].append("CodeLlamaTokenizer")
_import_structure["models.cpm"].append("CpmTokenizer")
_import_structure["models.deberta_v2"].append("DebertaV2Tokenizer")
_import_structure["models.ernie_m"].append("ErnieMTokenizer")
_import_structure["models.fnet"].append("FNetTokenizer")
_import_structure["models.gemma"].append("GemmaTokenizer")
_import_structure["models.gpt_sw3"].append("GPTSw3Tokenizer")
_import_structure["models.layoutxlm"].append("LayoutXLMTokenizer")
_import_structure["models.llama"].append("LlamaTokenizer")
_import_structure["models.m2m_100"].append("M2M100Tokenizer")
_import_structure["models.marian"].append("MarianTokenizer")
_import_structure["models.mbart"].append("MBartTokenizer")
_import_structure["models.mbart50"].append("MBart50Tokenizer")
_import_structure["models.mluke"].append("MLukeTokenizer")
_import_structure["models.mt5"].append("MT5Tokenizer")
_import_structure["models.nllb"].append("NllbTokenizer")
_import_structure["models.pegasus"].append("PegasusTokenizer")
_import_structure["models.plbart"].append("PLBartTokenizer")
_import_structure["models.reformer"].append("ReformerTokenizer")
_import_structure["models.rembert"].append("RemBertTokenizer")
_import_structure["models.seamless_m4t"].append("SeamlessM4TTokenizer")
_import_structure["models.siglip"].append("SiglipTokenizer")
_import_structure["models.speech_to_text"].append("Speech2TextTokenizer")
_import_structure["models.speecht5"].append("SpeechT5Tokenizer")
_import_structure["models.t5"].append("T5Tokenizer")
_import_structure["models.udop"].append("UdopTokenizer")
_import_structure["models.xglm"].append("XGLMTokenizer")
_import_structure["models.xlm_prophetnet"].append("XLMProphetNetTokenizer")
_import_structure["models.xlm_roberta"].append("XLMRobertaTokenizer")
_import_structure["models.xlnet"].append("XLNetTokenizer")
# 将 "utils.dummy_tokenizers_objects" 添加到 _import_structure 字典中,其对应的值是一个列表
_import_structure["utils.dummy_tokenizers_objects"] = [
# 遍历 dummy_tokenizers_objects 模块中的所有名称,但排除以 "_" 开头的名称
name for name in dir(dummy_tokenizers_objects) if not name.startswith("_")
]
else:
# 如果不是慢速分词器,则使用快速分词器结构
# 将 AlbertTokenizerFast 添加到 _import_structure["models.albert"] 中
_import_structure["models.albert"].append("AlbertTokenizerFast")
# 将 BartTokenizerFast 添加到 _import_structure["models.bart"] 中
_import_structure["models.bart"].append("BartTokenizerFast")
# 将 BarthezTokenizerFast 添加到 _import_structure["models.barthez"] 中
_import_structure["models.barthez"].append("BarthezTokenizerFast")
# 将 BertTokenizerFast 添加到 _import_structure["models.bert"] 中
_import_structure["models.bert"].append("BertTokenizerFast")
# 将 BigBirdTokenizerFast 添加到 _import_structure["models.big_bird"] 中
_import_structure["models.big_bird"].append("BigBirdTokenizerFast")
# 将 BlenderbotTokenizerFast 添加到 _import_structure["models.blenderbot"] 中
_import_structure["models.blenderbot"].append("BlenderbotTokenizerFast")
# 将 BlenderbotSmallTokenizerFast 添加到 _import_structure["models.blenderbot_small"] 中
_import_structure["models.blenderbot_small"].append("BlenderbotSmallTokenizerFast")
# 将 BloomTokenizerFast 添加到 _import_structure["models.bloom"] 中
_import_structure["models.bloom"].append("BloomTokenizerFast")
# 将 CamembertTokenizerFast 添加到 _import_structure["models.camembert"] 中
_import_structure["models.camembert"].append("CamembertTokenizerFast")
# 将 CLIPTokenizerFast 添加到 _import_structure["models.clip"] 中
_import_structure["models.clip"].append("CLIPTokenizerFast")
# 将 CodeLlamaTokenizerFast 添加到 _import_structure["models.code_llama"] 中
_import_structure["models.code_llama"].append("CodeLlamaTokenizerFast")
# 将 CodeGenTokenizerFast 添加到 _import_structure["models.codegen"] 中
_import_structure["models.codegen"].append("CodeGenTokenizerFast")
# 将 CohereTokenizerFast 添加到 _import_structure["models.cohere"] 中
_import_structure["models.cohere"].append("CohereTokenizerFast")
# 将 ConvBertTokenizerFast 添加到 _import_structure["models.convbert"] 中
_import_structure["models.convbert"].append("ConvBertTokenizerFast")
# 将 CpmTokenizerFast 添加到 _import_structure["models.cpm"] 中
_import_structure["models.cpm"].append("CpmTokenizerFast")
# 将 DebertaTokenizerFast 添加到 _import_structure["models.deberta"] 中
_import_structure["models.deberta"].append("DebertaTokenizerFast")
# 将 DebertaV2TokenizerFast 添加到 _import_structure["models.deberta_v2"] 中
_import_structure["models.deberta_v2"].append("DebertaV2TokenizerFast")
# 将 RetriBertTokenizerFast 添加到 _import_structure["models.deprecated.retribert"] 中
_import_structure["models.deprecated.retribert"].append("RetriBertTokenizerFast")
# 将 DistilBertTokenizerFast 添加到 _import_structure["models.distilbert"] 中
_import_structure["models.distilbert"].append("DistilBertTokenizerFast")
# 将 DPRContextEncoderTokenizerFast、DPRQuestionEncoderTokenizerFast、DPRReaderTokenizerFast 添加到 _import_structure["models.dpr"] 中
_import_structure["models.dpr"].extend(
[
"DPRContextEncoderTokenizerFast",
"DPRQuestionEncoderTokenizerFast",
"DPRReaderTokenizerFast",
]
)
# 将 ElectraTokenizerFast 添加到 _import_structure["models.electra"] 中
_import_structure["models.electra"].append("ElectraTokenizerFast")
# 将 FNetTokenizerFast 添加到 _import_structure["models.fnet"] 中
_import_structure["models.fnet"].append("FNetTokenizerFast")
# 将 FunnelTokenizerFast 添加到 _import_structure["models.funnel"] 中
_import_structure["models.funnel"].append("FunnelTokenizerFast")
# 将 GemmaTokenizerFast 添加到 _import_structure["models.gemma"] 中
_import_structure["models.gemma"].append("GemmaTokenizerFast")
# 将 GPT2TokenizerFast 添加到 _import_structure["models.gpt2"] 中
_import_structure["models.gpt2"].append("GPT2TokenizerFast")
# 将 GPTNeoXTokenizerFast 添加到 _import_structure["models.gpt_neox"] 中
_import_structure["models.gpt_neox"].append("GPTNeoXTokenizerFast")
# 将 GPTNeoXJapaneseTokenizer 添加到 _import_structure["models.gpt_neox_japanese"] 中
_import_structure["models.gpt_neox_japanese"].append("GPTNeoXJapaneseTokenizer")
# 将 HerbertTokenizerFast 添加到 _import_structure["models.herbert"] 中
_import_structure["models.herbert"].append("HerbertTokenizerFast")
# 将 LayoutLMTokenizerFast 添加到 _import_structure["models.layoutlm"] 中
_import_structure["models.layoutlm"].append("LayoutLMTokenizerFast")
# 将 LayoutLMv2TokenizerFast 添加到 _import_structure["models.layoutlmv2"] 中
_import_structure["models.layoutlmv2"].append("LayoutLMv2TokenizerFast")
# 将 LayoutLMv3TokenizerFast 添加到 _import_structure["models.layoutlmv3"] 中
_import_structure["models.layoutlmv3"].append("LayoutLMv3TokenizerFast")
# 将 LayoutXLMTokenizerFast 添加到 _import_structure["models.layoutxlm"] 中
_import_structure["models.layoutxlm"].append("LayoutXLMTokenizerFast")
# 将 LEDTokenizerFast 添加到 _import_structure["models.led"] 中
_import_structure["models.led"].append("LEDTokenizerFast")
# 将 LlamaTokenizerFast 添加到 _import_structure["models.llama"] 中
_import_structure["models.llama"].append("LlamaTokenizerFast")
# 将 LongformerTokenizerFast 添加到 _import_structure["models.longformer"] 中
_import_structure["models.longformer"].append("LongformerTokenizerFast")
# 将 LxmertTokenizerFast 添加到 _import_structure["models.lxmert"] 中
_import_structure["models.lxmert"].append("LxmertTokenizerFast")
# 将 MarkupLMTokenizerFast 添加到 _import_structure["models.markuplm"] 中
_import_structure["models.markuplm"].append("MarkupLMTokenizerFast")
# 将 MBartTokenizerFast 添加到 _import_structure["models.mbart"] 中
_import_structure["models.mbart"].append("MBartTokenizerFast")
# 将 MBart50TokenizerFast 添加到 _import_structure["models.mbart50"] 中
_import_structure["models.mbart50"].append("MBart50TokenizerFast")
# 将 "MobileBertTokenizerFast" 添加到 _import_structure["models.mobilebert"] 列表中
_import_structure["models.mobilebert"].append("MobileBertTokenizerFast")
# 将 "MPNetTokenizerFast" 添加到 _import_structure["models.mpnet"] 列表中
_import_structure["models.mpnet"].append("MPNetTokenizerFast")
# 将 "MT5TokenizerFast" 添加到 _import_structure["models.mt5"] 列表中
_import_structure["models.mt5"].append("MT5TokenizerFast")
# 将 "MvpTokenizerFast" 添加到 _import_structure["models.mvp"] 列表中
_import_structure["models.mvp"].append("MvpTokenizerFast")
# 将 "NllbTokenizerFast" 添加到 _import_structure["models.nllb"] 列表中
_import_structure["models.nllb"].append("NllbTokenizerFast")
# 将 "NougatTokenizerFast" 添加到 _import_structure["models.nougat"] 列表中
_import_structure["models.nougat"].append("NougatTokenizerFast")
# 将 "OpenAIGPTTokenizerFast" 添加到 _import_structure["models.openai"] 列表中
_import_structure["models.openai"].append("OpenAIGPTTokenizerFast")
# 将 "PegasusTokenizerFast" 添加到 _import_structure["models.pegasus"] 列表中
_import_structure["models.pegasus"].append("PegasusTokenizerFast")
# 将 "Qwen2TokenizerFast" 添加到 _import_structure["models.qwen2"] 列表中
_import_structure["models.qwen2"].append("Qwen2TokenizerFast")
# 将 "RealmTokenizerFast" 添加到 _import_structure["models.realm"] 列表中
_import_structure["models.realm"].append("RealmTokenizerFast")
# 将 "ReformerTokenizerFast" 添加到 _import_structure["models.reformer"] 列表中
_import_structure["models.reformer"].append("ReformerTokenizerFast")
# 将 "RemBertTokenizerFast" 添加到 _import_structure["models.rembert"] 列表中
_import_structure["models.rembert"].append("RemBertTokenizerFast")
# 将 "RobertaTokenizerFast" 添加到 _import_structure["models.roberta"] 列表中
_import_structure["models.roberta"].append("RobertaTokenizerFast")
# 将 "RoFormerTokenizerFast" 添加到 _import_structure["models.roformer"] 列表中
_import_structure["models.roformer"].append("RoFormerTokenizerFast")
# 将 "SeamlessM4TTokenizerFast" 添加到 _import_structure["models.seamless_m4t"] 列表中
_import_structure["models.seamless_m4t"].append("SeamlessM4TTokenizerFast")
# 将 "SplinterTokenizerFast" 添加到 _import_structure["models.splinter"] 列表中
_import_structure["models.splinter"].append("SplinterTokenizerFast")
# 将 "SqueezeBertTokenizerFast" 添加到 _import_structure["models.squeezebert"] 列表中
_import_structure["models.squeezebert"].append("SqueezeBertTokenizerFast")
# 将 "T5TokenizerFast" 添加到 _import_structure["models.t5"] 列表中
_import_structure["models.t5"].append("T5TokenizerFast")
# 将 "UdopTokenizerFast" 添加到 _import_structure["models.udop"] 列表中
_import_structure["models.udop"].append("UdopTokenizerFast")
# 将 "WhisperTokenizerFast" 添加到 _import_structure["models.whisper"] 列表中
_import_structure["models.whisper"].append("WhisperTokenizerFast")
# 将 "XGLMTokenizerFast" 添加到 _import_structure["models.xglm"] 列表中
_import_structure["models.xglm"].append("XGLMTokenizerFast")
# 将 "XLMRobertaTokenizerFast" 添加到 _import_structure["models.xlm_roberta"] 列表中
_import_structure["models.xlm_roberta"].append("XLMRobertaTokenizerFast")
# 将 "XLNetTokenizerFast" 添加到 _import_structure["models.xlnet"] 列表中
_import_structure["models.xlnet"].append("XLNetTokenizerFast")
# 将 "PreTrainedTokenizerFast" 添加到 _import_structure["tokenization_utils_fast"] 列表中
_import_structure["tokenization_utils_fast"] = ["PreTrainedTokenizerFast"]
# 检查是否安装了句子分词器和分词器模块,如果未安装则引发自定义的OptionalDependencyNotAvailable异常
try:
if not (is_sentencepiece_available() and is_tokenizers_available()):
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
# 导入替代的虚拟模块,用于句子分词器和分词器
from .utils import dummy_sentencepiece_and_tokenizers_objects
# 将虚拟模块中的非私有名称添加到_import_structure字典中
_import_structure["utils.dummy_sentencepiece_and_tokenizers_objects"] = [
name for name in dir(dummy_sentencepiece_and_tokenizers_objects) if not name.startswith("_")
]
else:
# 如果依赖可用,则将相关名称添加到_import_structure字典中的"convert_slow_tokenizer"键下
_import_structure["convert_slow_tokenizer"] = [
"SLOW_TO_FAST_CONVERTERS",
"convert_slow_tokenizer",
]
# Tensorflow-text-specific objects
# 检查是否安装了TensorFlow Text模块,如果未安装则引发自定义的OptionalDependencyNotAvailable异常
try:
if not is_tensorflow_text_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
# 导入替代的虚拟模块,用于TensorFlow Text
from .utils import dummy_tensorflow_text_objects
# 将虚拟模块中的非私有名称添加到_import_structure字典中
_import_structure["utils.dummy_tensorflow_text_objects"] = [
name for name in dir(dummy_tensorflow_text_objects) if not name.startswith("_")
]
else:
# 如果依赖可用,则将"TFBertTokenizer"添加到"models.bert"键对应的列表中
_import_structure["models.bert"].append("TFBertTokenizer")
# keras-nlp-specific objects
# 检查是否安装了Keras NLP模块,如果未安装则引发自定义的OptionalDependencyNotAvailable异常
try:
if not is_keras_nlp_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
# 导入替代的虚拟模块,用于Keras NLP
from .utils import dummy_keras_nlp_objects
# 将虚拟模块中的非私有名称添加到_import_structure字典中
_import_structure["utils.dummy_keras_nlp_objects"] = [
name for name in dir(dummy_keras_nlp_objects) if not name.startswith("_")
]
else:
# 如果依赖可用,则将"TFGPT2Tokenizer"添加到"models.gpt2"键对应的列表中
_import_structure["models.gpt2"].append("TFGPT2Tokenizer")
# Vision-specific objects
# 检查是否安装了Vision模块,如果未安装则引发自定义的OptionalDependencyNotAvailable异常
try:
if not is_vision_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
# 导入替代的虚拟模块,用于Vision
from .utils import dummy_vision_objects
# 将虚拟模块中的非私有名称添加到_import_structure字典中
_import_structure["utils.dummy_vision_objects"] = [
name for name in dir(dummy_vision_objects) if not name.startswith("_")
]
else:
# 如果依赖可用,则按需添加各种Vision模型处理器到对应的_import_structure字典中的不同键下
_import_structure["image_processing_utils"] = ["ImageProcessingMixin"]
_import_structure["image_utils"] = ["ImageFeatureExtractionMixin"]
_import_structure["models.beit"].extend(["BeitFeatureExtractor", "BeitImageProcessor"])
_import_structure["models.bit"].extend(["BitImageProcessor"])
_import_structure["models.blip"].extend(["BlipImageProcessor"])
_import_structure["models.bridgetower"].append("BridgeTowerImageProcessor")
_import_structure["models.chinese_clip"].extend(["ChineseCLIPFeatureExtractor", "ChineseCLIPImageProcessor"])
_import_structure["models.clip"].extend(["CLIPFeatureExtractor", "CLIPImageProcessor"])
_import_structure["models.conditional_detr"].extend(
["ConditionalDetrFeatureExtractor", "ConditionalDetrImageProcessor"]
)
_import_structure["models.convnext"].extend(["ConvNextFeatureExtractor", "ConvNextImageProcessor"])
_import_structure["models.deformable_detr"].extend(
["DeformableDetrFeatureExtractor", "DeformableDetrImageProcessor"]
)
_import_structure["models.deit"].extend(["DeiTFeatureExtractor", "DeiTImageProcessor"])
_import_structure["models.deta"].append("DetaImageProcessor")
# 将 "models.detr" 模块下的 "DetrFeatureExtractor" 和 "DetrImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.detr"].extend(["DetrFeatureExtractor", "DetrImageProcessor"])
# 将 "models.donut" 模块下的 "DonutFeatureExtractor" 和 "DonutImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.donut"].extend(["DonutFeatureExtractor", "DonutImageProcessor"])
# 将 "models.dpt" 模块下的 "DPTFeatureExtractor" 和 "DPTImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.dpt"].extend(["DPTFeatureExtractor", "DPTImageProcessor"])
# 将 "models.efficientformer" 模块下的 "EfficientFormerImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.efficientformer"].append("EfficientFormerImageProcessor")
# 将 "models.efficientnet" 模块下的 "EfficientNetImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.efficientnet"].append("EfficientNetImageProcessor")
# 将 "models.flava" 模块下的 "FlavaFeatureExtractor", "FlavaImageProcessor" 和 "FlavaProcessor" 添加到 _import_structure 字典中
_import_structure["models.flava"].extend(["FlavaFeatureExtractor", "FlavaImageProcessor", "FlavaProcessor"])
# 将 "models.fuyu" 模块下的 "FuyuImageProcessor" 和 "FuyuProcessor" 添加到 _import_structure 字典中
_import_structure["models.fuyu"].extend(["FuyuImageProcessor", "FuyuProcessor"])
# 将 "models.glpn" 模块下的 "GLPNFeatureExtractor" 和 "GLPNImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.glpn"].extend(["GLPNFeatureExtractor", "GLPNImageProcessor"])
# 将 "models.idefics" 模块下的 "IdeficsImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.idefics"].extend(["IdeficsImageProcessor"])
# 将 "models.imagegpt" 模块下的 "ImageGPTFeatureExtractor" 和 "ImageGPTImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.imagegpt"].extend(["ImageGPTFeatureExtractor", "ImageGPTImageProcessor"])
# 将 "models.layoutlmv2" 模块下的 "LayoutLMv2FeatureExtractor" 和 "LayoutLMv2ImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.layoutlmv2"].extend(["LayoutLMv2FeatureExtractor", "LayoutLMv2ImageProcessor"])
# 将 "models.layoutlmv3" 模块下的 "LayoutLMv3FeatureExtractor" 和 "LayoutLMv3ImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.layoutlmv3"].extend(["LayoutLMv3FeatureExtractor", "LayoutLMv3ImageProcessor"])
# 将 "models.levit" 模块下的 "LevitFeatureExtractor" 和 "LevitImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.levit"].extend(["LevitFeatureExtractor", "LevitImageProcessor"])
# 将 "models.llava_next" 模块下的 "LlavaNextImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.llava_next"].append("LlavaNextImageProcessor")
# 将 "models.mask2former" 模块下的 "Mask2FormerImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.mask2former"].append("Mask2FormerImageProcessor")
# 将 "models.maskformer" 模块下的 "MaskFormerFeatureExtractor" 和 "MaskFormerImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.maskformer"].extend(["MaskFormerFeatureExtractor", "MaskFormerImageProcessor"])
# 将 "models.mobilenet_v1" 模块下的 "MobileNetV1FeatureExtractor" 和 "MobileNetV1ImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.mobilenet_v1"].extend(["MobileNetV1FeatureExtractor", "MobileNetV1ImageProcessor"])
# 将 "models.mobilenet_v2" 模块下的 "MobileNetV2FeatureExtractor" 和 "MobileNetV2ImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.mobilenet_v2"].extend(["MobileNetV2FeatureExtractor", "MobileNetV2ImageProcessor"])
# 将 "models.mobilevit" 模块下的 "MobileViTFeatureExtractor" 和 "MobileViTImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.mobilevit"].extend(["MobileViTFeatureExtractor", "MobileViTImageProcessor"])
# 将 "models.nougat" 模块下的 "NougatImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.nougat"].append("NougatImageProcessor")
# 将 "models.oneformer" 模块下的 "OneFormerImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.oneformer"].extend(["OneFormerImageProcessor"])
# 将 "models.owlv2" 模块下的 "Owlv2ImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.owlv2"].append("Owlv2ImageProcessor")
# 将 "models.owlvit" 模块下的 "OwlViTFeatureExtractor" 和 "OwlViTImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.owlvit"].extend(["OwlViTFeatureExtractor", "OwlViTImageProcessor"])
# 将 "models.perceiver" 模块下的 "PerceiverFeatureExtractor" 和 "PerceiverImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.perceiver"].extend(["PerceiverFeatureExtractor", "PerceiverImageProcessor"])
# 将 "models.pix2struct" 模块下的 "Pix2StructImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.pix2struct"].extend(["Pix2StructImageProcessor"])
# 将 "models.poolformer" 模块下的 "PoolFormerFeatureExtractor" 和 "PoolFormerImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.poolformer"].extend(["PoolFormerFeatureExtractor", "PoolFormerImageProcessor"])
# 将 "models.pvt" 模块下的 "PvtImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.pvt"].extend(["PvtImageProcessor"])
# 将 "models.sam" 模块下的 "SamImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.sam"].extend(["SamImageProcessor"])
# 将 "models.segformer" 模块下的 "SegformerFeatureExtractor" 和 "SegformerImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.segformer"].extend(["SegformerFeatureExtractor", "SegformerImageProcessor"])
# 将 "models.seggpt" 模块下的 "SegGptImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.seggpt"].extend(["SegGptImageProcessor"])
# 将 "models.siglip" 模块下的 "SiglipImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.siglip"].append("SiglipImageProcessor")
# 将 "models.superpoint" 模块下的 "SuperPointImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.superpoint"].extend(["SuperPointImageProcessor"])
# 将 "models.swin2sr" 模块下的 "Swin2SRImageProcessor" 添加到 _import_structure 字典中
_import_structure["models.swin2sr"].append("Swin2SRImageProcessor")
# 将 "TvltImageProcessor" 添加到 _import_structure 字典中的 "models.tvlt" 键对应的列表中
_import_structure["models.tvlt"].append("TvltImageProcessor")
# 将 "TvpImageProcessor" 添加到 _import_structure 字典中的 "models.tvp" 键对应的列表中
_import_structure["models.tvp"].append("TvpImageProcessor")
# 将 ["VideoMAEFeatureExtractor", "VideoMAEImageProcessor"] 扩展添加到 _import_structure 字典中的 "models.videomae" 键对应的列表中
_import_structure["models.videomae"].extend(["VideoMAEFeatureExtractor", "VideoMAEImageProcessor"])
# 将 ["ViltFeatureExtractor", "ViltImageProcessor", "ViltProcessor"] 扩展添加到 _import_structure 字典中的 "models.vilt" 键对应的列表中
_import_structure["models.vilt"].extend(["ViltFeatureExtractor", "ViltImageProcessor", "ViltProcessor"])
# 将 ["ViTFeatureExtractor", "ViTImageProcessor"] 扩展添加到 _import_structure 字典中的 "models.vit" 键对应的列表中
_import_structure["models.vit"].extend(["ViTFeatureExtractor", "ViTImageProcessor"])
# 将 ["ViTHybridImageProcessor"] 扩展添加到 _import_structure 字典中的 "models.vit_hybrid" 键对应的列表中
_import_structure["models.vit_hybrid"].extend(["ViTHybridImageProcessor"])
# 将 "VitMatteImageProcessor" 添加到 _import_structure 字典中的 "models.vitmatte" 键对应的列表中
_import_structure["models.vitmatte"].append("VitMatteImageProcessor")
# 将 "VivitImageProcessor" 添加到 _import_structure 字典中的 "models.vivit" 键对应的列表中
_import_structure["models.vivit"].append("VivitImageProcessor")
# 将 ["YolosFeatureExtractor", "YolosImageProcessor"] 扩展添加到 _import_structure 字典中的 "models.yolos" 键对应的列表中
_import_structure["models.yolos"].extend(["YolosFeatureExtractor", "YolosImageProcessor"])
# 尝试检测是否存在 PyTorch 库
try:
# 如果 PyTorch 不可用,则抛出 OptionalDependencyNotAvailable 异常
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
# 导入 dummy_pt_objects 模块替代
from .utils import dummy_pt_objects
# 将 dummy_pt_objects 模块内的非下划线开头的所有名称加入 _import_structure
_import_structure["utils.dummy_pt_objects"] = [name for name in dir(dummy_pt_objects) if not name.startswith("_")]
else:
# 如果 PyTorch 可用,则分别设置以下模块的导入结构
_import_structure["activations"] = []
_import_structure["benchmark.benchmark"] = ["PyTorchBenchmark"]
_import_structure["benchmark.benchmark_args"] = ["PyTorchBenchmarkArguments"]
_import_structure["cache_utils"] = ["Cache", "DynamicCache", "SinkCache", "StaticCache"]
_import_structure["data.datasets"] = [
"GlueDataset",
"GlueDataTrainingArguments",
"LineByLineTextDataset",
"LineByLineWithRefDataset",
"LineByLineWithSOPTextDataset",
"SquadDataset",
"SquadDataTrainingArguments",
"TextDataset",
"TextDatasetForNextSentencePrediction",
]
_import_structure["generation"].extend(
[
"AlternatingCodebooksLogitsProcessor",
"BeamScorer",
"BeamSearchScorer",
"ClassifierFreeGuidanceLogitsProcessor",
"ConstrainedBeamSearchScorer",
"Constraint",
"ConstraintListState",
"DisjunctiveConstraint",
"EncoderNoRepeatNGramLogitsProcessor",
"EncoderRepetitionPenaltyLogitsProcessor",
"EpsilonLogitsWarper",
"EtaLogitsWarper",
"ExponentialDecayLengthPenalty",
"ForcedBOSTokenLogitsProcessor",
"ForcedEOSTokenLogitsProcessor",
"ForceTokensLogitsProcessor",
"GenerationMixin",
"HammingDiversityLogitsProcessor",
"InfNanRemoveLogitsProcessor",
"LogitNormalization",
"LogitsProcessor",
"LogitsProcessorList",
"LogitsWarper",
"MaxLengthCriteria",
"MaxTimeCriteria",
"MinLengthLogitsProcessor",
"MinNewTokensLengthLogitsProcessor",
"NoBadWordsLogitsProcessor",
"NoRepeatNGramLogitsProcessor",
"PhrasalConstraint",
"PrefixConstrainedLogitsProcessor",
"RepetitionPenaltyLogitsProcessor",
"SequenceBiasLogitsProcessor",
"StoppingCriteria",
"StoppingCriteriaList",
"SuppressTokensAtBeginLogitsProcessor",
"SuppressTokensLogitsProcessor",
"TemperatureLogitsWarper",
"TopKLogitsWarper",
"TopPLogitsWarper",
"TypicalLogitsWarper",
"UnbatchedClassifierFreeGuidanceLogitsProcessor",
"WhisperTimeStampLogitsProcessor",
]
)
_import_structure["generation_utils"] = []
_import_structure["modeling_outputs"] = []
_import_structure["modeling_utils"] = ["PreTrainedModel"]
# PyTorch 模型结构的导入部分
# 将 "models.albert" 模块的导入结构扩展,包括以下内容:
_import_structure["models.albert"].extend(
[
"ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST", # ALBERT 模型的预训练模型存档列表
"AlbertForMaskedLM", # 用于Masked Language Modeling的ALBERT模型
"AlbertForMultipleChoice", # 用于多项选择任务的ALBERT模型
"AlbertForPreTraining", # ALBERT的预训练模型
"AlbertForQuestionAnswering", # 用于问答任务的ALBERT模型
"AlbertForSequenceClassification", # 用于序列分类任务的ALBERT模型
"AlbertForTokenClassification", # 用于标记分类任务的ALBERT模型
"AlbertModel", # ALBERT模型
"AlbertPreTrainedModel", # ALBERT预训练模型基类
"load_tf_weights_in_albert", # 加载在ALBERT中的TensorFlow权重
]
)
# 将 "models.align" 模块的导入结构扩展,包括以下内容:
_import_structure["models.align"].extend(
[
"ALIGN_PRETRAINED_MODEL_ARCHIVE_LIST", # ALIGN模型的预训练模型存档列表
"AlignModel", # ALIGN模型
"AlignPreTrainedModel", # ALIGN预训练模型基类
"AlignTextModel", # ALIGN的文本模型
"AlignVisionModel", # ALIGN的视觉模型
]
)
# 将 "models.altclip" 模块的导入结构扩展,包括以下内容:
_import_structure["models.altclip"].extend(
[
"ALTCLIP_PRETRAINED_MODEL_ARCHIVE_LIST", # ALTCLIP模型的预训练模型存档列表
"AltCLIPModel", # ALTCLIP模型
"AltCLIPPreTrainedModel", # ALTCLIP预训练模型基类
"AltCLIPTextModel", # ALTCLIP的文本模型
"AltCLIPVisionModel", # ALTCLIP的视觉模型
]
)
# 将 "models.audio_spectrogram_transformer" 模块的导入结构扩展,包括以下内容:
_import_structure["models.audio_spectrogram_transformer"].extend(
[
"AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST", # 音频频谱变换器模型的预训练模型存档列表
"ASTForAudioClassification", # 用于音频分类任务的AST模型
"ASTModel", # AST模型
"ASTPreTrainedModel", # AST预训练模型基类
]
)
# 将 "models.autoformer" 模块的导入结构扩展,包括以下内容:
_import_structure["models.autoformer"].extend(
[
"AUTOFORMER_PRETRAINED_MODEL_ARCHIVE_LIST", # AUTOFORMER模型的预训练模型存档列表
"AutoformerForPrediction", # 用于预测任务的Autoformer模型
"AutoformerModel", # Autoformer模型
"AutoformerPreTrainedModel", # Autoformer预训练模型基类
]
)
# 将 "models.bark" 模块的导入结构扩展,包括以下内容:
_import_structure["models.bark"].extend(
[
"BARK_PRETRAINED_MODEL_ARCHIVE_LIST", # BARK模型的预训练模型存档列表
"BarkCausalModel", # 用于因果建模的BARK模型
"BarkCoarseModel", # 粗粒度任务的BARK模型
"BarkFineModel", # 细粒度任务的BARK模型
"BarkModel", # BARK模型
"BarkPreTrainedModel", # BARK预训练模型基类
"BarkSemanticModel", # 语义任务的BARK模型
]
)
# 将 "models.bart" 模块的导入结构扩展,包括以下内容:
_import_structure["models.bart"].extend(
[
"BART_PRETRAINED_MODEL_ARCHIVE_LIST", # BART模型的预训练模型存档列表
"BartForCausalLM", # 用于因果语言建模的BART模型
"BartForConditionalGeneration", # 用于条件生成任务的BART模型
"BartForQuestionAnswering", # 用于问答任务的BART模型
"BartForSequenceClassification", # 用于序列分类任务的BART模型
"BartModel", # BART模型
"BartPretrainedModel", # BART预训练模型
"BartPreTrainedModel", # BART预训练模型基类
"PretrainedBartModel", # 预训练的BART模型
]
)
# 将 "models.beit" 模块的导入结构扩展,包括以下内容:
_import_structure["models.beit"].extend(
[
"BEIT_PRETRAINED_MODEL_ARCHIVE_LIST", # BEIT模型的预训练模型存档列表
"BeitBackbone", # BEIT的骨干模型
"BeitForImageClassification", # 用于图像分类任务的BEIT模型
"BeitForMaskedImageModeling", # 用于图像建模任务的BEIT模型
"BeitForSemanticSegmentation", # 用于语义分割任务的BEIT模型
"BeitModel", # BEIT模型
"BeitPreTrainedModel", # BEIT预训练模型基类
]
)
# 将 "models.bert" 模块中的特定对象列表扩展到 _import_structure 字典中
_import_structure["models.bert"].extend(
[
"BERT_PRETRAINED_MODEL_ARCHIVE_LIST", # BERT 预训练模型归档列表
"BertForMaskedLM", # 用于遮蔽语言建模的 BERT 模型
"BertForMultipleChoice", # 用于多项选择任务的 BERT 模型
"BertForNextSentencePrediction", # 用于下一个句子预测任务的 BERT 模型
"BertForPreTraining", # 用于预训练的 BERT 模型
"BertForQuestionAnswering", # 用于问答任务的 BERT 模型
"BertForSequenceClassification", # 用于序列分类任务的 BERT 模型
"BertForTokenClassification", # 用于标记分类任务的 BERT 模型
"BertLayer", # BERT 的层类
"BertLMHeadModel", # BERT 语言建模头模型
"BertModel", # BERT 模型
"BertPreTrainedModel", # BERT 预训练模型基类
"load_tf_weights_in_bert", # 加载 TF 格式权重到 BERT 模型中的函数
]
)
# 将 "models.bert_generation" 模块中的特定对象列表扩展到 _import_structure 字典中
_import_structure["models.bert_generation"].extend(
[
"BertGenerationDecoder", # Bert Generation 解码器
"BertGenerationEncoder", # Bert Generation 编码器
"BertGenerationPreTrainedModel", # Bert Generation 预训练模型基类
"load_tf_weights_in_bert_generation", # 加载 TF 格式权重到 Bert Generation 模型中的函数
]
)
# 将 "models.big_bird" 模块中的特定对象列表扩展到 _import_structure 字典中
_import_structure["models.big_bird"].extend(
[
"BIG_BIRD_PRETRAINED_MODEL_ARCHIVE_LIST", # BigBird 预训练模型归档列表
"BigBirdForCausalLM", # 用于因果语言建模的 BigBird 模型
"BigBirdForMaskedLM", # 用于遮蔽语言建模的 BigBird 模型
"BigBirdForMultipleChoice", # 用于多项选择任务的 BigBird 模型
"BigBirdForPreTraining", # 用于预训练的 BigBird 模型
"BigBirdForQuestionAnswering", # 用于问答任务的 BigBird 模型
"BigBirdForSequenceClassification", # 用于序列分类任务的 BigBird 模型
"BigBirdForTokenClassification", # 用于标记分类任务的 BigBird 模型
"BigBirdLayer", # BigBird 的层类
"BigBirdModel", # BigBird 模型
"BigBirdPreTrainedModel", # BigBird 预训练模型基类
"load_tf_weights_in_big_bird", # 加载 TF 格式权重到 BigBird 模型中的函数
]
)
# 将 "models.bigbird_pegasus" 模块中的特定对象列表扩展到 _import_structure 字典中
_import_structure["models.bigbird_pegasus"].extend(
[
"BIGBIRD_PEGASUS_PRETRAINED_MODEL_ARCHIVE_LIST", # BigBirdPegasus 预训练模型归档列表
"BigBirdPegasusForCausalLM", # 用于因果语言建模的 BigBirdPegasus 模型
"BigBirdPegasusForConditionalGeneration", # 用于条件生成任务的 BigBirdPegasus 模型
"BigBirdPegasusForQuestionAnswering", # 用于问答任务的 BigBirdPegasus 模型
"BigBirdPegasusForSequenceClassification", # 用于序列分类任务的 BigBirdPegasus 模型
"BigBirdPegasusModel", # BigBirdPegasus 模型
"BigBirdPegasusPreTrainedModel", # BigBirdPegasus 预训练模型基类
]
)
# 将 "models.biogpt" 模块中的特定对象列表扩展到 _import_structure 字典中
_import_structure["models.biogpt"].extend(
[
"BIOGPT_PRETRAINED_MODEL_ARCHIVE_LIST", # BioGpt 预训练模型归档列表
"BioGptForCausalLM", # 用于因果语言建模的 BioGpt 模型
"BioGptForSequenceClassification", # 用于序列分类任务的 BioGpt 模型
"BioGptForTokenClassification", # 用于标记分类任务的 BioGpt 模型
"BioGptModel", # BioGpt 模型
"BioGptPreTrainedModel", # BioGpt 预训练模型基类
]
)
# 将 "models.bit" 模块中的特定对象列表扩展到 _import_structure 字典中
_import_structure["models.bit"].extend(
[
"BIT_PRETRAINED_MODEL_ARCHIVE_LIST", # Bit 预训练模型归档列表
"BitBackbone", # Bit 的骨干网络
"BitForImageClassification", # 用于图像分类任务的 Bit 模型
"BitModel", # Bit 模型
"BitPreTrainedModel", # Bit 预训练模型基类
]
)
# 将 "models.blenderbot" 模块中的特定对象列表扩展到 _import_structure 字典中
_import_structure["models.blenderbot"].extend(
[
"BLENDERBOT_PRETRAINED_MODEL_ARCHIVE_LIST", # Blenderbot 预训练模型归档列表
"BlenderbotForCausalLM", # 用于因果语言建模的 Blenderbot 模型
"BlenderbotForConditionalGeneration", # 用于条件生成任务的 Blenderbot 模型
"BlenderbotModel", # Blenderbot 模型
"BlenderbotPreTrainedModel", # Blenderbot 预训练模型基类
]
)
# 将 "models.blenderbot_small" 模块中的特定对象列表扩展到 _import_structure 字典中
_import_structure["models.blenderbot_small"].extend(
[
"BLENDERBOT_SMALL_PRETRAINED_MODEL_ARCHIVE_LIST", # BlenderbotSmall 预训练模型归档列表
"BlenderbotSmallForCausalLM", # 用于因果语言建模的 BlenderbotSmall 模型
"BlenderbotSmallForConditionalGeneration", # 用于条件生成任务的 BlenderbotSmall 模型
"BlenderbotSmallModel", # BlenderbotSmall 模型
"BlenderbotSmallPreTrainedModel", # BlenderbotSmall 预训练模型基类
]
)
# 将指定模块中的一组预定义字符串和类名添加到_import_structure字典中的models.blip条目中
_import_structure["models.blip"].extend(
[
"BLIP_PRETRAINED_MODEL_ARCHIVE_LIST", # BLIP预训练模型存档列表
"BlipForConditionalGeneration", # 用于条件生成的Blip模型
"BlipForImageTextRetrieval", # 用于图像文本检索的Blip模型
"BlipForQuestionAnswering", # 用于问答的Blip模型
"BlipModel", # Blip模型基类
"BlipPreTrainedModel", # Blip预训练模型基类
"BlipTextModel", # 用于文本任务的Blip模型
"BlipVisionModel", # 用于视觉任务的Blip模型
]
)
# 将指定模块中的一组预定义字符串和类名添加到_import_structure字典中的models.blip_2条目中
_import_structure["models.blip_2"].extend(
[
"BLIP_2_PRETRAINED_MODEL_ARCHIVE_LIST", # BLIP_2预训练模型存档列表
"Blip2ForConditionalGeneration", # 用于条件生成的Blip2模型
"Blip2Model", # Blip2模型基类
"Blip2PreTrainedModel", # Blip2预训练模型基类
"Blip2QFormerModel", # Blip2的Q-Former模型
"Blip2VisionModel", # 用于视觉任务的Blip2模型
]
)
# 将指定模块中的一组预定义字符串和类名添加到_import_structure字典中的models.bloom条目中
_import_structure["models.bloom"].extend(
[
"BLOOM_PRETRAINED_MODEL_ARCHIVE_LIST", # BLOOM预训练模型存档列表
"BloomForCausalLM", # 用于因果语言建模的Bloom模型
"BloomForQuestionAnswering", # 用于问答的Bloom模型
"BloomForSequenceClassification", # 用于序列分类的Bloom模型
"BloomForTokenClassification", # 用于标记分类的Bloom模型
"BloomModel", # Bloom模型基类
"BloomPreTrainedModel", # Bloom预训练模型基类
]
)
# 将指定模块中的一组预定义字符串和类名添加到_import_structure字典中的models.bridgetower条目中
_import_structure["models.bridgetower"].extend(
[
"BRIDGETOWER_PRETRAINED_MODEL_ARCHIVE_LIST", # BRIDGETOWER预训练模型存档列表
"BridgeTowerForContrastiveLearning", # 用于对比学习的BridgeTower模型
"BridgeTowerForImageAndTextRetrieval", # 用于图像文本检索的BridgeTower模型
"BridgeTowerForMaskedLM", # 用于掩蔽语言建模的BridgeTower模型
"BridgeTowerModel", # BridgeTower模型基类
"BridgeTowerPreTrainedModel", # BridgeTower预训练模型基类
]
)
# 将指定模块中的一组预定义字符串和类名添加到_import_structure字典中的models.bros条目中
_import_structure["models.bros"].extend(
[
"BROS_PRETRAINED_MODEL_ARCHIVE_LIST", # BROS预训练模型存档列表
"BrosForTokenClassification", # 用于标记分类的Bros模型
"BrosModel", # Bros模型基类
"BrosPreTrainedModel", # Bros预训练模型基类
"BrosProcessor", # Bros处理器
"BrosSpadeEEForTokenClassification", # 用于标记分类的Bros Spade EE模型
"BrosSpadeELForTokenClassification", # 用于标记分类的Bros Spade EL模型
]
)
# 将指定模块中的一组预定义字符串和类名添加到_import_structure字典中的models.camembert条目中
_import_structure["models.camembert"].extend(
[
"CAMEMBERT_PRETRAINED_MODEL_ARCHIVE_LIST", # CAMEMBERT预训练模型存档列表
"CamembertForCausalLM", # 用于因果语言建模的Camembert模型
"CamembertForMaskedLM", # 用于掩蔽语言建模的Camembert模型
"CamembertForMultipleChoice", # 用于多项选择任务的Camembert模型
"CamembertForQuestionAnswering", # 用于问答的Camembert模型
"CamembertForSequenceClassification", # 用于序列分类的Camembert模型
"CamembertForTokenClassification", # 用于标记分类的Camembert模型
"CamembertModel", # Camembert模型基类
"CamembertPreTrainedModel", # Camembert预训练模型基类
]
)
# 将指定模块中的一组预定义字符串和类名添加到_import_structure字典中的models.canine条目中
_import_structure["models.canine"].extend(
[
"CANINE_PRETRAINED_MODEL_ARCHIVE_LIST", # CANINE预训练模型存档列表
"CanineForMultipleChoice", # 用于多项选择任务的Canine模型
"CanineForQuestionAnswering", # 用于问答的Canine模型
"CanineForSequenceClassification", # 用于序列分类的Canine模型
"CanineForTokenClassification", # 用于标记分类的Canine模型
"CanineLayer", # Canine模型的层
"CanineModel", # Canine模型基类
"CaninePreTrainedModel", # Canine预训练模型基类
"load_tf_weights_in_canine", # 加载TensorFlow权重到Canine模型中的函数
]
)
# 将指定模块中的一组预定义字符串和类名添加到_import_structure字典中的models.chinese_clip条目中
_import_structure["models.chinese_clip"].extend(
[
"CHINESE_CLIP_PRETRAINED_MODEL_ARCHIVE_LIST", # CHINESE_CLIP预训练模型存档列表
"ChineseCLIPModel", # 中文CLIP模型
"ChineseCLIPPreTrainedModel", # 中文CLIP预训练模型基类
"ChineseCLIPTextModel", # 用于文本任务的中文CLIP模型
"ChineseCLIPVisionModel", # 用于视觉任务的中文CLIP模型
]
)
# 将 "models.clap" 中的模块列表扩展,包括预训练模型存档列表和各个特定模型类
_import_structure["models.clap"].extend(
[
"CLAP_PRETRAINED_MODEL_ARCHIVE_LIST",
"ClapAudioModel",
"ClapAudioModelWithProjection",
"ClapFeatureExtractor",
"ClapModel",
"ClapPreTrainedModel",
"ClapTextModel",
"ClapTextModelWithProjection",
]
)
# 将 "models.clip" 中的模块列表扩展,包括预训练模型存档列表和各个特定模型类
_import_structure["models.clip"].extend(
[
"CLIP_PRETRAINED_MODEL_ARCHIVE_LIST",
"CLIPForImageClassification",
"CLIPModel",
"CLIPPreTrainedModel",
"CLIPTextModel",
"CLIPTextModelWithProjection",
"CLIPVisionModel",
"CLIPVisionModelWithProjection",
]
)
# 将 "models.clipseg" 中的模块列表扩展,包括预训练模型存档列表和各个特定模型类
_import_structure["models.clipseg"].extend(
[
"CLIPSEG_PRETRAINED_MODEL_ARCHIVE_LIST",
"CLIPSegForImageSegmentation",
"CLIPSegModel",
"CLIPSegPreTrainedModel",
"CLIPSegTextModel",
"CLIPSegVisionModel",
]
)
# 将 "models.clvp" 中的模块列表扩展,包括预训练模型存档列表和各个特定模型类
_import_structure["models.clvp"].extend(
[
"CLVP_PRETRAINED_MODEL_ARCHIVE_LIST",
"ClvpDecoder",
"ClvpEncoder",
"ClvpForCausalLM",
"ClvpModel",
"ClvpModelForConditionalGeneration",
"ClvpPreTrainedModel",
]
)
# 将 "models.codegen" 中的模块列表扩展,包括预训练模型存档列表和各个特定模型类
_import_structure["models.codegen"].extend(
[
"CODEGEN_PRETRAINED_MODEL_ARCHIVE_LIST",
"CodeGenForCausalLM",
"CodeGenModel",
"CodeGenPreTrainedModel",
]
)
# 将 "models.cohere" 中的模块列表扩展,包括各个特定模型类
_import_structure["models.cohere"].extend(
[
"CohereForCausalLM",
"CohereModel",
"CoherePreTrainedModel",
]
)
# 将 "models.conditional_detr" 中的模块列表扩展,包括预训练模型存档列表和各个特定模型类
_import_structure["models.conditional_detr"].extend(
[
"CONDITIONAL_DETR_PRETRAINED_MODEL_ARCHIVE_LIST",
"ConditionalDetrForObjectDetection",
"ConditionalDetrForSegmentation",
"ConditionalDetrModel",
"ConditionalDetrPreTrainedModel",
]
)
# 将 "models.convbert" 中的模块列表扩展,包括预训练模型存档列表和各个特定模型类
_import_structure["models.convbert"].extend(
[
"CONVBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
"ConvBertForMaskedLM",
"ConvBertForMultipleChoice",
"ConvBertForQuestionAnswering",
"ConvBertForSequenceClassification",
"ConvBertForTokenClassification",
"ConvBertLayer",
"ConvBertModel",
"ConvBertPreTrainedModel",
"load_tf_weights_in_convbert",
]
)
# 将 "models.convnext" 中的模块列表扩展,包括预训练模型存档列表和各个特定模型类
_import_structure["models.convnext"].extend(
[
"CONVNEXT_PRETRAINED_MODEL_ARCHIVE_LIST",
"ConvNextBackbone",
"ConvNextForImageClassification",
"ConvNextModel",
"ConvNextPreTrainedModel",
]
)
# 将以下模块的名称列表扩展到_import_structure字典中的对应键
_import_structure["models.convnextv2"].extend(
[
"CONVNEXTV2_PRETRAINED_MODEL_ARCHIVE_LIST", # ConvNextV2模型的预训练模型存档列表
"ConvNextV2Backbone", # ConvNextV2的主干模型
"ConvNextV2ForImageClassification", # 用于图像分类的ConvNextV2模型
"ConvNextV2Model", # ConvNextV2模型
"ConvNextV2PreTrainedModel", # ConvNextV2预训练模型
]
)
# 将以下模块的名称列表扩展到_import_structure字典中的对应键
_import_structure["models.cpmant"].extend(
[
"CPMANT_PRETRAINED_MODEL_ARCHIVE_LIST", # CpmAnt模型的预训练模型存档列表
"CpmAntForCausalLM", # 用于因果语言建模的CpmAnt模型
"CpmAntModel", # CpmAnt模型
"CpmAntPreTrainedModel", # CpmAnt预训练模型
]
)
# 将以下模块的名称列表扩展到_import_structure字典中的对应键
_import_structure["models.ctrl"].extend(
[
"CTRL_PRETRAINED_MODEL_ARCHIVE_LIST", # CTRL模型的预训练模型存档列表
"CTRLForSequenceClassification", # 用于序列分类的CTRL模型
"CTRLLMHeadModel", # CTRL模型的LM头部模型
"CTRLModel", # CTRL模型
"CTRLPreTrainedModel", # CTRL预训练模型
]
)
# 将以下模块的名称列表扩展到_import_structure字典中的对应键
_import_structure["models.cvt"].extend(
[
"CVT_PRETRAINED_MODEL_ARCHIVE_LIST", # CVT模型的预训练模型存档列表
"CvtForImageClassification", # 用于图像分类的CVT模型
"CvtModel", # CVT模型
"CvtPreTrainedModel", # CVT预训练模型
]
)
# 将以下模块的名称列表扩展到_import_structure字典中的对应键
_import_structure["models.data2vec"].extend(
[
"DATA2VEC_AUDIO_PRETRAINED_MODEL_ARCHIVE_LIST", # Data2Vec音频模型的预训练模型存档列表
"DATA2VEC_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST", # Data2Vec文本模型的预训练模型存档列表
"DATA2VEC_VISION_PRETRAINED_MODEL_ARCHIVE_LIST", # Data2Vec视觉模型的预训练模型存档列表
"Data2VecAudioForAudioFrameClassification", # 用于音频帧分类的Data2Vec音频模型
"Data2VecAudioForCTC", # 用于CTC的Data2Vec音频模型
"Data2VecAudioForSequenceClassification", # 用于序列分类的Data2Vec音频模型
"Data2VecAudioForXVector", # 用于X向量的Data2Vec音频模型
"Data2VecAudioModel", # Data2Vec音频模型
"Data2VecAudioPreTrainedModel", # Data2Vec音频预训练模型
"Data2VecTextForCausalLM", # 用于因果语言建模的Data2Vec文本模型
"Data2VecTextForMaskedLM", # 用于掩码语言建模的Data2Vec文本模型
"Data2VecTextForMultipleChoice", # 用于多选题的Data2Vec文本模型
"Data2VecTextForQuestionAnswering", # 用于问答的Data2Vec文本模型
"Data2VecTextForSequenceClassification", # 用于序列分类的Data2Vec文本模型
"Data2VecTextForTokenClassification", # 用于标记分类的Data2Vec文本模型
"Data2VecTextModel", # Data2Vec文本模型
"Data2VecTextPreTrainedModel", # Data2Vec文本预训练模型
"Data2VecVisionForImageClassification", # 用于图像分类的Data2Vec视觉模型
"Data2VecVisionForSemanticSegmentation", # 用于语义分割的Data2Vec视觉模型
"Data2VecVisionModel", # Data2Vec视觉模型
"Data2VecVisionPreTrainedModel", # Data2Vec视觉预训练模型
]
)
# 将以下模块的名称列表扩展到_import_structure字典中的对应键
_import_structure["models.deberta"].extend(
[
"DEBERTA_PRETRAINED_MODEL_ARCHIVE_LIST", # Deberta模型的预训练模型存档列表
"DebertaForMaskedLM", # 用于掩码语言建模的Deberta模型
"DebertaForQuestionAnswering", # 用于问答的Deberta模型
"DebertaForSequenceClassification", # 用于序列分类的Deberta模型
"DebertaForTokenClassification", # 用于标记分类的Deberta模型
"DebertaModel", # Deberta模型
"DebertaPreTrainedModel", # Deberta预训练模型
]
)
# 将以下模块的名称列表扩展到_import_structure字典中的对应键
_import_structure["models.deberta_v2"].extend(
[
"DEBERTA_V2_PRETRAINED_MODEL_ARCHIVE_LIST", # DebertaV2模型的预训练模型存档列表
"DebertaV2ForMaskedLM", # 用于掩码语言建模的DebertaV2模型
"DebertaV2ForMultipleChoice", # 用于多选题的DebertaV2模型
"DebertaV2ForQuestionAnswering", # 用于问答的DebertaV2模型
"DebertaV2ForSequenceClassification", # 用于序列分类的DebertaV2模型
"DebertaV2ForTokenClassification", # 用于标记分类的DebertaV2模型
"DebertaV2Model", # DebertaV2模型
"DebertaV2PreTrainedModel", # DebertaV2预训练模型
]
)
_import_structure["models.decision_transformer"].extend(
[
"DECISION_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST",
"DecisionTransformerGPT2Model",
"DecisionTransformerGPT2PreTrainedModel",
"DecisionTransformerModel",
"DecisionTransformerPreTrainedModel",
]
)
_import_structure["models.deformable_detr"].extend(
[
"DEFORMABLE_DETR_PRETRAINED_MODEL_ARCHIVE_LIST",
"DeformableDetrForObjectDetection",
"DeformableDetrModel",
"DeformableDetrPreTrainedModel",
]
)
_import_structure["models.deit"].extend(
[
"DEIT_PRETRAINED_MODEL_ARCHIVE_LIST",
"DeiTForImageClassification",
"DeiTForImageClassificationWithTeacher",
"DeiTForMaskedImageModeling",
"DeiTModel",
"DeiTPreTrainedModel",
]
)
_import_structure["models.deprecated.mctct"].extend(
[
"MCTCT_PRETRAINED_MODEL_ARCHIVE_LIST",
"MCTCTForCTC",
"MCTCTModel",
"MCTCTPreTrainedModel",
]
)
_import_structure["models.deprecated.mmbt"].extend(
[
"MMBTForClassification",
"MMBTModel",
"ModalEmbeddings"
]
)
_import_structure["models.deprecated.open_llama"].extend(
[
"OpenLlamaForCausalLM",
"OpenLlamaForSequenceClassification",
"OpenLlamaModel",
"OpenLlamaPreTrainedModel",
]
)
_import_structure["models.deprecated.retribert"].extend(
[
"RETRIBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
"RetriBertModel",
"RetriBertPreTrainedModel",
]
)
_import_structure["models.deprecated.trajectory_transformer"].extend(
[
"TRAJECTORY_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST",
"TrajectoryTransformerModel",
"TrajectoryTransformerPreTrainedModel",
]
)
_import_structure["models.deprecated.transfo_xl"].extend(
[
"TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_LIST",
"AdaptiveEmbedding",
"TransfoXLForSequenceClassification",
"TransfoXLLMHeadModel",
"TransfoXLModel",
"TransfoXLPreTrainedModel",
"load_tf_weights_in_transfo_xl",
]
)
_import_structure["models.deprecated.van"].extend(
[
"VAN_PRETRAINED_MODEL_ARCHIVE_LIST",
"VanForImageClassification",
"VanModel",
"VanPreTrainedModel",
]
)
_import_structure["models.depth_anything"].extend(
[
"DEPTH_ANYTHING_PRETRAINED_MODEL_ARCHIVE_LIST",
"DepthAnythingForDepthEstimation",
"DepthAnythingPreTrainedModel",
]
)
注释:
# 扩展导入结构中的 models.decision_transformer,包括预训练模型存档列表和相关模型类
_import_structure["models.decision_transformer"].extend(
[
"DECISION_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST",
"DecisionTransformerGPT2Model",
"DecisionTransformerGPT2PreTrainedModel",
"DecisionTransformerModel",
"DecisionTransformerPreTrainedModel",
]
)
# 扩展导入结构中的 models.deformable_detr,包括预训练模型存档列表和相关模型类
_import_structure["models.deformable_detr"].extend(
[
"DEFORMABLE_DETR_PRETRAINED_MODEL_ARCHIVE_LIST",
"DeformableDetrForObjectDetection",
"DeformableDetrModel",
"DeformableDetrPreTrainedModel",
]
)
# 扩展导入结构中的 models.deit,包括预训练模型存档列表和相关模型类
_import_structure["models.deit"].extend(
[
"DEIT_PRETRAINED_MODEL_ARCHIVE_LIST",
"DeiTForImageClassification",
"DeiTForImageClassificationWithTeacher",
"DeiTForMaskedImageModeling",
"DeiTModel",
"DeiTPreTrainedModel",
]
)
# 扩展导入结构中的 models.deprecated.mctct,包括预训练模型存档列表和相关模型类
_import_structure["models.deprecated.mctct"].extend(
[
"MCTCT_PRETRAINED_MODEL_ARCHIVE_LIST",
"MCTCTForCTC",
"MCTCTModel",
"MCTCTPreTrainedModel",
]
)
# 扩展导入结构中的 models.deprecated.mmbt,包括相关分类和嵌入模型
_import_structure["models.deprecated.mmbt"].extend(
[
"MMBTForClassification",
"MMBTModel",
"ModalEmbeddings"
]
)
# 扩展导入结构中的 models.deprecated.open_llama,包括用于因果语言建模和序列分类的模型
_import_structure["models.deprecated.open_llama"].extend(
[
"OpenLlamaForCausalLM",
"OpenLlamaForSequenceClassification",
"OpenLlamaModel",
"OpenLlamaPreTrainedModel",
]
)
# 扩展导入结构中的 models.deprecated.retribert,包括预训练模型存档列表和相关模型类
_import_structure["models.deprecated.retribert"].extend(
[
"RETRIBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
"RetriBertModel",
"RetriBertPreTrainedModel",
]
)
# 扩展导入结构中的 models.deprecated.trajectory_transformer,包括轨迹转换模型类和预训练模型
_import_structure["models.deprecated.trajectory_transformer"].extend(
[
"TRAJECTORY_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST",
"TrajectoryTransformerModel",
"TrajectoryTransformerPreTrainedModel",
]
)
# 扩展导入结构中的 models.deprecated.transfo_xl,包括用于序列分类和语言建模的 TransfoXL 相关模型和工具
_import_structure["models.deprecated.transfo_xl"].extend(
[
"TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_LIST",
"AdaptiveEmbedding",
"TransfoXLForSequenceClassification",
"TransfoXLLMHeadModel",
"TransfoXLModel",
"TransfoXLPreTrainedModel",
"load_tf_weights_in_transfo_xl",
]
)
# 扩展导入结构中的 models.deprecated.van,包括用于图像分类的 Van 模型和相关预训练模型
_import_structure["models.deprecated.van"].extend(
[
"VAN_PRETRAINED_MODEL_ARCHIVE_LIST",
"VanForImageClassification",
"VanModel",
"VanPreTrainedModel",
]
)
# 扩展导入结构中的 models.depth_anything,包括深度估计相关模型和预训练模型
_import_structure["models.depth_anything"].extend(
[
"DEPTH_ANYTHING_PRETRAINED_MODEL_ARCHIVE_LIST",
"DepthAnythingForDepthEstimation",
"DepthAnythingPreTrainedModel",
]
)
# 将 "models.deta" 模块的相关对象添加到导入结构中
_import_structure["models.deta"].extend(
[
"DETA_PRETRAINED_MODEL_ARCHIVE_LIST", # DETA 预训练模型的存档列表
"DetaForObjectDetection", # 用于目标检测的 Deta 模型
"DetaModel", # Deta 模型
"DetaPreTrainedModel", # Deta 预训练模型
]
)
# 将 "models.detr" 模块的相关对象添加到导入结构中
_import_structure["models.detr"].extend(
[
"DETR_PRETRAINED_MODEL_ARCHIVE_LIST", # DETR 预训练模型的存档列表
"DetrForObjectDetection", # 用于目标检测的 Detr 模型
"DetrForSegmentation", # 用于分割任务的 Detr 模型
"DetrModel", # Detr 模型
"DetrPreTrainedModel", # Detr 预训练模型
]
)
# 将 "models.dinat" 模块的相关对象添加到导入结构中
_import_structure["models.dinat"].extend(
[
"DINAT_PRETRAINED_MODEL_ARCHIVE_LIST", # DINAT 预训练模型的存档列表
"DinatBackbone", # Dinat 的骨干网络
"DinatForImageClassification", # 用于图像分类的 Dinat 模型
"DinatModel", # Dinat 模型
"DinatPreTrainedModel", # Dinat 预训练模型
]
)
# 将 "models.dinov2" 模块的相关对象添加到导入结构中
_import_structure["models.dinov2"].extend(
[
"DINOV2_PRETRAINED_MODEL_ARCHIVE_LIST", # DINOV2 预训练模型的存档列表
"Dinov2Backbone", # Dinov2 的骨干网络
"Dinov2ForImageClassification", # 用于图像分类的 Dinov2 模型
"Dinov2Model", # Dinov2 模型
"Dinov2PreTrainedModel", # Dinov2 预训练模型
]
)
# 将 "models.distilbert" 模块的相关对象添加到导入结构中
_import_structure["models.distilbert"].extend(
[
"DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST", # DISTILBERT 预训练模型的存档列表
"DistilBertForMaskedLM", # 用于遮蔽语言建模任务的 DistilBERT 模型
"DistilBertForMultipleChoice", # 用于多项选择任务的 DistilBERT 模型
"DistilBertForQuestionAnswering", # 用于问答任务的 DistilBERT 模型
"DistilBertForSequenceClassification", # 用于序列分类任务的 DistilBERT 模型
"DistilBertForTokenClassification", # 用于标记分类任务的 DistilBERT 模型
"DistilBertModel", # DistilBERT 模型
"DistilBertPreTrainedModel", # DistilBERT 预训练模型
]
)
# 将 "models.donut" 模块的相关对象添加到导入结构中
_import_structure["models.donut"].extend(
[
"DONUT_SWIN_PRETRAINED_MODEL_ARCHIVE_LIST", # DONUT SWIN 预训练模型的存档列表
"DonutSwinModel", # DonutSwin 模型
"DonutSwinPreTrainedModel", # DonutSwin 预训练模型
]
)
# 将 "models.dpr" 模块的相关对象添加到导入结构中
_import_structure["models.dpr"].extend(
[
"DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST", # DPR 上下文编码器预训练模型的存档列表
"DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST", # DPR 问题编码器预训练模型的存档列表
"DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST", # DPR 阅读器预训练模型的存档列表
"DPRContextEncoder", # DPR 上下文编码器
"DPRPretrainedContextEncoder", # DPR 预训练上下文编码器
"DPRPreTrainedModel", # DPR 预训练模型
"DPRPretrainedQuestionEncoder", # DPR 预训练问题编码器
"DPRPretrainedReader", # DPR 预训练阅读器
"DPRQuestionEncoder", # DPR 问题编码器
"DPRReader", # DPR 阅读器
]
)
# 将 "models.dpt" 模块的相关对象添加到导入结构中
_import_structure["models.dpt"].extend(
[
"DPT_PRETRAINED_MODEL_ARCHIVE_LIST", # DPT 预训练模型的存档列表
"DPTForDepthEstimation", # 用于深度估计任务的 DPT 模型
"DPTForSemanticSegmentation", # 用于语义分割任务的 DPT 模型
"DPTModel", # DPT 模型
"DPTPreTrainedModel", # DPT 预训练模型
]
)
# 将 "models.efficientformer" 模块的相关对象添加到导入结构中
_import_structure["models.efficientformer"].extend(
[
"EFFICIENTFORMER_PRETRAINED_MODEL_ARCHIVE_LIST", # EFFICIENTFORMER 预训练模型的存档列表
"EfficientFormerForImageClassification", # 用于图像分类的 EfficientFormer 模型
"EfficientFormerForImageClassificationWithTeacher", # 带有教师模型的图像分类 EfficientFormer 模型
"EfficientFormerModel", # EfficientFormer 模型
"EfficientFormerPreTrainedModel", # EfficientFormer 预训练模型
]
)
# 将 "models.efficientnet" 模块的相关对象添加到导入结构中
_import_structure["models.efficientnet"].extend(
[
"EFFICIENTNET_PRETRAINED_MODEL_ARCHIVE_LIST", # EFFICIENTNET 预训练模型的存档列表
"EfficientNetForImageClassification", # 用于图像分类的 EfficientNet 模型
"EfficientNetModel", # EfficientNet 模型
"EfficientNetPreTrainedModel", # EfficientNet 预训练模型
]
)
# 扩展 _import_structure 字典中 "models.electra" 键的值,添加多个 Electra 相关的模型和常量
_import_structure["models.electra"].extend(
[
"ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST",
"ElectraForCausalLM",
"ElectraForMaskedLM",
"ElectraForMultipleChoice",
"ElectraForPreTraining",
"ElectraForQuestionAnswering",
"ElectraForSequenceClassification",
"ElectraForTokenClassification",
"ElectraModel",
"ElectraPreTrainedModel",
"load_tf_weights_in_electra",
]
)
# 扩展 _import_structure 字典中 "models.encodec" 键的值,添加 Encodec 相关的模型和常量
_import_structure["models.encodec"].extend(
[
"ENCODEC_PRETRAINED_MODEL_ARCHIVE_LIST",
"EncodecModel",
"EncodecPreTrainedModel",
]
)
# 向 _import_structure 字典中 "models.encoder_decoder" 键的值添加 EncoderDecoderModel
_import_structure["models.encoder_decoder"].append("EncoderDecoderModel")
# 扩展 _import_structure 字典中 "models.ernie" 键的值,添加多个 Ernie 相关的模型和常量
_import_structure["models.ernie"].extend(
[
"ERNIE_PRETRAINED_MODEL_ARCHIVE_LIST",
"ErnieForCausalLM",
"ErnieForMaskedLM",
"ErnieForMultipleChoice",
"ErnieForNextSentencePrediction",
"ErnieForPreTraining",
"ErnieForQuestionAnswering",
"ErnieForSequenceClassification",
"ErnieForTokenClassification",
"ErnieModel",
"ErniePreTrainedModel",
]
)
# 扩展 _import_structure 字典中 "models.ernie_m" 键的值,添加多个 ErnieM 相关的模型和常量
_import_structure["models.ernie_m"].extend(
[
"ERNIE_M_PRETRAINED_MODEL_ARCHIVE_LIST",
"ErnieMForInformationExtraction",
"ErnieMForMultipleChoice",
"ErnieMForQuestionAnswering",
"ErnieMForSequenceClassification",
"ErnieMForTokenClassification",
"ErnieMModel",
"ErnieMPreTrainedModel",
]
)
# 扩展 _import_structure 字典中 "models.esm" 键的值,添加多个 Esm 相关的模型和常量
_import_structure["models.esm"].extend(
[
"ESM_PRETRAINED_MODEL_ARCHIVE_LIST",
"EsmFoldPreTrainedModel",
"EsmForMaskedLM",
"EsmForProteinFolding",
"EsmForSequenceClassification",
"EsmForTokenClassification",
"EsmModel",
"EsmPreTrainedModel",
]
)
# 扩展 _import_structure 字典中 "models.falcon" 键的值,添加多个 Falcon 相关的模型和常量
_import_structure["models.falcon"].extend(
[
"FALCON_PRETRAINED_MODEL_ARCHIVE_LIST",
"FalconForCausalLM",
"FalconForQuestionAnswering",
"FalconForSequenceClassification",
"FalconForTokenClassification",
"FalconModel",
"FalconPreTrainedModel",
]
)
# 扩展 _import_structure 字典中 "models.fastspeech2_conformer" 键的值,添加多个 FastSpeech2 Conformer 相关的模型和常量
_import_structure["models.fastspeech2_conformer"].extend(
[
"FASTSPEECH2_CONFORMER_PRETRAINED_MODEL_ARCHIVE_LIST",
"FastSpeech2ConformerHifiGan",
"FastSpeech2ConformerModel",
"FastSpeech2ConformerPreTrainedModel",
"FastSpeech2ConformerWithHifiGan",
]
)
# 将 "models.flaubert" 中指定的模块名列表扩展到 _import_structure 字典的值中
_import_structure["models.flaubert"].extend(
[
"FLAUBERT_PRETRAINED_MODEL_ARCHIVE_LIST", # 预训练模型存档列表
"FlaubertForMultipleChoice", # 用于多项选择任务的 Flaubert 模型
"FlaubertForQuestionAnswering", # 用于问答任务的 Flaubert 模型
"FlaubertForQuestionAnsweringSimple", # 简化版本的问答任务 Flaubert 模型
"FlaubertForSequenceClassification", # 用于序列分类任务的 Flaubert 模型
"FlaubertForTokenClassification", # 用于标记分类任务的 Flaubert 模型
"FlaubertModel", # Flaubert 模型基类
"FlaubertPreTrainedModel", # Flaubert 预训练模型基类
"FlaubertWithLMHeadModel", # 带有语言模型头的 Flaubert 模型
]
)
# 将 "models.flava" 中指定的模块名列表扩展到 _import_structure 字典的值中
_import_structure["models.flava"].extend(
[
"FLAVA_PRETRAINED_MODEL_ARCHIVE_LIST", # FLAVA 模型预训练模型存档列表
"FlavaForPreTraining", # 用于预训练任务的 FLAVA 模型
"FlavaImageCodebook", # 图像编码簿模块
"FlavaImageModel", # 图像模型
"FlavaModel", # FLAVA 模型基类
"FlavaMultimodalModel", # 多模态 FLAVA 模型
"FlavaPreTrainedModel", # FLAVA 预训练模型基类
"FlavaTextModel", # 文本模型
]
)
# 将 "models.fnet" 中指定的模块名列表扩展到 _import_structure 字典的值中
_import_structure["models.fnet"].extend(
[
"FNET_PRETRAINED_MODEL_ARCHIVE_LIST", # FNET 模型预训练模型存档列表
"FNetForMaskedLM", # 用于掩码语言建模任务的 FNet 模型
"FNetForMultipleChoice", # 用于多项选择任务的 FNet 模型
"FNetForNextSentencePrediction", # 用于下一个句子预测任务的 FNet 模型
"FNetForPreTraining", # 用于预训练任务的 FNet 模型
"FNetForQuestionAnswering", # 用于问答任务的 FNet 模型
"FNetForSequenceClassification", # 用于序列分类任务的 FNet 模型
"FNetForTokenClassification", # 用于标记分类任务的 FNet 模型
"FNetLayer", # FNet 模型的层
"FNetModel", # FNet 模型基类
"FNetPreTrainedModel", # FNet 预训练模型基类
]
)
# 将 "models.focalnet" 中指定的模块名列表扩展到 _import_structure 字典的值中
_import_structure["models.focalnet"].extend(
[
"FOCALNET_PRETRAINED_MODEL_ARCHIVE_LIST", # FOCALNET 模型预训练模型存档列表
"FocalNetBackbone", # FocalNet 模型的骨干网络
"FocalNetForImageClassification", # 用于图像分类任务的 FocalNet 模型
"FocalNetForMaskedImageModeling", # 用于遮罩图像建模任务的 FocalNet 模型
"FocalNetModel", # FocalNet 模型基类
"FocalNetPreTrainedModel", # FocalNet 预训练模型基类
]
)
# 将 "models.fsmt" 中指定的模块名列表扩展到 _import_structure 字典的值中
_import_structure["models.fsmt"].extend(["FSMTForConditionalGeneration", "FSMTModel", "PretrainedFSMTModel"])
# 将 "models.funnel" 中指定的模块名列表扩展到 _import_structure 字典的值中
_import_structure["models.funnel"].extend(
[
"FUNNEL_PRETRAINED_MODEL_ARCHIVE_LIST", # FUNNEL 模型预训练模型存档列表
"FunnelBaseModel", # Funnel 模型基类
"FunnelForMaskedLM", # 用于掩码语言建模任务的 Funnel 模型
"FunnelForMultipleChoice", # 用于多项选择任务的 Funnel 模型
"FunnelForPreTraining", # 用于预训练任务的 Funnel 模型
"FunnelForQuestionAnswering", # 用于问答任务的 Funnel 模型
"FunnelForSequenceClassification", # 用于序列分类任务的 Funnel 模型
"FunnelForTokenClassification", # 用于标记分类任务的 Funnel 模型
"FunnelModel", # Funnel 模型基类
"FunnelPreTrainedModel", # Funnel 预训练模型基类
"load_tf_weights_in_funnel", # 加载 TensorFlow 权重到 Funnel 模型中的函数
]
)
# 将 "models.fuyu" 中指定的模块名列表扩展到 _import_structure 字典的值中
_import_structure["models.fuyu"].extend(["FuyuForCausalLM", "FuyuPreTrainedModel"])
# 将 "models.gemma" 中指定的模块名列表扩展到 _import_structure 字典的值中
_import_structure["models.gemma"].extend(
[
"GemmaForCausalLM", # 用于因果语言建模任务的 Gemma 模型
"GemmaForSequenceClassification", # 用于序列分类任务的 Gemma 模型
"GemmaModel", # Gemma 模型基类
"GemmaPreTrainedModel", # Gemma 预训练模型基类
]
)
# 将 "models.git" 中指定的模块名列表扩展到 _import_structure 字典的值中
_import_structure["models.git"].extend(
[
"GIT_PRETRAINED_MODEL_ARCHIVE_LIST", # GIT 模型预训练模型存档列表
"GitForCausalLM", # 用于因果语言建模任务的 Git 模型
"GitModel", # Git 模型基类
"GitPreTrainedModel", # Git 预训练模型基类
"GitVisionModel", # Git 视觉模型
]
)
# 将 "models.glpn" 中指定的模块名列表扩展到 _import_structure 字典的值中
_import_structure["models.glpn"].extend(
[
"GLPN_PRETRAINED_MODEL_ARCHIVE_LIST", # GLPN 模型预训练模型存档列表
"GLPNForDepthEstimation", # 用于深度估计任务的 GLPN 模型
"GLPNModel", # GLPN 模型基类
"GLPNPreTrainedModel", # GLPN 预训练模型基类
]
)
# 将指定的模型模块导入结构中,并扩展模块列表
_import_structure["models.gpt2"].extend(
[
"GPT2_PRETRAINED_MODEL_ARCHIVE_LIST", # GPT-2 预训练模型存档列表
"GPT2DoubleHeadsModel", # GPT-2 双头模型
"GPT2ForQuestionAnswering", # GPT-2 问答模型
"GPT2ForSequenceClassification", # GPT-2 序列分类模型
"GPT2ForTokenClassification", # GPT-2 标记分类模型
"GPT2LMHeadModel", # GPT-2 语言模型头
"GPT2Model", # GPT-2 模型
"GPT2PreTrainedModel", # GPT-2 预训练模型基类
"load_tf_weights_in_gpt2", # 加载 TensorFlow 权重到 GPT-2 模型
]
)
# 将大代码模块的相关类名添加到导入结构中
_import_structure["models.gpt_bigcode"].extend(
[
"GPT_BIGCODE_PRETRAINED_MODEL_ARCHIVE_LIST", # 大代码预训练模型存档列表
"GPTBigCodeForCausalLM", # 大代码因果语言模型
"GPTBigCodeForSequenceClassification", # 大代码序列分类模型
"GPTBigCodeForTokenClassification", # 大代码标记分类模型
"GPTBigCodeModel", # 大代码模型
"GPTBigCodePreTrainedModel", # 大代码预训练模型基类
]
)
# 将 GPT-Neo 模块的相关类名添加到导入结构中
_import_structure["models.gpt_neo"].extend(
[
"GPT_NEO_PRETRAINED_MODEL_ARCHIVE_LIST", # GPT-Neo 预训练模型存档列表
"GPTNeoForCausalLM", # GPT-Neo 因果语言模型
"GPTNeoForQuestionAnswering", # GPT-Neo 问答模型
"GPTNeoForSequenceClassification", # GPT-Neo 序列分类模型
"GPTNeoForTokenClassification", # GPT-Neo 标记分类模型
"GPTNeoModel", # GPT-Neo 模型
"GPTNeoPreTrainedModel", # GPT-Neo 预训练模型基类
"load_tf_weights_in_gpt_neo", # 加载 TensorFlow 权重到 GPT-Neo 模型
]
)
# 将 GPT-NeoX 模块的相关类名添加到导入结构中
_import_structure["models.gpt_neox"].extend(
[
"GPT_NEOX_PRETRAINED_MODEL_ARCHIVE_LIST", # GPT-NeoX 预训练模型存档列表
"GPTNeoXForCausalLM", # GPT-NeoX 因果语言模型
"GPTNeoXForQuestionAnswering", # GPT-NeoX 问答模型
"GPTNeoXForSequenceClassification", # GPT-NeoX 序列分类模型
"GPTNeoXForTokenClassification", # GPT-NeoX 标记分类模型
"GPTNeoXLayer", # GPT-NeoX 模型层
"GPTNeoXModel", # GPT-NeoX 模型
"GPTNeoXPreTrainedModel", # GPT-NeoX 预训练模型基类
]
)
# 将 GPT-NeoX 日本语模块的相关类名添加到导入结构中
_import_structure["models.gpt_neox_japanese"].extend(
[
"GPT_NEOX_JAPANESE_PRETRAINED_MODEL_ARCHIVE_LIST", # GPT-NeoX 日本语预训练模型存档列表
"GPTNeoXJapaneseForCausalLM", # GPT-NeoX 日本语因果语言模型
"GPTNeoXJapaneseLayer", # GPT-NeoX 日本语模型层
"GPTNeoXJapaneseModel", # GPT-NeoX 日本语模型
"GPTNeoXJapanesePreTrainedModel", # GPT-NeoX 日本语预训练模型基类
]
)
# 将 GPT-J 模块的相关类名添加到导入结构中
_import_structure["models.gptj"].extend(
[
"GPTJ_PRETRAINED_MODEL_ARCHIVE_LIST", # GPT-J 预训练模型存档列表
"GPTJForCausalLM", # GPT-J 因果语言模型
"GPTJForQuestionAnswering", # GPT-J 问答模型
"GPTJForSequenceClassification", # GPT-J 序列分类模型
"GPTJModel", # GPT-J 模型
"GPTJPreTrainedModel", # GPT-J 预训练模型基类
]
)
# 将 GPT-SAN 日本语模块的相关类名添加到导入结构中
_import_structure["models.gptsan_japanese"].extend(
[
"GPTSAN_JAPANESE_PRETRAINED_MODEL_ARCHIVE_LIST", # GPT-SAN 日本语预训练模型存档列表
"GPTSanJapaneseForConditionalGeneration", # GPT-SAN 日本语条件生成模型
"GPTSanJapaneseModel", # GPT-SAN 日本语模型
"GPTSanJapanesePreTrainedModel", # GPT-SAN 日本语预训练模型基类
]
)
# 将 Graphormer 模块的相关类名添加到导入结构中
_import_structure["models.graphormer"].extend(
[
"GRAPHORMER_PRETRAINED_MODEL_ARCHIVE_LIST", # Graphormer 预训练模型存档列表
"GraphormerForGraphClassification", # Graphormer 图分类模型
"GraphormerModel", # Graphormer 模型
"GraphormerPreTrainedModel", # Graphormer 预训练模型基类
]
)
# 将 GroupViT 模块的相关类名添加到导入结构中
_import_structure["models.groupvit"].extend(
[
"GROUPVIT_PRETRAINED_MODEL_ARCHIVE_LIST", # GroupViT 预训练模型存档列表
"GroupViTModel", # GroupViT 模型
"GroupViTPreTrainedModel", # GroupViT 预训练模型基类
"GroupViTTextModel", # GroupViT 文本模型
"GroupViTVisionModel", # GroupViT 视觉模型
]
)
# 将 "models.hubert" 中的模块名称列表扩展,包括预训练模型存档列表和各种 Hubert 模型类
_import_structure["models.hubert"].extend(
[
"HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
"HubertForCTC",
"HubertForSequenceClassification",
"HubertModel",
"HubertPreTrainedModel",
]
)
# 将 "models.ibert" 中的模块名称列表扩展,包括预训练模型存档列表和各种 IBert 模型类
_import_structure["models.ibert"].extend(
[
"IBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
"IBertForMaskedLM",
"IBertForMultipleChoice",
"IBertForQuestionAnswering",
"IBertForSequenceClassification",
"IBertForTokenClassification",
"IBertModel",
"IBertPreTrainedModel",
]
)
# 将 "models.idefics" 中的模块名称列表扩展,包括预训练模型存档列表和各种 IDEFICS 模型类
_import_structure["models.idefics"].extend(
[
"IDEFICS_PRETRAINED_MODEL_ARCHIVE_LIST",
"IdeficsForVisionText2Text",
"IdeficsModel",
"IdeficsPreTrainedModel",
"IdeficsProcessor",
]
)
# 将 "models.imagegpt" 中的模块名称列表扩展,包括预训练模型存档列表和各种 ImageGPT 模型类以及相关函数
_import_structure["models.imagegpt"].extend(
[
"IMAGEGPT_PRETRAINED_MODEL_ARCHIVE_LIST",
"ImageGPTForCausalImageModeling",
"ImageGPTForImageClassification",
"ImageGPTModel",
"ImageGPTPreTrainedModel",
"load_tf_weights_in_imagegpt",
]
)
# 将 "models.informer" 中的模块名称列表扩展,包括预训练模型存档列表和各种 Informer 模型类
_import_structure["models.informer"].extend(
[
"INFORMER_PRETRAINED_MODEL_ARCHIVE_LIST",
"InformerForPrediction",
"InformerModel",
"InformerPreTrainedModel",
]
)
# 将 "models.instructblip" 中的模块名称列表扩展,包括预训练模型存档列表和各种 InstructBlip 模型类
_import_structure["models.instructblip"].extend(
[
"INSTRUCTBLIP_PRETRAINED_MODEL_ARCHIVE_LIST",
"InstructBlipForConditionalGeneration",
"InstructBlipPreTrainedModel",
"InstructBlipQFormerModel",
"InstructBlipVisionModel",
]
)
# 将 "models.jukebox" 中的模块名称列表扩展,包括预训练模型存档列表和各种 Jukebox 模型类
_import_structure["models.jukebox"].extend(
[
"JUKEBOX_PRETRAINED_MODEL_ARCHIVE_LIST",
"JukeboxModel",
"JukeboxPreTrainedModel",
"JukeboxPrior",
"JukeboxVQVAE",
]
)
# 将 "models.kosmos2" 中的模块名称列表扩展,包括预训练模型存档列表和各种 Kosmos2 模型类
_import_structure["models.kosmos2"].extend(
[
"KOSMOS2_PRETRAINED_MODEL_ARCHIVE_LIST",
"Kosmos2ForConditionalGeneration",
"Kosmos2Model",
"Kosmos2PreTrainedModel",
]
)
# 将 "models.layoutlm" 中的模块名称列表扩展,包括预训练模型存档列表和各种 LayoutLM 模型类
_import_structure["models.layoutlm"].extend(
[
"LAYOUTLM_PRETRAINED_MODEL_ARCHIVE_LIST",
"LayoutLMForMaskedLM",
"LayoutLMForQuestionAnswering",
"LayoutLMForSequenceClassification",
"LayoutLMForTokenClassification",
"LayoutLMModel",
"LayoutLMPreTrainedModel",
]
)
# 将 "models.layoutlmv2" 中的模块名称列表扩展,包括预训练模型存档列表和各种 LayoutLMv2 模型类
_import_structure["models.layoutlmv2"].extend(
[
"LAYOUTLMV2_PRETRAINED_MODEL_ARCHIVE_LIST",
"LayoutLMv2ForQuestionAnswering",
"LayoutLMv2ForSequenceClassification",
"LayoutLMv2ForTokenClassification",
"LayoutLMv2Model",
"LayoutLMv2PreTrainedModel",
]
)
)
# 扩展 _import_structure 中 "models.layoutlmv3" 的列表,添加以下条目
_import_structure["models.layoutlmv3"].extend(
[
"LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST",
"LayoutLMv3ForQuestionAnswering",
"LayoutLMv3ForSequenceClassification",
"LayoutLMv3ForTokenClassification",
"LayoutLMv3Model",
"LayoutLMv3PreTrainedModel",
]
)
# 扩展 _import_structure 中 "models.led" 的列表,添加以下条目
_import_structure["models.led"].extend(
[
"LED_PRETRAINED_MODEL_ARCHIVE_LIST",
"LEDForConditionalGeneration",
"LEDForQuestionAnswering",
"LEDForSequenceClassification",
"LEDModel",
"LEDPreTrainedModel",
]
)
# 扩展 _import_structure 中 "models.levit" 的列表,添加以下条目
_import_structure["models.levit"].extend(
[
"LEVIT_PRETRAINED_MODEL_ARCHIVE_LIST",
"LevitForImageClassification",
"LevitForImageClassificationWithTeacher",
"LevitModel",
"LevitPreTrainedModel",
]
)
# 扩展 _import_structure 中 "models.lilt" 的列表,添加以下条目
_import_structure["models.lilt"].extend(
[
"LILT_PRETRAINED_MODEL_ARCHIVE_LIST",
"LiltForQuestionAnswering",
"LiltForSequenceClassification",
"LiltForTokenClassification",
"LiltModel",
"LiltPreTrainedModel",
]
)
# 扩展 _import_structure 中 "models.llama" 的列表,添加以下条目
_import_structure["models.llama"].extend(
[
"LlamaForCausalLM",
"LlamaForQuestionAnswering",
"LlamaForSequenceClassification",
"LlamaModel",
"LlamaPreTrainedModel",
]
)
# 扩展 _import_structure 中 "models.llava" 的列表,添加以下条目
_import_structure["models.llava"].extend(
[
"LLAVA_PRETRAINED_MODEL_ARCHIVE_LIST",
"LlavaForConditionalGeneration",
"LlavaPreTrainedModel",
]
)
# 扩展 _import_structure 中 "models.llava_next" 的列表,添加以下条目
_import_structure["models.llava_next"].extend(
[
"LLAVA_NEXT_PRETRAINED_MODEL_ARCHIVE_LIST",
"LlavaNextForConditionalGeneration",
"LlavaNextPreTrainedModel",
]
)
# 扩展 _import_structure 中 "models.longformer" 的列表,添加以下条目
_import_structure["models.longformer"].extend(
[
"LONGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST",
"LongformerForMaskedLM",
"LongformerForMultipleChoice",
"LongformerForQuestionAnswering",
"LongformerForSequenceClassification",
"LongformerForTokenClassification",
"LongformerModel",
"LongformerPreTrainedModel",
"LongformerSelfAttention",
]
)
# 扩展 _import_structure 中 "models.longt5" 的列表,添加以下条目
_import_structure["models.longt5"].extend(
[
"LONGT5_PRETRAINED_MODEL_ARCHIVE_LIST",
"LongT5EncoderModel",
"LongT5ForConditionalGeneration",
"LongT5Model",
"LongT5PreTrainedModel",
]
)
# 将 "models.luke" 模块的若干标识符添加到 _import_structure 字典中
_import_structure["models.luke"].extend(
[
"LUKE_PRETRAINED_MODEL_ARCHIVE_LIST",
"LukeForEntityClassification",
"LukeForEntityPairClassification",
"LukeForEntitySpanClassification",
"LukeForMaskedLM",
"LukeForMultipleChoice",
"LukeForQuestionAnswering",
"LukeForSequenceClassification",
"LukeForTokenClassification",
"LukeModel",
"LukePreTrainedModel",
]
)
# 将 "models.lxmert" 模块的若干标识符添加到 _import_structure 字典中
_import_structure["models.lxmert"].extend(
[
"LxmertEncoder",
"LxmertForPreTraining",
"LxmertForQuestionAnswering",
"LxmertModel",
"LxmertPreTrainedModel",
"LxmertVisualFeatureEncoder",
"LxmertXLayer",
]
)
# 将 "models.m2m_100" 模块的若干标识符添加到 _import_structure 字典中
_import_structure["models.m2m_100"].extend(
[
"M2M_100_PRETRAINED_MODEL_ARCHIVE_LIST",
"M2M100ForConditionalGeneration",
"M2M100Model",
"M2M100PreTrainedModel",
]
)
# 将 "models.mamba" 模块的若干标识符添加到 _import_structure 字典中
_import_structure["models.mamba"].extend(
[
"MAMBA_PRETRAINED_MODEL_ARCHIVE_LIST",
"MambaForCausalLM",
"MambaModel",
"MambaPreTrainedModel",
]
)
# 将 "models.marian" 模块的若干标识符添加到 _import_structure 字典中
_import_structure["models.marian"].extend(
["MarianForCausalLM", "MarianModel", "MarianMTModel"]
)
# 将 "models.markuplm" 模块的若干标识符添加到 _import_structure 字典中
_import_structure["models.markuplm"].extend(
[
"MARKUPLM_PRETRAINED_MODEL_ARCHIVE_LIST",
"MarkupLMForQuestionAnswering",
"MarkupLMForSequenceClassification",
"MarkupLMForTokenClassification",
"MarkupLMModel",
"MarkupLMPreTrainedModel",
]
)
# 将 "models.mask2former" 模块的若干标识符添加到 _import_structure 字典中
_import_structure["models.mask2former"].extend(
[
"MASK2FORMER_PRETRAINED_MODEL_ARCHIVE_LIST",
"Mask2FormerForUniversalSegmentation",
"Mask2FormerModel",
"Mask2FormerPreTrainedModel",
]
)
# 将 "models.maskformer" 模块的若干标识符添加到 _import_structure 字典中
_import_structure["models.maskformer"].extend(
[
"MASKFORMER_PRETRAINED_MODEL_ARCHIVE_LIST",
"MaskFormerForInstanceSegmentation",
"MaskFormerModel",
"MaskFormerPreTrainedModel",
"MaskFormerSwinBackbone",
]
)
# 将 "models.mbart" 模块的若干标识符添加到 _import_structure 字典中
_import_structure["models.mbart"].extend(
[
"MBartForCausalLM",
"MBartForConditionalGeneration",
"MBartForQuestionAnswering",
"MBartForSequenceClassification",
"MBartModel",
"MBartPreTrainedModel",
]
)
# 将 "models.mega" 模块的若干标识符添加到 _import_structure 字典中
_import_structure["models.mega"].extend(
[
"MEGA_PRETRAINED_MODEL_ARCHIVE_LIST",
"MegaForCausalLM",
"MegaForMaskedLM",
"MegaForMultipleChoice",
"MegaForQuestionAnswering",
"MegaForSequenceClassification",
"MegaForTokenClassification",
"MegaModel",
"MegaPreTrainedModel",
]
)
# 将 "models.megatron_bert" 中指定的模块列表添加到 _import_structure 字典中
_import_structure["models.megatron_bert"].extend(
[
"MEGATRON_BERT_PRETRAINED_MODEL_ARCHIVE_LIST",
"MegatronBertForCausalLM",
"MegatronBertForMaskedLM",
"MegatronBertForMultipleChoice",
"MegatronBertForNextSentencePrediction",
"MegatronBertForPreTraining",
"MegatronBertForQuestionAnswering",
"MegatronBertForSequenceClassification",
"MegatronBertForTokenClassification",
"MegatronBertModel",
"MegatronBertPreTrainedModel",
]
)
# 将 "models.mgp_str" 中指定的模块列表添加到 _import_structure 字典中
_import_structure["models.mgp_str"].extend(
[
"MGP_STR_PRETRAINED_MODEL_ARCHIVE_LIST",
"MgpstrForSceneTextRecognition",
"MgpstrModel",
"MgpstrPreTrainedModel",
]
)
# 将 "models.mistral" 中指定的模块列表添加到 _import_structure 字典中
_import_structure["models.mistral"].extend(
[
"MistralForCausalLM",
"MistralForSequenceClassification",
"MistralModel",
"MistralPreTrainedModel",
]
)
# 将 "models.mixtral" 中指定的模块列表添加到 _import_structure 字典中
_import_structure["models.mixtral"].extend(
["MixtralForCausalLM", "MixtralForSequenceClassification", "MixtralModel", "MixtralPreTrainedModel"]
)
# 将 "models.mobilebert" 中指定的模块列表添加到 _import_structure 字典中
_import_structure["models.mobilebert"].extend(
[
"MOBILEBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
"MobileBertForMaskedLM",
"MobileBertForMultipleChoice",
"MobileBertForNextSentencePrediction",
"MobileBertForPreTraining",
"MobileBertForQuestionAnswering",
"MobileBertForSequenceClassification",
"MobileBertForTokenClassification",
"MobileBertLayer",
"MobileBertModel",
"MobileBertPreTrainedModel",
"load_tf_weights_in_mobilebert",
]
)
# 将 "models.mobilenet_v1" 中指定的模块列表添加到 _import_structure 字典中
_import_structure["models.mobilenet_v1"].extend(
[
"MOBILENET_V1_PRETRAINED_MODEL_ARCHIVE_LIST",
"MobileNetV1ForImageClassification",
"MobileNetV1Model",
"MobileNetV1PreTrainedModel",
"load_tf_weights_in_mobilenet_v1",
]
)
# 将 "models.mobilenet_v2" 中指定的模块列表添加到 _import_structure 字典中
_import_structure["models.mobilenet_v2"].extend(
[
"MOBILENET_V2_PRETRAINED_MODEL_ARCHIVE_LIST",
"MobileNetV2ForImageClassification",
"MobileNetV2ForSemanticSegmentation",
"MobileNetV2Model",
"MobileNetV2PreTrainedModel",
"load_tf_weights_in_mobilenet_v2",
]
)
# 将 "models.mobilevit" 中指定的模块列表添加到 _import_structure 字典中
_import_structure["models.mobilevit"].extend(
[
"MOBILEVIT_PRETRAINED_MODEL_ARCHIVE_LIST",
"MobileViTForImageClassification",
"MobileViTForSemanticSegmentation",
"MobileViTModel",
"MobileViTPreTrainedModel",
]
)
# 将以下模型名称和相关属性扩展到_import_structure字典中的"models.mobilevitv2"
_import_structure["models.mobilevitv2"].extend(
[
"MOBILEVITV2_PRETRAINED_MODEL_ARCHIVE_LIST", # 预训练模型存档列表
"MobileViTV2ForImageClassification", # 图像分类的MobileViTV2模型
"MobileViTV2ForSemanticSegmentation", # 语义分割的MobileViTV2模型
"MobileViTV2Model", # MobileViTV2模型
"MobileViTV2PreTrainedModel", # MobileViTV2预训练模型
]
)
# 将以下模型名称和相关属性扩展到_import_structure字典中的"models.mpnet"
_import_structure["models.mpnet"].extend(
[
"MPNET_PRETRAINED_MODEL_ARCHIVE_LIST", # MPNet预训练模型存档列表
"MPNetForMaskedLM", # 掩码语言建模的MPNet模型
"MPNetForMultipleChoice", # 多项选择的MPNet模型
"MPNetForQuestionAnswering", # 问答的MPNet模型
"MPNetForSequenceClassification", # 序列分类的MPNet模型
"MPNetForTokenClassification", # 标记分类的MPNet模型
"MPNetLayer", # MPNet层
"MPNetModel", # MPNet模型
"MPNetPreTrainedModel", # MPNet预训练模型
]
)
# 将以下模型名称和相关属性扩展到_import_structure字典中的"models.mpt"
_import_structure["models.mpt"].extend(
[
"MPT_PRETRAINED_MODEL_ARCHIVE_LIST", # MPT预训练模型存档列表
"MptForCausalLM", # 因果语言建模的Mpt模型
"MptForQuestionAnswering", # 问答的Mpt模型
"MptForSequenceClassification", # 序列分类的Mpt模型
"MptForTokenClassification", # 标记分类的Mpt模型
"MptModel", # Mpt模型
"MptPreTrainedModel", # Mpt预训练模型
]
)
# 将以下模型名称和相关属性扩展到_import_structure字典中的"models.mra"
_import_structure["models.mra"].extend(
[
"MRA_PRETRAINED_MODEL_ARCHIVE_LIST", # MRA预训练模型存档列表
"MraForMaskedLM", # 掩码语言建模的Mra模型
"MraForMultipleChoice", # 多项选择的Mra模型
"MraForQuestionAnswering", # 问答的Mra模型
"MraForSequenceClassification", # 序列分类的Mra模型
"MraForTokenClassification", # 标记分类的Mra模型
"MraModel", # Mra模型
"MraPreTrainedModel", # Mra预训练模型
]
)
# 将以下模型名称和相关属性扩展到_import_structure字典中的"models.mt5"
_import_structure["models.mt5"].extend(
[
"MT5EncoderModel", # MT5编码器模型
"MT5ForConditionalGeneration", # 条件生成的MT5模型
"MT5ForQuestionAnswering", # 问答的MT5模型
"MT5ForSequenceClassification", # 序列分类的MT5模型
"MT5ForTokenClassification", # 标记分类的MT5模型
"MT5Model", # MT5模型
"MT5PreTrainedModel", # MT5预训练模型
]
)
# 将以下模型名称和相关属性扩展到_import_structure字典中的"models.musicgen"
_import_structure["models.musicgen"].extend(
[
"MUSICGEN_PRETRAINED_MODEL_ARCHIVE_LIST", # MUSICGEN预训练模型存档列表
"MusicgenForCausalLM", # 因果语言建模的Musicgen模型
"MusicgenForConditionalGeneration", # 条件生成的Musicgen模型
"MusicgenModel", # Musicgen模型
"MusicgenPreTrainedModel", # Musicgen预训练模型
"MusicgenProcessor", # Musicgen处理器
]
)
# 将以下模型名称和相关属性扩展到_import_structure字典中的"models.musicgen_melody"
_import_structure["models.musicgen_melody"].extend(
[
"MUSICGEN_MELODY_PRETRAINED_MODEL_ARCHIVE_LIST", # MUSICGEN_MELODY预训练模型存档列表
"MusicgenMelodyForCausalLM", # 因果语言建模的MusicgenMelody模型
"MusicgenMelodyForConditionalGeneration", # 条件生成的MusicgenMelody模型
"MusicgenMelodyModel", # MusicgenMelody模型
"MusicgenMelodyPreTrainedModel", # MusicgenMelody预训练模型
]
)
# 将以下模型名称和相关属性扩展到_import_structure字典中的"models.mvp"
_import_structure["models.mvp"].extend(
[
"MVP_PRETRAINED_MODEL_ARCHIVE_LIST", # MVP预训练模型存档列表
"MvpForCausalLM", # 因果语言建模的Mvp模型
"MvpForConditionalGeneration", # 条件生成的Mvp模型
"MvpForQuestionAnswering", # 问答的Mvp模型
"MvpForSequenceClassification", # 序列分类的Mvp模型
"MvpModel", # Mvp模型
"MvpPreTrainedModel", # Mvp预训练模型
]
)
# 将以下模型名称和相关属性扩展到_import_structure字典中的"models.nat"
_import_structure["models.nat"].extend(
[
"NAT_PRETRAINED_MODEL_ARCHIVE_LIST", # NAT预训练模型存档列表
"NatBackbone", # NatBackbone
"NatForImageClassification", # 图像分类的Nat模型
"NatModel", # Nat模型
"NatPreTrainedModel", # Nat预训练模型
]
)
# 将 "models.nezha" 模块下的特定类名和常量列表扩展到 _import_structure 字典中
_import_structure["models.nezha"].extend(
[
"NEZHA_PRETRAINED_MODEL_ARCHIVE_LIST", # NEZHA 预训练模型存档列表常量
"NezhaForMaskedLM", # NEZHA Masked LM 模型类
"NezhaForMultipleChoice", # NEZHA 多选题模型类
"NezhaForNextSentencePrediction", # NEZHA 下一句预测模型类
"NezhaForPreTraining", # NEZHA 预训练模型类
"NezhaForQuestionAnswering", # NEZHA 问答模型类
"NezhaForSequenceClassification", # NEZHA 序列分类模型类
"NezhaForTokenClassification", # NEZHA 标记分类模型类
"NezhaModel", # NEZHA 模型基类
"NezhaPreTrainedModel", # NEZHA 预训练模型基类
]
)
# 将 "models.nllb_moe" 模块下的特定类名和常量列表扩展到 _import_structure 字典中
_import_structure["models.nllb_moe"].extend(
[
"NLLB_MOE_PRETRAINED_MODEL_ARCHIVE_LIST", # NLLB_MOE 预训练模型存档列表常量
"NllbMoeForConditionalGeneration", # NLLB_MOE 生成条件模型类
"NllbMoeModel", # NLLB_MOE 模型类
"NllbMoePreTrainedModel", # NLLB_MOE 预训练模型基类
"NllbMoeSparseMLP", # NLLB_MOE 稀疏MLP模型类
"NllbMoeTop2Router", # NLLB_MOE Top2路由模型类
]
)
# 将 "models.nystromformer" 模块下的特定类名和常量列表扩展到 _import_structure 字典中
_import_structure["models.nystromformer"].extend(
[
"NYSTROMFORMER_PRETRAINED_MODEL_ARCHIVE_LIST", # NYSTROMFORMER 预训练模型存档列表常量
"NystromformerForMaskedLM", # NYSTROMFORMER Masked LM 模型类
"NystromformerForMultipleChoice", # NYSTROMFORMER 多选题模型类
"NystromformerForQuestionAnswering", # NYSTROMFORMER 问答模型类
"NystromformerForSequenceClassification", # NYSTROMFORMER 序列分类模型类
"NystromformerForTokenClassification", # NYSTROMFORMER 标记分类模型类
"NystromformerLayer", # NYSTROMFORMER 模型层类
"NystromformerModel", # NYSTROMFORMER 模型类
"NystromformerPreTrainedModel", # NYSTROMFORMER 预训练模型基类
]
)
# 将 "models.oneformer" 模块下的特定类名和常量列表扩展到 _import_structure 字典中
_import_structure["models.oneformer"].extend(
[
"ONEFORMER_PRETRAINED_MODEL_ARCHIVE_LIST", # ONEFORMER 预训练模型存档列表常量
"OneFormerForUniversalSegmentation", # ONEFORMER 通用分割模型类
"OneFormerModel", # ONEFORMER 模型类
"OneFormerPreTrainedModel", # ONEFORMER 预训练模型基类
]
)
# 将 "models.openai" 模块下的特定类名和常量列表扩展到 _import_structure 字典中
_import_structure["models.openai"].extend(
[
"OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_LIST", # OPENAI_GPT 预训练模型存档列表常量
"OpenAIGPTDoubleHeadsModel", # OPENAI_GPT 双头模型类
"OpenAIGPTForSequenceClassification", # OPENAI_GPT 序列分类模型类
"OpenAIGPTLMHeadModel", # OPENAI_GPT LM头模型类
"OpenAIGPTModel", # OPENAI_GPT 模型类
"OpenAIGPTPreTrainedModel", # OPENAI_GPT 预训练模型基类
"load_tf_weights_in_openai_gpt", # 在 OPENAI_GPT 中加载 TensorFlow 权重函数
]
)
# 将 "models.opt" 模块下的特定类名和常量列表扩展到 _import_structure 字典中
_import_structure["models.opt"].extend(
[
"OPT_PRETRAINED_MODEL_ARCHIVE_LIST", # OPT 预训练模型存档列表常量
"OPTForCausalLM", # OPT 因果LM模型类
"OPTForQuestionAnswering", # OPT 问答模型类
"OPTForSequenceClassification", # OPT 序列分类模型类
"OPTModel", # OPT 模型类
"OPTPreTrainedModel", # OPT 预训练模型基类
]
)
# 将 "models.owlv2" 模块下的特定类名和常量列表扩展到 _import_structure 字典中
_import_structure["models.owlv2"].extend(
[
"OWLV2_PRETRAINED_MODEL_ARCHIVE_LIST", # OWLV2 预训练模型存档列表常量
"Owlv2ForObjectDetection", # OWLV2 目标检测模型类
"Owlv2Model", # OWLV2 模型类
"Owlv2PreTrainedModel", # OWLV2 预训练模型基类
"Owlv2TextModel", # OWLV2 文本模型类
"Owlv2VisionModel", # OWLV2 视觉模型类
]
)
# 将 "models.owlvit" 模块下的特定类名和常量列表扩展到 _import_structure 字典中
_import_structure["models.owlvit"].extend(
[
"OWLVIT_PRETRAINED_MODEL_ARCHIVE_LIST", # OWLVIT 预训练模型存档列表常量
"OwlViTForObjectDetection", # OWLVIT 目标检测模型类
"OwlViTModel", # OWLVIT 模型类
"OwlViTPreTrainedModel", # OWLVIT 预训练模型基类
"OwlViTTextModel", # OWLVIT 文本模型类
"OwlViTVisionModel", # OWLVIT 视觉模型类
]
)
# 将以下模块添加到 `_import_structure` 字典中的 "models.patchtsmixer" 键对应的列表中
_import_structure["models.patchtsmixer"].extend(
[
"PATCHTSMIXER_PRETRAINED_MODEL_ARCHIVE_LIST",
"PatchTSMixerForPrediction",
"PatchTSMixerForPretraining",
"PatchTSMixerForRegression",
"PatchTSMixerForTimeSeriesClassification",
"PatchTSMixerModel",
"PatchTSMixerPreTrainedModel",
]
)
# 将以下模块添加到 `_import_structure` 字典中的 "models.patchtst" 键对应的列表中
_import_structure["models.patchtst"].extend(
[
"PATCHTST_PRETRAINED_MODEL_ARCHIVE_LIST",
"PatchTSTForClassification",
"PatchTSTForPrediction",
"PatchTSTForPretraining",
"PatchTSTForRegression",
"PatchTSTModel",
"PatchTSTPreTrainedModel",
]
)
# 将以下模块添加到 `_import_structure` 字典中的 "models.pegasus" 键对应的列表中
_import_structure["models.pegasus"].extend(
[
"PegasusForCausalLM",
"PegasusForConditionalGeneration",
"PegasusModel",
"PegasusPreTrainedModel",
]
)
# 将以下模块添加到 `_import_structure` 字典中的 "models.pegasus_x" 键对应的列表中
_import_structure["models.pegasus_x"].extend(
[
"PEGASUS_X_PRETRAINED_MODEL_ARCHIVE_LIST",
"PegasusXForConditionalGeneration",
"PegasusXModel",
"PegasusXPreTrainedModel",
]
)
# 将以下模块添加到 `_import_structure` 字典中的 "models.perceiver" 键对应的列表中
_import_structure["models.perceiver"].extend(
[
"PERCEIVER_PRETRAINED_MODEL_ARCHIVE_LIST",
"PerceiverForImageClassificationConvProcessing",
"PerceiverForImageClassificationFourier",
"PerceiverForImageClassificationLearned",
"PerceiverForMaskedLM",
"PerceiverForMultimodalAutoencoding",
"PerceiverForOpticalFlow",
"PerceiverForSequenceClassification",
"PerceiverLayer",
"PerceiverModel",
"PerceiverPreTrainedModel",
]
)
# 将以下模块添加到 `_import_structure` 字典中的 "models.persimmon" 键对应的列表中
_import_structure["models.persimmon"].extend(
[
"PersimmonForCausalLM",
"PersimmonForSequenceClassification",
"PersimmonModel",
"PersimmonPreTrainedModel",
]
)
# 将以下模块添加到 `_import_structure` 字典中的 "models.phi" 键对应的列表中
_import_structure["models.phi"].extend(
[
"PHI_PRETRAINED_MODEL_ARCHIVE_LIST",
"PhiForCausalLM",
"PhiForSequenceClassification",
"PhiForTokenClassification",
"PhiModel",
"PhiPreTrainedModel",
]
)
# 将以下模块添加到 `_import_structure` 字典中的 "models.pix2struct" 键对应的列表中
_import_structure["models.pix2struct"].extend(
[
"PIX2STRUCT_PRETRAINED_MODEL_ARCHIVE_LIST",
"Pix2StructForConditionalGeneration",
"Pix2StructPreTrainedModel",
"Pix2StructTextModel",
"Pix2StructVisionModel",
]
)
# 将以下模块添加到 `_import_structure` 字典中的 "models.plbart" 键对应的列表中
_import_structure["models.plbart"].extend(
[
"PLBART_PRETRAINED_MODEL_ARCHIVE_LIST",
"PLBartForCausalLM",
"PLBartForConditionalGeneration",
"PLBartForSequenceClassification",
"PLBartModel",
"PLBartPreTrainedModel",
]
)
# 将 "models.poolformer" 模块的预训练模型列表、图像分类的 PoolFormer 类、PoolFormer 模型、PoolFormer 的预训练模型添加到导入结构中
_import_structure["models.poolformer"].extend(
[
"POOLFORMER_PRETRAINED_MODEL_ARCHIVE_LIST",
"PoolFormerForImageClassification",
"PoolFormerModel",
"PoolFormerPreTrainedModel",
]
)
# 将 "models.pop2piano" 模块的预训练模型列表、条件生成的 Pop2Piano 类、Pop2Piano 模型、Pop2Piano 的预训练模型添加到导入结构中
_import_structure["models.pop2piano"].extend(
[
"POP2PIANO_PRETRAINED_MODEL_ARCHIVE_LIST",
"Pop2PianoForConditionalGeneration",
"Pop2PianoPreTrainedModel",
]
)
# 将 "models.prophetnet" 模块的预训练模型列表、ProphetNet 解码器、ProphetNet 编码器等添加到导入结构中
_import_structure["models.prophetnet"].extend(
[
"PROPHETNET_PRETRAINED_MODEL_ARCHIVE_LIST",
"ProphetNetDecoder",
"ProphetNetEncoder",
"ProphetNetForCausalLM",
"ProphetNetForConditionalGeneration",
"ProphetNetModel",
"ProphetNetPreTrainedModel",
]
)
# 将 "models.pvt" 模块的预训练模型列表、图像分类的 Pvt 类、Pvt 模型、Pvt 的预训练模型添加到导入结构中
_import_structure["models.pvt"].extend(
[
"PVT_PRETRAINED_MODEL_ARCHIVE_LIST",
"PvtForImageClassification",
"PvtModel",
"PvtPreTrainedModel",
]
)
# 将 "models.pvt_v2" 模块的预训练模型列表、PvtV2 的骨干网络、图像分类的 PvtV2 类、PvtV2 模型、PvtV2 的预训练模型添加到导入结构中
_import_structure["models.pvt_v2"].extend(
[
"PVT_V2_PRETRAINED_MODEL_ARCHIVE_LIST",
"PvtV2Backbone",
"PvtV2ForImageClassification",
"PvtV2Model",
"PvtV2PreTrainedModel",
]
)
# 将 "models.qdqbert" 模块的预训练模型列表、QDQBert 的各种任务专用类、QDQBert 层、QDQBert 语言模型头部等添加到导入结构中
_import_structure["models.qdqbert"].extend(
[
"QDQBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
"QDQBertForMaskedLM",
"QDQBertForMultipleChoice",
"QDQBertForNextSentencePrediction",
"QDQBertForQuestionAnswering",
"QDQBertForSequenceClassification",
"QDQBertForTokenClassification",
"QDQBertLayer",
"QDQBertLMHeadModel",
"QDQBertModel",
"QDQBertPreTrainedModel",
"load_tf_weights_in_qdqbert",
]
)
# 将 "models.qwen2" 模块的条件生成 Qwen2 类、Qwen2 模型、Qwen2 的预训练模型添加到导入结构中
_import_structure["models.qwen2"].extend(
[
"Qwen2ForCausalLM",
"Qwen2ForSequenceClassification",
"Qwen2Model",
"Qwen2PreTrainedModel",
]
)
# 将 "models.rag" 模块的 RAG 模型、RAG 的预训练模型添加到导入结构中
_import_structure["models.rag"].extend(
[
"RagModel",
"RagPreTrainedModel",
"RagSequenceForGeneration",
"RagTokenForGeneration",
]
)
# 将 "models.realm" 模块的预训练模型列表、RealmEmbedder、RealmForOpenQA 等添加到导入结构中
_import_structure["models.realm"].extend(
[
"REALM_PRETRAINED_MODEL_ARCHIVE_LIST",
"RealmEmbedder",
"RealmForOpenQA",
"RealmKnowledgeAugEncoder",
"RealmPreTrainedModel",
"RealmReader",
"RealmRetriever",
"RealmScorer",
"load_tf_weights_in_realm",
]
)
# 将以下模型和相关内容导入到_import_structure中的"models.reformer"模块中
_import_structure["models.reformer"].extend(
[
"REFORMER_PRETRAINED_MODEL_ARCHIVE_LIST", # 引入预训练模型存档列表
"ReformerAttention", # 引入ReformerAttention类
"ReformerForMaskedLM", # 引入ReformerForMaskedLM类
"ReformerForQuestionAnswering", # 引入ReformerForQuestionAnswering类
"ReformerForSequenceClassification", # 引入ReformerForSequenceClassification类
"ReformerLayer", # 引入ReformerLayer类
"ReformerModel", # 引入ReformerModel类
"ReformerModelWithLMHead", # 引入ReformerModelWithLMHead类
"ReformerPreTrainedModel", # 引入ReformerPreTrainedModel类
]
)
# 将以下模型和相关内容导入到_import_structure中的"models.regnet"模块中
_import_structure["models.regnet"].extend(
[
"REGNET_PRETRAINED_MODEL_ARCHIVE_LIST", # 引入预训练模型存档列表
"RegNetForImageClassification", # 引入RegNetForImageClassification类
"RegNetModel", # 引入RegNetModel类
"RegNetPreTrainedModel", # 引入RegNetPreTrainedModel类
]
)
# 将以下模型和相关内容导入到_import_structure中的"models.rembert"模块中
_import_structure["models.rembert"].extend(
[
"REMBERT_PRETRAINED_MODEL_ARCHIVE_LIST", # 引入预训练模型存档列表
"RemBertForCausalLM", # 引入RemBertForCausalLM类
"RemBertForMaskedLM", # 引入RemBertForMaskedLM类
"RemBertForMultipleChoice", # 引入RemBertForMultipleChoice类
"RemBertForQuestionAnswering", # 引入RemBertForQuestionAnswering类
"RemBertForSequenceClassification", # 引入RemBertForSequenceClassification类
"RemBertForTokenClassification", # 引入RemBertForTokenClassification类
"RemBertLayer", # 引入RemBertLayer类
"RemBertModel", # 引入RemBertModel类
"RemBertPreTrainedModel", # 引入RemBertPreTrainedModel类
"load_tf_weights_in_rembert", # 引入load_tf_weights_in_rembert函数
]
)
# 将以下模型和相关内容导入到_import_structure中的"models.resnet"模块中
_import_structure["models.resnet"].extend(
[
"RESNET_PRETRAINED_MODEL_ARCHIVE_LIST", # 引入预训练模型存档列表
"ResNetBackbone", # 引入ResNetBackbone类
"ResNetForImageClassification", # 引入ResNetForImageClassification类
"ResNetModel", # 引入ResNetModel类
"ResNetPreTrainedModel", # 引入ResNetPreTrainedModel类
]
)
# 将以下模型和相关内容导入到_import_structure中的"models.roberta"模块中
_import_structure["models.roberta"].extend(
[
"ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST", # 引入预训练模型存档列表
"RobertaForCausalLM", # 引入RobertaForCausalLM类
"RobertaForMaskedLM", # 引入RobertaForMaskedLM类
"RobertaForMultipleChoice", # 引入RobertaForMultipleChoice类
"RobertaForQuestionAnswering", # 引入RobertaForQuestionAnswering类
"RobertaForSequenceClassification", # 引入RobertaForSequenceClassification类
"RobertaForTokenClassification", # 引入RobertaForTokenClassification类
"RobertaModel", # 引入RobertaModel类
"RobertaPreTrainedModel", # 引入RobertaPreTrainedModel类
]
)
# 将以下模型和相关内容导入到_import_structure中的"models.roberta_prelayernorm"模块中
_import_structure["models.roberta_prelayernorm"].extend(
[
"ROBERTA_PRELAYERNORM_PRETRAINED_MODEL_ARCHIVE_LIST", # 引入预训练模型存档列表
"RobertaPreLayerNormForCausalLM", # 引入RobertaPreLayerNormForCausalLM类
"RobertaPreLayerNormForMaskedLM", # 引入RobertaPreLayerNormForMaskedLM类
"RobertaPreLayerNormForMultipleChoice", # 引入RobertaPreLayerNormForMultipleChoice类
"RobertaPreLayerNormForQuestionAnswering", # 引入RobertaPreLayerNormForQuestionAnswering类
"RobertaPreLayerNormForSequenceClassification", # 引入RobertaPreLayerNormForSequenceClassification类
"RobertaPreLayerNormForTokenClassification", # 引入RobertaPreLayerNormForTokenClassification类
"RobertaPreLayerNormModel", # 引入RobertaPreLayerNormModel类
"RobertaPreLayerNormPreTrainedModel", # 引入RobertaPreLayerNormPreTrainedModel类
]
)
# 将以下模型和相关内容导入到_import_structure中的"models.roc_bert"模块中
_import_structure["models.roc_bert"].extend(
[
"ROC_BERT_PRETRAINED_MODEL_ARCHIVE_LIST", # 引入预训练模型存档列表
"RoCBertForCausalLM", # 引入RoCBertForCausalLM类
"RoCBertForMaskedLM", # 引入RoCBertForMaskedLM类
"RoCBertForMultipleChoice", # 引入RoCBertForMultipleChoice类
"RoCBertForPreTraining", # 引入RoCBertForPreTraining类
"RoCBertForQuestionAnswering", # 引入RoCBertForQuestionAnswering类
"RoCBertForSequenceClassification", # 引入RoCBertForSequenceClassification类
"RoCBertForTokenClassification", # 引入RoCBertForTokenClassification类
"RoCBertLayer", # 引入RoCBertLayer类
"RoCBertModel", # 引入RoCBertModel类
"RoCBertPreTrainedModel", # 引入RoCBertPreTrainedModel类
"load_tf_weights_in_roc_bert", # 引入load_tf_weights_in_roc_bert函数
]
)
# 将 "models.roformer" 模块中的一组成员添加到 _import_structure 字典的列表中
_import_structure["models.roformer"].extend(
[
"ROFORMER_PRETRAINED_MODEL_ARCHIVE_LIST", # RoFormer 预训练模型的存档列表
"RoFormerForCausalLM", # 用于因果语言建模的 RoFormer 模型
"RoFormerForMaskedLM", # 用于遮蔽语言建模的 RoFormer 模型
"RoFormerForMultipleChoice", # 用于多选题任务的 RoFormer 模型
"RoFormerForQuestionAnswering", # 用于问答任务的 RoFormer 模型
"RoFormerForSequenceClassification", # 用于序列分类任务的 RoFormer 模型
"RoFormerForTokenClassification", # 用于标记分类任务的 RoFormer 模型
"RoFormerLayer", # RoFormer 模型的层定义
"RoFormerModel", # RoFormer 模型的主体定义
"RoFormerPreTrainedModel", # RoFormer 模型的预训练模型基类
"load_tf_weights_in_roformer", # 加载 TensorFlow 权重到 RoFormer 模型中的函数
]
)
# 将 "models.rwkv" 模块中的一组成员添加到 _import_structure 字典的列表中
_import_structure["models.rwkv"].extend(
[
"RWKV_PRETRAINED_MODEL_ARCHIVE_LIST", # Rwkv 预训练模型的存档列表
"RwkvForCausalLM", # 用于因果语言建模的 Rwkv 模型
"RwkvModel", # Rwkv 模型的主体定义
"RwkvPreTrainedModel", # Rwkv 模型的预训练模型基类
]
)
# 将 "models.sam" 模块中的一组成员添加到 _import_structure 字典的列表中
_import_structure["models.sam"].extend(
[
"SAM_PRETRAINED_MODEL_ARCHIVE_LIST", # SAM 预训练模型的存档列表
"SamModel", # SAM 模型的主体定义
"SamPreTrainedModel", # SAM 模型的预训练模型基类
]
)
# 将 "models.seamless_m4t" 模块中的一组成员添加到 _import_structure 字典的列表中
_import_structure["models.seamless_m4t"].extend(
[
"SEAMLESS_M4T_PRETRAINED_MODEL_ARCHIVE_LIST", # Seamless M4T 预训练模型的存档列表
"SeamlessM4TCodeHifiGan", # 用于代码 Hifi Gan 的 Seamless M4T 模型
"SeamlessM4TForSpeechToSpeech", # 用于语音转语音任务的 Seamless M4T 模型
"SeamlessM4TForSpeechToText", # 用于语音转文本任务的 Seamless M4T 模型
"SeamlessM4TForTextToSpeech", # 用于文本转语音任务的 Seamless M4T 模型
"SeamlessM4TForTextToText", # 用于文本转文本任务的 Seamless M4T 模型
"SeamlessM4THifiGan", # 用于 Hifi Gan 的 Seamless M4T 模型
"SeamlessM4TModel", # Seamless M4T 模型的主体定义
"SeamlessM4TPreTrainedModel", # Seamless M4T 模型的预训练模型基类
"SeamlessM4TTextToUnitForConditionalGeneration", # 用于条件生成的 Seamless M4T 模型
"SeamlessM4TTextToUnitModel", # 用于文本生成的 Seamless M4T 模型
]
)
# 将 "models.seamless_m4t_v2" 模块中的一组成员添加到 _import_structure 字典的列表中
_import_structure["models.seamless_m4t_v2"].extend(
[
"SEAMLESS_M4T_V2_PRETRAINED_MODEL_ARCHIVE_LIST", # Seamless M4T V2 预训练模型的存档列表
"SeamlessM4Tv2ForSpeechToSpeech", # 用于语音转语音任务的 Seamless M4T V2 模型
"SeamlessM4Tv2ForSpeechToText", # 用于语音转文本任务的 Seamless M4T V2 模型
"SeamlessM4Tv2ForTextToSpeech", # 用于文本转语音任务的 Seamless M4T V2 模型
"SeamlessM4Tv2ForTextToText", # 用于文本转文本任务的 Seamless M4T V2 模型
"SeamlessM4Tv2Model", # Seamless M4T V2 模型的主体定义
"SeamlessM4Tv2PreTrainedModel", # Seamless M4T V2 模型的预训练模型基类
]
)
# 将 "models.segformer" 模块中的一组成员添加到 _import_structure 字典的列表中
_import_structure["models.segformer"].extend(
[
"SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST", # Segformer 预训练模型的存档列表
"SegformerDecodeHead", # Segformer 解码头部定义
"SegformerForImageClassification", # 用于图像分类任务的 Segformer 模型
"SegformerForSemanticSegmentation", # 用于语义分割任务的 Segformer 模型
"SegformerLayer", # Segformer 模型的层定义
"SegformerModel", # Segformer 模型的主体定义
"SegformerPreTrainedModel", # Segformer 模型的预训练模型基类
]
)
# 将 "models.seggpt" 模块中的一组成员添加到 _import_structure 字典的列表中
_import_structure["models.seggpt"].extend(
[
"SEGGPT_PRETRAINED_MODEL_ARCHIVE_LIST", # SegGpt 预训练模型的存档列表
"SegGptForImageSegmentation", # 用于图像分割任务的 SegGpt 模型
"SegGptModel", # SegGpt 模型的主体定义
"SegGptPreTrainedModel", # SegGpt 模型的预训练模型基类
]
)
# 将 "models.sew" 模块中的一组成员添加到 _import_structure 字典的列表中
_import_structure["models.sew"].extend(
[
"SEW_PRETRAINED_MODEL_ARCHIVE_LIST", # SEW 预训练模型的存档列表
"SEWForCTC", # 用于 CTC 模型的 SEW 模型
"SEWForSequenceClassification", # 用于序列分类任务的 SEW 模型
"SEWModel", # SEW 模型的主体定义
"SEWPreTrainedModel", # SEW 模型的预训练模型基类
]
)
# 将 "models.sew_d" 模块中的一组成员添加到 _import_structure 字典的列表中
_import_structure["models.sew_d"].extend(
[
"SEW_D_PRETRAINED_MODEL_ARCHIVE_LIST", # SEW_D 预训练模型的存档列表
"SEWDForCTC", # 用于 CTC 模型的 SEW_D 模型
"SEWDForSequenceClassification", # 用于序列分类任务的 SEW_D 模型
"SEWDModel", # SEW_D 模型的主体定义
"SEWDPreTrainedModel", # SEW_D 模型的预训练模型基类
]
)
# 扩展导入结构中 "models.siglip" 的内容列表,包括预训练模型列表、图像分类模型、基础模型、预训练模型和文本模型、视觉模型
_import_structure["models.siglip"].extend(
[
"SIGLIP_PRETRAINED_MODEL_ARCHIVE_LIST",
"SiglipForImageClassification",
"SiglipModel",
"SiglipPreTrainedModel",
"SiglipTextModel",
"SiglipVisionModel",
]
)
# 扩展导入结构中 "models.speech_encoder_decoder" 的内容列表,包括语音编码解码模型
_import_structure["models.speech_encoder_decoder"].extend(["SpeechEncoderDecoderModel"])
# 扩展导入结构中 "models.speech_to_text" 的内容列表,包括语音转文本预训练模型列表、语音转文本生成模型、语音转文本基础模型、语音转文本预训练模型
_import_structure["models.speech_to_text"].extend(
[
"SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST",
"Speech2TextForConditionalGeneration",
"Speech2TextModel",
"Speech2TextPreTrainedModel",
]
)
# 扩展导入结构中 "models.speech_to_text_2" 的内容列表,包括第二个语音转文本条件LM模型和第二个语音转文本预训练模型
_import_structure["models.speech_to_text_2"].extend(["Speech2Text2ForCausalLM", "Speech2Text2PreTrainedModel"])
# 扩展导入结构中 "models.speecht5" 的内容列表,包括T5风格语音到语音预训练模型列表、T5风格语音到文本模型、T5风格文本到语音模型、T5风格HifiGan模型、T5风格基础模型、T5风格预训练模型
_import_structure["models.speecht5"].extend(
[
"SPEECHT5_PRETRAINED_MODEL_ARCHIVE_LIST",
"SpeechT5ForSpeechToSpeech",
"SpeechT5ForSpeechToText",
"SpeechT5ForTextToSpeech",
"SpeechT5HifiGan",
"SpeechT5Model",
"SpeechT5PreTrainedModel",
]
)
# 扩展导入结构中 "models.splinter" 的内容列表,包括SPLINTER预训练模型列表、SPLINTER预训练模型、SPLINTER问答模型、SPLINTER层、SPLINTER基础模型、SPLINTER预训练模型
_import_structure["models.splinter"].extend(
[
"SPLINTER_PRETRAINED_MODEL_ARCHIVE_LIST",
"SplinterForPreTraining",
"SplinterForQuestionAnswering",
"SplinterLayer",
"SplinterModel",
"SplinterPreTrainedModel",
]
)
# 扩展导入结构中 "models.squeezebert" 的内容列表,包括SQUEEZEBERT预训练模型列表、SQUEEZEBERT遮蔽LM模型、SQUEEZEBERT多项选择模型、SQUEEZEBERT问答模型、SQUEEZEBERT序列分类模型、SQUEEZEBERT标记分类模型、SQUEEZEBERT基础模型、SQUEEZEBERT模块、SQUEEZEBERT预训练模型
_import_structure["models.squeezebert"].extend(
[
"SQUEEZEBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
"SqueezeBertForMaskedLM",
"SqueezeBertForMultipleChoice",
"SqueezeBertForQuestionAnswering",
"SqueezeBertForSequenceClassification",
"SqueezeBertForTokenClassification",
"SqueezeBertModel",
"SqueezeBertModule",
"SqueezeBertPreTrainedModel",
]
)
# 扩展导入结构中 "models.stablelm" 的内容列表,包括稳定LM条件LM模型、稳定LM序列分类模型、稳定LM基础模型、稳定LM预训练模型
_import_structure["models.stablelm"].extend(
[
"StableLmForCausalLM",
"StableLmForSequenceClassification",
"StableLmModel",
"StableLmPreTrainedModel",
]
)
# 扩展导入结构中 "models.starcoder2" 的内容列表,包括Starcoder2条件LM模型、Starcoder2序列分类模型、Starcoder2基础模型、Starcoder2预训练模型
_import_structure["models.starcoder2"].extend(
[
"Starcoder2ForCausalLM",
"Starcoder2ForSequenceClassification",
"Starcoder2Model",
"Starcoder2PreTrainedModel",
]
)
# 扩展导入结构中 "models.superpoint" 的内容列表,包括SUPERPOINT预训练模型列表、SUPERPOINT关键点检测模型、SUPERPOINT基础模型
_import_structure["models.superpoint"].extend(
[
"SUPERPOINT_PRETRAINED_MODEL_ARCHIVE_LIST",
"SuperPointForKeypointDetection",
"SuperPointPreTrainedModel",
]
)
# 扩展导入结构中 "models.swiftformer" 的内容列表,包括SWIFTFORMER预训练模型列表、SWIFTFORMER图像分类模型、SWIFTFORMER基础模型、SWIFTFORMER预训练模型
_import_structure["models.swiftformer"].extend(
[
"SWIFTFORMER_PRETRAINED_MODEL_ARCHIVE_LIST",
"SwiftFormerForImageClassification",
"SwiftFormerModel",
"SwiftFormerPreTrainedModel",
]
)
# 将指定模块的一组模型名称添加到_import_structure字典中
_import_structure["models.swin"].extend(
[
"SWIN_PRETRAINED_MODEL_ARCHIVE_LIST", # 预训练模型列表
"SwinBackbone", # Swin模型的骨干网络
"SwinForImageClassification", # 用于图像分类的Swin模型
"SwinForMaskedImageModeling", # 用于带遮罩图像建模的Swin模型
"SwinModel", # Swin模型
"SwinPreTrainedModel", # Swin预训练模型
]
)
# 将另一组模型名称添加到_import_structure字典中,此处处理swin2sr模块
_import_structure["models.swin2sr"].extend(
[
"SWIN2SR_PRETRAINED_MODEL_ARCHIVE_LIST", # SWIN2SR的预训练模型列表
"Swin2SRForImageSuperResolution", # 用于图像超分辨率的Swin2SR模型
"Swin2SRModel", # Swin2SR模型
"Swin2SRPreTrainedModel", # Swin2SR预训练模型
]
)
# 将另一组模型名称添加到_import_structure字典中,此处处理swinv2模块
_import_structure["models.swinv2"].extend(
[
"SWINV2_PRETRAINED_MODEL_ARCHIVE_LIST", # SWINV2的预训练模型列表
"Swinv2Backbone", # Swinv2模型的骨干网络
"Swinv2ForImageClassification", # 用于图像分类的Swinv2模型
"Swinv2ForMaskedImageModeling", # 用于带遮罩图像建模的Swinv2模型
"Swinv2Model", # Swinv2模型
"Swinv2PreTrainedModel", # Swinv2预训练模型
]
)
# 将另一组模型名称添加到_import_structure字典中,此处处理switch_transformers模块
_import_structure["models.switch_transformers"].extend(
[
"SWITCH_TRANSFORMERS_PRETRAINED_MODEL_ARCHIVE_LIST", # SWITCH_TRANSFORMERS的预训练模型列表
"SwitchTransformersEncoderModel", # SwitchTransformers编码器模型
"SwitchTransformersForConditionalGeneration", # SwitchTransformers条件生成模型
"SwitchTransformersModel", # SwitchTransformers通用模型
"SwitchTransformersPreTrainedModel", # SwitchTransformers预训练模型
"SwitchTransformersSparseMLP", # SwitchTransformers稀疏MLP模型
"SwitchTransformersTop1Router", # SwitchTransformers顶级1路由器模型
]
)
# 将另一组模型名称添加到_import_structure字典中,此处处理t5模块
_import_structure["models.t5"].extend(
[
"T5_PRETRAINED_MODEL_ARCHIVE_LIST", # T5的预训练模型列表
"T5EncoderModel", # T5编码器模型
"T5ForConditionalGeneration", # T5条件生成模型
"T5ForQuestionAnswering", # T5问答模型
"T5ForSequenceClassification", # T5序列分类模型
"T5ForTokenClassification", # T5标记分类模型
"T5Model", # T5通用模型
"T5PreTrainedModel", # T5预训练模型
"load_tf_weights_in_t5", # 在T5中加载TensorFlow权重
]
)
# 将另一组模型名称添加到_import_structure字典中,此处处理table_transformer模块
_import_structure["models.table_transformer"].extend(
[
"TABLE_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST", # TABLE_TRANSFORMER的预训练模型列表
"TableTransformerForObjectDetection", # 用于对象检测的TableTransformer模型
"TableTransformerModel", # TableTransformer通用模型
"TableTransformerPreTrainedModel", # TableTransformer预训练模型
]
)
# 将另一组模型名称添加到_import_structure字典中,此处处理tapas模块
_import_structure["models.tapas"].extend(
[
"TAPAS_PRETRAINED_MODEL_ARCHIVE_LIST", # TAPAS的预训练模型列表
"TapasForMaskedLM", # 用于掩码语言模型的Tapas模型
"TapasForQuestionAnswering", # Tapas问答模型
"TapasForSequenceClassification", # Tapas序列分类模型
"TapasModel", # Tapas通用模型
"TapasPreTrainedModel", # Tapas预训练模型
"load_tf_weights_in_tapas", # 在Tapas中加载TensorFlow权重
]
)
# 将另一组模型名称添加到_import_structure字典中,此处处理time_series_transformer模块
_import_structure["models.time_series_transformer"].extend(
[
"TIME_SERIES_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST", # TIME_SERIES_TRANSFORMER的预训练模型列表
"TimeSeriesTransformerForPrediction", # 用于预测的TimeSeriesTransformer模型
"TimeSeriesTransformerModel", # TimeSeriesTransformer通用模型
"TimeSeriesTransformerPreTrainedModel", # TimeSeriesTransformer预训练模型
]
)
# 将另一组模型名称添加到_import_structure字典中,此处处理timesformer模块
_import_structure["models.timesformer"].extend(
[
"TIMESFORMER_PRETRAINED_MODEL_ARCHIVE_LIST", # TIMESFORMER的预训练模型列表
"TimesformerForVideoClassification", # 用于视频分类的Timesformer模型
"TimesformerModel", # Timesformer通用模型
"TimesformerPreTrainedModel", # Timesformer预训练模型
]
)
# 将一个模型名称添加到_import_structure字典中,此处处理timm_backbone模块
_import_structure["models.timm_backbone"].extend(["TimmBackbone"]) # TimmBackbone模型
# 将 "models.trocr" 模块的列表扩展,包括预训练模型存档列表、特定模型类等
_import_structure["models.trocr"].extend(
[
"TROCR_PRETRAINED_MODEL_ARCHIVE_LIST",
"TrOCRForCausalLM",
"TrOCRPreTrainedModel",
]
)
# 将 "models.tvlt" 模块的列表扩展,包括预训练模型存档列表、特定模型类等
_import_structure["models.tvlt"].extend(
[
"TVLT_PRETRAINED_MODEL_ARCHIVE_LIST",
"TvltForAudioVisualClassification",
"TvltForPreTraining",
"TvltModel",
"TvltPreTrainedModel",
]
)
# 将 "models.tvp" 模块的列表扩展,包括预训练模型存档列表、特定模型类等
_import_structure["models.tvp"].extend(
[
"TVP_PRETRAINED_MODEL_ARCHIVE_LIST",
"TvpForVideoGrounding",
"TvpModel",
"TvpPreTrainedModel",
]
)
# 将 "models.udop" 模块的列表扩展,包括预训练模型存档列表、特定模型类等
_import_structure["models.udop"].extend(
[
"UDOP_PRETRAINED_MODEL_ARCHIVE_LIST",
"UdopEncoderModel",
"UdopForConditionalGeneration",
"UdopModel",
"UdopPreTrainedModel",
],
)
# 将 "models.umt5" 模块的列表扩展,包括特定模型类,如编码器、生成条件模型等
_import_structure["models.umt5"].extend(
[
"UMT5EncoderModel",
"UMT5ForConditionalGeneration",
"UMT5ForQuestionAnswering",
"UMT5ForSequenceClassification",
"UMT5ForTokenClassification",
"UMT5Model",
"UMT5PreTrainedModel",
]
)
# 将 "models.unispeech" 模块的列表扩展,包括预训练模型存档列表、特定语音处理模型类等
_import_structure["models.unispeech"].extend(
[
"UNISPEECH_PRETRAINED_MODEL_ARCHIVE_LIST",
"UniSpeechForCTC",
"UniSpeechForPreTraining",
"UniSpeechForSequenceClassification",
"UniSpeechModel",
"UniSpeechPreTrainedModel",
]
)
# 将 "models.unispeech_sat" 模块的列表扩展,包括预训练模型存档列表、特定语音处理模型类等
_import_structure["models.unispeech_sat"].extend(
[
"UNISPEECH_SAT_PRETRAINED_MODEL_ARCHIVE_LIST",
"UniSpeechSatForAudioFrameClassification",
"UniSpeechSatForCTC",
"UniSpeechSatForPreTraining",
"UniSpeechSatForSequenceClassification",
"UniSpeechSatForXVector",
"UniSpeechSatModel",
"UniSpeechSatPreTrainedModel",
]
)
# 将 "models.univnet" 模块的列表扩展,包括预训练模型存档列表、特定模型类等
_import_structure["models.univnet"].extend(
[
"UNIVNET_PRETRAINED_MODEL_ARCHIVE_LIST",
"UnivNetModel",
]
)
# 将 "models.upernet" 模块的列表扩展,包括语义分割模型类、预训练模型类等
_import_structure["models.upernet"].extend(
[
"UperNetForSemanticSegmentation",
"UperNetPreTrainedModel",
]
)
# 将 "models.videomae" 模块的列表扩展,包括预训练模型存档列表、视频分类模型类等
_import_structure["models.videomae"].extend(
[
"VIDEOMAE_PRETRAINED_MODEL_ARCHIVE_LIST",
"VideoMAEForPreTraining",
"VideoMAEForVideoClassification",
"VideoMAEModel",
"VideoMAEPreTrainedModel",
]
)
# 将指定模块内的预定义符号(变量和类)扩展到_import_structure字典中的models.vilt模块
_import_structure["models.vilt"].extend(
[
"VILT_PRETRAINED_MODEL_ARCHIVE_LIST", # 扩展预训练模型存档列表
"ViltForImageAndTextRetrieval", # 扩展图像和文本检索模型
"ViltForImagesAndTextClassification", # 扩展图像和文本分类模型
"ViltForMaskedLM", # 扩展掩码语言建模模型
"ViltForQuestionAnswering", # 扩展问答模型
"ViltForTokenClassification", # 扩展标记分类模型
"ViltLayer", # 扩展VILT层
"ViltModel", # 扩展VILT模型
"ViltPreTrainedModel", # 扩展VILT预训练模型
]
)
# 将指定模块内的预定义符号扩展到_import_structure字典中的models.vipllava模块
_import_structure["models.vipllava"].extend(
[
"VIPLLAVA_PRETRAINED_MODEL_ARCHIVE_LIST", # 扩展VIPLLAVA预训练模型存档列表
"VipLlavaForConditionalGeneration", # 扩展条件生成模型
"VipLlavaPreTrainedModel", # 扩展VIP LLAVA预训练模型
]
)
# 将指定模块内的预定义符号扩展到_import_structure字典中的models.vision_encoder_decoder模块
_import_structure["models.vision_encoder_decoder"].extend(["VisionEncoderDecoderModel"])
# 将指定模块内的预定义符号扩展到_import_structure字典中的models.vision_text_dual_encoder模块
_import_structure["models.vision_text_dual_encoder"].extend(["VisionTextDualEncoderModel"])
# 将指定模块内的预定义符号扩展到_import_structure字典中的models.visual_bert模块
_import_structure["models.visual_bert"].extend(
[
"VISUAL_BERT_PRETRAINED_MODEL_ARCHIVE_LIST", # 扩展VISUAL BERT预训练模型存档列表
"VisualBertForMultipleChoice", # 扩展多选题模型
"VisualBertForPreTraining", # 扩展预训练模型
"VisualBertForQuestionAnswering", # 扩展视觉BERT问答模型
"VisualBertForRegionToPhraseAlignment", # 扩展区域到短语对齐模型
"VisualBertForVisualReasoning", # 扩展视觉推理模型
"VisualBertLayer", # 扩展Visual BERT层
"VisualBertModel", # 扩展Visual BERT模型
"VisualBertPreTrainedModel", # 扩展Visual BERT预训练模型
]
)
# 将指定模块内的预定义符号扩展到_import_structure字典中的models.vit模块
_import_structure["models.vit"].extend(
[
"VIT_PRETRAINED_MODEL_ARCHIVE_LIST", # 扩展VIT预训练模型存档列表
"ViTForImageClassification", # 扩展图像分类模型
"ViTForMaskedImageModeling", # 扩展掩码图像建模模型
"ViTModel", # 扩展ViT模型
"ViTPreTrainedModel", # 扩展ViT预训练模型
]
)
# 将指定模块内的预定义符号扩展到_import_structure字典中的models.vit_hybrid模块
_import_structure["models.vit_hybrid"].extend(
[
"VIT_HYBRID_PRETRAINED_MODEL_ARCHIVE_LIST", # 扩展VIT HYBRID预训练模型存档列表
"ViTHybridForImageClassification", # 扩展图像分类模型
"ViTHybridModel", # 扩展ViT Hybrid模型
"ViTHybridPreTrainedModel", # 扩展ViT Hybrid预训练模型
]
)
# 将指定模块内的预定义符号扩展到_import_structure字典中的models.vit_mae模块
_import_structure["models.vit_mae"].extend(
[
"VIT_MAE_PRETRAINED_MODEL_ARCHIVE_LIST", # 扩展VIT MAE预训练模型存档列表
"ViTMAEForPreTraining", # 扩展预训练模型
"ViTMAELayer", # 扩展ViT MAE层
"ViTMAEModel", # 扩展ViT MAE模型
"ViTMAEPreTrainedModel", # 扩展ViT MAE预训练模型
]
)
# 将指定模块内的预定义符号扩展到_import_structure字典中的models.vit_msn模块
_import_structure["models.vit_msn"].extend(
[
"VIT_MSN_PRETRAINED_MODEL_ARCHIVE_LIST", # 扩展VIT MSN预训练模型存档列表
"ViTMSNForImageClassification", # 扩展图像分类模型
"ViTMSNModel", # 扩展ViT MSN模型
"ViTMSNPreTrainedModel", # 扩展ViT MSN预训练模型
]
)
# 将指定模块内的预定义符号扩展到_import_structure字典中的models.vitdet模块
_import_structure["models.vitdet"].extend(
[
"VITDET_PRETRAINED_MODEL_ARCHIVE_LIST", # 扩展VITDET预训练模型存档列表
"VitDetBackbone", # 扩展VitDet后端模型
"VitDetModel", # 扩展VitDet模型
"VitDetPreTrainedModel", # 扩展VitDet预训练模型
]
)
# 将指定模块内的预定义符号扩展到_import_structure字典中的models.vitmatte模块
_import_structure["models.vitmatte"].extend(
[
"VITMATTE_PRETRAINED_MODEL_ARCHIVE_LIST", # 扩展VITMATTE预训练模型存档列表
"VitMatteForImageMatting", # 扩展图像抠图模型
"VitMattePreTrainedModel", # 扩展VitMatte预训练模型
]
)
# 将指定模块内的预定义符号扩展到_import_structure字典中的models.vits模块
_import_structure["models.vits"].extend(
[
"VITS_PRETRAINED_MODEL_ARCHIVE_LIST", # 扩展VITS预训练模型存档列表
"VitsModel", # 扩展Vits模型
"VitsPreTrainedModel", # 扩展Vits预训练模型
]
)
# 将以下模型类和预训练模型列表添加到_import_structure字典中的各自模块中
_import_structure["models.vivit"].extend(
[
"VIVIT_PRETRAINED_MODEL_ARCHIVE_LIST", # Vivit模块的预训练模型归档列表
"VivitForVideoClassification", # Vivit模型用于视频分类
"VivitModel", # Vivit模型
"VivitPreTrainedModel", # Vivit预训练模型
]
)
_import_structure["models.wav2vec2"].extend(
[
"WAV_2_VEC_2_PRETRAINED_MODEL_ARCHIVE_LIST", # Wav2Vec2模块的预训练模型归档列表
"Wav2Vec2ForAudioFrameClassification", # Wav2Vec2模型用于音频帧分类
"Wav2Vec2ForCTC", # Wav2Vec2模型用于CTC任务
"Wav2Vec2ForMaskedLM", # Wav2Vec2模型用于遮蔽语言建模
"Wav2Vec2ForPreTraining", # Wav2Vec2模型用于预训练
"Wav2Vec2ForSequenceClassification", # Wav2Vec2模型用于序列分类
"Wav2Vec2ForXVector", # Wav2Vec2模型用于X向量生成
"Wav2Vec2Model", # Wav2Vec2模型
"Wav2Vec2PreTrainedModel", # Wav2Vec2预训练模型
]
)
_import_structure["models.wav2vec2_bert"].extend(
[
"WAV2VEC2_BERT_PRETRAINED_MODEL_ARCHIVE_LIST", # Wav2Vec2 BERT模块的预训练模型归档列表
"Wav2Vec2BertForAudioFrameClassification", # Wav2Vec2 BERT模型用于音频帧分类
"Wav2Vec2BertForCTC", # Wav2Vec2 BERT模型用于CTC任务
"Wav2Vec2BertForSequenceClassification", # Wav2Vec2 BERT模型用于序列分类
"Wav2Vec2BertForXVector", # Wav2Vec2 BERT模型用于X向量生成
"Wav2Vec2BertModel", # Wav2Vec2 BERT模型
"Wav2Vec2BertPreTrainedModel", # Wav2Vec2 BERT预训练模型
]
)
_import_structure["models.wav2vec2_conformer"].extend(
[
"WAV2VEC2_CONFORMER_PRETRAINED_MODEL_ARCHIVE_LIST", # Wav2Vec2 Conformer模块的预训练模型归档列表
"Wav2Vec2ConformerForAudioFrameClassification", # Wav2Vec2 Conformer模型用于音频帧分类
"Wav2Vec2ConformerForCTC", # Wav2Vec2 Conformer模型用于CTC任务
"Wav2Vec2ConformerForPreTraining", # Wav2Vec2 Conformer模型用于预训练
"Wav2Vec2ConformerForSequenceClassification", # Wav2Vec2 Conformer模型用于序列分类
"Wav2Vec2ConformerForXVector", # Wav2Vec2 Conformer模型用于X向量生成
"Wav2Vec2ConformerModel", # Wav2Vec2 Conformer模型
"Wav2Vec2ConformerPreTrainedModel", # Wav2Vec2 Conformer预训练模型
]
)
_import_structure["models.wavlm"].extend(
[
"WAVLM_PRETRAINED_MODEL_ARCHIVE_LIST", # WavLM模块的预训练模型归档列表
"WavLMForAudioFrameClassification", # WavLM模型用于音频帧分类
"WavLMForCTC", # WavLM模型用于CTC任务
"WavLMForSequenceClassification", # WavLM模型用于序列分类
"WavLMForXVector", # WavLM模型用于X向量生成
"WavLMModel", # WavLM模型
"WavLMPreTrainedModel", # WavLM预训练模型
]
)
_import_structure["models.whisper"].extend(
[
"WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST", # Whisper模块的预训练模型归档列表
"WhisperForAudioClassification", # Whisper模型用于音频分类
"WhisperForCausalLM", # Whisper模型用于因果语言建模
"WhisperForConditionalGeneration", # Whisper模型用于条件生成
"WhisperModel", # Whisper模型
"WhisperPreTrainedModel", # Whisper预训练模型
]
)
_import_structure["models.x_clip"].extend(
[
"XCLIP_PRETRAINED_MODEL_ARCHIVE_LIST", # XCLIP模块的预训练模型归档列表
"XCLIPModel", # XCLIP模型
"XCLIPPreTrainedModel", # XCLIP预训练模型
"XCLIPTextModel", # XCLIP文本模型
"XCLIPVisionModel", # XCLIP视觉模型
]
)
_import_structure["models.xglm"].extend(
[
"XGLM_PRETRAINED_MODEL_ARCHIVE_LIST", # XGLM模块的预训练模型归档列表
"XGLMForCausalLM", # XGLM模型用于因果语言建模
"XGLMModel", # XGLM模型
"XGLMPreTrainedModel", # XGLM预训练模型
]
)
# 将以下模型名称添加到 _import_structure 字典的 "models.xlm" 键对应的值列表中
_import_structure["models.xlm"].extend(
[
"XLM_PRETRAINED_MODEL_ARCHIVE_LIST",
"XLMForMultipleChoice",
"XLMForQuestionAnswering",
"XLMForQuestionAnsweringSimple",
"XLMForSequenceClassification",
"XLMForTokenClassification",
"XLMModel",
"XLMPreTrainedModel",
"XLMWithLMHeadModel",
]
)
# 将以下模型名称添加到 _import_structure 字典的 "models.xlm_prophetnet" 键对应的值列表中
_import_structure["models.xlm_prophetnet"].extend(
[
"XLM_PROPHETNET_PRETRAINED_MODEL_ARCHIVE_LIST",
"XLMProphetNetDecoder",
"XLMProphetNetEncoder",
"XLMProphetNetForCausalLM",
"XLMProphetNetForConditionalGeneration",
"XLMProphetNetModel",
"XLMProphetNetPreTrainedModel",
]
)
# 将以下模型名称添加到 _import_structure 字典的 "models.xlm_roberta" 键对应的值列表中
_import_structure["models.xlm_roberta"].extend(
[
"XLM_ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST",
"XLMRobertaForCausalLM",
"XLMRobertaForMaskedLM",
"XLMRobertaForMultipleChoice",
"XLMRobertaForQuestionAnswering",
"XLMRobertaForSequenceClassification",
"XLMRobertaForTokenClassification",
"XLMRobertaModel",
"XLMRobertaPreTrainedModel",
]
)
# 将以下模型名称添加到 _import_structure 字典的 "models.xlm_roberta_xl" 键对应的值列表中
_import_structure["models.xlm_roberta_xl"].extend(
[
"XLM_ROBERTA_XL_PRETRAINED_MODEL_ARCHIVE_LIST",
"XLMRobertaXLForCausalLM",
"XLMRobertaXLForMaskedLM",
"XLMRobertaXLForMultipleChoice",
"XLMRobertaXLForQuestionAnswering",
"XLMRobertaXLForSequenceClassification",
"XLMRobertaXLForTokenClassification",
"XLMRobertaXLModel",
"XLMRobertaXLPreTrainedModel",
]
)
# 将以下模型名称添加到 _import_structure 字典的 "models.xlnet" 键对应的值列表中
_import_structure["models.xlnet"].extend(
[
"XLNET_PRETRAINED_MODEL_ARCHIVE_LIST",
"XLNetForMultipleChoice",
"XLNetForQuestionAnswering",
"XLNetForQuestionAnsweringSimple",
"XLNetForSequenceClassification",
"XLNetForTokenClassification",
"XLNetLMHeadModel",
"XLNetModel",
"XLNetPreTrainedModel",
"load_tf_weights_in_xlnet",
]
)
# 将以下模型名称添加到 _import_structure 字典的 "models.xmod" 键对应的值列表中
_import_structure["models.xmod"].extend(
[
"XMOD_PRETRAINED_MODEL_ARCHIVE_LIST",
"XmodForCausalLM",
"XmodForMaskedLM",
"XmodForMultipleChoice",
"XmodForQuestionAnswering",
"XmodForSequenceClassification",
"XmodForTokenClassification",
"XmodModel",
"XmodPreTrainedModel",
]
)
# 将以下模型名称添加到 _import_structure 字典的 "models.yolos" 键对应的值列表中
_import_structure["models.yolos"].extend(
[
"YOLOS_PRETRAINED_MODEL_ARCHIVE_LIST",
"YolosForObjectDetection",
"YolosModel",
"YolosPreTrainedModel",
]
)
_import_structure["models.yoso"].extend(
[
"YOSO_PRETRAINED_MODEL_ARCHIVE_LIST",
"YosoForMaskedLM",
"YosoForMultipleChoice",
"YosoForQuestionAnswering",
"YosoForSequenceClassification",
"YosoForTokenClassification",
"YosoLayer",
"YosoModel",
"YosoPreTrainedModel",
]
)
# 将列表中的模块名称扩展到 "models.yoso" 的导入结构中
_import_structure["optimization"] = [
"Adafactor",
"AdamW",
"get_constant_schedule",
"get_constant_schedule_with_warmup",
"get_cosine_schedule_with_warmup",
"get_cosine_with_hard_restarts_schedule_with_warmup",
"get_inverse_sqrt_schedule",
"get_linear_schedule_with_warmup",
"get_polynomial_decay_schedule_with_warmup",
"get_scheduler",
]
# 设置 "optimization" 的导入结构为包含的优化模块列表
_import_structure["pytorch_utils"] = [
"Conv1D",
"apply_chunking_to_forward",
"prune_layer",
]
# 设置 "pytorch_utils" 的导入结构为包含的 PyTorch 实用工具列表
_import_structure["sagemaker"] = []
# 设置 "sagemaker" 的导入结构为空列表
_import_structure["time_series_utils"] = []
# 设置 "time_series_utils" 的导入结构为空列表
_import_structure["trainer"] = ["Trainer"]
# 设置 "trainer" 的导入结构为包含单个元素 "Trainer" 的列表
_import_structure["trainer_pt_utils"] = ["torch_distributed_zero_first"]
# 设置 "trainer_pt_utils" 的导入结构为包含单个元素 "torch_distributed_zero_first" 的列表
_import_structure["trainer_seq2seq"] = ["Seq2SeqTrainer"]
# 设置 "trainer_seq2seq" 的导入结构为包含单个元素 "Seq2SeqTrainer" 的列表
# TensorFlow-backed objects
# 尝试检查是否可用 TensorFlow
try:
if not is_tf_available():
# 如果 TensorFlow 不可用,抛出自定义的依赖未满足异常
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
# 如果依赖未满足,从本地导入虚拟的 TensorFlow 对象
from .utils import dummy_tf_objects
# 更新导入结构,将 dummy_tf_objects 中非私有的对象名称添加到 _import_structure 中
_import_structure["utils.dummy_tf_objects"] = [name for name in dir(dummy_tf_objects) if not name.startswith("_")]
else:
# 如果 TensorFlow 可用,更新导入结构来包含以下模块和类
_import_structure["activations_tf"] = []
_import_structure["benchmark.benchmark_args_tf"] = ["TensorFlowBenchmarkArguments"]
_import_structure["benchmark.benchmark_tf"] = ["TensorFlowBenchmark"]
_import_structure["generation"].extend(
[
"TFForcedBOSTokenLogitsProcessor",
"TFForcedEOSTokenLogitsProcessor",
"TFForceTokensLogitsProcessor",
"TFGenerationMixin",
"TFLogitsProcessor",
"TFLogitsProcessorList",
"TFLogitsWarper",
"TFMinLengthLogitsProcessor",
"TFNoBadWordsLogitsProcessor",
"TFNoRepeatNGramLogitsProcessor",
"TFRepetitionPenaltyLogitsProcessor",
"TFSuppressTokensAtBeginLogitsProcessor",
"TFSuppressTokensLogitsProcessor",
"TFTemperatureLogitsWarper",
"TFTopKLogitsWarper",
"TFTopPLogitsWarper",
]
)
_import_structure["generation_tf_utils"] = []
_import_structure["keras_callbacks"] = ["KerasMetricCallback", "PushToHubCallback"]
_import_structure["modeling_tf_outputs"] = []
_import_structure["modeling_tf_utils"] = [
"TFPreTrainedModel",
"TFSequenceSummary",
"TFSharedEmbeddings",
"shape_list",
]
# 更新导入结构,将 models.albert 中指定的类和常量添加到 _import_structure 中
_import_structure["models.albert"].extend(
[
"TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFAlbertForMaskedLM",
"TFAlbertForMultipleChoice",
"TFAlbertForPreTraining",
"TFAlbertForQuestionAnswering",
"TFAlbertForSequenceClassification",
"TFAlbertForTokenClassification",
"TFAlbertMainLayer",
"TFAlbertModel",
"TFAlbertPreTrainedModel",
]
)
# 将 "models.auto" 下的模型名称列表扩展,添加多个 TensorFlow 模型映射
_import_structure["models.auto"].extend(
[
"TF_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING", # 音频分类模型映射
"TF_MODEL_FOR_CAUSAL_LM_MAPPING", # 因果语言模型映射
"TF_MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING", # 文档问答模型映射
"TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING", # 图像分类模型映射
"TF_MODEL_FOR_MASKED_IMAGE_MODELING_MAPPING", # 掩膜图像建模模型映射
"TF_MODEL_FOR_MASKED_LM_MAPPING", # 掩膜语言模型映射
"TF_MODEL_FOR_MASK_GENERATION_MAPPING", # 掩膜生成模型映射
"TF_MODEL_FOR_MULTIPLE_CHOICE_MAPPING", # 多项选择模型映射
"TF_MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPING", # 下一句预测模型映射
"TF_MODEL_FOR_PRETRAINING_MAPPING", # 预训练模型映射
"TF_MODEL_FOR_QUESTION_ANSWERING_MAPPING", # 问答模型映射
"TF_MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING", # 语义分割模型映射
"TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING", # 序列到序列因果语言模型映射
"TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING", # 序列分类模型映射
"TF_MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING", # 语音序列到序列模型映射
"TF_MODEL_FOR_TABLE_QUESTION_ANSWERING_MAPPING", # 表格问答模型映射
"TF_MODEL_FOR_TEXT_ENCODING_MAPPING", # 文本编码模型映射
"TF_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING", # 标记分类模型映射
"TF_MODEL_FOR_VISION_2_SEQ_MAPPING", # 视觉到序列模型映射
"TF_MODEL_FOR_ZERO_SHOT_IMAGE_CLASSIFICATION_MAPPING", # 零样本图像分类模型映射
"TF_MODEL_MAPPING", # TensorFlow 模型映射
"TF_MODEL_WITH_LM_HEAD_MAPPING", # 带语言模型头的 TensorFlow 模型映射
"TFAutoModel", # 自动选择模型
"TFAutoModelForAudioClassification", # 自动选择音频分类模型
"TFAutoModelForCausalLM", # 自动选择因果语言模型
"TFAutoModelForDocumentQuestionAnswering", # 自动选择文档问答模型
"TFAutoModelForImageClassification", # 自动选择图像分类模型
"TFAutoModelForMaskedImageModeling", # 自动选择掩膜图像建模模型
"TFAutoModelForMaskedLM", # 自动选择掩膜语言模型
"TFAutoModelForMaskGeneration", # 自动选择掩膜生成模型
"TFAutoModelForMultipleChoice", # 自动选择多项选择模型
"TFAutoModelForNextSentencePrediction", # 自动选择下一句预测模型
"TFAutoModelForPreTraining", # 自动选择预训练模型
"TFAutoModelForQuestionAnswering", # 自动选择问答模型
"TFAutoModelForSemanticSegmentation", # 自动选择语义分割模型
"TFAutoModelForSeq2SeqLM", # 自动选择序列到序列语言模型
"TFAutoModelForSequenceClassification", # 自动选择序列分类模型
"TFAutoModelForSpeechSeq2Seq", # 自动选择语音序列到序列模型
"TFAutoModelForTableQuestionAnswering", # 自动选择表格问答模型
"TFAutoModelForTextEncoding", # 自动选择文本编码模型
"TFAutoModelForTokenClassification", # 自动选择标记分类模型
"TFAutoModelForVision2Seq", # 自动选择视觉到序列模型
"TFAutoModelForZeroShotImageClassification", # 自动选择零样本图像分类模型
"TFAutoModelWithLMHead", # 自动选择带语言模型头的模型
]
)
# 将 "models.bart" 下的模型名称列表扩展,添加多个 TFBart 模型映射
_import_structure["models.bart"].extend(
[
"TFBartForConditionalGeneration", # 条件生成模型
"TFBartForSequenceClassification", # 序列分类模型
"TFBartModel", # BART 模型
"TFBartPretrainedModel", # 预训练的 BART 模型
]
)
# 将 "models.bert" 中的模块列表扩展,包括多个预训练模型和类
_import_structure["models.bert"].extend(
[
"TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFBertEmbeddings",
"TFBertForMaskedLM",
"TFBertForMultipleChoice",
"TFBertForNextSentencePrediction",
"TFBertForPreTraining",
"TFBertForQuestionAnswering",
"TFBertForSequenceClassification",
"TFBertForTokenClassification",
"TFBertLMHeadModel",
"TFBertMainLayer",
"TFBertModel",
"TFBertPreTrainedModel",
]
)
# 将 "models.blenderbot" 中的模块列表扩展,包括条件生成、模型和预训练模型
_import_structure["models.blenderbot"].extend(
[
"TFBlenderbotForConditionalGeneration",
"TFBlenderbotModel",
"TFBlenderbotPreTrainedModel",
]
)
# 将 "models.blenderbot_small" 中的模块列表扩展,包括条件生成、模型和预训练模型
_import_structure["models.blenderbot_small"].extend(
[
"TFBlenderbotSmallForConditionalGeneration",
"TFBlenderbotSmallModel",
"TFBlenderbotSmallPreTrainedModel",
]
)
# 将 "models.blip" 中的模块列表扩展,包括条件生成、图像文本检索、问答、模型和预训练模型
_import_structure["models.blip"].extend(
[
"TF_BLIP_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFBlipForConditionalGeneration",
"TFBlipForImageTextRetrieval",
"TFBlipForQuestionAnswering",
"TFBlipModel",
"TFBlipPreTrainedModel",
"TFBlipTextModel",
"TFBlipVisionModel",
]
)
# 将 "models.camembert" 中的模块列表扩展,包括语言建模、多项选择、问答、分类、标记分类、模型和预训练模型
_import_structure["models.camembert"].extend(
[
"TF_CAMEMBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFCamembertForCausalLM",
"TFCamembertForMaskedLM",
"TFCamembertForMultipleChoice",
"TFCamembertForQuestionAnswering",
"TFCamembertForSequenceClassification",
"TFCamembertForTokenClassification",
"TFCamembertModel",
"TFCamembertPreTrainedModel",
]
)
# 将 "models.clip" 中的模块列表扩展,包括语言与图像交互的模型和预训练模型
_import_structure["models.clip"].extend(
[
"TF_CLIP_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFCLIPModel",
"TFCLIPPreTrainedModel",
"TFCLIPTextModel",
"TFCLIPVisionModel",
]
)
# 将 "models.convbert" 中的模块列表扩展,包括语言建模、多项选择、问答、分类、标记分类、层和预训练模型
_import_structure["models.convbert"].extend(
[
"TF_CONVBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFConvBertForMaskedLM",
"TFConvBertForMultipleChoice",
"TFConvBertForQuestionAnswering",
"TFConvBertForSequenceClassification",
"TFConvBertForTokenClassification",
"TFConvBertLayer",
"TFConvBertModel",
"TFConvBertPreTrainedModel",
]
)
# 将 "models.convnext" 中的模块列表扩展,包括图像分类、模型和预训练模型
_import_structure["models.convnext"].extend(
[
"TFConvNextForImageClassification",
"TFConvNextModel",
"TFConvNextPreTrainedModel",
]
)
# 将 "models.convnextv2" 中的模块列表扩展,包括图像分类、模型和预训练模型
_import_structure["models.convnextv2"].extend(
[
"TFConvNextV2ForImageClassification",
"TFConvNextV2Model",
"TFConvNextV2PreTrainedModel",
]
)
# 将指定模块中的多个成员添加到_import_structure字典中的“models.ctrl”部分
_import_structure["models.ctrl"].extend(
[
"TF_CTRL_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFCTRLForSequenceClassification",
"TFCTRLLMHeadModel",
"TFCTRLModel",
"TFCTRLPreTrainedModel",
]
)
# 将指定模块中的多个成员添加到_import_structure字典中的“models.cvt”部分
_import_structure["models.cvt"].extend(
[
"TF_CVT_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFCvtForImageClassification",
"TFCvtModel",
"TFCvtPreTrainedModel",
]
)
# 将指定模块中的多个成员添加到_import_structure字典中的“models.data2vec”部分
_import_structure["models.data2vec"].extend(
[
"TFData2VecVisionForImageClassification",
"TFData2VecVisionForSemanticSegmentation",
"TFData2VecVisionModel",
"TFData2VecVisionPreTrainedModel",
]
)
# 将指定模块中的多个成员添加到_import_structure字典中的“models.deberta”部分
_import_structure["models.deberta"].extend(
[
"TF_DEBERTA_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFDebertaForMaskedLM",
"TFDebertaForQuestionAnswering",
"TFDebertaForSequenceClassification",
"TFDebertaForTokenClassification",
"TFDebertaModel",
"TFDebertaPreTrainedModel",
]
)
# 将指定模块中的多个成员添加到_import_structure字典中的“models.deberta_v2”部分
_import_structure["models.deberta_v2"].extend(
[
"TF_DEBERTA_V2_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFDebertaV2ForMaskedLM",
"TFDebertaV2ForMultipleChoice",
"TFDebertaV2ForQuestionAnswering",
"TFDebertaV2ForSequenceClassification",
"TFDebertaV2ForTokenClassification",
"TFDebertaV2Model",
"TFDebertaV2PreTrainedModel",
]
)
# 将指定模块中的多个成员添加到_import_structure字典中的“models.deit”部分
_import_structure["models.deit"].extend(
[
"TF_DEIT_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFDeiTForImageClassification",
"TFDeiTForImageClassificationWithTeacher",
"TFDeiTForMaskedImageModeling",
"TFDeiTModel",
"TFDeiTPreTrainedModel",
]
)
# 将指定模块中的多个成员添加到_import_structure字典中的“models.deprecated.transfo_xl”部分
_import_structure["models.deprecated.transfo_xl"].extend(
[
"TF_TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFAdaptiveEmbedding",
"TFTransfoXLForSequenceClassification",
"TFTransfoXLLMHeadModel",
"TFTransfoXLMainLayer",
"TFTransfoXLModel",
"TFTransfoXLPreTrainedModel",
]
)
# 将指定模块中的多个成员添加到_import_structure字典中的“models.distilbert”部分
_import_structure["models.distilbert"].extend(
[
"TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFDistilBertForMaskedLM",
"TFDistilBertForMultipleChoice",
"TFDistilBertForQuestionAnswering",
"TFDistilBertForSequenceClassification",
"TFDistilBertForTokenClassification",
"TFDistilBertMainLayer",
"TFDistilBertModel",
"TFDistilBertPreTrainedModel",
]
)
# 将指定模块中的类和常量列表添加到_import_structure字典中的"models.dpr"键下
_import_structure["models.dpr"].extend(
[
"TF_DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST",
"TF_DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST",
"TF_DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFDPRContextEncoder",
"TFDPRPretrainedContextEncoder",
"TFDPRPretrainedQuestionEncoder",
"TFDPRPretrainedReader",
"TFDPRQuestionEncoder",
"TFDPRReader",
]
)
# 将指定模块中的类和常量列表添加到_import_structure字典中的"models.efficientformer"键下
_import_structure["models.efficientformer"].extend(
[
"TF_EFFICIENTFORMER_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFEfficientFormerForImageClassification",
"TFEfficientFormerForImageClassificationWithTeacher",
"TFEfficientFormerModel",
"TFEfficientFormerPreTrainedModel",
]
)
# 将指定模块中的类和常量列表添加到_import_structure字典中的"models.electra"键下
_import_structure["models.electra"].extend(
[
"TF_ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFElectraForMaskedLM",
"TFElectraForMultipleChoice",
"TFElectraForPreTraining",
"TFElectraForQuestionAnswering",
"TFElectraForSequenceClassification",
"TFElectraForTokenClassification",
"TFElectraModel",
"TFElectraPreTrainedModel",
]
)
# 将指定模块中的"TFEncoderDecoderModel"类添加到_import_structure字典中的"models.encoder_decoder"键下
_import_structure["models.encoder_decoder"].append("TFEncoderDecoderModel")
# 将指定模块中的类和常量列表添加到_import_structure字典中的"models.esm"键下
_import_structure["models.esm"].extend(
[
"ESM_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFEsmForMaskedLM",
"TFEsmForSequenceClassification",
"TFEsmForTokenClassification",
"TFEsmModel",
"TFEsmPreTrainedModel",
]
)
# 将指定模块中的类和常量列表添加到_import_structure字典中的"models.flaubert"键下
_import_structure["models.flaubert"].extend(
[
"TF_FLAUBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFFlaubertForMultipleChoice",
"TFFlaubertForQuestionAnsweringSimple",
"TFFlaubertForSequenceClassification",
"TFFlaubertForTokenClassification",
"TFFlaubertModel",
"TFFlaubertPreTrainedModel",
"TFFlaubertWithLMHeadModel",
]
)
# 将指定模块中的类和常量列表添加到_import_structure字典中的"models.funnel"键下
_import_structure["models.funnel"].extend(
[
"TF_FUNNEL_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFFunnelBaseModel",
"TFFunnelForMaskedLM",
"TFFunnelForMultipleChoice",
"TFFunnelForPreTraining",
"TFFunnelForQuestionAnswering",
"TFFunnelForSequenceClassification",
"TFFunnelForTokenClassification",
"TFFunnelModel",
"TFFunnelPreTrainedModel",
]
)
# 将指定模块中的类和常量列表添加到_import_structure字典中的"models.gpt2"键下
_import_structure["models.gpt2"].extend(
[
"TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFGPT2DoubleHeadsModel",
"TFGPT2ForSequenceClassification",
"TFGPT2LMHeadModel",
"TFGPT2MainLayer",
"TFGPT2Model",
"TFGPT2PreTrainedModel",
]
)
# 将指定模块下的类名添加到导入结构中
_import_structure["models.gptj"].extend(
[
"TFGPTJForCausalLM", # 添加 GPTJ 的条件语言模型类
"TFGPTJForQuestionAnswering", # 添加 GPTJ 的问答模型类
"TFGPTJForSequenceClassification", # 添加 GPTJ 的序列分类模型类
"TFGPTJModel", # 添加 GPTJ 的基础模型类
"TFGPTJPreTrainedModel", # 添加 GPTJ 的预训练模型基类
]
)
# 将指定模块下的类名添加到导入结构中
_import_structure["models.groupvit"].extend(
[
"TF_GROUPVIT_PRETRAINED_MODEL_ARCHIVE_LIST", # 添加 GroupViT 预训练模型存档列表
"TFGroupViTModel", # 添加 GroupViT 模型类
"TFGroupViTPreTrainedModel", # 添加 GroupViT 预训练模型基类
"TFGroupViTTextModel", # 添加 GroupViT 文本模型类
"TFGroupViTVisionModel", # 添加 GroupViT 视觉模型类
]
)
# 将指定模块下的类名添加到导入结构中
_import_structure["models.hubert"].extend(
[
"TF_HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST", # 添加 Hubert 预训练模型存档列表
"TFHubertForCTC", # 添加 Hubert CTC 模型类
"TFHubertModel", # 添加 Hubert 模型类
"TFHubertPreTrainedModel", # 添加 Hubert 预训练模型基类
]
)
# 将指定模块下的类名添加到导入结构中
_import_structure["models.layoutlm"].extend(
[
"TF_LAYOUTLM_PRETRAINED_MODEL_ARCHIVE_LIST", # 添加 LayoutLM 预训练模型存档列表
"TFLayoutLMForMaskedLM", # 添加 LayoutLM 掩码语言模型类
"TFLayoutLMForQuestionAnswering", # 添加 LayoutLM 问答模型类
"TFLayoutLMForSequenceClassification", # 添加 LayoutLM 序列分类模型类
"TFLayoutLMForTokenClassification", # 添加 LayoutLM 标记分类模型类
"TFLayoutLMMainLayer", # 添加 LayoutLM 主层类
"TFLayoutLMModel", # 添加 LayoutLM 模型类
"TFLayoutLMPreTrainedModel", # 添加 LayoutLM 预训练模型基类
]
)
# 将指定模块下的类名添加到导入结构中
_import_structure["models.layoutlmv3"].extend(
[
"TF_LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST", # 添加 LayoutLMv3 预训练模型存档列表
"TFLayoutLMv3ForQuestionAnswering", # 添加 LayoutLMv3 问答模型类
"TFLayoutLMv3ForSequenceClassification", # 添加 LayoutLMv3 序列分类模型类
"TFLayoutLMv3ForTokenClassification", # 添加 LayoutLMv3 标记分类模型类
"TFLayoutLMv3Model", # 添加 LayoutLMv3 模型类
"TFLayoutLMv3PreTrainedModel", # 添加 LayoutLMv3 预训练模型基类
]
)
# 将指定模块下的类名添加到导入结构中
_import_structure["models.led"].extend(
[
"TFLEDForConditionalGeneration", # 添加 LED 有条件生成模型类
"TFLEDModel", # 添加 LED 模型类
"TFLEDPreTrainedModel", # 添加 LED 预训练模型基类
]
)
# 将指定模块下的类名添加到导入结构中
_import_structure["models.longformer"].extend(
[
"TF_LONGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST", # 添加 Longformer 预训练模型存档列表
"TFLongformerForMaskedLM", # 添加 Longformer 掩码语言模型类
"TFLongformerForMultipleChoice", # 添加 Longformer 多项选择模型类
"TFLongformerForQuestionAnswering", # 添加 Longformer 问答模型类
"TFLongformerForSequenceClassification", # 添加 Longformer 序列分类模型类
"TFLongformerForTokenClassification", # 添加 Longformer 标记分类模型类
"TFLongformerModel", # 添加 Longformer 模型类
"TFLongformerPreTrainedModel", # 添加 Longformer 预训练模型基类
"TFLongformerSelfAttention", # 添加 Longformer 自注意力类
]
)
# 将指定模块下的类名添加到导入结构中
_import_structure["models.lxmert"].extend(
[
"TF_LXMERT_PRETRAINED_MODEL_ARCHIVE_LIST", # 添加 LXMERT 预训练模型存档列表
"TFLxmertForPreTraining", # 添加 LXMERT 预训练模型类
"TFLxmertMainLayer", # 添加 LXMERT 主层类
"TFLxmertModel", # 添加 LXMERT 模型类
"TFLxmertPreTrainedModel", # 添加 LXMERT 预训练模型基类
"TFLxmertVisualFeatureEncoder", # 添加 LXMERT 视觉特征编码器类
]
)
# 将指定模块下的类名添加到导入结构中
_import_structure["models.marian"].extend(
[
"TFMarianModel", # 添加 Marian 模型类
"TFMarianMTModel", # 添加 Marian 机器翻译模型类
"TFMarianPreTrainedModel", # 添加 Marian 预训练模型基类
]
)
# 将指定模块下的类名添加到导入结构中
_import_structure["models.mbart"].extend(
[
"TFMBartForConditionalGeneration", # 添加 MBart 有条件生成模型类
"TFMBartModel", # 添加 MBart 模型类
"TFMBartPreTrainedModel", # 添加 MBart 预训练模型基类
]
)
# 扩展_import_structure字典中"models.mobilebert"的内容
_import_structure["models.mobilebert"].extend(
[
"TF_MOBILEBERT_PRETRAINED_MODEL_ARCHIVE_LIST", # 添加预训练模型归档列表
"TFMobileBertForMaskedLM", # MobileBERT的Masked Language Model
"TFMobileBertForMultipleChoice", # MobileBERT的多选题模型
"TFMobileBertForNextSentencePrediction", # MobileBERT的下一句预测模型
"TFMobileBertForPreTraining", # MobileBERT的预训练模型
"TFMobileBertForQuestionAnswering", # MobileBERT的问答模型
"TFMobileBertForSequenceClassification", # MobileBERT的序列分类模型
"TFMobileBertForTokenClassification", # MobileBERT的标记分类模型
"TFMobileBertMainLayer", # MobileBERT的主层
"TFMobileBertModel", # MobileBERT的模型
"TFMobileBertPreTrainedModel", # MobileBERT的预训练模型基类
]
)
# 扩展_import_structure字典中"models.mobilevit"的内容
_import_structure["models.mobilevit"].extend(
[
"TF_MOBILEVIT_PRETRAINED_MODEL_ARCHIVE_LIST", # 添加预训练模型归档列表
"TFMobileViTForImageClassification", # MobileViT的图像分类模型
"TFMobileViTForSemanticSegmentation", # MobileViT的语义分割模型
"TFMobileViTModel", # MobileViT的模型
"TFMobileViTPreTrainedModel", # MobileViT的预训练模型基类
]
)
# 扩展_import_structure字典中"models.mpnet"的内容
_import_structure["models.mpnet"].extend(
[
"TF_MPNET_PRETRAINED_MODEL_ARCHIVE_LIST", # 添加预训练模型归档列表
"TFMPNetForMaskedLM", # MPNet的Masked Language Model
"TFMPNetForMultipleChoice", # MPNet的多选题模型
"TFMPNetForQuestionAnswering", # MPNet的问答模型
"TFMPNetForSequenceClassification", # MPNet的序列分类模型
"TFMPNetForTokenClassification", # MPNet的标记分类模型
"TFMPNetMainLayer", # MPNet的主层
"TFMPNetModel", # MPNet的模型
"TFMPNetPreTrainedModel", # MPNet的预训练模型基类
]
)
# 扩展_import_structure字典中"models.mt5"的内容
_import_structure["models.mt5"].extend(
[
"TFMT5EncoderModel", # MT5的编码器模型
"TFMT5ForConditionalGeneration", # MT5的条件生成模型
"TFMT5Model", # MT5的模型
]
)
# 扩展_import_structure字典中"models.openai"的内容
_import_structure["models.openai"].extend(
[
"TF_OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_LIST", # 添加预训练模型归档列表
"TFOpenAIGPTDoubleHeadsModel", # OpenAI GPT的双头模型
"TFOpenAIGPTForSequenceClassification", # OpenAI GPT的序列分类模型
"TFOpenAIGPTLMHeadModel", # OpenAI GPT的语言模型头
"TFOpenAIGPTMainLayer", # OpenAI GPT的主层
"TFOpenAIGPTModel", # OpenAI GPT的模型
"TFOpenAIGPTPreTrainedModel", # OpenAI GPT的预训练模型基类
]
)
# 扩展_import_structure字典中"models.opt"的内容
_import_structure["models.opt"].extend(
[
"TFOPTForCausalLM", # OPT的因果语言模型
"TFOPTModel", # OPT的模型
"TFOPTPreTrainedModel", # OPT的预训练模型基类
]
)
# 扩展_import_structure字典中"models.pegasus"的内容
_import_structure["models.pegasus"].extend(
[
"TFPegasusForConditionalGeneration", # Pegasus的条件生成模型
"TFPegasusModel", # Pegasus的模型
"TFPegasusPreTrainedModel", # Pegasus的预训练模型基类
]
)
# 扩展_import_structure字典中"models.rag"的内容
_import_structure["models.rag"].extend(
[
"TFRagModel", # RAG的模型
"TFRagPreTrainedModel", # RAG的预训练模型基类
"TFRagSequenceForGeneration", # RAG用于生成序列的模型
"TFRagTokenForGeneration", # RAG用于生成标记的模型
]
)
# 扩展_import_structure字典中"models.regnet"的内容
_import_structure["models.regnet"].extend(
[
"TF_REGNET_PRETRAINED_MODEL_ARCHIVE_LIST", # 添加预训练模型归档列表
"TFRegNetForImageClassification", # RegNet的图像分类模型
"TFRegNetModel", # RegNet的模型
"TFRegNetPreTrainedModel", # RegNet的预训练模型基类
]
)
# 将以下模块的多个预定义名称添加到 _import_structure 字典中的相应模块下
_import_structure["models.rembert"].extend(
[
"TF_REMBERT_PRETRAINED_MODEL_ARCHIVE_LIST", # REMBERT 模型的预训练模型存档列表
"TFRemBertForCausalLM", # 用于因果语言建模的 TFRemBert 模型
"TFRemBertForMaskedLM", # 用于遮蔽语言建模的 TFRemBert 模型
"TFRemBertForMultipleChoice", # 用于多选题的 TFRemBert 模型
"TFRemBertForQuestionAnswering", # 用于问答任务的 TFRemBert 模型
"TFRemBertForSequenceClassification", # 用于序列分类任务的 TFRemBert 模型
"TFRemBertForTokenClassification", # 用于标记分类任务的 TFRemBert 模型
"TFRemBertLayer", # REMBERT 模型的层定义
"TFRemBertModel", # REMBERT 模型的主模型
"TFRemBertPreTrainedModel", # REMBERT 模型的预训练模型基类
]
)
# 将以下模块的多个预定义名称添加到 _import_structure 字典中的相应模块下
_import_structure["models.resnet"].extend(
[
"TF_RESNET_PRETRAINED_MODEL_ARCHIVE_LIST", # RESNET 模型的预训练模型存档列表
"TFResNetForImageClassification", # 用于图像分类的 TFResNet 模型
"TFResNetModel", # RESNET 模型的主模型
"TFResNetPreTrainedModel", # RESNET 模型的预训练模型基类
]
)
# 将以下模块的多个预定义名称添加到 _import_structure 字典中的相应模块下
_import_structure["models.roberta"].extend(
[
"TF_ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST", # ROBERTA 模型的预训练模型存档列表
"TFRobertaForCausalLM", # 用于因果语言建模的 TFRoberta 模型
"TFRobertaForMaskedLM", # 用于遮蔽语言建模的 TFRoberta 模型
"TFRobertaForMultipleChoice", # 用于多选题的 TFRoberta 模型
"TFRobertaForQuestionAnswering", # 用于问答任务的 TFRoberta 模型
"TFRobertaForSequenceClassification", # 用于序列分类任务的 TFRoberta 模型
"TFRobertaForTokenClassification", # 用于标记分类任务的 TFRoberta 模型
"TFRobertaMainLayer", # ROBERTA 模型的主层定义
"TFRobertaModel", # ROBERTA 模型的主模型
"TFRobertaPreTrainedModel", # ROBERTA 模型的预训练模型基类
]
)
# 将以下模块的多个预定义名称添加到 _import_structure 字典中的相应模块下
_import_structure["models.roberta_prelayernorm"].extend(
[
"TF_ROBERTA_PRELAYERNORM_PRETRAINED_MODEL_ARCHIVE_LIST", # ROBERTA 模型带有预层标准化的预训练模型存档列表
"TFRobertaPreLayerNormForCausalLM", # 带有预层标准化的因果语言建模 TFRoberta 模型
"TFRobertaPreLayerNormForMaskedLM", # 带有预层标准化的遮蔽语言建模 TFRoberta 模型
"TFRobertaPreLayerNormForMultipleChoice", # 带有预层标准化的多选题 TFRoberta 模型
"TFRobertaPreLayerNormForQuestionAnswering", # 带有预层标准化的问答任务 TFRoberta 模型
"TFRobertaPreLayerNormForSequenceClassification", # 带有预层标准化的序列分类任务 TFRoberta 模型
"TFRobertaPreLayerNormForTokenClassification", # 带有预层标准化的标记分类任务 TFRoberta 模型
"TFRobertaPreLayerNormMainLayer", # 带有预层标准化的 ROBERTA 模型的主层定义
"TFRobertaPreLayerNormModel", # 带有预层标准化的 ROBERTA 模型的主模型
"TFRobertaPreLayerNormPreTrainedModel", # 带有预层标准化的 ROBERTA 模型的预训练模型基类
]
)
# 将以下模块的多个预定义名称添加到 _import_structure 字典中的相应模块下
_import_structure["models.roformer"].extend(
[
"TF_ROFORMER_PRETRAINED_MODEL_ARCHIVE_LIST", # ROFORMER 模型的预训练模型存档列表
"TFRoFormerForCausalLM", # 用于因果语言建模的 TFRoFormer 模型
"TFRoFormerForMaskedLM", # 用于遮蔽语言建模的 TFRoFormer 模型
"TFRoFormerForMultipleChoice", # 用于多选题的 TFRoFormer 模型
"TFRoFormerForQuestionAnswering", # 用于问答任务的 TFRoFormer 模型
"TFRoFormerForSequenceClassification", # 用于序列分类任务的 TFRoFormer 模型
"TFRoFormerForTokenClassification", # 用于标记分类任务的 TFRoFormer 模型
"TFRoFormerLayer", # ROFORMER 模型的层定义
"TFRoFormerModel", # ROFORMER 模型的主模型
"TFRoFormerPreTrainedModel", # ROFORMER 模型的预训练模型基类
]
)
# 将以下模块的多个预定义名称添加到 _import_structure 字典中的相应模块下
_import_structure["models.sam"].extend(
[
"TF_SAM_PRETRAINED_MODEL_ARCHIVE_LIST", # SAM 模型的预训练模型存档列表
"TFSamModel", # SAM 模型的主模型
"TFSamPreTrainedModel", # SAM 模型的预训练模型基类
]
)
# 将以下模块的多个预定义名称添加到 _import_structure 字典中的相应模块下
_import_structure["models.segformer"].extend(
[
"TF_SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST", # SEGFORMER 模型的预训练模型存档列表
"TFSegformerDecodeHead", # 用于解码头的 TFSegformer 模型
"TFSegformerForImageClassification", # 用于图像分类的 TFSegformer 模型
"TFSegformerForSemanticSegmentation", # 用于语义分割的 TFSegformer 模型
"TFSegformerModel", # SEGFORMER 模型的主模型
"TFSegformerPreTrainedModel", # SEGFORMER 模型的预训练模型基类
]
)
# 将"models.speech_to_text"模块中的特定名称列表添加到_import_structure字典中
_import_structure["models.speech_to_text"].extend(
[
"TF_SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFSpeech2TextForConditionalGeneration",
"TFSpeech2TextModel",
"TFSpeech2TextPreTrainedModel",
]
)
# 将"models.swin"模块中的特定名称列表添加到_import_structure字典中
_import_structure["models.swin"].extend(
[
"TF_SWIN_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFSwinForImageClassification",
"TFSwinForMaskedImageModeling",
"TFSwinModel",
"TFSwinPreTrainedModel",
]
)
# 将"models.t5"模块中的特定名称列表添加到_import_structure字典中
_import_structure["models.t5"].extend(
[
"TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFT5EncoderModel",
"TFT5ForConditionalGeneration",
"TFT5Model",
"TFT5PreTrainedModel",
]
)
# 将"models.tapas"模块中的特定名称列表添加到_import_structure字典中
_import_structure["models.tapas"].extend(
[
"TF_TAPAS_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFTapasForMaskedLM",
"TFTapasForQuestionAnswering",
"TFTapasForSequenceClassification",
"TFTapasModel",
"TFTapasPreTrainedModel",
]
)
# 将"models.vision_encoder_decoder"模块中的特定名称添加到_import_structure字典中
_import_structure["models.vision_encoder_decoder"].extend(["TFVisionEncoderDecoderModel"])
# 将"models.vision_text_dual_encoder"模块中的特定名称添加到_import_structure字典中
_import_structure["models.vision_text_dual_encoder"].extend(["TFVisionTextDualEncoderModel"])
# 将"models.vit"模块中的特定名称列表添加到_import_structure字典中
_import_structure["models.vit"].extend(
[
"TFViTForImageClassification",
"TFViTModel",
"TFViTPreTrainedModel",
]
)
# 将"models.vit_mae"模块中的特定名称列表添加到_import_structure字典中
_import_structure["models.vit_mae"].extend(
[
"TFViTMAEForPreTraining",
"TFViTMAEModel",
"TFViTMAEPreTrainedModel",
]
)
# 将"models.wav2vec2"模块中的特定名称列表添加到_import_structure字典中
_import_structure["models.wav2vec2"].extend(
[
"TF_WAV_2_VEC_2_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFWav2Vec2ForCTC",
"TFWav2Vec2ForSequenceClassification",
"TFWav2Vec2Model",
"TFWav2Vec2PreTrainedModel",
]
)
# 将"models.whisper"模块中的特定名称列表添加到_import_structure字典中
_import_structure["models.whisper"].extend(
[
"TF_WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFWhisperForConditionalGeneration",
"TFWhisperModel",
"TFWhisperPreTrainedModel",
]
)
# 将"models.xglm"模块中的特定名称列表添加到_import_structure字典中
_import_structure["models.xglm"].extend(
[
"TF_XGLM_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFXGLMForCausalLM",
"TFXGLMModel",
"TFXGLMPreTrainedModel",
]
)
# 将"models.xlm"模块中的特定名称列表添加到_import_structure字典中
_import_structure["models.xlm"].extend(
[
"TF_XLM_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFXLMForMultipleChoice",
"TFXLMForQuestionAnsweringSimple",
"TFXLMForSequenceClassification",
"TFXLMForTokenClassification",
"TFXLMMainLayer",
"TFXLMModel",
"TFXLMPreTrainedModel",
"TFXLMWithLMHeadModel",
]
)
# 扩展 _import_structure 中 "models.xlm_roberta" 的模块列表
_import_structure["models.xlm_roberta"].extend(
[
"TF_XLM_ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFXLMRobertaForCausalLM",
"TFXLMRobertaForMaskedLM",
"TFXLMRobertaForMultipleChoice",
"TFXLMRobertaForQuestionAnswering",
"TFXLMRobertaForSequenceClassification",
"TFXLMRobertaForTokenClassification",
"TFXLMRobertaModel",
"TFXLMRobertaPreTrainedModel",
]
)
# 扩展 _import_structure 中 "models.xlnet" 的模块列表
_import_structure["models.xlnet"].extend(
[
"TF_XLNET_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFXLNetForMultipleChoice",
"TFXLNetForQuestionAnsweringSimple",
"TFXLNetForSequenceClassification",
"TFXLNetForTokenClassification",
"TFXLNetLMHeadModel",
"TFXLNetMainLayer",
"TFXLNetModel",
"TFXLNetPreTrainedModel",
]
)
# 将 "optimization_tf" 中的模块列表设置为指定的值
_import_structure["optimization_tf"] = [
"AdamWeightDecay",
"GradientAccumulator",
"WarmUp",
"create_optimizer",
]
# 将 "tf_utils" 中的模块列表设置为空列表
_import_structure["tf_utils"] = []
# 检查是否所有的必需依赖库都可用:Librosa、Essentia、Scipy、Torch、Pretty MIDI
try:
if not (
is_librosa_available()
and is_essentia_available()
and is_scipy_available()
and is_torch_available()
and is_pretty_midi_available()
):
# 如果有任何一个依赖库不可用,抛出OptionalDependencyNotAvailable异常
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
# 如果捕获到OptionalDependencyNotAvailable异常,则导入dummy模块,用于替代依赖库功能
from .utils import (
dummy_essentia_and_librosa_and_pretty_midi_and_scipy_and_torch_objects,
)
# 将dummy模块中非下划线开头的对象名添加到_import_structure字典中的相应位置
_import_structure["utils.dummy_essentia_and_librosa_and_pretty_midi_and_scipy_and_torch_objects"] = [
name
for name in dir(dummy_essentia_and_librosa_and_pretty_midi_and_scipy_and_torch_objects)
if not name.startswith("_")
]
else:
# 如果所有依赖库都可用,则将相关对象名添加到_import_structure字典中的"models.pop2piano"列表中
_import_structure["models.pop2piano"].append("Pop2PianoFeatureExtractor")
_import_structure["models.pop2piano"].append("Pop2PianoTokenizer")
_import_structure["models.pop2piano"].append("Pop2PianoProcessor")
# 检查是否Torchaudio库可用
try:
if not is_torchaudio_available():
# 如果Torchaudio库不可用,抛出OptionalDependencyNotAvailable异常
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
# 如果捕获到OptionalDependencyNotAvailable异常,则导入dummy模块,用于替代Torchaudio库功能
from .utils import (
dummy_torchaudio_objects,
)
# 将dummy模块中非下划线开头的对象名添加到_import_structure字典中的相应位置
_import_structure["utils.dummy_torchaudio_objects"] = [
name for name in dir(dummy_torchaudio_objects) if not name.startswith("_")
]
else:
# 如果Torchaudio库可用,则将相关对象名添加到_import_structure字典中的"models.musicgen_melody"列表中
_import_structure["models.musicgen_melody"].append("MusicgenMelodyFeatureExtractor")
_import_structure["models.musicgen_melody"].append("MusicgenMelodyProcessor")
# 检查是否Flax库可用
try:
if not is_flax_available():
# 如果Flax库不可用,抛出OptionalDependencyNotAvailable异常
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
# 如果捕获到OptionalDependencyNotAvailable异常,则导入dummy_flax_objects模块,用于替代Flax库功能
from .utils import dummy_flax_objects
# 将dummy_flax_objects模块中非下划线开头的对象名添加到_import_structure字典中的相应位置
_import_structure["utils.dummy_flax_objects"] = [
name for name in dir(dummy_flax_objects) if not name.startswith("_")
]
else:
# 如果Flax库可用,则扩展_import_structure中的多个列表,添加Flax相关对象名
_import_structure["generation"].extend(
[
"FlaxForcedBOSTokenLogitsProcessor",
"FlaxForcedEOSTokenLogitsProcessor",
"FlaxForceTokensLogitsProcessor",
"FlaxGenerationMixin",
"FlaxLogitsProcessor",
"FlaxLogitsProcessorList",
"FlaxLogitsWarper",
"FlaxMinLengthLogitsProcessor",
"FlaxTemperatureLogitsWarper",
"FlaxSuppressTokensAtBeginLogitsProcessor",
"FlaxSuppressTokensLogitsProcessor",
"FlaxTopKLogitsWarper",
"FlaxTopPLogitsWarper",
"FlaxWhisperTimeStampLogitsProcessor",
]
)
# 添加额外的导入结构,以及Flax相关的模块和类名到_import_structure字典中
_import_structure["generation_flax_utils"] = []
_import_structure["modeling_flax_outputs"] = []
_import_structure["modeling_flax_utils"] = ["FlaxPreTrainedModel"]
_import_structure["models.albert"].extend(
[
"FlaxAlbertForMaskedLM",
"FlaxAlbertForMultipleChoice",
"FlaxAlbertForPreTraining",
"FlaxAlbertForQuestionAnswering",
"FlaxAlbertForSequenceClassification",
"FlaxAlbertForTokenClassification",
"FlaxAlbertModel",
"FlaxAlbertPreTrainedModel",
]
)
# 扩展 `models.auto` 模块的导入结构,添加了多个 FLAX 自动模型映射和模型类
_import_structure["models.auto"].extend(
[
"FLAX_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING", # 自动模型音频分类映射
"FLAX_MODEL_FOR_CAUSAL_LM_MAPPING", # 自动模型因果语言建模映射
"FLAX_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING", # 自动模型图像分类映射
"FLAX_MODEL_FOR_MASKED_LM_MAPPING", # 自动模型掩蔽语言建模映射
"FLAX_MODEL_FOR_MULTIPLE_CHOICE_MAPPING", # 自动模型多选题映射
"FLAX_MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPING", # 自动模型下一句预测映射
"FLAX_MODEL_FOR_PRETRAINING_MAPPING", # 自动模型预训练映射
"FLAX_MODEL_FOR_QUESTION_ANSWERING_MAPPING", # 自动模型问答映射
"FLAX_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING", # 自动模型序列到序列因果语言建模映射
"FLAX_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING", # 自动模型序列分类映射
"FLAX_MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING", # 自动模型语音序列到序列映射
"FLAX_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING", # 自动模型标记分类映射
"FLAX_MODEL_FOR_VISION_2_SEQ_MAPPING", # 自动模型视觉到序列映射
"FLAX_MODEL_MAPPING", # 自动模型映射
"FlaxAutoModel", # FLAX 自动模型类
"FlaxAutoModelForCausalLM", # FLAX 自动因果语言建模模型类
"FlaxAutoModelForImageClassification", # FLAX 自动图像分类模型类
"FlaxAutoModelForMaskedLM", # FLAX 自动掩蔽语言建模模型类
"FlaxAutoModelForMultipleChoice", # FLAX 自动多选题模型类
"FlaxAutoModelForNextSentencePrediction", # FLAX 自动下一句预测模型类
"FlaxAutoModelForPreTraining", # FLAX 自动预训练模型类
"FlaxAutoModelForQuestionAnswering", # FLAX 自动问答模型类
"FlaxAutoModelForSeq2SeqLM", # FLAX 自动序列到序列语言建模模型类
"FlaxAutoModelForSequenceClassification", # FLAX 自动序列分类模型类
"FlaxAutoModelForSpeechSeq2Seq", # FLAX 自动语音序列到序列模型类
"FlaxAutoModelForTokenClassification", # FLAX 自动标记分类模型类
"FlaxAutoModelForVision2Seq", # FLAX 自动视觉到序列模型类
]
)
# Flax 模型结构,扩展 `models.bart` 模块的导入结构,包含了 BART 相关模型
_import_structure["models.bart"].extend(
[
"FlaxBartDecoderPreTrainedModel", # FLAX BART 解码器预训练模型类
"FlaxBartForCausalLM", # FLAX BART 因果语言建模模型类
"FlaxBartForConditionalGeneration", # FLAX BART 生成条件模型类
"FlaxBartForQuestionAnswering", # FLAX BART 问答模型类
"FlaxBartForSequenceClassification", # FLAX BART 序列分类模型类
"FlaxBartModel", # FLAX BART 模型类
"FlaxBartPreTrainedModel", # FLAX BART 预训练模型类
]
)
# 扩展 `models.beit` 模块的导入结构,添加了 BEiT 相关模型
_import_structure["models.beit"].extend(
[
"FlaxBeitForImageClassification", # FLAX BEiT 图像分类模型类
"FlaxBeitForMaskedImageModeling", # FLAX BEiT 掩蔽图像建模模型类
"FlaxBeitModel", # FLAX BEiT 模型类
"FlaxBeitPreTrainedModel", # FLAX BEiT 预训练模型类
]
)
# 扩展 `models.bert` 模块的导入结构,添加了 BERT 相关模型
_import_structure["models.bert"].extend(
[
"FlaxBertForCausalLM", # FLAX BERT 因果语言建模模型类
"FlaxBertForMaskedLM", # FLAX BERT 掩蔽语言建模模型类
"FlaxBertForMultipleChoice", # FLAX BERT 多选题模型类
"FlaxBertForNextSentencePrediction", # FLAX BERT 下一句预测模型类
"FlaxBertForPreTraining", # FLAX BERT 预训练模型类
"FlaxBertForQuestionAnswering", # FLAX BERT 问答模型类
"FlaxBertForSequenceClassification", # FLAX BERT 序列分类模型类
"FlaxBertForTokenClassification", # FLAX BERT 标记分类模型类
"FlaxBertModel", # FLAX BERT 模型类
"FlaxBertPreTrainedModel", # FLAX BERT 预训练模型类
]
)
# 扩展 `models.big_bird` 模块的导入结构,添加了 BigBird 相关模型
_import_structure["models.big_bird"].extend(
[
"FlaxBigBirdForCausalLM", # FLAX BigBird 因果语言建模模型类
"FlaxBigBirdForMaskedLM", # FLAX BigBird 掩蔽语言建模模型类
"FlaxBigBirdForMultipleChoice", # FLAX BigBird 多选题模型类
"FlaxBigBirdForPreTraining", # FLAX BigBird 预训练模型类
"FlaxBigBirdForQuestionAnswering", # FLAX BigBird 问答模型类
"FlaxBigBirdForSequenceClassification", # FLAX BigBird 序列分类模型类
"FlaxBigBirdForTokenClassification", # FLAX BigBird 标记分类模型类
"FlaxBigBirdModel", # FLAX BigBird 模型类
"FlaxBigBirdPreTrainedModel", # FLAX BigBird 预训练模型类
]
)
# 扩展 "models.blenderbot" 的导入结构,添加以下类名:
# - FlaxBlenderbotForConditionalGeneration
# - FlaxBlenderbotModel
# - FlaxBlenderbotPreTrainedModel
_import_structure["models.blenderbot"].extend(
[
"FlaxBlenderbotForConditionalGeneration",
"FlaxBlenderbotModel",
"FlaxBlenderbotPreTrainedModel",
]
)
# 扩展 "models.blenderbot_small" 的导入结构,添加以下类名:
# - FlaxBlenderbotSmallForConditionalGeneration
# - FlaxBlenderbotSmallModel
# - FlaxBlenderbotSmallPreTrainedModel
_import_structure["models.blenderbot_small"].extend(
[
"FlaxBlenderbotSmallForConditionalGeneration",
"FlaxBlenderbotSmallModel",
"FlaxBlenderbotSmallPreTrainedModel",
]
)
# 扩展 "models.bloom" 的导入结构,添加以下类名:
# - FlaxBloomForCausalLM
# - FlaxBloomModel
# - FlaxBloomPreTrainedModel
_import_structure["models.bloom"].extend(
[
"FlaxBloomForCausalLM",
"FlaxBloomModel",
"FlaxBloomPreTrainedModel",
]
)
# 扩展 "models.clip" 的导入结构,添加以下类名:
# - FlaxCLIPModel
# - FlaxCLIPPreTrainedModel
# - FlaxCLIPTextModel
# - FlaxCLIPTextPreTrainedModel
# - FlaxCLIPTextModelWithProjection
# - FlaxCLIPVisionModel
# - FlaxCLIPVisionPreTrainedModel
_import_structure["models.clip"].extend(
[
"FlaxCLIPModel",
"FlaxCLIPPreTrainedModel",
"FlaxCLIPTextModel",
"FlaxCLIPTextPreTrainedModel",
"FlaxCLIPTextModelWithProjection",
"FlaxCLIPVisionModel",
"FlaxCLIPVisionPreTrainedModel",
]
)
# 扩展 "models.distilbert" 的导入结构,添加以下类名:
# - FlaxDistilBertForMaskedLM
# - FlaxDistilBertForMultipleChoice
# - FlaxDistilBertForQuestionAnswering
# - FlaxDistilBertForSequenceClassification
# - FlaxDistilBertForTokenClassification
# - FlaxDistilBertModel
# - FlaxDistilBertPreTrainedModel
_import_structure["models.distilbert"].extend(
[
"FlaxDistilBertForMaskedLM",
"FlaxDistilBertForMultipleChoice",
"FlaxDistilBertForQuestionAnswering",
"FlaxDistilBertForSequenceClassification",
"FlaxDistilBertForTokenClassification",
"FlaxDistilBertModel",
"FlaxDistilBertPreTrainedModel",
]
)
# 扩展 "models.electra" 的导入结构,添加以下类名:
# - FlaxElectraForCausalLM
# - FlaxElectraForMaskedLM
# - FlaxElectraForMultipleChoice
# - FlaxElectraForPreTraining
# - FlaxElectraForQuestionAnswering
# - FlaxElectraForSequenceClassification
# - FlaxElectraForTokenClassification
# - FlaxElectraModel
# - FlaxElectraPreTrainedModel
_import_structure["models.electra"].extend(
[
"FlaxElectraForCausalLM",
"FlaxElectraForMaskedLM",
"FlaxElectraForMultipleChoice",
"FlaxElectraForPreTraining",
"FlaxElectraForQuestionAnswering",
"FlaxElectraForSequenceClassification",
"FlaxElectraForTokenClassification",
"FlaxElectraModel",
"FlaxElectraPreTrainedModel",
]
)
# 添加 "models.encoder_decoder" 的导入结构,包含以下类名:
# - FlaxEncoderDecoderModel
_import_structure["models.encoder_decoder"].append("FlaxEncoderDecoderModel")
# 扩展 "models.gpt2" 的导入结构,添加以下类名:
# - FlaxGPT2LMHeadModel
# - FlaxGPT2Model
# - FlaxGPT2PreTrainedModel
_import_structure["models.gpt2"].extend(
[
"FlaxGPT2LMHeadModel",
"FlaxGPT2Model",
"FlaxGPT2PreTrainedModel",
]
)
# 扩展 "models.gpt_neo" 的导入结构,添加以下类名:
# - FlaxGPTNeoForCausalLM
# - FlaxGPTNeoModel
# - FlaxGPTNeoPreTrainedModel
_import_structure["models.gpt_neo"].extend(
[
"FlaxGPTNeoForCausalLM",
"FlaxGPTNeoModel",
"FlaxGPTNeoPreTrainedModel",
]
)
# 扩展 "models.gptj" 的导入结构,添加以下类名:
# - FlaxGPTJForCausalLM
# - FlaxGPTJModel
# - FlaxGPTJPreTrainedModel
_import_structure["models.gptj"].extend(
[
"FlaxGPTJForCausalLM",
"FlaxGPTJModel",
"FlaxGPTJPreTrainedModel",
]
)
# 扩展 "models.llama" 的导入结构,添加以下类名:
# - FlaxLlamaForCausalLM
# - FlaxLlamaModel
# - FlaxLlamaPreTrainedModel
_import_structure["models.llama"].extend(
[
"FlaxLlamaForCausalLM",
"FlaxLlamaModel",
"FlaxLlamaPreTrainedModel",
]
)
# 扩展 "models.gemma" 的导入结构,添加以下类名:
# - FlaxGemmaForCausalLM
# - FlaxGemmaModel
# - FlaxGemmaPreTrainedModel
_import_structure["models.gemma"].extend(
[
"FlaxGemmaForCausalLM",
"FlaxGemmaModel",
"FlaxGemmaPreTrainedModel",
]
)
# 扩展 "models.longt5" 的导入结构,添加以下类名:
# - FlaxLongT5ForConditionalGeneration
# - FlaxLongT5Model
# - FlaxLongT5PreTrainedModel
_import_structure["models.longt5"].extend(
[
"FlaxLongT5ForConditionalGeneration",
"FlaxLongT5Model",
"FlaxLongT5PreTrainedModel",
]
)
# 扩展 "models.marian" 的导入结构,添加以下类名:
# - FlaxMarianModel
# - FlaxMarianMTModel
# - FlaxMarianPreTrainedModel
_import_structure["models.marian"].extend(
[
"FlaxMarianModel",
"FlaxMarianMTModel",
"FlaxMarianPreTrainedModel",
]
)
# 将指定模块(models.mbart)下的类名列表扩展,包括以下类:
# FlaxMBartForConditionalGeneration、FlaxMBartForQuestionAnswering、
# FlaxMBartForSequenceClassification、FlaxMBartModel、FlaxMBartPreTrainedModel
_import_structure["models.mbart"].extend(
[
"FlaxMBartForConditionalGeneration",
"FlaxMBartForQuestionAnswering",
"FlaxMBartForSequenceClassification",
"FlaxMBartModel",
"FlaxMBartPreTrainedModel",
]
)
# 将指定模块(models.mistral)下的类名列表扩展,包括以下类:
# FlaxMistralForCausalLM、FlaxMistralModel、FlaxMistralPreTrainedModel
_import_structure["models.mistral"].extend(
[
"FlaxMistralForCausalLM",
"FlaxMistralModel",
"FlaxMistralPreTrainedModel",
]
)
# 将指定模块(models.mt5)下的类名列表扩展,包括以下类:
# FlaxMT5EncoderModel、FlaxMT5ForConditionalGeneration、FlaxMT5Model
_import_structure["models.mt5"].extend(
[
"FlaxMT5EncoderModel",
"FlaxMT5ForConditionalGeneration",
"FlaxMT5Model"
]
)
# 将指定模块(models.opt)下的类名列表扩展,包括以下类:
# FlaxOPTForCausalLM、FlaxOPTModel、FlaxOPTPreTrainedModel
_import_structure["models.opt"].extend(
[
"FlaxOPTForCausalLM",
"FlaxOPTModel",
"FlaxOPTPreTrainedModel",
]
)
# 将指定模块(models.pegasus)下的类名列表扩展,包括以下类:
# FlaxPegasusForConditionalGeneration、FlaxPegasusModel、FlaxPegasusPreTrainedModel
_import_structure["models.pegasus"].extend(
[
"FlaxPegasusForConditionalGeneration",
"FlaxPegasusModel",
"FlaxPegasusPreTrainedModel",
]
)
# 将指定模块(models.regnet)下的类名列表扩展,包括以下类:
# FlaxRegNetForImageClassification、FlaxRegNetModel、FlaxRegNetPreTrainedModel
_import_structure["models.regnet"].extend(
[
"FlaxRegNetForImageClassification",
"FlaxRegNetModel",
"FlaxRegNetPreTrainedModel",
]
)
# 将指定模块(models.resnet)下的类名列表扩展,包括以下类:
# FlaxResNetForImageClassification、FlaxResNetModel、FlaxResNetPreTrainedModel
_import_structure["models.resnet"].extend(
[
"FlaxResNetForImageClassification",
"FlaxResNetModel",
"FlaxResNetPreTrainedModel",
]
)
# 将指定模块(models.roberta)下的类名列表扩展,包括以下类:
# FlaxRobertaForCausalLM、FlaxRobertaForMaskedLM、FlaxRobertaForMultipleChoice、
# FlaxRobertaForQuestionAnswering、FlaxRobertaForSequenceClassification、
# FlaxRobertaForTokenClassification、FlaxRobertaModel、FlaxRobertaPreTrainedModel
_import_structure["models.roberta"].extend(
[
"FlaxRobertaForCausalLM",
"FlaxRobertaForMaskedLM",
"FlaxRobertaForMultipleChoice",
"FlaxRobertaForQuestionAnswering",
"FlaxRobertaForSequenceClassification",
"FlaxRobertaForTokenClassification",
"FlaxRobertaModel",
"FlaxRobertaPreTrainedModel",
]
)
# 将指定模块(models.roberta_prelayernorm)下的类名列表扩展,包括以下类:
# FlaxRobertaPreLayerNormForCausalLM、FlaxRobertaPreLayerNormForMaskedLM、
# FlaxRobertaPreLayerNormForMultipleChoice、FlaxRobertaPreLayerNormForQuestionAnswering、
# FlaxRobertaPreLayerNormForSequenceClassification、FlaxRobertaPreLayerNormForTokenClassification、
# FlaxRobertaPreLayerNormModel、FlaxRobertaPreLayerNormPreTrainedModel
_import_structure["models.roberta_prelayernorm"].extend(
[
"FlaxRobertaPreLayerNormForCausalLM",
"FlaxRobertaPreLayerNormForMaskedLM",
"FlaxRobertaPreLayerNormForMultipleChoice",
"FlaxRobertaPreLayerNormForQuestionAnswering",
"FlaxRobertaPreLayerNormForSequenceClassification",
"FlaxRobertaPreLayerNormForTokenClassification",
"FlaxRobertaPreLayerNormModel",
"FlaxRobertaPreLayerNormPreTrainedModel",
]
)
# 将指定模块(models.roformer)下的类名列表扩展,包括以下类:
# FlaxRoFormerForMaskedLM、FlaxRoFormerForMultipleChoice、FlaxRoFormerForQuestionAnswering、
# FlaxRoFormerForSequenceClassification、FlaxRoFormerForTokenClassification、
# FlaxRoFormerModel、FlaxRoFormerPreTrainedModel
_import_structure["models.roformer"].extend(
[
"FlaxRoFormerForMaskedLM",
"FlaxRoFormerForMultipleChoice",
"FlaxRoFormerForQuestionAnswering",
"FlaxRoFormerForSequenceClassification",
"FlaxRoFormerForTokenClassification",
"FlaxRoFormerModel",
"FlaxRoFormerPreTrainedModel",
]
)
# 将指定模块(models.speech_encoder_decoder)下的类名添加到列表中:
# FlaxSpeechEncoderDecoderModel
_import_structure["models.speech_encoder_decoder"].append("FlaxSpeechEncoderDecoderModel")
# 将指定模块(models.t5)下的类名列表扩展,包括以下类:
# FlaxT5EncoderModel、FlaxT5ForConditionalGeneration、FlaxT5Model、FlaxT5PreTrainedModel
_import_structure["models.t5"].extend(
[
"FlaxT5EncoderModel",
"FlaxT5ForConditionalGeneration",
"FlaxT5Model",
"FlaxT5PreTrainedModel",
]
)
_import_structure["models.vision_encoder_decoder"].append("FlaxVisionEncoderDecoderModel")
# 将字符串 "FlaxVisionEncoderDecoderModel" 添加到 _import_structure 字典中 "models.vision_encoder_decoder" 键对应的列表末尾
_import_structure["models.vision_text_dual_encoder"].extend(["FlaxVisionTextDualEncoderModel"])
# 将列表 ["FlaxVisionTextDualEncoderModel"] 扩展(即添加)到 _import_structure 字典中 "models.vision_text_dual_encoder" 键对应的列表末尾
_import_structure["models.vit"].extend(["FlaxViTForImageClassification", "FlaxViTModel", "FlaxViTPreTrainedModel"])
# 将包含三个字符串的列表扩展到 _import_structure 字典中 "models.vit" 键对应的列表末尾
_import_structure["models.wav2vec2"].extend(
[
"FlaxWav2Vec2ForCTC",
"FlaxWav2Vec2ForPreTraining",
"FlaxWav2Vec2Model",
"FlaxWav2Vec2PreTrainedModel",
]
)
# 将包含四个字符串的列表扩展到 _import_structure 字典中 "models.wav2vec2" 键对应的列表末尾
_import_structure["models.whisper"].extend(
[
"FlaxWhisperForConditionalGeneration",
"FlaxWhisperModel",
"FlaxWhisperPreTrainedModel",
"FlaxWhisperForAudioClassification",
]
)
# 将包含四个字符串的列表扩展到 _import_structure 字典中 "models.whisper" 键对应的列表末尾
_import_structure["models.xglm"].extend(
[
"FlaxXGLMForCausalLM",
"FlaxXGLMModel",
"FlaxXGLMPreTrainedModel",
]
)
# 将包含三个字符串的列表扩展到 _import_structure 字典中 "models.xglm" 键对应的列表末尾
_import_structure["models.xlm_roberta"].extend(
[
"FLAX_XLM_ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST",
"FlaxXLMRobertaForMaskedLM",
"FlaxXLMRobertaForMultipleChoice",
"FlaxXLMRobertaForQuestionAnswering",
"FlaxXLMRobertaForSequenceClassification",
"FlaxXLMRobertaForTokenClassification",
"FlaxXLMRobertaModel",
"FlaxXLMRobertaForCausalLM",
"FlaxXLMRobertaPreTrainedModel",
]
)
# 将包含九个字符串的列表扩展到 _import_structure 字典中 "models.xlm_roberta" 键对应的列表末尾
# 直接导入用于类型检查的模块
if TYPE_CHECKING:
# 配置相关
from .configuration_utils import PretrainedConfig
# 数据相关
from .data import (
DataProcessor, # 数据处理器
InputExample, # 输入示例
InputFeatures, # 输入特征
SingleSentenceClassificationProcessor, # 单句分类处理器
SquadExample, # SQuAD 示例
SquadFeatures, # SQuAD 特征
SquadV1Processor, # SQuAD v1 处理器
SquadV2Processor, # SQuAD v2 处理器
glue_compute_metrics, # GLUE 计算评估指标函数
glue_convert_examples_to_features, # 将示例转换为 GLUE 特征的函数
glue_output_modes, # GLUE 输出模式
glue_processors, # GLUE 处理器列表
glue_tasks_num_labels, # GLUE 任务的标签数量
squad_convert_examples_to_features,# 将示例转换为 SQuAD 特征的函数
xnli_compute_metrics, # XNLI 计算评估指标函数
xnli_output_modes, # XNLI 输出模式
xnli_processors, # XNLI 处理器列表
xnli_tasks_num_labels, # XNLI 任务的标签数量
)
from .data.data_collator import (
DataCollator, # 数据收集器
DataCollatorForLanguageModeling, # 用于语言建模的数据收集器
DataCollatorForPermutationLanguageModeling, # 用于排列语言建模的数据收集器
DataCollatorForSeq2Seq, # 用于序列到序列的数据收集器
DataCollatorForSOP, # 用于SOP的数据收集器
DataCollatorForTokenClassification, # 用于标记分类的数据收集器
DataCollatorForWholeWordMask, # 用于整词掩码的数据收集器
DataCollatorWithPadding, # 带填充的数据收集器
DefaultDataCollator, # 默认数据收集器
default_data_collator, # 默认数据收集器的别名
)
from .feature_extraction_sequence_utils import SequenceFeatureExtractor # 序列特征提取器
# 特征提取相关
from .feature_extraction_utils import BatchFeature, FeatureExtractionMixin # 批次特征,特征提取混合类
# 生成相关
from .generation import (
GenerationConfig, # 生成配置
TextIteratorStreamer, # 文本迭代器流
TextStreamer, # 文本流
)
from .hf_argparser import HfArgumentParser # Hugging Face 参数解析器
# 集成相关
from .integrations import (
is_clearml_available, # 是否支持 ClearML
is_comet_available, # 是否支持 Comet
is_dvclive_available, # 是否支持 DVCLive
is_neptune_available, # 是否支持 Neptune
is_optuna_available, # 是否支持 Optuna
is_ray_available, # 是否支持 Ray
is_ray_tune_available, # 是否支持 Ray Tune
is_sigopt_available, # 是否支持 SigOpt
is_tensorboard_available, # 是否支持 TensorBoard
is_wandb_available, # 是否支持 Weights & Biases
)
# 模型卡相关
from .modelcard import ModelCard # 模型卡片
# TF 2.0 <=> PyTorch 转换工具
from .modeling_tf_pytorch_utils import (
convert_tf_weight_name_to_pt_weight_name, # 转换 TF 权重名到 PyTorch 权重名
load_pytorch_checkpoint_in_tf2_model, # 在 TF2 模型中加载 PyTorch 检查点
load_pytorch_model_in_tf2_model, # 在 TF2 模型中加载 PyTorch 模型
load_pytorch_weights_in_tf2_model, # 在 TF2 模型中加载 PyTorch 权重
load_tf2_checkpoint_in_pytorch_model, # 在 PyTorch 模型中加载 TF2 检查点
load_tf2_model_in_pytorch_model, # 在 PyTorch 模型中加载 TF2 模型
load_tf2_weights_in_pytorch_model, # 在 PyTorch 模型中加载 TF2 权重
)
# 模型相关
from .models.albert import ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, AlbertConfig # ALBERT 预训练配置映射,ALBERT 配置
from .models.align import (
ALIGN_PRETRAINED_CONFIG_ARCHIVE_MAP, # ALIGN 预训练配置映射
AlignConfig, # ALIGN 配置
AlignProcessor, # ALIGN 处理器
AlignTextConfig, # ALIGN 文本配置
AlignVisionConfig, # ALIGN 视觉配置
)
from .models.altclip import (
ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP, # ALTCLIP 预训练配置映射
AltCLIPConfig, # ALTCLIP 配置
AltCLIPProcessor, # ALTCLIP 处理器
AltCLIPTextConfig, # ALTCLIP 文本配置
AltCLIPVisionConfig, # ALTCLIP 视觉配置
)
from .models.audio_spectrogram_transformer import (
AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, # 音频频谱变换器预训练配置映射
ASTConfig, # 音频频谱变换器配置
ASTFeatureExtractor, # 音频频谱变换器特征提取器
)
# 导入自动模型相关的所有预训练配置映射
from .models.auto import (
ALL_PRETRAINED_CONFIG_ARCHIVE_MAP,
# 自动模型的配置映射
CONFIG_MAPPING,
# 自动模型的特征提取器映射
FEATURE_EXTRACTOR_MAPPING,
# 自动模型的图像处理器映射
IMAGE_PROCESSOR_MAPPING,
# 自动模型的模型名称映射
MODEL_NAMES_MAPPING,
# 自动模型的处理器映射
PROCESSOR_MAPPING,
# 自动模型的分词器映射
TOKENIZER_MAPPING,
# 自动模型的配置类
AutoConfig,
# 自动模型的特征提取器类
AutoFeatureExtractor,
# 自动模型的图像处理器类
AutoImageProcessor,
# 自动模型的处理器类
AutoProcessor,
# 自动模型的分词器类
AutoTokenizer,
)
# 导入自动形态模型相关的预训练配置映射
from .models.autoformer import (
AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
# 自动形态模型的配置类
AutoformerConfig,
)
# 导入Bark模型相关的配置和处理器类
from .models.bark import (
BarkCoarseConfig,
BarkConfig,
BarkFineConfig,
# Bark模型的处理器类
BarkProcessor,
BarkSemanticConfig,
)
# 导入BART模型相关的配置类和分词器类
from .models.bart import BartConfig, BartTokenizer
# 导入BEIT模型相关的预训练配置映射和配置类
from .models.beit import BEIT_PRETRAINED_CONFIG_ARCHIVE_MAP, BeitConfig
# 导入BERT模型相关的预训练配置映射和分词器类
from .models.bert import (
BERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
# BERT模型的基本分词器类
BasicTokenizer,
BertConfig,
BertTokenizer,
WordpieceTokenizer,
)
# 导入BERT生成模型的配置类
from .models.bert_generation import BertGenerationConfig
# 导入BERT日语模型相关的分词器类
from .models.bert_japanese import (
BertJapaneseTokenizer,
# 日语分词器的字符级分词器类
CharacterTokenizer,
# 日语分词器的MeCab分词器类
MecabTokenizer,
)
# 导入Bertweet模型的分词器类
from .models.bertweet import BertweetTokenizer
# 导入Big Bird模型相关的预训练配置映射和配置类
from .models.big_bird import BIG_BIRD_PRETRAINED_CONFIG_ARCHIVE_MAP, BigBirdConfig
# 导入BigBird-Pegasus模型相关的预训练配置映射和配置类
from .models.bigbird_pegasus import (
BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP,
BigBirdPegasusConfig,
)
# 导入BioGPT模型相关的预训练配置映射和配置类
from .models.biogpt import (
BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP,
BioGptConfig,
BioGptTokenizer,
)
# 导入Bit模型相关的预训练配置映射和配置类
from .models.bit import BIT_PRETRAINED_CONFIG_ARCHIVE_MAP, BitConfig
# 导入Blenderbot模型相关的预训练配置映射和配置类、分词器类
from .models.blenderbot import (
BLENDERBOT_PRETRAINED_CONFIG_ARCHIVE_MAP,
BlenderbotConfig,
BlenderbotTokenizer,
)
# 导入Blenderbot-Small模型相关的预训练配置映射和配置类、分词器类
from .models.blenderbot_small import (
BLENDERBOT_SMALL_PRETRAINED_CONFIG_ARCHIVE_MAP,
BlenderbotSmallConfig,
BlenderbotSmallTokenizer,
)
# 导入Blip模型相关的预训练配置映射和配置类、处理器类
from .models.blip import (
BLIP_PRETRAINED_CONFIG_ARCHIVE_MAP,
BlipConfig,
# Blip模型的处理器类
BlipProcessor,
BlipTextConfig,
BlipVisionConfig,
)
# 导入Blip-2模型相关的预训练配置映射和配置类、处理器类
from .models.blip_2 import (
BLIP_2_PRETRAINED_CONFIG_ARCHIVE_MAP,
Blip2Config,
# Blip-2模型的处理器类
Blip2Processor,
Blip2QFormerConfig,
Blip2VisionConfig,
)
# 导入Bloom模型相关的预训练配置映射和配置类
from .models.bloom import BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP, BloomConfig
# 导入BridgeTower模型相关的预训练配置映射和配置类、处理器类
from .models.bridgetower import (
BRIDGETOWER_PRETRAINED_CONFIG_ARCHIVE_MAP,
BridgeTowerConfig,
# BridgeTower模型的处理器类
BridgeTowerProcessor,
BridgeTowerTextConfig,
BridgeTowerVisionConfig,
)
# 导入Bros模型相关的预训练配置映射和配置类、处理器类
from .models.bros import (
BROS_PRETRAINED_CONFIG_ARCHIVE_MAP,
BrosConfig,
BrosProcessor,
)
# 导入ByT5模型的分词器类
from .models.byt5 import ByT5Tokenizer
# 导入Camembert模型相关的预训练配置映射和配置类
from .models.camembert import (
CAMEMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
CamembertConfig,
)
# 导入Canine模型相关的配置、配置类和分词器
from .models.canine import (
CANINE_PRETRAINED_CONFIG_ARCHIVE_MAP,
CanineConfig,
CanineTokenizer,
)
# 导入Chinese CLIP模型相关的配置、配置类、处理器以及文本和视觉配置
from .models.chinese_clip import (
CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP,
ChineseCLIPConfig,
ChineseCLIPProcessor,
ChineseCLIPTextConfig,
ChineseCLIPVisionConfig,
)
# 导入CLAP模型相关的预训练模型列表、音频配置、配置类和处理器
from .models.clap import (
CLAP_PRETRAINED_MODEL_ARCHIVE_LIST,
ClapAudioConfig,
ClapConfig,
ClapProcessor,
ClapTextConfig,
)
# 导入CLIP模型相关的配置、配置类、处理器、文本配置、分词器和视觉配置
from .models.clip import (
CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP,
CLIPConfig,
CLIPProcessor,
CLIPTextConfig,
CLIPTokenizer,
CLIPVisionConfig,
)
# 导入CLIPSeg模型相关的配置、配置类、处理器、文本配置和视觉配置
from .models.clipseg import (
CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP,
CLIPSegConfig,
CLIPSegProcessor,
CLIPSegTextConfig,
CLIPSegVisionConfig,
)
# 导入CLVP模型相关的配置、配置类、解码器配置、编码器配置、特征提取器、处理器和分词器
from .models.clvp import (
CLVP_PRETRAINED_CONFIG_ARCHIVE_MAP,
ClvpConfig,
ClvpDecoderConfig,
ClvpEncoderConfig,
ClvpFeatureExtractor,
ClvpProcessor,
ClvpTokenizer,
)
# 导入CodeGen模型相关的配置、配置类和分词器
from .models.codegen import (
CODEGEN_PRETRAINED_CONFIG_ARCHIVE_MAP,
CodeGenConfig,
CodeGenTokenizer,
)
# 导入Cohere模型相关的配置和配置类
from .models.cohere import COHERE_PRETRAINED_CONFIG_ARCHIVE_MAP, CohereConfig
# 导入Conditional DETR模型相关的配置和配置类
from .models.conditional_detr import (
CONDITIONAL_DETR_PRETRAINED_CONFIG_ARCHIVE_MAP,
ConditionalDetrConfig,
)
# 导入ConvBERT模型相关的配置、配置类和分词器
from .models.convbert import (
CONVBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
ConvBertConfig,
ConvBertTokenizer,
)
# 导入ConvNext模型相关的配置
from .models.convnext import CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MAP, ConvNextConfig
# 导入ConvNextV2模型相关的配置
from .models.convnextv2 import (
CONVNEXTV2_PRETRAINED_CONFIG_ARCHIVE_MAP,
ConvNextV2Config,
)
# 导入CPMANT模型相关的配置、配置类和分词器
from .models.cpmant import (
CPMANT_PRETRAINED_CONFIG_ARCHIVE_MAP,
CpmAntConfig,
CpmAntTokenizer,
)
# 导入CTRL模型相关的配置、配置类和分词器
from .models.ctrl import (
CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP,
CTRLConfig,
CTRLTokenizer,
)
# 导入CVT模型相关的配置
from .models.cvt import CVT_PRETRAINED_CONFIG_ARCHIVE_MAP, CvtConfig
# 导入Data2Vec模型相关的文本和视觉预训练配置、音频配置、文本配置和视觉配置
from .models.data2vec import (
DATA2VEC_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP,
DATA2VEC_VISION_PRETRAINED_CONFIG_ARCHIVE_MAP,
Data2VecAudioConfig,
Data2VecTextConfig,
Data2VecVisionConfig,
)
# 导入DeBERTa模型相关的配置、配置类和分词器
from .models.deberta import (
DEBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP,
DebertaConfig,
DebertaTokenizer,
)
# 导入DeBERTa V2模型相关的配置和配置类
from .models.deberta_v2 import (
DEBERTA_V2_PRETRAINED_CONFIG_ARCHIVE_MAP,
DebertaV2Config,
)
# 导入Decision Transformer模型相关的配置和配置类
from .models.decision_transformer import (
DECISION_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
DecisionTransformerConfig,
)
# 导入Deformable DETR模型相关的配置和配置类
from .models.deformable_detr import (
DEFORMABLE_DETR_PRETRAINED_CONFIG_ARCHIVE_MAP,
DeformableDetrConfig,
)
# 导入 DEIT 模型相关的预训练配置映射和配置类
from .models.deit import DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP, DeiTConfig
# 导入 MCTCT 模型相关的预训练配置映射、配置类、特征提取器和处理器
from .models.deprecated.mctct import (
MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP,
MCTCTConfig,
MCTCTFeatureExtractor,
MCTCTProcessor,
)
# 导入 MMBT 模型的配置类
from .models.deprecated.mmbt import MMBTConfig
# 导入 OpenLlama 模型相关的预训练配置映射和配置类
from .models.deprecated.open_llama import (
OPEN_LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP,
OpenLlamaConfig,
)
# 导入 RetriBert 模型相关的预训练配置映射、配置类和分词器
from .models.deprecated.retribert import (
RETRIBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
RetriBertConfig,
RetriBertTokenizer,
)
# 导入 Tapex 模型的分词器
from .models.deprecated.tapex import TapexTokenizer
# 导入 TrajectoryTransformer 模型相关的预训练配置映射和配置类
from .models.deprecated.trajectory_transformer import (
TRAJECTORY_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
TrajectoryTransformerConfig,
)
# 导入 TransfoXL 模型相关的预训练配置映射、配置类、语料库和分词器
from .models.deprecated.transfo_xl import (
TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP,
TransfoXLConfig,
TransfoXLCorpus,
TransfoXLTokenizer,
)
# 导入 VAN 模型相关的预训练配置映射和配置类
from .models.deprecated.van import VAN_PRETRAINED_CONFIG_ARCHIVE_MAP, VanConfig
# 导入 DepthAnything 模型相关的预训练配置映射和配置类
from .models.depth_anything import DEPTH_ANYTHING_PRETRAINED_CONFIG_ARCHIVE_MAP, DepthAnythingConfig
# 导入 Deta 模型相关的预训练配置映射和配置类
from .models.deta import DETA_PRETRAINED_CONFIG_ARCHIVE_MAP, DetaConfig
# 导入 Detr 模型相关的预训练配置映射和配置类
from .models.detr import DETR_PRETRAINED_CONFIG_ARCHIVE_MAP, DetrConfig
# 导入 Dinat 模型相关的预训练配置映射和配置类
from .models.dinat import DINAT_PRETRAINED_CONFIG_ARCHIVE_MAP, DinatConfig
# 导入 Dinov2 模型相关的预训练配置映射和配置类
from .models.dinov2 import DINOV2_PRETRAINED_CONFIG_ARCHIVE_MAP, Dinov2Config
# 导入 DistilBert 模型相关的预训练配置映射、配置类和分词器
from .models.distilbert import (
DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
DistilBertConfig,
DistilBertTokenizer,
)
# 导入 DonutSwin 模型相关的预训练配置映射、处理器和配置类
from .models.donut import (
DONUT_SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP,
DonutProcessor,
DonutSwinConfig,
)
# 导入 DPR 模型相关的预训练配置映射、配置类和分词器
from .models.dpr import (
DPR_PRETRAINED_CONFIG_ARCHIVE_MAP,
DPRConfig,
DPRContextEncoderTokenizer,
DPRQuestionEncoderTokenizer,
DPRReaderOutput,
DPRReaderTokenizer,
)
# 导入 DPT 模型相关的预训练配置映射和配置类
from .models.dpt import DPT_PRETRAINED_CONFIG_ARCHIVE_MAP, DPTConfig
# 导入 EfficientFormer 模型相关的预训练配置映射和配置类
from .models.efficientformer import (
EFFICIENTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
EfficientFormerConfig,
)
# 导入 EfficientNet 模型相关的预训练配置映射和配置类
from .models.efficientnet import (
EFFICIENTNET_PRETRAINED_CONFIG_ARCHIVE_MAP,
EfficientNetConfig,
)
# 导入 Electra 模型相关的预训练配置映射、配置类和分词器
from .models.electra import (
ELECTRA_PRETRAINED_CONFIG_ARCHIVE_MAP,
ElectraConfig,
ElectraTokenizer,
)
# 导入 Encodec 模型相关的预训练配置映射、配置类和特征提取器
from .models.encodec import (
ENCODEC_PRETRAINED_CONFIG_ARCHIVE_MAP,
EncodecConfig,
EncodecFeatureExtractor,
)
# 导入 EncoderDecoder 模型的配置类
from .models.encoder_decoder import EncoderDecoderConfig
# 导入 ERNIE 模型相关的预训练配置映射和配置类
from .models.ernie import ERNIE_PRETRAINED_CONFIG_ARCHIVE_MAP, ErnieConfig
# 导入 ERNIE-M 模型相关的预训练配置映射和配置类
from .models.ernie_m import ERNIE_M_PRETRAINED_CONFIG_ARCHIVE_MAP, ErnieMConfig
# 导入 ESM 模型相关的预训练配置映射、配置类和分词器
from .models.esm import ESM_PRETRAINED_CONFIG_ARCHIVE_MAP, EsmConfig, EsmTokenizer
# 导入 Falcon 模型相关的预训练配置映射和配置类
from .models.falcon import FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP, FalconConfig
# 导入 FASTSPEECH2_CONFORMER 相关模块和配置
from .models.fastspeech2_conformer import (
FASTSPEECH2_CONFORMER_HIFIGAN_PRETRAINED_CONFIG_ARCHIVE_MAP,
FASTSPEECH2_CONFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
FASTSPEECH2_CONFORMER_WITH_HIFIGAN_PRETRAINED_CONFIG_ARCHIVE_MAP,
FastSpeech2ConformerConfig,
FastSpeech2ConformerHifiGanConfig,
FastSpeech2ConformerTokenizer,
)
# 导入 FLAUBERT 相关模块和配置
from .models.flaubert import FLAUBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, FlaubertConfig, FlaubertTokenizer
# 导入 FLAVA 相关模块和配置
from .models.flava import (
FLAVA_PRETRAINED_CONFIG_ARCHIVE_MAP,
FlavaConfig,
FlavaImageCodebookConfig,
FlavaImageConfig,
FlavaMultimodalConfig,
FlavaTextConfig,
)
# 导入 FNET 相关模块和配置
from .models.fnet import FNET_PRETRAINED_CONFIG_ARCHIVE_MAP, FNetConfig
# 导入 FOCALNET 相关模块和配置
from .models.focalnet import FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP, FocalNetConfig
# 导入 FSMT 相关模块和配置
from .models.fsmt import FSMT_PRETRAINED_CONFIG_ARCHIVE_MAP, FSMTConfig, FSMTTokenizer
# 导入 FUNNEL 相关模块和配置
from .models.funnel import FUNNEL_PRETRAINED_CONFIG_ARCHIVE_MAP, FunnelConfig, FunnelTokenizer
# 导入 FUYU 相关模块和配置
from .models.fuyu import FUYU_PRETRAINED_CONFIG_ARCHIVE_MAP, FuyuConfig
# 导入 GEMMA 相关模块和配置
from .models.gemma import GEMMA_PRETRAINED_CONFIG_ARCHIVE_MAP, GemmaConfig
# 导入 GIT 相关模块和配置
from .models.git import (
GIT_PRETRAINED_CONFIG_ARCHIVE_MAP,
GitConfig,
GitProcessor,
GitVisionConfig,
)
# 导入 GLPN 相关模块和配置
from .models.glpn import GLPN_PRETRAINED_CONFIG_ARCHIVE_MAP, GLPNConfig
# 导入 GPT2 相关模块和配置
from .models.gpt2 import GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP, GPT2Config, GPT2Tokenizer
# 导入 GPT_BIGCODE 相关模块和配置
from .models.gpt_bigcode import GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP, GPTBigCodeConfig
# 导入 GPT_NEO 相关模块和配置
from .models.gpt_neo import GPT_NEO_PRETRAINED_CONFIG_ARCHIVE_MAP, GPTNeoConfig
# 导入 GPT_NEOX 相关模块和配置
from .models.gpt_neox import GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_MAP, GPTNeoXConfig
# 导入 GPT_NEOX_JAPANESE 相关模块和配置
from .models.gpt_neox_japanese import (
GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP,
GPTNeoXJapaneseConfig,
)
# 导入 GPTJ 相关模块和配置
from .models.gptj import GPTJ_PRETRAINED_CONFIG_ARCHIVE_MAP, GPTJConfig
# 导入 GPTSAN_JAPANESE 相关模块和配置
from .models.gptsan_japanese import (
GPTSAN_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP,
GPTSanJapaneseConfig,
GPTSanJapaneseTokenizer,
)
# 导入 GRAPHORMER 相关模块和配置
from .models.graphormer import GRAPHORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, GraphormerConfig
# 导入 GROUPVIT 相关模块和配置
from .models.groupvit import (
GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP,
GroupViTConfig,
GroupViTTextConfig,
GroupViTVisionConfig,
)
# 导入 HerbertTokenizer 类
from .models.herbert import HerbertTokenizer
# 导入 HUBERT 相关模块和配置
from .models.hubert import HUBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, HubertConfig
# 导入 IBERT 相关模块和配置
from .models.ibert import IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, IBertConfig
# 导入 IDEFICS 相关模块和配置
from .models.idefics import IDEFICS_PRETRAINED_CONFIG_ARCHIVE_MAP, IdeficsConfig
# 导入所需模块和类
from .models.imagegpt import IMAGEGPT_PRETRAINED_CONFIG_ARCHIVE_MAP, ImageGPTConfig
from .models.informer import INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, InformerConfig
from .models.instructblip import (
INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP,
InstructBlipConfig,
InstructBlipProcessor,
InstructBlipQFormerConfig,
InstructBlipVisionConfig,
)
from .models.jukebox import (
JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP,
JukeboxConfig,
JukeboxPriorConfig,
JukeboxTokenizer,
JukeboxVQVAEConfig,
)
from .models.kosmos2 import (
KOSMOS2_PRETRAINED_CONFIG_ARCHIVE_MAP,
Kosmos2Config,
Kosmos2Processor,
)
from .models.layoutlm import (
LAYOUTLM_PRETRAINED_CONFIG_ARCHIVE_MAP,
LayoutLMConfig,
LayoutLMTokenizer,
)
from .models.layoutlmv2 import (
LAYOUTLMV2_PRETRAINED_CONFIG_ARCHIVE_MAP,
LayoutLMv2Config,
LayoutLMv2FeatureExtractor,
LayoutLMv2ImageProcessor,
LayoutLMv2Processor,
LayoutLMv2Tokenizer,
)
from .models.layoutlmv3 import (
LAYOUTLMV3_PRETRAINED_CONFIG_ARCHIVE_MAP,
LayoutLMv3Config,
LayoutLMv3FeatureExtractor,
LayoutLMv3ImageProcessor,
LayoutLMv3Processor,
LayoutLMv3Tokenizer,
)
from .models.layoutxlm import LayoutXLMProcessor
from .models.led import LED_PRETRAINED_CONFIG_ARCHIVE_MAP, LEDConfig, LEDTokenizer
from .models.levit import LEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP, LevitConfig
from .models.lilt import LILT_PRETRAINED_CONFIG_ARCHIVE_MAP, LiltConfig
from .models.llama import LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP, LlamaConfig
from .models.llava import (
LLAVA_PRETRAINED_CONFIG_ARCHIVE_MAP,
LlavaConfig,
LlavaProcessor,
)
from .models.llava_next import (
LLAVA_NEXT_PRETRAINED_CONFIG_ARCHIVE_MAP,
LlavaNextConfig,
LlavaNextProcessor,
)
from .models.longformer import (
LONGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
LongformerConfig,
LongformerTokenizer,
)
from .models.longt5 import LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP, LongT5Config
from .models.luke import LUKE_PRETRAINED_CONFIG_ARCHIVE_MAP, LukeConfig, LukeTokenizer
from .models.lxmert import LXMERT_PRETRAINED_CONFIG_ARCHIVE_MAP, LxmertConfig, LxmertTokenizer
from .models.m2m_100 import M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP, M2M100Config
from .models.mamba import MAMBA_PRETRAINED_CONFIG_ARCHIVE_MAP, MambaConfig
from .models.marian import MarianConfig
from .models.markuplm import (
MARKUPLM_PRETRAINED_CONFIG_ARCHIVE_MAP,
MarkupLMConfig,
MarkupLMFeatureExtractor,
MarkupLMProcessor,
MarkupLMTokenizer,
)
# 导入 mask2former 模块中的预训练配置映射和 Mask2FormerConfig 类
from .models.mask2former import (
MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
Mask2FormerConfig,
)
# 导入 maskformer 模块中的预训练配置映射、MaskFormerConfig 类以及 MaskFormerSwinConfig 类
from .models.maskformer import (
MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
MaskFormerConfig,
MaskFormerSwinConfig,
)
# 导入 mbart 模块中的 MBartConfig 类
from .models.mbart import MBartConfig
# 导入 mega 模块中的预训练配置映射和 MegaConfig 类
from .models.mega import MEGA_PRETRAINED_CONFIG_ARCHIVE_MAP, MegaConfig
# 导入 megatron_bert 模块中的预训练配置映射和 MegatronBertConfig 类
from .models.megatron_bert import (
MEGATRON_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
MegatronBertConfig,
)
# 导入 mgp_str 模块中的预训练配置映射、MgpstrConfig 类、MgpstrProcessor 类和 MgpstrTokenizer 类
from .models.mgp_str import (
MGP_STR_PRETRAINED_CONFIG_ARCHIVE_MAP,
MgpstrConfig,
MgpstrProcessor,
MgpstrTokenizer,
)
# 导入 mistral 模块中的预训练配置映射和 MistralConfig 类
from .models.mistral import MISTRAL_PRETRAINED_CONFIG_ARCHIVE_MAP, MistralConfig
# 导入 mixtral 模块中的预训练配置映射和 MixtralConfig 类
from .models.mixtral import MIXTRAL_PRETRAINED_CONFIG_ARCHIVE_MAP, MixtralConfig
# 导入 mobilebert 模块中的预训练配置映射、MobileBertConfig 类和 MobileBertTokenizer 类
from .models.mobilebert import (
MOBILEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
MobileBertConfig,
MobileBertTokenizer,
)
# 导入 mobilenet_v1 模块中的预训练配置映射和 MobileNetV1Config 类
from .models.mobilenet_v1 import (
MOBILENET_V1_PRETRAINED_CONFIG_ARCHIVE_MAP,
MobileNetV1Config,
)
# 导入 mobilenet_v2 模块中的预训练配置映射和 MobileNetV2Config 类
from .models.mobilenet_v2 import (
MOBILENET_V2_PRETRAINED_CONFIG_ARCHIVE_MAP,
MobileNetV2Config,
)
# 导入 mobilevit 模块中的预训练配置映射和 MobileViTConfig 类
from .models.mobilevit import (
MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP,
MobileViTConfig,
)
# 导入 mobilevitv2 模块中的预训练配置映射和 MobileViTV2Config 类
from .models.mobilevitv2 import (
MOBILEVITV2_PRETRAINED_CONFIG_ARCHIVE_MAP,
MobileViTV2Config,
)
# 导入 mpnet 模块中的预训练配置映射、MPNetConfig 类和 MPNetTokenizer 类
from .models.mpnet import (
MPNET_PRETRAINED_CONFIG_ARCHIVE_MAP,
MPNetConfig,
MPNetTokenizer,
)
# 导入 mpt 模块中的预训练配置映射和 MptConfig 类
from .models.mpt import MPT_PRETRAINED_CONFIG_ARCHIVE_MAP, MptConfig
# 导入 mra 模块中的预训练配置映射和 MraConfig 类
from .models.mra import MRA_PRETRAINED_CONFIG_ARCHIVE_MAP, MraConfig
# 导入 mt5 模块中的 MT5Config 类
from .models.mt5 import MT5Config
# 导入 musicgen 模块中的预训练配置映射、MusicgenConfig 类和 MusicgenDecoderConfig 类
from .models.musicgen import (
MUSICGEN_PRETRAINED_CONFIG_ARCHIVE_MAP,
MusicgenConfig,
MusicgenDecoderConfig,
)
# 导入 musicgen_melody 模块中的预训练模型存档列表、MusicgenMelodyConfig 类和 MusicgenMelodyDecoderConfig 类
from .models.musicgen_melody import (
MUSICGEN_MELODY_PRETRAINED_MODEL_ARCHIVE_LIST,
MusicgenMelodyConfig,
MusicgenMelodyDecoderConfig,
)
# 导入 mvp 模块中的 MvpConfig 类和 MvpTokenizer 类
from .models.mvp import MvpConfig, MvpTokenizer
# 导入 nat 模块中的预训练配置映射和 NatConfig 类
from .models.nat import NAT_PRETRAINED_CONFIG_ARCHIVE_MAP, NatConfig
# 导入 nezha 模块中的预训练配置映射和 NezhaConfig 类
from .models.nezha import NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP, NezhaConfig
# 导入 nllb_moe 模块中的预训练配置映射和 NllbMoeConfig 类
from .models.nllb_moe import NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP, NllbMoeConfig
# 导入 nougat 模块中的 NougatProcessor 类
from .models.nougat import NougatProcessor
# 导入 nystromformer 模块中的预训练配置映射和 NystromformerConfig 类
from .models.nystromformer import (
NYSTROMFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
NystromformerConfig,
)
# 导入 oneformer 模块中的预训练配置映射、OneFormerConfig 类和 OneFormerProcessor 类
from .models.oneformer import (
ONEFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
OneFormerConfig,
OneFormerProcessor,
)
# 导入 openai 模块中的预训练配置映射、OpenAIGPTConfig 类和 OpenAIGPTTokenizer 类
from .models.openai import (
OPENAI_GPT_PRETRAINED_CONFIG_ARCHIVE_MAP,
OpenAIGPTConfig,
OpenAIGPTTokenizer,
)
# 导入 opt 模块中的 OPTConfig 类
from .models.opt import OPTConfig
# 导入OWLv2模型相关的配置、处理器等
from .models.owlv2 import (
OWLV2_PRETRAINED_CONFIG_ARCHIVE_MAP,
Owlv2Config,
Owlv2Processor,
Owlv2TextConfig,
Owlv2VisionConfig,
)
# 导入OWLViT模型相关的配置、处理器等
from .models.owlvit import (
OWLVIT_PRETRAINED_CONFIG_ARCHIVE_MAP,
OwlViTConfig,
OwlViTProcessor,
OwlViTTextConfig,
OwlViTVisionConfig,
)
# 导入PatchTSMixer模型相关的配置
from .models.patchtsmixer import (
PATCHTSMIXER_PRETRAINED_CONFIG_ARCHIVE_MAP,
PatchTSMixerConfig,
)
# 导入PatchTST模型相关的配置
from .models.patchtst import PATCHTST_PRETRAINED_CONFIG_ARCHIVE_MAP, PatchTSTConfig
# 导入Pegasus模型相关的配置、配置解析器等
from .models.pegasus import (
PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP,
PegasusConfig,
PegasusTokenizer,
)
# 导入PegasusX模型相关的配置
from .models.pegasus_x import (
PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP,
PegasusXConfig,
)
# 导入Perceiver模型相关的配置、配置解析器等
from .models.perceiver import (
PERCEIVER_PRETRAINED_CONFIG_ARCHIVE_MAP,
PerceiverConfig,
PerceiverTokenizer,
)
# 导入Persimmon模型相关的配置
from .models.persimmon import (
PERSIMMON_PRETRAINED_CONFIG_ARCHIVE_MAP,
PersimmonConfig,
)
# 导入PHI模型相关的配置
from .models.phi import PHI_PRETRAINED_CONFIG_ARCHIVE_MAP, PhiConfig
# 导入Phobert模型的分词器
from .models.phobert import PhobertTokenizer
# 导入Pix2Struct模型相关的配置、配置解析器等
from .models.pix2struct import (
PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP,
Pix2StructConfig,
Pix2StructProcessor,
Pix2StructTextConfig,
Pix2StructVisionConfig,
)
# 导入PLBART模型相关的配置
from .models.plbart import PLBART_PRETRAINED_CONFIG_ARCHIVE_MAP, PLBartConfig
# 导入PoolFormer模型相关的配置
from .models.poolformer import (
POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
PoolFormerConfig,
)
# 导入Pop2Piano模型相关的配置
from .models.pop2piano import (
POP2PIANO_PRETRAINED_CONFIG_ARCHIVE_MAP,
Pop2PianoConfig,
)
# 导入ProphetNet模型相关的配置、配置解析器等
from .models.prophetnet import (
PROPHETNET_PRETRAINED_CONFIG_ARCHIVE_MAP,
ProphetNetConfig,
ProphetNetTokenizer,
)
# 导入PVT模型相关的配置
from .models.pvt import PVT_PRETRAINED_CONFIG_ARCHIVE_MAP, PvtConfig
# 导入PVT-V2模型相关的配置
from .models.pvt_v2 import PVT_V2_PRETRAINED_CONFIG_ARCHIVE_MAP, PvtV2Config
# 导入QDQBERT模型相关的配置
from .models.qdqbert import QDQBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, QDQBertConfig
# 导入QWEN2模型相关的配置、配置解析器等
from .models.qwen2 import (
QWEN2_PRETRAINED_CONFIG_ARCHIVE_MAP,
Qwen2Config,
Qwen2Tokenizer,
)
# 导入RAG模型的配置、检索器、分词器等
from .models.rag import RagConfig, RagRetriever, RagTokenizer
# 导入REALM模型相关的配置、配置解析器等
from .models.realm import (
REALM_PRETRAINED_CONFIG_ARCHIVE_MAP,
RealmConfig,
RealmTokenizer,
)
# 导入Reformer模型相关的配置
from .models.reformer import REFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, ReformerConfig
# 导入RegNet模型相关的配置
from .models.regnet import REGNET_PRETRAINED_CONFIG_ARCHIVE_MAP, RegNetConfig
# 导入RemBert模型相关的配置
from .models.rembert import REMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, RemBertConfig
# 导入ResNet模型相关的配置
from .models.resnet import RESNET_PRETRAINED_CONFIG_ARCHIVE_MAP, ResNetConfig
# 导入RoBERTa模型相关的配置、配置解析器等
from .models.roberta import (
ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP,
RobertaConfig,
RobertaTokenizer,
)
# 导入 RoBERTa 模型的配置映射和配置类
from .models.roberta_prelayernorm import (
ROBERTA_PRELAYERNORM_PRETRAINED_CONFIG_ARCHIVE_MAP,
RobertaPreLayerNormConfig,
)
# 导入 ROC-BERT 模型的配置映射、配置类和分词器类
from .models.roc_bert import (
ROC_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
RoCBertConfig,
RoCBertTokenizer,
)
# 导入 RoFormer 模型的配置映射、配置类和分词器类
from .models.roformer import (
ROFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
RoFormerConfig,
RoFormerTokenizer,
)
# 导入 RWKV 模型的配置映射和配置类
from .models.rwkv import RWKV_PRETRAINED_CONFIG_ARCHIVE_MAP, RwkvConfig
# 导入 SAM 模型的配置映射和多个配置类
from .models.sam import (
SAM_PRETRAINED_CONFIG_ARCHIVE_MAP,
SamConfig,
SamMaskDecoderConfig,
SamProcessor,
SamPromptEncoderConfig,
SamVisionConfig,
)
# 导入 Seamless M4T 模型的配置映射和多个配置类
from .models.seamless_m4t import (
SEAMLESS_M4T_PRETRAINED_CONFIG_ARCHIVE_MAP,
SeamlessM4TConfig,
SeamlessM4TFeatureExtractor,
SeamlessM4TProcessor,
)
# 导入 Seamless M4T V2 模型的配置映射和配置类
from .models.seamless_m4t_v2 import (
SEAMLESS_M4T_V2_PRETRAINED_CONFIG_ARCHIVE_MAP,
SeamlessM4Tv2Config,
)
# 导入 Segformer 模型的配置映射和配置类
from .models.segformer import SEGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, SegformerConfig
# 导入 SegGPT 模型的配置映射和配置类
from .models.seggpt import SEGGPT_PRETRAINED_CONFIG_ARCHIVE_MAP, SegGptConfig
# 导入 SEW 模型的配置映射和配置类
from .models.sew import SEW_PRETRAINED_CONFIG_ARCHIVE_MAP, SEWConfig
# 导入 SEW-D 模型的配置映射和配置类
from .models.sew_d import SEW_D_PRETRAINED_CONFIG_ARCHIVE_MAP, SEWDConfig
# 导入 Siglip 模型的配置映射和多个配置类
from .models.siglip import (
SIGLIP_PRETRAINED_CONFIG_ARCHIVE_MAP,
SiglipConfig,
SiglipProcessor,
SiglipTextConfig,
SiglipVisionConfig,
)
# 导入语音编码解码模型的配置类
from .models.speech_encoder_decoder import SpeechEncoderDecoderConfig
# 导入语音到文本模型的配置映射、配置类、特征提取器类和处理器类
from .models.speech_to_text import (
SPEECH_TO_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP,
Speech2TextConfig,
Speech2TextFeatureExtractor,
Speech2TextProcessor,
)
# 导入语音到文本 2 模型的配置映射、配置类、处理器类和分词器类
from .models.speech_to_text_2 import (
SPEECH_TO_TEXT_2_PRETRAINED_CONFIG_ARCHIVE_MAP,
Speech2Text2Config,
Speech2Text2Processor,
Speech2Text2Tokenizer,
)
# 导入 SpeechT5 模型的配置映射、配置类、特征提取器类和处理器类
from .models.speecht5 import (
SPEECHT5_PRETRAINED_CONFIG_ARCHIVE_MAP,
SPEECHT5_PRETRAINED_HIFIGAN_CONFIG_ARCHIVE_MAP,
SpeechT5Config,
SpeechT5FeatureExtractor,
SpeechT5HifiGanConfig,
SpeechT5Processor,
)
# 导入 Splinter 模型的配置映射、配置类和分词器类
from .models.splinter import (
SPLINTER_PRETRAINED_CONFIG_ARCHIVE_MAP,
SplinterConfig,
SplinterTokenizer,
)
# 导入 SqueezeBERT 模型的配置映射、配置类和分词器类
from .models.squeezebert import (
SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
SqueezeBertConfig,
SqueezeBertTokenizer,
)
# 导入 StableLM 模型的配置映射和配置类
from .models.stablelm import STABLELM_PRETRAINED_CONFIG_ARCHIVE_MAP, StableLmConfig
# 导入 Starcoder2 模型的配置映射和配置类
from .models.starcoder2 import STARCODER2_PRETRAINED_CONFIG_ARCHIVE_MAP, Starcoder2Config
# 导入 SuperPoint 模型的配置映射和配置类
from .models.superpoint import SUPERPOINT_PRETRAINED_CONFIG_ARCHIVE_MAP, SuperPointConfig
# 导入 SwiftFormer 模型的配置映射和配置类
from .models.swiftformer import (
SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
SwiftFormerConfig,
)
# 导入 SWIN 模型相关的预训练配置映射和配置类
from .models.swin import SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP, SwinConfig
# 导入 SWIN2SR 模型相关的预训练配置映射和配置类
from .models.swin2sr import SWIN2SR_PRETRAINED_CONFIG_ARCHIVE_MAP, Swin2SRConfig
# 导入 SWINV2 模型相关的预训练配置映射和配置类
from .models.swinv2 import SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP, Swinv2Config
# 导入 Switch Transformers 模型相关的预训练配置映射和配置类
from .models.switch_transformers import (
SWITCH_TRANSFORMERS_PRETRAINED_CONFIG_ARCHIVE_MAP,
SwitchTransformersConfig,
)
# 导入 T5 模型相关的预训练配置映射和配置类
from .models.t5 import T5_PRETRAINED_CONFIG_ARCHIVE_MAP, T5Config
# 导入 Table Transformer 模型相关的预训练配置映射和配置类
from .models.table_transformer import (
TABLE_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
TableTransformerConfig,
)
# 导入 TAPAS 模型相关的预训练配置映射、配置类和分词器类
from .models.tapas import (
TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP,
TapasConfig,
TapasTokenizer,
)
# 导入 Time Series Transformer 模型相关的预训练配置映射和配置类
from .models.time_series_transformer import (
TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
TimeSeriesTransformerConfig,
)
# 导入 Timesformer 模型相关的预训练配置映射和配置类
from .models.timesformer import (
TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
TimesformerConfig,
)
# 导入 Timm Backbone 模型的配置类
from .models.timm_backbone import TimmBackboneConfig
# 导入 TrOCR 模型相关的预训练配置映射、配置类和处理器类
from .models.trocr import (
TROCR_PRETRAINED_CONFIG_ARCHIVE_MAP,
TrOCRConfig,
TrOCRProcessor,
)
# 导入 TVLT 模型相关的预训练配置映射、配置类和特征提取器类、处理器类
from .models.tvlt import (
TVLT_PRETRAINED_CONFIG_ARCHIVE_MAP,
TvltConfig,
TvltFeatureExtractor,
TvltProcessor,
)
# 导入 TVP 模型相关的预训练配置映射、配置类和处理器类
from .models.tvp import (
TVP_PRETRAINED_CONFIG_ARCHIVE_MAP,
TvpConfig,
TvpProcessor,
)
# 导入 UDOP 模型相关的预训练配置映射、配置类和处理器类
from .models.udop import UDOP_PRETRAINED_CONFIG_ARCHIVE_MAP, UdopConfig, UdopProcessor
# 导入 UMT5 模型的配置类
from .models.umt5 import UMT5Config
# 导入 UniSpeech 模型相关的预训练配置映射和配置类
from .models.unispeech import (
UNISPEECH_PRETRAINED_CONFIG_ARCHIVE_MAP,
UniSpeechConfig,
)
# 导入 UniSpeech SAT 模型相关的预训练配置映射和配置类
from .models.unispeech_sat import (
UNISPEECH_SAT_PRETRAINED_CONFIG_ARCHIVE_MAP,
UniSpeechSatConfig,
)
# 导入 UnivNet 模型相关的预训练配置映射、配置类和特征提取器类
from .models.univnet import (
UNIVNET_PRETRAINED_CONFIG_ARCHIVE_MAP,
UnivNetConfig,
UnivNetFeatureExtractor,
)
# 导入 UperNet 模型的配置类
from .models.upernet import UperNetConfig
# 导入 VideoMAE 模型相关的预训练配置映射和配置类
from .models.videomae import VIDEOMAE_PRETRAINED_CONFIG_ARCHIVE_MAP, VideoMAEConfig
# 导入 VILT 模型相关的预训练配置映射、配置类和特征提取器类、图像处理器类、处理器类
from .models.vilt import (
VILT_PRETRAINED_CONFIG_ARCHIVE_MAP,
ViltConfig,
ViltFeatureExtractor,
ViltImageProcessor,
ViltProcessor,
)
# 导入 VIPLLAVA 模型相关的预训练配置映射和配置类
from .models.vipllava import (
VIPLLAVA_PRETRAINED_CONFIG_ARCHIVE_MAP,
VipLlavaConfig,
)
# 导入 Vision Encoder-Decoder 模型的配置类
from .models.vision_encoder_decoder import VisionEncoderDecoderConfig
# 导入 Vision Text Dual Encoder 模型的配置类和处理器类
from .models.vision_text_dual_encoder import (
VisionTextDualEncoderConfig,
VisionTextDualEncoderProcessor,
)
# 导入 VisualBERT 模型相关的预训练配置映射和配置类
from .models.visual_bert import (
VISUAL_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
VisualBertConfig,
)
# 导入 ViT 模型相关的预训练配置映射和配置类
from .models.vit import VIT_PRETRAINED_CONFIG_ARCHIVE_MAP, ViTConfig
# 导入 ViT Hybrid 模型相关的预训练配置映射和配置类
from .models.vit_hybrid import (
VIT_HYBRID_PRETRAINED_CONFIG_ARCHIVE_MAP,
ViTHybridConfig,
)
# 导入各个模型的预训练配置映射和配置类
from .models.vit_mae import VIT_MAE_PRETRAINED_CONFIG_ARCHIVE_MAP, ViTMAEConfig
from .models.vit_msn import VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP, ViTMSNConfig
from .models.vitdet import VITDET_PRETRAINED_CONFIG_ARCHIVE_MAP, VitDetConfig
from .models.vitmatte import VITMATTE_PRETRAINED_CONFIG_ARCHIVE_MAP, VitMatteConfig
from .models.vits import (
VITS_PRETRAINED_CONFIG_ARCHIVE_MAP,
VitsConfig,
VitsTokenizer,
)
from .models.vivit import VIVIT_PRETRAINED_CONFIG_ARCHIVE_MAP, VivitConfig
from .models.wav2vec2 import (
WAV_2_VEC_2_PRETRAINED_CONFIG_ARCHIVE_MAP,
Wav2Vec2Config,
Wav2Vec2CTCTokenizer,
Wav2Vec2FeatureExtractor,
Wav2Vec2Processor,
Wav2Vec2Tokenizer,
)
from .models.wav2vec2_bert import (
WAV2VEC2_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
Wav2Vec2BertConfig,
Wav2Vec2BertProcessor,
)
from .models.wav2vec2_conformer import (
WAV2VEC2_CONFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
Wav2Vec2ConformerConfig,
)
from .models.wav2vec2_phoneme import Wav2Vec2PhonemeCTCTokenizer
from .models.wav2vec2_with_lm import Wav2Vec2ProcessorWithLM
from .models.wavlm import WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP, WavLMConfig
from .models.whisper import (
WHISPER_PRETRAINED_CONFIG_ARCHIVE_MAP,
WhisperConfig,
WhisperFeatureExtractor,
WhisperProcessor,
WhisperTokenizer,
)
from .models.x_clip import (
XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP,
XCLIPConfig,
XCLIPProcessor,
XCLIPTextConfig,
XCLIPVisionConfig,
)
from .models.xglm import XGLM_PRETRAINED_CONFIG_ARCHIVE_MAP, XGLMConfig
from .models.xlm import XLM_PRETRAINED_CONFIG_ARCHIVE_MAP, XLMConfig, XLMTokenizer
from .models.xlm_prophetnet import (
XLM_PROPHETNET_PRETRAINED_CONFIG_ARCHIVE_MAP,
XLMProphetNetConfig,
)
from .models.xlm_roberta import XLM_ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP, XLMRobertaConfig
from .models.xlm_roberta_xl import (
XLM_ROBERTA_XL_PRETRAINED_CONFIG_ARCHIVE_MAP,
XLMRobertaXLConfig,
)
from .models.xlnet import XLNET_PRETRAINED_CONFIG_ARCHIVE_MAP, XLNetConfig
from .models.xmod import XMOD_PRETRAINED_CONFIG_ARCHIVE_MAP, XmodConfig
from .models.yolos import YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP, YolosConfig
from .models.yoso import YOSO_PRETRAINED_CONFIG_ARCHIVE_MAP, YosoConfig
# 各个模型的预训练配置映射和配置类的导入
# 导入具体的数据处理管道类
from .pipelines import (
AudioClassificationPipeline, # 音频分类管道
AutomaticSpeechRecognitionPipeline, # 自动语音识别管道
Conversation, # 对话处理
ConversationalPipeline, # 对话式处理管道
CsvPipelineDataFormat, # CSV 数据格式处理管道
DepthEstimationPipeline, # 深度估计管道
DocumentQuestionAnsweringPipeline, # 文档问答管道
FeatureExtractionPipeline, # 特征提取管道
FillMaskPipeline, # 填空管道
ImageClassificationPipeline, # 图像分类管道
ImageFeatureExtractionPipeline, # 图像特征提取管道
ImageSegmentationPipeline, # 图像分割管道
ImageToImagePipeline, # 图像到图像转换管道
ImageToTextPipeline, # 图像到文本转换管道
JsonPipelineDataFormat, # JSON 数据格式处理管道
MaskGenerationPipeline, # 掩码生成管道
NerPipeline, # 命名实体识别管道
ObjectDetectionPipeline, # 目标检测管道
PipedPipelineDataFormat, # 管道数据格式处理管道
Pipeline, # 通用管道基类
PipelineDataFormat, # 管道数据格式
QuestionAnsweringPipeline, # 问答管道
SummarizationPipeline, # 摘要生成管道
TableQuestionAnsweringPipeline, # 表格问答管道
Text2TextGenerationPipeline, # 文本到文本生成管道
TextClassificationPipeline, # 文本分类管道
TextGenerationPipeline, # 文本生成管道
TextToAudioPipeline, # 文本到音频生成管道
TokenClassificationPipeline, # 标记分类管道
TranslationPipeline, # 翻译管道
VideoClassificationPipeline, # 视频分类管道
VisualQuestionAnsweringPipeline, # 视觉问答管道
ZeroShotAudioClassificationPipeline, # 零样本音频分类管道
ZeroShotClassificationPipeline, # 零样本分类管道
ZeroShotImageClassificationPipeline, # 零样本图像分类管道
ZeroShotObjectDetectionPipeline, # 零样本目标检测管道
pipeline, # 简化调用的通用管道方法
)
# 导入处理工具和Mixin类
from .processing_utils import ProcessorMixin
# 导入分词相关工具类
# Tokenization
from .tokenization_utils import PreTrainedTokenizer # 预训练分词器
from .tokenization_utils_base import (
AddedToken, # 添加的特殊标记
BatchEncoding, # 批编码
CharSpan, # 字符跨度
PreTrainedTokenizerBase, # 预训练分词器基类
SpecialTokensMixin, # 特殊标记混合类
TokenSpan, # 标记跨度
)
# 导入工具类和相关函数
# Tools
from .tools import (
Agent, # 代理
AzureOpenAiAgent, # Azure OpenAI 代理
HfAgent, # Hugging Face 代理
LocalAgent, # 本地代理
OpenAiAgent, # OpenAI 代理
PipelineTool, # 管道工具
RemoteTool, # 远程工具
Tool, # 工具
launch_gradio_demo, # 启动 Gradio 演示
load_tool, # 载入工具
)
# 导入训练过程中的回调函数和状态类
# Trainer
from .trainer_callback import (
DefaultFlowCallback, # 默认流程回调
EarlyStoppingCallback, # 提前停止回调
PrinterCallback, # 打印机回调
ProgressCallback, # 进度回调
TrainerCallback, # 训练器回调基类
TrainerControl, # 训练控制
TrainerState, # 训练状态
)
# 导入训练过程中的实用函数和类
from .trainer_utils import (
EvalPrediction, # 评估预测
IntervalStrategy, # 间隔策略
SchedulerType, # 调度器类型
enable_full_determinism, # 启用完全确定性
set_seed, # 设置随机种子
)
# 导入训练参数类
from .training_args import TrainingArguments # 训练参数
from .training_args_seq2seq import Seq2SeqTrainingArguments # 序列到序列训练参数
from .training_args_tf import TFTrainingArguments # TensorFlow 训练参数
# 导入文件和通用工具
# Files and general utilities
# 从.utils模块中导入多个常量和函数
from .utils import (
CONFIG_NAME, # 导入配置名称常量
MODEL_CARD_NAME, # 导入模型卡名称常量
PYTORCH_PRETRAINED_BERT_CACHE, # 导入PyTorch预训练BERT缓存常量
PYTORCH_TRANSFORMERS_CACHE, # 导入PyTorch Transformers缓存常量
SPIECE_UNDERLINE, # 导入SPIECE_UNDERLINE常量
TF2_WEIGHTS_NAME, # 导入TensorFlow 2权重名称常量
TF_WEIGHTS_NAME, # 导入TensorFlow权重名称常量
TRANSFORMERS_CACHE, # 导入Transformers缓存常量
WEIGHTS_NAME, # 导入权重名称常量
TensorType, # 导入TensorType类
add_end_docstrings, # 导入添加文档结束注释的函数
add_start_docstrings, # 导入添加文档起始注释的函数
is_apex_available, # 导入检查Apex是否可用的函数
is_bitsandbytes_available, # 导入检查bitsandbytes是否可用的函数
is_datasets_available, # 导入检查datasets是否可用的函数
is_decord_available, # 导入检查decord是否可用的函数
is_faiss_available, # 导入检查faiss是否可用的函数
is_flax_available, # 导入检查flax是否可用的函数
is_keras_nlp_available, # 导入检查keras-nlp是否可用的函数
is_phonemizer_available, # 导入检查phonemizer是否可用的函数
is_psutil_available, # 导入检查psutil是否可用的函数
is_py3nvml_available, # 导入检查py3nvml是否可用的函数
is_pyctcdecode_available, # 导入检查pyctcdecode是否可用的函数
is_sacremoses_available, # 导入检查sacremoses是否可用的函数
is_safetensors_available, # 导入检查safetensors是否可用的函数
is_scipy_available, # 导入检查scipy是否可用的函数
is_sentencepiece_available, # 导入检查sentencepiece是否可用的函数
is_sklearn_available, # 导入检查scikit-learn是否可用的函数
is_speech_available, # 导入检查speech是否可用的函数
is_tensorflow_text_available, # 导入检查tensorflow-text是否可用的函数
is_tf_available, # 导入检查TensorFlow是否可用的函数
is_timm_available, # 导入检查timm是否可用的函数
is_tokenizers_available, # 导入检查tokenizers是否可用的函数
is_torch_available, # 导入检查PyTorch是否可用的函数
is_torch_neuroncore_available, # 导入检查torch-neuroncore是否可用的函数
is_torch_npu_available, # 导入检查torch-npu是否可用的函数
is_torch_tpu_available, # 导入检查torch-tpu是否可用的函数
is_torch_xla_available, # 导入检查torch-xla是否可用的函数
is_torch_xpu_available, # 导入检查torch-xpu是否可用的函数
is_torchvision_available, # 导入检查torchvision是否可用的函数
is_vision_available, # 导入检查vision是否可用的函数
logging, # 导入logging模块
)
# bitsandbytes配置
# 从.utils.quantization_config模块导入多个配置类
from .utils.quantization_config import AqlmConfig, AwqConfig, BitsAndBytesConfig, GPTQConfig, QuantoConfig
try:
# 如果sentencepiece不可用,抛出OptionalDependencyNotAvailable异常
if not is_sentencepiece_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
# 导入虚拟的sentencepiece对象,以便在没有实际依赖时使用
from .utils.dummy_sentencepiece_objects import *
else:
# 导入各种模型的分词器
from .models.albert import AlbertTokenizer
from .models.barthez import BarthezTokenizer
from .models.bartpho import BartphoTokenizer
from .models.bert_generation import BertGenerationTokenizer
from .models.big_bird import BigBirdTokenizer
from .models.camembert import CamembertTokenizer
from .models.code_llama import CodeLlamaTokenizer
from .models.cpm import CpmTokenizer
from .models.deberta_v2 import DebertaV2Tokenizer
from .models.ernie_m import ErnieMTokenizer
from .models.fnet import FNetTokenizer
from .models.gemma import GemmaTokenizer
from .models.gpt_sw3 import GPTSw3Tokenizer
from .models.layoutxlm import LayoutXLMTokenizer
from .models.llama import LlamaTokenizer
from .models.m2m_100 import M2M100Tokenizer
from .models.marian import MarianTokenizer
from .models.mbart import MBart50Tokenizer, MBartTokenizer
from .models.mluke import MLukeTokenizer
from .models.mt5 import MT5Tokenizer
from .models.nllb import NllbTokenizer
from .models.pegasus import PegasusTokenizer
from .models.plbart import PLBartTokenizer
from .models.reformer import ReformerTokenizer
from .models.rembert import RemBertTokenizer
from .models.seamless_m4t import SeamlessM4TTokenizer
from .models.siglip import SiglipTokenizer
from .models.speech_to_text import Speech2TextTokenizer
from .models.speecht5 import SpeechT5Tokenizer
from .models.t5 import T5Tokenizer
from .models.udop import UdopTokenizer
from .models.xglm import XGLMTokenizer
from .models.xlm_prophetnet import XLMProphetNetTokenizer
from .models.xlm_roberta import XLMRobertaTokenizer
from .models.xlnet import XLNetTokenizer
try:
# 检查 tokenizers 库是否可用,如果不可用则引发 OptionalDependencyNotAvailable 异常
if not is_tokenizers_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
# 如果 tokenizers 库不可用,则导入虚拟的 tokenizers 对象
from .utils.dummy_tokenizers_objects import *
try:
# 检查是否同时可用 sentencepiece 和 tokenizers 库,如果不可用则引发 OptionalDependencyNotAvailable 异常
if not (is_sentencepiece_available() and is_tokenizers_available()):
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
# 如果 sentencepiece 和 tokenizers 库不可用,则导入虚拟的 sentencepiece 和 tokenizers 对象
from .utils.dummies_sentencepiece_and_tokenizers_objects import *
else:
# 如果以上检查都通过,则导入转换慢速分词器为快速分词器的相关函数和对象
from .convert_slow_tokenizer import (
SLOW_TO_FAST_CONVERTERS,
convert_slow_tokenizer,
)
try:
# 检查是否可用 tensorflow_text 库,如果不可用则引发 OptionalDependencyNotAvailable 异常
if not is_tensorflow_text_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
# 如果 tensorflow_text 库不可用,则导入虚拟的 tensorflow_text 对象
from .utils.dummy_tensorflow_text_objects import *
else:
# 如果 tensorflow_text 库可用,则导入 TF 版本的 BERT 分词器
from .models.bert import TFBertTokenizer
try:
# 检查是否可用 keras_nlp 库,如果不可用则引发 OptionalDependencyNotAvailable 异常
if not is_keras_nlp_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
# 如果 keras_nlp 库不可用,则导入虚拟的 keras_nlp 对象
from .utils.dummy_keras_nlp_objects import *
else:
# 如果 keras_nlp 库可用,则导入 TF 版本的 GPT-2 分词器
from .models.gpt2 import TFGPT2Tokenizer
# 检查是否有视觉模块可用
try:
if not is_vision_available():
# 如果视觉模块不可用,则引发 OptionalDependencyNotAvailable 异常
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
# 如果异常被引发,从 dummy_vision_objects 模块导入所有对象
from .utils.dummy_vision_objects import *
# 模型部分
# 检查是否有 Torch 库可用
try:
if not is_torch_available():
# 如果 Torch 库不可用,则引发 OptionalDependencyNotAvailable 异常
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
# 如果异常被引发,从 dummy_pt_objects 模块导入所有对象
from .utils.dummy_pt_objects import *
# TensorFlow 部分
try:
if not is_tf_available():
# 如果 TensorFlow 不可用,则引发 OptionalDependencyNotAvailable 异常
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
# 如果异常被引发,导入 dummy_tf_objects 模块,将对象置于命名空间中
from .utils.dummy_tf_objects import *
# 检查是否同时具备以下库的可用性:librosa、essentia、scipy、torch、pretty_midi
try:
if not (
is_librosa_available()
and is_essentia_available()
and is_scipy_available()
and is_torch_available()
and is_pretty_midi_available()
):
# 如果任何一个依赖库不可用,则引发 OptionalDependencyNotAvailable 异常
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
# 如果异常被引发,从 dummy_essentia_and_librosa_and_pretty_midi_and_scipy_and_torch_objects 模块导入所有对象
from .utils.dummy_essentia_and_librosa_and_pretty_midi_and_scipy_and_torch_objects import *
else:
# 如果所有依赖库都可用,则从 pop2piano 模块导入特定对象
from .models.pop2piano import (
Pop2PianoFeatureExtractor,
Pop2PianoProcessor,
Pop2PianoTokenizer,
)
# 检查是否有 torchaudio 库可用
try:
if not is_torchaudio_available():
# 如果 torchaudio 不可用,则引发 OptionalDependencyNotAvailable 异常
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
# 如果异常被引发,从 dummy_torchaudio_objects 模块导入所有对象
from .utils.dummy_torchaudio_objects import *
else:
# 如果 torchaudio 可用,则从 musicgen_melody 模块导入特定对象
from .models.musicgen_melody import MusicgenMelodyFeatureExtractor, MusicgenMelodyProcessor
# Flax 部分
try:
if not is_flax_available():
# 如果 Flax 不可用,则引发 OptionalDependencyNotAvailable 异常
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
# 如果异常被引发,导入 dummy_flax_objects 模块,将对象置于命名空间中
from .utils.dummy_flax_objects import *
# 如果不是在 TensorFlow、PyTorch 或 Flax 环境下,则给出警告建议信息
if not is_tf_available() and not is_torch_available() and not is_flax_available():
logger.warning_advice(
"None of PyTorch, TensorFlow >= 2.0, or Flax have been found. "
"Models won't be available and only tokenizers, configuration "
"and file/data utilities can be used."
)
else:
# 导入 sys 模块,用于后续操作
import sys
# 将当前模块替换为 _LazyModule 的实例,传入相关参数
sys.modules[__name__] = _LazyModule(
__name__,
globals()["__file__"],
_import_structure,
module_spec=__spec__,
extra_objects={"__version__": __version__},
)