Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: formatter 调用 datasets.load_dataset 时缓存位置问题 #41

Closed
3 tasks done
PommesPeter opened this issue Oct 24, 2023 · 10 comments · Fixed by #43
Closed
3 tasks done

[Bug]: formatter 调用 datasets.load_dataset 时缓存位置问题 #41

PommesPeter opened this issue Oct 24, 2023 · 10 comments · Fixed by #43
Assignees
Labels
bug Something isn't working

Comments

@PommesPeter
Copy link

PommesPeter commented Oct 24, 2023

Before Reporting 报告之前

  • I have pulled the latest code of main branch to run again and the bug still existed. 我已经拉取了主分支上最新的代码,重新运行之后,问题仍不能解决。

  • I have read the README carefully and no error occurred during the installation process. (Otherwise, we recommend that you can ask a question using the Question template) 我已经仔细阅读了 README 上的操作指引,并且在安装过程中没有错误发生。(否则,我们建议您使用Question模板向我们进行提问)

Search before reporting 先搜索,再报告

  • I have searched the Data-Juicer issues and found no similar bugs. 我已经在 issue列表 中搜索但是没有发现类似的bug报告。

OS 系统

Ubuntu 20.04.5 LTS x86_64

Installation Method 安装方式

source

Data-Juicer Version Data-Juicer版本

v0.1.2

Python Version Python版本

3.10

Describe the bug 描述这个bug

查阅 data-juicer 源码后,发现 LocalFormatter.load_dataset 在调用 datasets.load_dataset 时,系统指定的 HF_DATASETS_CACHE 环境变量没有生效,加载本地的 json 文件的时候仍然会放到默认的 ~/.cache/huggingface/datasets 下。

To Reproduce 如何复现

  1. Run command
python tools/process_data.py --config configs/data_juicer_recipes/alpaca_cot/alpaca-cot-en-refine.yaml
  1. Check .cache folder
ls ~/.cache/huggingface/datasets
  1. Shwo result
--> ls ~/.cache/huggingface/datasets
xxx-960372e22b98db9d_0.0.0_fe5dd6ea2639a6df622901539cb550cf8797e5a6b2dd7af1cf934bed8e233e6e.lock  json

Configs 配置信息

global parameters

project_name: 'Data-Juicer-recipes-alpaca-cot-en'
dataset_path: '../data/raw_data/raw_data_en.jsonl' # path to your dataset directory or file
export_path: '../data/refine_data/dataset.jsonl'

np: 100 # number of subprocess to process your dataset
open_tracer: true

process schedule

a list of several process operators with their arguments

process:

  • document_deduplicator: # 104636705
    lowercase: true
    ignore_non_character: true

  • alphanumeric_filter: # 104636381
    tokenization: false
    min_ratio: 0.1

  • character_repetition_filter: # 104630030
    rep_len: 10
    max_ratio: 0.6

  • flagged_words_filter: # 104576967
    lang: en
    tokenization: true
    max_ratio: 0.017

  • maximum_line_length_filter: # 104575811
    min_len: 20

  • text_length_filter: # 104573711
    min_len: 30

  • document_simhash_deduplicator: # 72855345
    tokenization: space
    window_size: 3
    lowercase: true
    ignore_pattern: '\p{P}'
    num_blocks: 9
    hamming_distance: 7

Logs 报错日志

None

Screenshots 截图

None

Additional 额外信息

代码发生位置 data-juicer/data_juicer/format/formatter.py

预期解决方案:

  1. 可从 config 动态给 load_dataset 传参,即通过 yaml 读取额外的 key 和 value,通过 **kwargs 传入 LocalFormatter.load_dataset 指定 cache_dir 参数。

如果可能的话,我可以作为社区开发者提 PR 作贡献。

@PommesPeter PommesPeter added the bug Something isn't working label Oct 24, 2023
@HYLcool HYLcool self-assigned this Oct 24, 2023
@HYLcool
Copy link
Collaborator

HYLcool commented Oct 24, 2023

您好,感谢您使用Data-Juicer!

我刚才在本地尝试了一下是能够work的。您可以直接通过在配置文件里指定ds_cache_dir参数来显示修改cache存放路径(完整的参数信息可参考config_all.yaml),而不需要通过环境变量的形式来修改。

由于Data-Juicer在处理过程中,ds_cache_dir的优先级会高于环境变量,所以环境变量的修改就没用了。内置参数的方式一方面可以更好管理各种参数,另一方面对用户更友好(一些用户可能并不太熟悉环境变量这一套东西)。

以上供您参考~如还有其它问题,可随时联系😄

@adrianJW421
Copy link

我也踩过这个坑,可能因为正好是属于熟悉环境变量那一套配置操作的用户,折腾好久才发现原来config里显式指定cache路径优先级最高 XD, 其实我觉得这个项目初始化的时候很容易占满cache目录,可能在readme提示一下cache路径设置的注意事项会好一点

@HYLcool
Copy link
Collaborator

HYLcool commented Oct 24, 2023

我也踩过这个坑,可能因为正好是属于熟悉环境变量那一套配置操作的用户,折腾好久才发现原来config里显式指定cache路径优先级最高 XD, 其实我觉得这个项目初始化的时候很容易占满cache目录,可能在readme提示一下cache路径设置的注意事项会好一点

好的,感谢您的意见~我们会在之后在文档中合适的位置特别说明下这个情况👌🏻

@PommesPeter
Copy link
Author

PommesPeter commented Oct 24, 2023

您好,感谢您使用Data-Juicer!

我刚才在本地尝试了一下是能够work的。您可以直接通过在配置文件里指定ds_cache_dir参数来显示修改cache存放路径(完整的参数信息可参考config_all.yaml),而不需要通过环境变量的形式来修改。

由于Data-Juicer在处理过程中,ds_cache_dir的优先级会高于环境变量,所以环境变量的修改就没用了。内置参数的方式一方面可以更好管理各种参数,另一方面对用户更友好(一些用户可能并不太熟悉环境变量这一套东西)。

以上供您参考~如还有其它问题,可随时联系😄

感谢您的回复,了解开发者的用意了。那希望可以在文档处补充一下相关注意事项,目前使用来看确实很容易占满 .cache 目录,特别是 / 比较小的时候。个人觉得除了文档处添加之外,可以在每一个 yaml 下单独新增一个注释来说明,这样让用户更加清晰看到,这个应该是大部分用户都会需要调整的 config。

@PommesPeter
Copy link
Author

PommesPeter commented Oct 24, 2023

我也踩过这个坑,可能因为正好是属于熟悉环境变量那一套配置操作的用户,折腾好久才发现原来config里显式指定cache路径优先级最高 XD, 其实我觉得这个项目初始化的时候很容易占满cache目录,可能在readme提示一下cache路径设置的注意事项会好一点

感谢您的回复,我是看直接调用的 datasets 库就往环境变量那里调了,原来 data-juicer 有对这方面做设计,不过也确实方便用户,如果文档处添加说明就更好了

@PommesPeter
Copy link
Author

PommesPeter commented Oct 24, 2023

哦对了,还想反馈一个问题,在第一次配好环境之后会遇到这个报错

NotImplementedError: Loading a streaming dataset cached in a LocalFileSystem is not supported yet.

网上查了一下好像说是和 fsspec 这个版本有关系。

huggingface/datasets#6330 (comment)

image

降级之后可以用了

@HYLcool
Copy link
Collaborator

HYLcool commented Oct 24, 2023

嗯是的,这个是datasets那边的问题,datasets正在修复,目前他们建议先降低fsspec的版本,我们也会在最近的PR里暂时先显式地加上这个版本限制

@PommesPeter
Copy link
Author

嗯是的,这个是datasets那边的问题,datasets正在修复,目前他们建议先降低fsspec的版本,我们也会在最近的PR里暂时先显式地加上这个版本限制

好的,我没有其他问题了,感谢您的回答!

@HYLcool
Copy link
Collaborator

HYLcool commented Oct 25, 2023

嗨,两位 @PommesPeter @adrianJW421

我们结合你们的意见修改了下ds_cache_dir这个参数的处理逻辑,用户显式指定这个参数时才会让其优先级高于环境变量,否则沿用环境变量的路径,这样相对更合理一些,参考PR #43

欢迎提出更多宝贵的建议~

@HYLcool HYLcool linked a pull request Oct 25, 2023 that will close this issue
@PommesPeter
Copy link
Author

PommesPeter commented Oct 25, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants