Skip to content

try to use deepseek with an agent to auto i18n to zh #12032

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

SamYuan1990
Copy link

What does this PR do?

Fixes # (issue)
Support some document i18n with DeepSeek in an agent.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
    yep.

  • Did you read the contributor guideline?
    I don't have access to discord, so I contracted someone offline for this attempt.

  • Did you read our philosophy doc (important for complex PRs)?

  • Was this discussed/approved via a GitHub issue or the forum? Please add a link to it if that's the case.

  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.

  • Did you write any new necessary tests?
    n/A?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

Signed-off-by: SamYuan1990 <yy19902439@126.com>
Signed-off-by: SamYuan1990 <yy19902439@126.com>
Signed-off-by: SamYuan1990 <yy19902439@126.com>
@yiyixuxu yiyixuxu requested a review from stevhliu August 4, 2025 02:29
Signed-off-by: SamYuan1990 <yy19902439@126.com>
@stevhliu
Copy link
Member

stevhliu commented Aug 4, 2025

Thanks! I don't have an issue with an AI translation, but if you don't mind, can you also read and verify the accuracy of the translation to make sure it makes sense please 🤗

A few other things of note:

  • Update the corresponding titles in the toctree with the translated title
  • Certain elements in the docs like, [[open-in-colab]], don't need to be translated because its part of the doc-builder syntax

@SamYuan1990
Copy link
Author

Thanks! I don't have an issue with an AI translation, but if you don't mind, can you also read and verify the accuracy of the translation to make sure it makes sense please 🤗

A few other things of note:

  • Update the corresponding titles in the toctree with the translated title
  • Certain elements in the docs like, [[open-in-colab]], don't need to be translated because its part of the doc-builder syntax

Hi @stevhliu , may I know where can I find all doc-builder syntax? and sure after go through the docs with a basic check I will make this PR ready for review.

@SamYuan1990
Copy link
Author

I hope I am right as
https://github.com/huggingface/diffusers/blob/main/docs/README.md#generating-the-documentation

I can use doc-builder for preview and make style for local linting?

and ... it seems [[xxx]] as either [[open-in-colab]] or [[autodoc]] are doc-builder syntax?

Signed-off-by: SamYuan1990 <yy19902439@126.com>
@SamYuan1990 SamYuan1990 marked this pull request as ready for review August 5, 2025 07:36
@SamYuan1990
Copy link
Author

Hi @stevhliu ,

I go through the docs with vs code, and... [[open-in-colab]] seems not a markdown or html format. May I know what's that?
So I made some fix and make the PR to ready for review.

BTW, I followed instruct as https://github.com/huggingface/diffusers/blob/main/docs/README.md#generating-the-documentation and...
it seems make style script or doc-builder missing some dependency here is my local error msg FYI.

(.venv) yuanyi@yuanyideMacBook-Pro diffusers % make style
ruff check examples scripts src tests utils benchmarks setup.py --fix
Found 1 error (1 fixed, 0 remaining).
ruff format examples scripts src tests utils benchmarks setup.py
1467 files left unchanged
doc-builder style src/diffusers docs/source --max_len 119
/Applications/Xcode.app/Contents/Developer/usr/bin/make autogenerate_code
Traceback (most recent call last):
  File "/Users/yuanyi/OpenSource/diffusers/setup.py", line 91, in <module>
    from setuptools import Command, find_packages, setup
ModuleNotFoundError: No module named 'setuptools'
make[1]: *** [deps_table_update] Error 1
make: *** [style] Error 2

and btw, for doc-builder , I meet error as I have to install pytorch?

(.venv) yuanyi@yuanyideMacBook-Pro diffusers % doc-builder preview diffusers docs/source/zh
Initial build docs for diffusers docs/source/zh /var/folders/gc/1zj1qyzj5sl03hvzmccb_bs00000gn/T/tmpy3qasypu/diffusers/main/en
Building the MDX files: 100%|████████████████████████████████████████████████████████████████| 24/24 [00:00<00:00, 640.96it/s]
Resolving internal links:  11%|██████▋                                                        | 2/19 [00:00<00:00, 654.49it/s]
Traceback (most recent call last):
  File "/Users/yuanyi/OpenSource/diffusers/.venv/bin/doc-builder", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/Users/yuanyi/OpenSource/diffusers/.venv/lib/python3.13/site-packages/doc_builder/commands/doc_builder_cli.py", line 47, in main
    args.func(args)
    ~~~~~~~~~^^^^^^
  File "/Users/yuanyi/OpenSource/diffusers/.venv/lib/python3.13/site-packages/doc_builder/commands/preview.py", line 174, in preview_command
    source_files_mapping = build_doc(
        args.library_name,
    ...<5 lines>...
        is_python_module=not args.not_python_module,
    )
  File "/Users/yuanyi/OpenSource/diffusers/.venv/lib/python3.13/site-packages/doc_builder/build_doc.py", line 374, in build_doc
    resolve_links(output_dir, package, anchors_mapping, page_info)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/yuanyi/OpenSource/diffusers/.venv/lib/python3.13/site-packages/doc_builder/build_doc.py", line 267, in resolve_links
    content = resolve_links_in_text(content, package, mapping, page_info)
  File "/Users/yuanyi/OpenSource/diffusers/.venv/lib/python3.13/site-packages/doc_builder/autodoc.py", line 587, in resolve_links_in_text
    return re.sub(r"\[`([^`]+)`\]([^\(])", _resolve_link, text)
           ~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/re/__init__.py", line 208, in sub
    return _compile(pattern, flags).sub(repl, string, count)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "/Users/yuanyi/OpenSource/diffusers/.venv/lib/python3.13/site-packages/doc_builder/autodoc.py", line 560, in _resolve_link
    obj = find_object_in_package(object_or_param_name[1:], package)
  File "/Users/yuanyi/OpenSource/diffusers/.venv/lib/python3.13/site-packages/doc_builder/autodoc.py", line 39, in find_object_in_package
    submodule = getattr(module, split, None)
  File "/Users/yuanyi/OpenSource/diffusers/src/diffusers/utils/import_utils.py", line 635, in __getattr__
    requires_backends(cls, cls._backends)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "/Users/yuanyi/OpenSource/diffusers/src/diffusers/utils/import_utils.py", line 603, in requires_backends
    raise ImportError("".join(failed))
ImportError: 
DiffusionPipeline requires the PyTorch library but it was not found in your environment. Checkout the instructions on the
installation page: https://pytorch.org/get-started/locally/ and follow the ones that match your environment.

@stevhliu
Copy link
Member

stevhliu commented Aug 5, 2025

may I know where can I find all doc-builder syntax

You can find the syntax on the doc-builder repo. For example, [[open-in-colab]] adds a button that opens a docs page in a Colab notebook so users can run it.

I can use doc-builder for preview and make style for local linting?

Yeah, looks like you may be missing PyTorch in your env. Can you try installing it and re-running the command?

@SamYuan1990
Copy link
Author

may I know where can I find all doc-builder syntax

You can find the syntax on the doc-builder repo. For example, [[open-in-colab]] adds a button that opens a docs page in a Colab notebook so users can run it.

I can use doc-builder for preview and make style for local linting?

Yeah, looks like you may be missing PyTorch in your env. Can you try installing it and re-running the command?

Hi @stevhliu

do we have a glossary? but not rules one by one... the rules one by one requires new joiner as me having knowledge base as markdown, html, Framework Content? LaTeX? see LaTeX and markdown is language, and seems tips and others are glossary.

here are my reproduce steps:

pip install -e ".[docs]" >> ./recording.md
pip install git+ssh://git@github.com/huggingface/doc-builder.git >> ./recording.md

pip install watchdog >> ./recording.md
doc-builder preview diffusers docs/source/zh >> ./recording.md

and yes...

Initial build docs for diffusers docs/source/zh /var/folders/gc/1zj1qyzj5sl03hvzmccb_bs00000gn/T/tmp8hqw4wje/diffusers/main/en
Building the MDX files: 100%|█████████████████████████████████████████████████████| 24/24 [00:00<00:00, 637.42it/s]
Resolving internal links:  11%|█████▍                                              | 2/19 [00:00<00:00, 556.98it/s]
Traceback (most recent call last):
  File "/Users/yuanyi/OpenSource/diffusers/.test/bin/doc-builder", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/Users/yuanyi/OpenSource/diffusers/.test/lib/python3.13/site-packages/doc_builder/commands/doc_builder_cli.py", line 49, in main
    args.func(args)
    ~~~~~~~~~^^^^^^
  File "/Users/yuanyi/OpenSource/diffusers/.test/lib/python3.13/site-packages/doc_builder/commands/preview.py", line 175, in preview_command
    source_files_mapping = build_doc(
        args.library_name,
    ...<5 lines>...
        is_python_module=not args.not_python_module,
    )
  File "/Users/yuanyi/OpenSource/diffusers/.test/lib/python3.13/site-packages/doc_builder/build_doc.py", line 377, in build_doc
    resolve_links(output_dir, package, anchors_mapping, page_info)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/yuanyi/OpenSource/diffusers/.test/lib/python3.13/site-packages/doc_builder/build_doc.py", line 269, in resolve_links
    content = resolve_links_in_text(content, package, mapping, page_info)
  File "/Users/yuanyi/OpenSource/diffusers/.test/lib/python3.13/site-packages/doc_builder/autodoc.py", line 769, in resolve_links_in_text
    return re.sub(r"\[`([^`]+)`\]([^\(])", _resolve_link, text)
           ~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/re/__init__.py", line 208, in sub
    return _compile(pattern, flags).sub(repl, string, count)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "/Users/yuanyi/OpenSource/diffusers/.test/lib/python3.13/site-packages/doc_builder/autodoc.py", line 742, in _resolve_link
    obj = find_object_in_package(object_or_param_name[1:], package)
  File "/Users/yuanyi/OpenSource/diffusers/.test/lib/python3.13/site-packages/doc_builder/autodoc.py", line 40, in find_object_in_package
    submodule = getattr(module, split, None)
  File "/Users/yuanyi/OpenSource/diffusers/src/diffusers/utils/import_utils.py", line 635, in __getattr__
    requires_backends(cls, cls._backends)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "/Users/yuanyi/OpenSource/diffusers/src/diffusers/utils/import_utils.py", line 603, in requires_backends
    raise ImportError("".join(failed))
ImportError: 
DiffusionPipeline requires the PyTorch library but it was not found in your environment. Checkout the instructions on the
installation page: https://pytorch.org/get-started/locally/ and follow the ones that match your environment.

@SamYuan1990
Copy link
Author

@stevhliu in function resolve_links_in_text it will dynamic load a python code which needs ....

but it breaks in the middle when dynamic compile

<class 'diffusers.configuration_utils.ConfigMixin'>
from_config
<module 'diffusers' from '/Users/yuanyi/OpenSource/diffusers/src/diffusers/__init__.py'>
DiffusionPipeline
<class 'diffusers.utils.dummy_pt_objects.DiffusionPipeline'>
enable_attention_slicing

with function find_object_in_package

@SamYuan1990
Copy link
Author

@stevhliu additional information.
after I switch to python 3.12, well in python 3.12 I can have torch installed. but the document build still blocked by error msg and dynamic lib checking...

RuntimeError: Failed to import diffusers.pipelines.pipeline_utils because of the following error (look up to see its traceback):
Failed to import diffusers.models.autoencoders.autoencoder_kl because of the following error (look up to see its traceback):
module 'torch.library' has no attribute 'custom_op'

as a document parts, why do we need dynamic library checking?
let's say as code as document or as user can get the code from opensource as github repo.
so... the logic check is just show me the code, hence in document phase, which should ... decouple from a full build isn't it?

@SamYuan1990
Copy link
Author

SamYuan1990 commented Aug 6, 2025

@stevhliu , I opened another issue for how to compile the build. as huggingface/doc-builder#613
is there any container way to help me with preview? or I have to struggle with full build with project for document change?

I traced code try to run container version, but... huggingface/doc-builder#614 which seems the container is not been used in document build. (sad face)

@SamYuan1990
Copy link
Author

I tried today... but no further progress. @stevhliu , waiting for your feedback and further comments.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@stevhliu
Copy link
Member

stevhliu commented Aug 7, 2025

do we have a glossary?

There's not a glossary, but feel free to open a PR to turn it into one if that helps!

As for the other issues, I'm not exactly sure what the problem is 😅 . But you can preview the docs here

@SamYuan1990
Copy link
Author

do we have a glossary?

There's not a glossary, but feel free to open a PR to turn it into one if that helps!

As for the other issues, I'm not exactly sure what the problem is 😅 . But you can preview the docs here

The reason is
https://github.com/huggingface/diffusers/tree/main/docs
the document here miss match with how kit in doc-builder works https://github.com/huggingface/doc-builder/blob/main/kit/package.json#L9
as doc build use vite which default port is 5173 but not 3000 which is easy for understand.

Signed-off-by: SamYuan1990 <yy19902439@126.com>
@SamYuan1990
Copy link
Author

do we have a glossary?

There's not a glossary, but feel free to open a PR to turn it into one if that helps!
As for the other issues, I'm not exactly sure what the problem is 😅 . But you can preview the docs here

The reason is https://github.com/huggingface/diffusers/tree/main/docs the document here miss match with how kit in doc-builder works https://github.com/huggingface/doc-builder/blob/main/kit/package.json#L9 as doc build use vite which default port is 5173 but not 3000 which is easy for understand.

and @stevhliu , what make the thing worse.

as I can't access moon-ci-docs.huggingface.co due to GFW, so I have to relay on local preview to check the content. Lucky in PR build, I can have the html content.
But... here we can see with example as [~ModelMixin.compile_repeated_blocks] this tag, the compile logic is no same between zh and en version and I don't know why.

2f45bb7494c62d13a8cbf33b63be9d3c

I tried my best to compile it on my local but ... it doesn't work. I found one issue and I fixed in today's PR.
please help review the content, and I will just check follow actions as PR review comments in this PR, as I can't preview the change.

Copy link
Member

@stevhliu stevhliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But... here we can see with example as [~ModelMixin.compile_repeated_blocks] this tag, the compile logic is no same between zh and en version and I don't know why.

It's because the API docs for compile_repeated_blocks doesn't exist in the Chinese version it just gets rendered in plain code format instead of a link to the API docs as in the English version.

The docs LGTM structurally. One thing to note is can you align the toctree with the English one? I also can't review the translated content since I don't read Chinese. If they look good to you, then I'm happy to merge!

Signed-off-by: SamYuan1990 <yy19902439@126.com>
@SamYuan1990
Copy link
Author

But... here we can see with example as [~ModelMixin.compile_repeated_blocks] this tag, the compile logic is no same between zh and en version and I don't know why.

It's because the API docs for compile_repeated_blocks doesn't exist in the Chinese version it just gets rendered in plain code format instead of a link to the API docs as in the English version.

The docs LGTM structurally. One thing to note is can you align the toctree with the English one? I also can't review the translated content since I don't read Chinese. If they look good to you, then I'm happy to merge!

I just make a fix to adjust toctree, please advise and let's move.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants