"git@developer.sourcefind.cn:wuxk1/megatron-lm.git" did not exist on "0ceeb3b4d94e1249aa300b8c4cae21abcab8b5a8"
Unverified Commit 8f6373c6 authored by Sylvain Gugger's avatar Sylvain Gugger Committed by GitHub
Browse files

Map model_type and doc pages names (#14944)



* Map model_type and doc pages names

* Add script

* Fix typo

* Quality

* Manual check for Auto
Co-authored-by: default avatarLysandre <lysandre.debut@reseau.eseo.fr>
parent e68c3756
......@@ -48,7 +48,7 @@ Tips:
on both printed (e.g. the [SROIE dataset](https://paperswithcode.com/dataset/sroie) and handwritten (e.g. the [IAM
Handwriting dataset](https://fki.tic.heia-fr.ch/databases/iam-handwriting-database>) text recognition tasks. For more
information, see the [official models](https://huggingface.co/models?other=trocr>).
- TrOCR is always used within the [VisionEncoderDecoder](./model_doc/visionencoderdecoder) framework.
- TrOCR is always used within the [VisionEncoderDecoder](vision-encoder-decoder) framework.
## Inference
......
......@@ -66,7 +66,7 @@ that at each position, the model can only look at the tokens before the attentio
<a href="https://huggingface.co/models?filter=openai-gpt">
<img alt="Models" src="https://img.shields.io/badge/All_model_pages-openai--gpt-blueviolet">
</a>
<a href="model_doc/gpt">
<a href="model_doc/openai-gpt">
<img alt="Doc" src="https://img.shields.io/badge/Model_documentation-openai--gpt-blueviolet">
</a>
......@@ -118,7 +118,7 @@ The library provides a version of the model for language modeling only.
<a href="https://huggingface.co/models?filter=transfo-xl">
<img alt="Models" src="https://img.shields.io/badge/All_model_pages-transfo--xl-blueviolet">
</a>
<a href="model_doc/transformerxl">
<a href="model_doc/transfo-xl">
<img alt="Doc" src="https://img.shields.io/badge/Model_documentation-transfo--xl-blueviolet">
</a>
......@@ -367,7 +367,7 @@ question answering.
<a href="https://huggingface.co/models?filter=xlm-roberta">
<img alt="Models" src="https://img.shields.io/badge/All_model_pages-xlm--roberta-blueviolet">
</a>
<a href="model_doc/xlmroberta">
<a href="model_doc/xlm-roberta">
<img alt="Doc" src="https://img.shields.io/badge/Model_documentation-xlm--roberta-blueviolet">
</a>
......@@ -649,7 +649,7 @@ summarization.
<a href="https://huggingface.co/models?filter=xprophetnet">
<img alt="Models" src="https://img.shields.io/badge/All_model_pages-xprophetnet-blueviolet">
</a>
<a href="model_doc/xlmprophetnet">
<a href="model_doc/xlm-prophetnet">
<img alt="Doc" src="https://img.shields.io/badge/Model_documentation-xprophetnet-blueviolet">
</a>
......
......@@ -279,6 +279,16 @@ MODEL_NAMES_MAPPING = OrderedDict(
("unispeech-sat", "UniSpeechSat"),
("unispeech", "UniSpeech"),
("wavlm", "WavLM"),
("bort", "BORT"),
("dialogpt", "DialoGPT"),
("xls_r", "XLS-R"),
("t5v1.1", "T5v1.1"),
("herbert", "HerBERT"),
("wav2vec2_phoneme", "Wav2Vec2Phoneme"),
("megatron_gpt2", "MegatronGPT2"),
("xlsr_wav2vec2", "XLSR-Wav2Vec2"),
("mluke", "mLUKE"),
("layoutxlm", "LayoutXLM"),
]
)
......
......@@ -18,6 +18,7 @@ import inspect
import os
import re
import warnings
from difflib import get_close_matches
from pathlib import Path
from transformers import is_flax_available, is_tf_available, is_torch_available
......@@ -596,6 +597,33 @@ def check_all_objects_are_documented():
+ "\n - ".join(undocumented_objs)
)
check_docstrings_are_in_md()
check_model_type_doc_match()
def check_model_type_doc_match():
"""Check all doc pages have a corresponding model type."""
model_doc_folder = Path(PATH_TO_DOC) / "model_doc"
model_docs = [m.stem for m in model_doc_folder.glob("*.mdx")]
model_types = list(transformers.models.auto.configuration_auto.MODEL_NAMES_MAPPING.keys())
errors = []
for m in model_docs:
if m not in model_types and m != "auto":
close_matches = get_close_matches(m, model_types)
error_message = f"{m} is not a proper model identifier."
if len(close_matches) > 0:
close_matches = "/".join(close_matches)
error_message += f" Did you mean {close_matches}?"
errors.append(error_message)
if len(errors) > 0:
raise ValueError(
"Some model doc pages do not match any existing model type:\n"
+ "\n".join(errors)
+ "\nYou can add any missing model type to the `MODEL_NAMES_MAPPING` constant in "
"models/auto/configuration_auto.py."
)
# Re pattern to catch :obj:`xx`, :class:`xx`, :func:`xx` or :meth:`xx`.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment