Files
openmind/docs/zh/api_reference/apis/omdatasets_api.md
2024-11-26 09:24:53 +08:00

48 lines
2.4 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# OmDataset接口
`OmDataset`模块可以实现魔乐社区数据集下载使用。
## OmDataset类
`OmDataset`抽取了datasets下载相关代码适配了`openmind_hub`。该类包含`load_dataset`接口,实现了`datasets``load_dataset`功能,支持从魔乐社区下载数据集。
### openmind.omdatasets.OmDataset.load_dataset()方法
**接口原型**
```python
def load_dataset(
path: Optional[str] = None,
name: Optional[str] = None,
revision: Optional[str] = "main",
split: Optional[str] = None,
data_dir: Optional[str] = None,
data_files: Optional[Union[str, Sequence[str], Mapping[str, Union[str, Sequence[str]]]]] = None,
download_mode: Optional[DownloadMode] = DownloadMode.REUSE_DATASET_IF_EXISTS,
cache_dir: Optional[str] = None,
token: Optional[str] = None,
dataset_info_only: Optional[bool] = False,
trust_remote_code: bool = None,
streaming: bool = False,
**config_kwargs,
)
```
**参数列表**
- **path**:数据集仓库名。
- **name**:数据集中子数据集名称。当需要指定下载多个子数据集中某一个时,可配置此参数。
- **revision**:数据集分支或版本。
- **split**加载数据集指定子数据集。如果值为None将返回包含所有数据 (具体配置情况请查看仓库数据集metadata)。
- **data_dir**:仓库中指定下载数据集所在的目录。
- **data_files**:数据集文件。
- **download_mode**:数据下载模式,可以选择输入`"reuse_dataset_if_exists"``"force_redownload"``"reuse_dataset_if_exists"`代表`DownloadMode.REUSE_DATASET_IF_EXISTS`, 即如果已下载过可复用缓存;`"force_redownload"`代表`DownloadMode.FORCE_REDOWNLOAD`,即强制重新下载数据集。目前默认使用`DownloadMode.REUSE_DATASET_IF_EXISTS`
- **cache_dir**:缓存数据的目录。
- **token**:用户访问令牌,访问非公开数据集时必填。
- **dataset_info_only**如果设定为True 只返回数据集config和info信息。
- **trust_remote_code**: 如果设定为True下载数据集中如包含py文件可被执行。
- **config_kwargs**:其余待传递关键参数。
- **streaming**如果设置为True则不下载数据文件。相反它会在遍历数据集时逐步流式传输数据。在这种情况下将返回一个IterableDataset或IterableDatasetDict。
若不设置`streaming=True`,该接口返回`datasets.dataset_dict.DatasetDict`类。