参考AI Studio----基于bert的模型的机器阅读理解
安装paddle2.0.2框架
- 执行以下命令安装(推荐使用百度源):
python -m pip install paddlepaddle==2.0.2 -i https://mirror.baidu.com/pypi/simple
修改下载到的paddle的源码
按理说下载好的库与参考链接中使用的库相同,在安装好该环境后就能直接使用。但实际情况是,pip安装的库与paddle的github仓库中的文件有所出入,因此将使用到的文件对照github进行更新(校园网为什么要屏蔽github o(╥﹏╥)o)
- 在dataset.py中添加load_dataset方法
def load_dataset(path_or_read_func,
name=None,
data_files=None,
splits=None,
lazy=None,
**kwargs):
if inspect.isfunction(path_or_read_func):
assert lazy is not None, "lazy can not be None in custom mode."
kwargs['name'] = name
kwargs['data_files'] = data_files
kwargs['splits'] = splits
custom_kwargs = {
}
for name in inspect.signature(path_or_read_func).parameters.keys():
if name in kwargs.keys():
custom_kwargs[name] = kwargs[name]
reader_instance = SimpleBuilder(lazy=lazy, read_func=path_or_read_func)
return reader_instance.read(**custom_kwargs)
else:
try:
reader_cls = import_main_class(path_or_read_func)
except ModuleNotFoundError:
datasets = load_from_hf(
path_or_read_func, name=name, splits=splits, **kwargs)
else:
reader_instance = reader_cls(lazy=lazy, name=name, **kwargs)
# Check if selected name and split is valid in this DatasetBuilder
if hasattr(reader_instance, 'BUILDER_CONFIGS'):