Compare commits
17 Commits
main
...
v4.37-rele
Author | SHA1 | Date |
---|---|---|
Amy Roberts | 345b9b1a6a | |
amyeroberts | ea5ca81cf9 | |
Yih-Dar | 711bed1f43 | |
Lysandre Debut | 56ee444d2a | |
Yih-Dar | 8d8fdb5202 | |
jeffhataws | e3934198a3 | |
Zach Mueller | 3001543b94 | |
amyeroberts | b94f5fdd7e | |
Amy Roberts | d02d006cf3 | |
amyeroberts | b102ab26c7 | |
Arthur | 8e3e145b42 | |
Ofir Zafrir | 344943b88a | |
NielsRogge | 5fc3e60cd8 | |
Fanli Lin | 5ee9fcb5cc | |
Patrick von Platen | e156abd05a | |
Yoach Lacombe | a485e469f6 | |
Amy Roberts | d381d85466 |
|
@ -458,7 +458,7 @@ Current number of checkpoints: ![](https://img.shields.io/endpoint?url=https://h
|
|||
1. **[ProphetNet](https://huggingface.co/docs/transformers/model_doc/prophetnet)** (from Microsoft Research) released with the paper [ProphetNet: Predicting Future N-gram for Sequence-to-Sequence Pre-training](https://arxiv.org/abs/2001.04063) by Yu Yan, Weizhen Qi, Yeyun Gong, Dayiheng Liu, Nan Duan, Jiusheng Chen, Ruofei Zhang and Ming Zhou.
|
||||
1. **[PVT](https://huggingface.co/docs/transformers/model_doc/pvt)** (from Nanjing University, The University of Hong Kong etc.) released with the paper [Pyramid Vision Transformer: A Versatile Backbone for Dense Prediction without Convolutions](https://arxiv.org/pdf/2102.12122.pdf) by Wenhai Wang, Enze Xie, Xiang Li, Deng-Ping Fan, Kaitao Song, Ding Liang, Tong Lu, Ping Luo, Ling Shao.
|
||||
1. **[QDQBert](https://huggingface.co/docs/transformers/model_doc/qdqbert)** (from NVIDIA) released with the paper [Integer Quantization for Deep Learning Inference: Principles and Empirical Evaluation](https://arxiv.org/abs/2004.09602) by Hao Wu, Patrick Judd, Xiaojie Zhang, Mikhail Isaev and Paulius Micikevicius.
|
||||
1. **[Qwen2](https://huggingface.co/docs/transformers/main/model_doc/qwen2)** (from the Qwen team, Alibaba Group) released with the paper [Qwen Technical Report](https://arxiv.org/abs/2309.16609) by Jinze Bai, Shuai Bai, Yunfei Chu, Zeyu Cui, Kai Dang, Xiaodong Deng, Yang Fan, Wenbin Ge, Yu Han, Fei Huang, Binyuan Hui, Luo Ji, Mei Li, Junyang Lin, Runji Lin, Dayiheng Liu, Gao Liu, Chengqiang Lu, Keming Lu, Jianxin Ma, Rui Men, Xingzhang Ren, Xuancheng Ren, Chuanqi Tan, Sinan Tan, Jianhong Tu, Peng Wang, Shijie Wang, Wei Wang, Shengguang Wu, Benfeng Xu, Jin Xu, An Yang, Hao Yang, Jian Yang, Shusheng Yang, Yang Yao, Bowen Yu, Hongyi Yuan, Zheng Yuan, Jianwei Zhang, Xingxuan Zhang, Yichang Zhang, Zhenru Zhang, Chang Zhou, Jingren Zhou, Xiaohuan Zhou and Tianhang Zhu.
|
||||
1. **[Qwen2](https://huggingface.co/docs/transformers/model_doc/qwen2)** (from the Qwen team, Alibaba Group) released with the paper [Qwen Technical Report](https://arxiv.org/abs/2309.16609) by Jinze Bai, Shuai Bai, Yunfei Chu, Zeyu Cui, Kai Dang, Xiaodong Deng, Yang Fan, Wenbin Ge, Yu Han, Fei Huang, Binyuan Hui, Luo Ji, Mei Li, Junyang Lin, Runji Lin, Dayiheng Liu, Gao Liu, Chengqiang Lu, Keming Lu, Jianxin Ma, Rui Men, Xingzhang Ren, Xuancheng Ren, Chuanqi Tan, Sinan Tan, Jianhong Tu, Peng Wang, Shijie Wang, Wei Wang, Shengguang Wu, Benfeng Xu, Jin Xu, An Yang, Hao Yang, Jian Yang, Shusheng Yang, Yang Yao, Bowen Yu, Hongyi Yuan, Zheng Yuan, Jianwei Zhang, Xingxuan Zhang, Yichang Zhang, Zhenru Zhang, Chang Zhou, Jingren Zhou, Xiaohuan Zhou and Tianhang Zhu.
|
||||
1. **[RAG](https://huggingface.co/docs/transformers/model_doc/rag)** (from Facebook) released with the paper [Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks](https://arxiv.org/abs/2005.11401) by Patrick Lewis, Ethan Perez, Aleksandara Piktus, Fabio Petroni, Vladimir Karpukhin, Naman Goyal, Heinrich Küttler, Mike Lewis, Wen-tau Yih, Tim Rocktäschel, Sebastian Riedel, Douwe Kiela.
|
||||
1. **[REALM](https://huggingface.co/docs/transformers/model_doc/realm.html)** (from Google Research) released with the paper [REALM: Retrieval-Augmented Language Model Pre-Training](https://arxiv.org/abs/2002.08909) by Kelvin Guu, Kenton Lee, Zora Tung, Panupong Pasupat and Ming-Wei Chang.
|
||||
1. **[Reformer](https://huggingface.co/docs/transformers/model_doc/reformer)** (from Google Research) released with the paper [Reformer: The Efficient Transformer](https://arxiv.org/abs/2001.04451) by Nikita Kitaev, Łukasz Kaiser, Anselm Levskaya.
|
||||
|
@ -476,7 +476,7 @@ Current number of checkpoints: ![](https://img.shields.io/endpoint?url=https://h
|
|||
1. **[Segment Anything](https://huggingface.co/docs/transformers/model_doc/sam)** (from Meta AI) released with the paper [Segment Anything](https://arxiv.org/pdf/2304.02643v1.pdf) by Alexander Kirillov, Eric Mintun, Nikhila Ravi, Hanzi Mao, Chloe Rolland, Laura Gustafson, Tete Xiao, Spencer Whitehead, Alex Berg, Wan-Yen Lo, Piotr Dollar, Ross Girshick.
|
||||
1. **[SEW](https://huggingface.co/docs/transformers/model_doc/sew)** (from ASAPP) released with the paper [Performance-Efficiency Trade-offs in Unsupervised Pre-training for Speech Recognition](https://arxiv.org/abs/2109.06870) by Felix Wu, Kwangyoun Kim, Jing Pan, Kyu Han, Kilian Q. Weinberger, Yoav Artzi.
|
||||
1. **[SEW-D](https://huggingface.co/docs/transformers/model_doc/sew_d)** (from ASAPP) released with the paper [Performance-Efficiency Trade-offs in Unsupervised Pre-training for Speech Recognition](https://arxiv.org/abs/2109.06870) by Felix Wu, Kwangyoun Kim, Jing Pan, Kyu Han, Kilian Q. Weinberger, Yoav Artzi.
|
||||
1. **[SigLIP](https://huggingface.co/docs/transformers/main/model_doc/siglip)** (from Google AI) released with the paper [Sigmoid Loss for Language Image Pre-Training](https://arxiv.org/abs/2303.15343) by Xiaohua Zhai, Basil Mustafa, Alexander Kolesnikov, Lucas Beyer.
|
||||
1. **[SigLIP](https://huggingface.co/docs/transformers/model_doc/siglip)** (from Google AI) released with the paper [Sigmoid Loss for Language Image Pre-Training](https://arxiv.org/abs/2303.15343) by Xiaohua Zhai, Basil Mustafa, Alexander Kolesnikov, Lucas Beyer.
|
||||
1. **[SpeechT5](https://huggingface.co/docs/transformers/model_doc/speecht5)** (from Microsoft Research) released with the paper [SpeechT5: Unified-Modal Encoder-Decoder Pre-Training for Spoken Language Processing](https://arxiv.org/abs/2110.07205) by Junyi Ao, Rui Wang, Long Zhou, Chengyi Wang, Shuo Ren, Yu Wu, Shujie Liu, Tom Ko, Qing Li, Yu Zhang, Zhihua Wei, Yao Qian, Jinyu Li, Furu Wei.
|
||||
1. **[SpeechToTextTransformer](https://huggingface.co/docs/transformers/model_doc/speech_to_text)** (from Facebook), released together with the paper [fairseq S2T: Fast Speech-to-Text Modeling with fairseq](https://arxiv.org/abs/2010.05171) by Changhan Wang, Yun Tang, Xutai Ma, Anne Wu, Dmytro Okhonko, Juan Pino.
|
||||
1. **[SpeechToTextTransformer2](https://huggingface.co/docs/transformers/model_doc/speech_to_text_2)** (from Facebook), released together with the paper [Large-Scale Self- and Semi-Supervised Learning for Speech Translation](https://arxiv.org/abs/2104.06678) by Changhan Wang, Anne Wu, Juan Pino, Alexei Baevski, Michael Auli, Alexis Conneau.
|
||||
|
@ -519,7 +519,7 @@ Current number of checkpoints: ![](https://img.shields.io/endpoint?url=https://h
|
|||
1. **[VITS](https://huggingface.co/docs/transformers/model_doc/vits)** (from Kakao Enterprise) released with the paper [Conditional Variational Autoencoder with Adversarial Learning for End-to-End Text-to-Speech](https://arxiv.org/abs/2106.06103) by Jaehyeon Kim, Jungil Kong, Juhee Son.
|
||||
1. **[ViViT](https://huggingface.co/docs/transformers/model_doc/vivit)** (from Google Research) released with the paper [ViViT: A Video Vision Transformer](https://arxiv.org/abs/2103.15691) by Anurag Arnab, Mostafa Dehghani, Georg Heigold, Chen Sun, Mario Lučić, Cordelia Schmid.
|
||||
1. **[Wav2Vec2](https://huggingface.co/docs/transformers/model_doc/wav2vec2)** (from Facebook AI) released with the paper [wav2vec 2.0: A Framework for Self-Supervised Learning of Speech Representations](https://arxiv.org/abs/2006.11477) by Alexei Baevski, Henry Zhou, Abdelrahman Mohamed, Michael Auli.
|
||||
1. **[Wav2Vec2-BERT](https://huggingface.co/docs/transformers/main/model_doc/wav2vec2-bert)** (from Meta AI) released with the paper [Seamless: Multilingual Expressive and Streaming Speech Translation](https://ai.meta.com/research/publications/seamless-multilingual-expressive-and-streaming-speech-translation/) by the Seamless Communication team.
|
||||
1. **[Wav2Vec2-BERT](https://huggingface.co/docs/transformers/model_doc/wav2vec2-bert)** (from Meta AI) released with the paper [Seamless: Multilingual Expressive and Streaming Speech Translation](https://ai.meta.com/research/publications/seamless-multilingual-expressive-and-streaming-speech-translation/) by the Seamless Communication team.
|
||||
1. **[Wav2Vec2-Conformer](https://huggingface.co/docs/transformers/model_doc/wav2vec2-conformer)** (from Facebook AI) released with the paper [FAIRSEQ S2T: Fast Speech-to-Text Modeling with FAIRSEQ](https://arxiv.org/abs/2010.05171) by Changhan Wang, Yun Tang, Xutai Ma, Anne Wu, Sravya Popuri, Dmytro Okhonko, Juan Pino.
|
||||
1. **[Wav2Vec2Phoneme](https://huggingface.co/docs/transformers/model_doc/wav2vec2_phoneme)** (from Facebook AI) released with the paper [Simple and Effective Zero-shot Cross-lingual Phoneme Recognition](https://arxiv.org/abs/2109.11680) by Qiantong Xu, Alexei Baevski, Michael Auli.
|
||||
1. **[WavLM](https://huggingface.co/docs/transformers/model_doc/wavlm)** (from Microsoft Research) released with the paper [WavLM: Large-Scale Self-Supervised Pre-Training for Full Stack Speech Processing](https://arxiv.org/abs/2110.13900) by Sanyuan Chen, Chengyi Wang, Zhengyang Chen, Yu Wu, Shujie Liu, Zhuo Chen, Jinyu Li, Naoyuki Kanda, Takuya Yoshioka, Xiong Xiao, Jian Wu, Long Zhou, Shuo Ren, Yanmin Qian, Yao Qian, Jian Wu, Michael Zeng, Furu Wei.
|
||||
|
|
|
@ -433,7 +433,7 @@ Número actual de puntos de control: ![](https://img.shields.io/endpoint?url=htt
|
|||
1. **[ProphetNet](https://huggingface.co/docs/transformers/model_doc/prophetnet)** (from Microsoft Research) released with the paper [ProphetNet: Predicting Future N-gram for Sequence-to-Sequence Pre-training](https://arxiv.org/abs/2001.04063) by Yu Yan, Weizhen Qi, Yeyun Gong, Dayiheng Liu, Nan Duan, Jiusheng Chen, Ruofei Zhang and Ming Zhou.
|
||||
1. **[PVT](https://huggingface.co/docs/transformers/model_doc/pvt)** (from Nanjing University, The University of Hong Kong etc.) released with the paper [Pyramid Vision Transformer: A Versatile Backbone for Dense Prediction without Convolutions](https://arxiv.org/pdf/2102.12122.pdf) by Wenhai Wang, Enze Xie, Xiang Li, Deng-Ping Fan, Kaitao Song, Ding Liang, Tong Lu, Ping Luo, Ling Shao.
|
||||
1. **[QDQBert](https://huggingface.co/docs/transformers/model_doc/qdqbert)** (from NVIDIA) released with the paper [Integer Quantization for Deep Learning Inference: Principles and Empirical Evaluation](https://arxiv.org/abs/2004.09602) by Hao Wu, Patrick Judd, Xiaojie Zhang, Mikhail Isaev and Paulius Micikevicius.
|
||||
1. **[Qwen2](https://huggingface.co/docs/transformers/main/model_doc/qwen2)** (from the Qwen team, Alibaba Group) released with the paper [Qwen Technical Report](https://arxiv.org/abs/2309.16609) by Jinze Bai, Shuai Bai, Yunfei Chu, Zeyu Cui, Kai Dang, Xiaodong Deng, Yang Fan, Wenbin Ge, Yu Han, Fei Huang, Binyuan Hui, Luo Ji, Mei Li, Junyang Lin, Runji Lin, Dayiheng Liu, Gao Liu, Chengqiang Lu, Keming Lu, Jianxin Ma, Rui Men, Xingzhang Ren, Xuancheng Ren, Chuanqi Tan, Sinan Tan, Jianhong Tu, Peng Wang, Shijie Wang, Wei Wang, Shengguang Wu, Benfeng Xu, Jin Xu, An Yang, Hao Yang, Jian Yang, Shusheng Yang, Yang Yao, Bowen Yu, Hongyi Yuan, Zheng Yuan, Jianwei Zhang, Xingxuan Zhang, Yichang Zhang, Zhenru Zhang, Chang Zhou, Jingren Zhou, Xiaohuan Zhou and Tianhang Zhu.
|
||||
1. **[Qwen2](https://huggingface.co/docs/transformers/model_doc/qwen2)** (from the Qwen team, Alibaba Group) released with the paper [Qwen Technical Report](https://arxiv.org/abs/2309.16609) by Jinze Bai, Shuai Bai, Yunfei Chu, Zeyu Cui, Kai Dang, Xiaodong Deng, Yang Fan, Wenbin Ge, Yu Han, Fei Huang, Binyuan Hui, Luo Ji, Mei Li, Junyang Lin, Runji Lin, Dayiheng Liu, Gao Liu, Chengqiang Lu, Keming Lu, Jianxin Ma, Rui Men, Xingzhang Ren, Xuancheng Ren, Chuanqi Tan, Sinan Tan, Jianhong Tu, Peng Wang, Shijie Wang, Wei Wang, Shengguang Wu, Benfeng Xu, Jin Xu, An Yang, Hao Yang, Jian Yang, Shusheng Yang, Yang Yao, Bowen Yu, Hongyi Yuan, Zheng Yuan, Jianwei Zhang, Xingxuan Zhang, Yichang Zhang, Zhenru Zhang, Chang Zhou, Jingren Zhou, Xiaohuan Zhou and Tianhang Zhu.
|
||||
1. **[RAG](https://huggingface.co/docs/transformers/model_doc/rag)** (from Facebook) released with the paper [Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks](https://arxiv.org/abs/2005.11401) by Patrick Lewis, Ethan Perez, Aleksandara Piktus, Fabio Petroni, Vladimir Karpukhin, Naman Goyal, Heinrich Küttler, Mike Lewis, Wen-tau Yih, Tim Rocktäschel, Sebastian Riedel, Douwe Kiela.
|
||||
1. **[REALM](https://huggingface.co/docs/transformers/model_doc/realm.html)** (from Google Research) released with the paper [REALM: Retrieval-Augmented Language Model Pre-Training](https://arxiv.org/abs/2002.08909) by Kelvin Guu, Kenton Lee, Zora Tung, Panupong Pasupat and Ming-Wei Chang.
|
||||
1. **[Reformer](https://huggingface.co/docs/transformers/model_doc/reformer)** (from Google Research) released with the paper [Reformer: The Efficient Transformer](https://arxiv.org/abs/2001.04451) by Nikita Kitaev, Łukasz Kaiser, Anselm Levskaya.
|
||||
|
@ -451,7 +451,7 @@ Número actual de puntos de control: ![](https://img.shields.io/endpoint?url=htt
|
|||
1. **[Segment Anything](https://huggingface.co/docs/transformers/model_doc/sam)** (from Meta AI) released with the paper [Segment Anything](https://arxiv.org/pdf/2304.02643v1.pdf) by Alexander Kirillov, Eric Mintun, Nikhila Ravi, Hanzi Mao, Chloe Rolland, Laura Gustafson, Tete Xiao, Spencer Whitehead, Alex Berg, Wan-Yen Lo, Piotr Dollar, Ross Girshick.
|
||||
1. **[SEW](https://huggingface.co/docs/transformers/model_doc/sew)** (from ASAPP) released with the paper [Performance-Efficiency Trade-offs in Unsupervised Pre-training for Speech Recognition](https://arxiv.org/abs/2109.06870) by Felix Wu, Kwangyoun Kim, Jing Pan, Kyu Han, Kilian Q. Weinberger, Yoav Artzi.
|
||||
1. **[SEW-D](https://huggingface.co/docs/transformers/model_doc/sew_d)** (from ASAPP) released with the paper [Performance-Efficiency Trade-offs in Unsupervised Pre-training for Speech Recognition](https://arxiv.org/abs/2109.06870) by Felix Wu, Kwangyoun Kim, Jing Pan, Kyu Han, Kilian Q. Weinberger, Yoav Artzi.
|
||||
1. **[SigLIP](https://huggingface.co/docs/transformers/main/model_doc/siglip)** (from Google AI) released with the paper [Sigmoid Loss for Language Image Pre-Training](https://arxiv.org/abs/2303.15343) by Xiaohua Zhai, Basil Mustafa, Alexander Kolesnikov, Lucas Beyer.
|
||||
1. **[SigLIP](https://huggingface.co/docs/transformers/model_doc/siglip)** (from Google AI) released with the paper [Sigmoid Loss for Language Image Pre-Training](https://arxiv.org/abs/2303.15343) by Xiaohua Zhai, Basil Mustafa, Alexander Kolesnikov, Lucas Beyer.
|
||||
1. **[SpeechT5](https://huggingface.co/docs/transformers/model_doc/speecht5)** (from Microsoft Research) released with the paper [SpeechT5: Unified-Modal Encoder-Decoder Pre-Training for Spoken Language Processing](https://arxiv.org/abs/2110.07205) by Junyi Ao, Rui Wang, Long Zhou, Chengyi Wang, Shuo Ren, Yu Wu, Shujie Liu, Tom Ko, Qing Li, Yu Zhang, Zhihua Wei, Yao Qian, Jinyu Li, Furu Wei.
|
||||
1. **[SpeechToTextTransformer](https://huggingface.co/docs/transformers/model_doc/speech_to_text)** (from Facebook), released together with the paper [fairseq S2T: Fast Speech-to-Text Modeling with fairseq](https://arxiv.org/abs/2010.05171) by Changhan Wang, Yun Tang, Xutai Ma, Anne Wu, Dmytro Okhonko, Juan Pino.
|
||||
1. **[SpeechToTextTransformer2](https://huggingface.co/docs/transformers/model_doc/speech_to_text_2)** (from Facebook), released together with the paper [Large-Scale Self- and Semi-Supervised Learning for Speech Translation](https://arxiv.org/abs/2104.06678) by Changhan Wang, Anne Wu, Juan Pino, Alexei Baevski, Michael Auli, Alexis Conneau.
|
||||
|
@ -494,7 +494,7 @@ Número actual de puntos de control: ![](https://img.shields.io/endpoint?url=htt
|
|||
1. **[VITS](https://huggingface.co/docs/transformers/model_doc/vits)** (from Kakao Enterprise) released with the paper [Conditional Variational Autoencoder with Adversarial Learning for End-to-End Text-to-Speech](https://arxiv.org/abs/2106.06103) by Jaehyeon Kim, Jungil Kong, Juhee Son.
|
||||
1. **[ViViT](https://huggingface.co/docs/transformers/model_doc/vivit)** (from Google Research) released with the paper [ViViT: A Video Vision Transformer](https://arxiv.org/abs/2103.15691) by Anurag Arnab, Mostafa Dehghani, Georg Heigold, Chen Sun, Mario Lučić, Cordelia Schmid.
|
||||
1. **[Wav2Vec2](https://huggingface.co/docs/transformers/model_doc/wav2vec2)** (from Facebook AI) released with the paper [wav2vec 2.0: A Framework for Self-Supervised Learning of Speech Representations](https://arxiv.org/abs/2006.11477) by Alexei Baevski, Henry Zhou, Abdelrahman Mohamed, Michael Auli.
|
||||
1. **[Wav2Vec2-BERT](https://huggingface.co/docs/transformers/main/model_doc/wav2vec2-bert)** (from Meta AI) released with the paper [Seamless: Multilingual Expressive and Streaming Speech Translation](https://ai.meta.com/research/publications/seamless-multilingual-expressive-and-streaming-speech-translation/) by the Seamless Communication team.
|
||||
1. **[Wav2Vec2-BERT](https://huggingface.co/docs/transformers/model_doc/wav2vec2-bert)** (from Meta AI) released with the paper [Seamless: Multilingual Expressive and Streaming Speech Translation](https://ai.meta.com/research/publications/seamless-multilingual-expressive-and-streaming-speech-translation/) by the Seamless Communication team.
|
||||
1. **[Wav2Vec2-Conformer](https://huggingface.co/docs/transformers/model_doc/wav2vec2-conformer)** (from Facebook AI) released with the paper [FAIRSEQ S2T: Fast Speech-to-Text Modeling with FAIRSEQ](https://arxiv.org/abs/2010.05171) by Changhan Wang, Yun Tang, Xutai Ma, Anne Wu, Sravya Popuri, Dmytro Okhonko, Juan Pino.
|
||||
1. **[Wav2Vec2Phoneme](https://huggingface.co/docs/transformers/model_doc/wav2vec2_phoneme)** (from Facebook AI) released with the paper [Simple and Effective Zero-shot Cross-lingual Phoneme Recognition](https://arxiv.org/abs/2109.11680) by Qiantong Xu, Alexei Baevski, Michael Auli.
|
||||
1. **[WavLM](https://huggingface.co/docs/transformers/model_doc/wavlm)** (from Microsoft Research) released with the paper [WavLM: Large-Scale Self-Supervised Pre-Training for Full Stack Speech Processing](https://arxiv.org/abs/2110.13900) by Sanyuan Chen, Chengyi Wang, Zhengyang Chen, Yu Wu, Shujie Liu, Zhuo Chen, Jinyu Li, Naoyuki Kanda, Takuya Yoshioka, Xiong Xiao, Jian Wu, Long Zhou, Shuo Ren, Yanmin Qian, Yao Qian, Jian Wu, Michael Zeng, Furu Wei.
|
||||
|
|
|
@ -407,7 +407,7 @@ conda install conda-forge::transformers
|
|||
1. **[ProphetNet](https://huggingface.co/docs/transformers/model_doc/prophetnet)** (माइक्रोसॉफ्ट रिसर्च से) साथ में पेपर [ProphetNet: प्रेडिक्टिंग फ्यूचर एन-ग्राम फॉर सीक्वेंस-टू-सीक्वेंस प्री-ट्रेनिंग ](https://arxiv.org/abs/2001.04063) यू यान, वीज़ेन क्यूई, येयुन गोंग, दयाहेंग लियू, नान डुआन, जिउशेंग चेन, रुओफ़ेई झांग और मिंग झोउ द्वारा पोस्ट किया गया।
|
||||
1. **[PVT](https://huggingface.co/docs/transformers/model_doc/pvt)** (Nanjing University, The University of Hong Kong etc. से) Wenhai Wang, Enze Xie, Xiang Li, Deng-Ping Fan, Kaitao Song, Ding Liang, Tong Lu, Ping Luo, Ling Shao. द्वाराअनुसंधान पत्र [Pyramid Vision Transformer: A Versatile Backbone for Dense Prediction without Convolutions](https://arxiv.org/pdf/2102.12122.pdf) के साथ जारी किया गया
|
||||
1. **[QDQBert](https://huggingface.co/docs/transformers/model_doc/qdqbert)** (NVIDIA से) साथ वाला पेपर [डीप लर्निंग इंफ़ेक्शन के लिए इंटीजर क्वांटिज़ेशन: प्रिंसिपल्स एंड एम्पिरिकल इवैल्यूएशन](https:// arxiv.org/abs/2004.09602) हाओ वू, पैट्रिक जुड, जिआओजी झांग, मिखाइल इसेव और पॉलियस माइकेविसियस द्वारा।
|
||||
1. **[Qwen2](https://huggingface.co/docs/transformers/main/model_doc/qwen2)** (the Qwen team, Alibaba Group से) Jinze Bai, Shuai Bai, Yunfei Chu, Zeyu Cui, Kai Dang, Xiaodong Deng, Yang Fan, Wenbin Ge, Yu Han, Fei Huang, Binyuan Hui, Luo Ji, Mei Li, Junyang Lin, Runji Lin, Dayiheng Liu, Gao Liu, Chengqiang Lu, Keming Lu, Jianxin Ma, Rui Men, Xingzhang Ren, Xuancheng Ren, Chuanqi Tan, Sinan Tan, Jianhong Tu, Peng Wang, Shijie Wang, Wei Wang, Shengguang Wu, Benfeng Xu, Jin Xu, An Yang, Hao Yang, Jian Yang, Shusheng Yang, Yang Yao, Bowen Yu, Hongyi Yuan, Zheng Yuan, Jianwei Zhang, Xingxuan Zhang, Yichang Zhang, Zhenru Zhang, Chang Zhou, Jingren Zhou, Xiaohuan Zhou and Tianhang Zhu. द्वाराअनुसंधान पत्र [Qwen Technical Report](https://arxiv.org/abs/2309.16609) के साथ जारी किया गया
|
||||
1. **[Qwen2](https://huggingface.co/docs/transformers/model_doc/qwen2)** (the Qwen team, Alibaba Group से) Jinze Bai, Shuai Bai, Yunfei Chu, Zeyu Cui, Kai Dang, Xiaodong Deng, Yang Fan, Wenbin Ge, Yu Han, Fei Huang, Binyuan Hui, Luo Ji, Mei Li, Junyang Lin, Runji Lin, Dayiheng Liu, Gao Liu, Chengqiang Lu, Keming Lu, Jianxin Ma, Rui Men, Xingzhang Ren, Xuancheng Ren, Chuanqi Tan, Sinan Tan, Jianhong Tu, Peng Wang, Shijie Wang, Wei Wang, Shengguang Wu, Benfeng Xu, Jin Xu, An Yang, Hao Yang, Jian Yang, Shusheng Yang, Yang Yao, Bowen Yu, Hongyi Yuan, Zheng Yuan, Jianwei Zhang, Xingxuan Zhang, Yichang Zhang, Zhenru Zhang, Chang Zhou, Jingren Zhou, Xiaohuan Zhou and Tianhang Zhu. द्वाराअनुसंधान पत्र [Qwen Technical Report](https://arxiv.org/abs/2309.16609) के साथ जारी किया गया
|
||||
1. **[RAG](https://huggingface.co/docs/transformers/model_doc/rag)** (फेसबुक से) साथ में कागज [रिट्रीवल-ऑगमेंटेड जेनरेशन फॉर नॉलेज-इंटेंसिव एनएलपी टास्क](https://arxiv .org/abs/2005.11401) पैट्रिक लुईस, एथन पेरेज़, अलेक्जेंड्रा पिक्टस, फैबियो पेट्रोनी, व्लादिमीर कारपुखिन, नमन गोयल, हेनरिक कुटलर, माइक लुईस, वेन-ताउ यिह, टिम रॉकटाशेल, सेबस्टियन रिडेल, डौवे कीला द्वारा।
|
||||
1. **[REALM](https://huggingface.co/docs/transformers/model_doc/realm.html)** (Google अनुसंधान से) केल्विन गु, केंटन ली, ज़ोरा तुंग, पानुपोंग पसुपत और मिंग-वेई चांग द्वारा साथ में दिया गया पेपर [REALM: रिट्रीवल-ऑगमेंटेड लैंग्वेज मॉडल प्री-ट्रेनिंग](https://arxiv.org/abs/2002.08909)।
|
||||
1. **[Reformer](https://huggingface.co/docs/transformers/model_doc/reformer)** (from Google Research) released with the paper [Reformer: The Efficient Transformer](https://arxiv.org/abs/2001.04451) by Nikita Kitaev, Łukasz Kaiser, Anselm Levskaya.
|
||||
|
@ -425,7 +425,7 @@ conda install conda-forge::transformers
|
|||
1. **[Segment Anything](https://huggingface.co/docs/transformers/model_doc/sam)** (Meta AI से) Alexander Kirillov, Eric Mintun, Nikhila Ravi, Hanzi Mao, Chloe Rolland, Laura Gustafson, Tete Xiao, Spencer Whitehead, Alex Berg, Wan-Yen Lo, Piotr Dollar, Ross Girshick. द्वाराअनुसंधान पत्र [Segment Anything](https://arxiv.org/pdf/2304.02643v1.pdf) के साथ जारी किया गया
|
||||
1. **[SEW](https://huggingface.co/docs/transformers/model_doc/sew)** (ASAPP से) साथ देने वाला पेपर [भाषण पहचान के लिए अनसुपरवाइज्ड प्री-ट्रेनिंग में परफॉर्मेंस-एफिशिएंसी ट्रेड-ऑफ्स](https ://arxiv.org/abs/2109.06870) फेलिक्स वू, क्वांगयुन किम, जिंग पैन, क्यू हान, किलियन क्यू. वेनबर्गर, योव आर्टज़ी द्वारा।
|
||||
1. **[SEW-D](https://huggingface.co/docs/transformers/model_doc/sew_d)** (ASAPP से) साथ में पेपर [भाषण पहचान के लिए अनसुपरवाइज्ड प्री-ट्रेनिंग में परफॉर्मेंस-एफिशिएंसी ट्रेड-ऑफ्स] (https://arxiv.org/abs/2109.06870) फेलिक्स वू, क्वांगयुन किम, जिंग पैन, क्यू हान, किलियन क्यू. वेनबर्गर, योआव आर्टज़ी द्वारा पोस्ट किया गया।
|
||||
1. **[SigLIP](https://huggingface.co/docs/transformers/main/model_doc/siglip)** (Google AI से) Xiaohua Zhai, Basil Mustafa, Alexander Kolesnikov, Lucas Beyer. द्वाराअनुसंधान पत्र [Sigmoid Loss for Language Image Pre-Training](https://arxiv.org/abs/2303.15343) के साथ जारी किया गया
|
||||
1. **[SigLIP](https://huggingface.co/docs/transformers/model_doc/siglip)** (Google AI से) Xiaohua Zhai, Basil Mustafa, Alexander Kolesnikov, Lucas Beyer. द्वाराअनुसंधान पत्र [Sigmoid Loss for Language Image Pre-Training](https://arxiv.org/abs/2303.15343) के साथ जारी किया गया
|
||||
1. **[SpeechT5](https://huggingface.co/docs/transformers/model_doc/speecht5)** (from Microsoft Research) released with the paper [SpeechT5: Unified-Modal Encoder-Decoder Pre-Training for Spoken Language Processing](https://arxiv.org/abs/2110.07205) by Junyi Ao, Rui Wang, Long Zhou, Chengyi Wang, Shuo Ren, Yu Wu, Shujie Liu, Tom Ko, Qing Li, Yu Zhang, Zhihua Wei, Yao Qian, Jinyu Li, Furu Wei.
|
||||
1. **[SpeechToTextTransformer](https://huggingface.co/docs/transformers/model_doc/speech_to_text)** (फेसबुक से), साथ में पेपर [फेयरसेक S2T: फास्ट स्पीच-टू-टेक्स्ट मॉडलिंग विद फेयरसेक](https: //arxiv.org/abs/2010.05171) चांगहान वांग, यूं तांग, जुताई मा, ऐनी वू, दिमित्रो ओखोनको, जुआन पिनो द्वारा पोस्ट किया गया。
|
||||
1. **[SpeechToTextTransformer2](https://huggingface.co/docs/transformers/model_doc/speech_to_text_2)** (फेसबुक से) साथ में पेपर [लार्ज-स्केल सेल्फ- एंड सेमी-सुपरवाइज्ड लर्निंग फॉर स्पीच ट्रांसलेशन](https://arxiv.org/abs/2104.06678) चांगहान वांग, ऐनी वू, जुआन पिनो, एलेक्सी बेवस्की, माइकल औली, एलेक्सिस द्वारा Conneau द्वारा पोस्ट किया गया।
|
||||
|
@ -468,7 +468,7 @@ conda install conda-forge::transformers
|
|||
1. **[VITS](https://huggingface.co/docs/transformers/model_doc/vits)** (Kakao Enterprise से) Jaehyeon Kim, Jungil Kong, Juhee Son. द्वाराअनुसंधान पत्र [Conditional Variational Autoencoder with Adversarial Learning for End-to-End Text-to-Speech](https://arxiv.org/abs/2106.06103) के साथ जारी किया गया
|
||||
1. **[ViViT](https://huggingface.co/docs/transformers/model_doc/vivit)** (from Google Research) released with the paper [ViViT: A Video Vision Transformer](https://arxiv.org/abs/2103.15691) by Anurag Arnab, Mostafa Dehghani, Georg Heigold, Chen Sun, Mario Lučić, Cordelia Schmid.
|
||||
1. **[Wav2Vec2](https://huggingface.co/docs/transformers/model_doc/wav2vec2)** (फेसबुक एआई से) साथ में पेपर [wav2vec 2.0: ए फ्रेमवर्क फॉर सेल्फ-सुपरवाइज्ड लर्निंग ऑफ स्पीच रिप्रेजेंटेशन](https://arxiv.org/abs/2006.11477) एलेक्सी बेवस्की, हेनरी झोउ, अब्देलरहमान मोहम्मद, माइकल औली द्वारा।
|
||||
1. **[Wav2Vec2-BERT](https://huggingface.co/docs/transformers/main/model_doc/wav2vec2-bert)** (from Meta AI) released with the paper [Seamless: Multilingual Expressive and Streaming Speech Translation](https://ai.meta.com/research/publications/seamless-multilingual-expressive-and-streaming-speech-translation/) by the Seamless Communication team.
|
||||
1. **[Wav2Vec2-BERT](https://huggingface.co/docs/transformers/model_doc/wav2vec2-bert)** (from Meta AI) released with the paper [Seamless: Multilingual Expressive and Streaming Speech Translation](https://ai.meta.com/research/publications/seamless-multilingual-expressive-and-streaming-speech-translation/) by the Seamless Communication team.
|
||||
1. **[Wav2Vec2-Conformer](https://huggingface.co/docs/transformers/model_doc/wav2vec2-conformer)** (Facebook AI से) साथ वाला पेपर [FAIRSEQ S2T: FAIRSEQ के साथ फास्ट स्पीच-टू-टेक्स्ट मॉडलिंग ](https://arxiv.org/abs/2010.05171) चांगहान वांग, यूं तांग, जुताई मा, ऐनी वू, सरव्या पोपुरी, दिमित्रो ओखोनको, जुआन पिनो द्वारा पोस्ट किया गया।
|
||||
1. **[Wav2Vec2Phoneme](https://huggingface.co/docs/transformers/model_doc/wav2vec2_phoneme)** (Facebook AI से) साथ वाला पेपर [सरल और प्रभावी जीरो-शॉट क्रॉस-लिंगुअल फोनेम रिकॉग्निशन](https://arxiv.org/abs/2109.11680) कियानटोंग जू, एलेक्सी बाएव्स्की, माइकल औली द्वारा।
|
||||
1. **[WavLM](https://huggingface.co/docs/transformers/model_doc/wavlm)** (माइक्रोसॉफ्ट रिसर्च से) पेपर के साथ जारी किया गया [WavLM: फुल स्टैक के लिए बड़े पैमाने पर स्व-पर्यवेक्षित पूर्व-प्रशिक्षण स्पीच प्रोसेसिंग](https://arxiv.org/abs/2110.13900) सानयुआन चेन, चेंगयी वांग, झेंगयांग चेन, यू वू, शुजी लियू, ज़ुओ चेन, जिन्यु ली, नाओयुकी कांडा, ताकुया योशियोका, ज़िओंग जिओ, जियान वू, लॉन्ग झोउ, शुओ रेन, यानमिन कियान, याओ कियान, जियान वू, माइकल ज़ेंग, फुरु वेई।
|
||||
|
|
|
@ -467,7 +467,7 @@ Flax、PyTorch、TensorFlowをcondaでインストールする方法は、それ
|
|||
1. **[ProphetNet](https://huggingface.co/docs/transformers/model_doc/prophetnet)** (Microsoft Research から) Yu Yan, Weizhen Qi, Yeyun Gong, Dayiheng Liu, Nan Duan, Jiusheng Chen, Ruofei Zhang and Ming Zhou から公開された研究論文: [ProphetNet: Predicting Future N-gram for Sequence-to-Sequence Pre-training](https://arxiv.org/abs/2001.04063)
|
||||
1. **[PVT](https://huggingface.co/docs/transformers/model_doc/pvt)** (Nanjing University, The University of Hong Kong etc. から) Wenhai Wang, Enze Xie, Xiang Li, Deng-Ping Fan, Kaitao Song, Ding Liang, Tong Lu, Ping Luo, Ling Shao. から公開された研究論文 [Pyramid Vision Transformer: A Versatile Backbone for Dense Prediction without Convolutions](https://arxiv.org/pdf/2102.12122.pdf)
|
||||
1. **[QDQBert](https://huggingface.co/docs/transformers/model_doc/qdqbert)** (NVIDIA から) Hao Wu, Patrick Judd, Xiaojie Zhang, Mikhail Isaev and Paulius Micikevicius から公開された研究論文: [Integer Quantization for Deep Learning Inference: Principles and Empirical Evaluation](https://arxiv.org/abs/2004.09602)
|
||||
1. **[Qwen2](https://huggingface.co/docs/transformers/main/model_doc/qwen2)** (the Qwen team, Alibaba Group から) Jinze Bai, Shuai Bai, Yunfei Chu, Zeyu Cui, Kai Dang, Xiaodong Deng, Yang Fan, Wenbin Ge, Yu Han, Fei Huang, Binyuan Hui, Luo Ji, Mei Li, Junyang Lin, Runji Lin, Dayiheng Liu, Gao Liu, Chengqiang Lu, Keming Lu, Jianxin Ma, Rui Men, Xingzhang Ren, Xuancheng Ren, Chuanqi Tan, Sinan Tan, Jianhong Tu, Peng Wang, Shijie Wang, Wei Wang, Shengguang Wu, Benfeng Xu, Jin Xu, An Yang, Hao Yang, Jian Yang, Shusheng Yang, Yang Yao, Bowen Yu, Hongyi Yuan, Zheng Yuan, Jianwei Zhang, Xingxuan Zhang, Yichang Zhang, Zhenru Zhang, Chang Zhou, Jingren Zhou, Xiaohuan Zhou and Tianhang Zhu. から公開された研究論文 [Qwen Technical Report](https://arxiv.org/abs/2309.16609)
|
||||
1. **[Qwen2](https://huggingface.co/docs/transformers/model_doc/qwen2)** (the Qwen team, Alibaba Group から) Jinze Bai, Shuai Bai, Yunfei Chu, Zeyu Cui, Kai Dang, Xiaodong Deng, Yang Fan, Wenbin Ge, Yu Han, Fei Huang, Binyuan Hui, Luo Ji, Mei Li, Junyang Lin, Runji Lin, Dayiheng Liu, Gao Liu, Chengqiang Lu, Keming Lu, Jianxin Ma, Rui Men, Xingzhang Ren, Xuancheng Ren, Chuanqi Tan, Sinan Tan, Jianhong Tu, Peng Wang, Shijie Wang, Wei Wang, Shengguang Wu, Benfeng Xu, Jin Xu, An Yang, Hao Yang, Jian Yang, Shusheng Yang, Yang Yao, Bowen Yu, Hongyi Yuan, Zheng Yuan, Jianwei Zhang, Xingxuan Zhang, Yichang Zhang, Zhenru Zhang, Chang Zhou, Jingren Zhou, Xiaohuan Zhou and Tianhang Zhu. から公開された研究論文 [Qwen Technical Report](https://arxiv.org/abs/2309.16609)
|
||||
1. **[RAG](https://huggingface.co/docs/transformers/model_doc/rag)** (Facebook から) Patrick Lewis, Ethan Perez, Aleksandara Piktus, Fabio Petroni, Vladimir Karpukhin, Naman Goyal, Heinrich Küttler, Mike Lewis, Wen-tau Yih, Tim Rocktäschel, Sebastian Riedel, Douwe Kiela から公開された研究論文: [Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks](https://arxiv.org/abs/2005.11401)
|
||||
1. **[REALM](https://huggingface.co/docs/transformers/model_doc/realm.html)** (Google Research から) Kelvin Guu, Kenton Lee, Zora Tung, Panupong Pasupat and Ming-Wei Chang から公開された研究論文: [REALM: Retrieval-Augmented Language Model Pre-Training](https://arxiv.org/abs/2002.08909)
|
||||
1. **[Reformer](https://huggingface.co/docs/transformers/model_doc/reformer)** (Google Research から) Nikita Kitaev, Łukasz Kaiser, Anselm Levskaya から公開された研究論文: [Reformer: The Efficient Transformer](https://arxiv.org/abs/2001.04451)
|
||||
|
@ -485,7 +485,7 @@ Flax、PyTorch、TensorFlowをcondaでインストールする方法は、それ
|
|||
1. **[Segment Anything](https://huggingface.co/docs/transformers/model_doc/sam)** (Meta AI から) Alexander Kirillov, Eric Mintun, Nikhila Ravi, Hanzi Mao, Chloe Rolland, Laura Gustafson, Tete Xiao, Spencer Whitehead, Alex Berg, Wan-Yen Lo, Piotr Dollar, Ross Girshick. から公開された研究論文 [Segment Anything](https://arxiv.org/pdf/2304.02643v1.pdf)
|
||||
1. **[SEW](https://huggingface.co/docs/transformers/model_doc/sew)** (ASAPP から) Felix Wu, Kwangyoun Kim, Jing Pan, Kyu Han, Kilian Q. Weinberger, Yoav Artzi から公開された研究論文: [Performance-Efficiency Trade-offs in Unsupervised Pre-training for Speech Recognition](https://arxiv.org/abs/2109.06870)
|
||||
1. **[SEW-D](https://huggingface.co/docs/transformers/model_doc/sew_d)** (ASAPP から) Felix Wu, Kwangyoun Kim, Jing Pan, Kyu Han, Kilian Q. Weinberger, Yoav Artzi から公開された研究論文: [Performance-Efficiency Trade-offs in Unsupervised Pre-training for Speech Recognition](https://arxiv.org/abs/2109.06870)
|
||||
1. **[SigLIP](https://huggingface.co/docs/transformers/main/model_doc/siglip)** (Google AI から) Xiaohua Zhai, Basil Mustafa, Alexander Kolesnikov, Lucas Beyer. から公開された研究論文 [Sigmoid Loss for Language Image Pre-Training](https://arxiv.org/abs/2303.15343)
|
||||
1. **[SigLIP](https://huggingface.co/docs/transformers/model_doc/siglip)** (Google AI から) Xiaohua Zhai, Basil Mustafa, Alexander Kolesnikov, Lucas Beyer. から公開された研究論文 [Sigmoid Loss for Language Image Pre-Training](https://arxiv.org/abs/2303.15343)
|
||||
1. **[SpeechT5](https://huggingface.co/docs/transformers/model_doc/speecht5)** (Microsoft Research から) Junyi Ao, Rui Wang, Long Zhou, Chengyi Wang, Shuo Ren, Yu Wu, Shujie Liu, Tom Ko, Qing Li, Yu Zhang, Zhihua Wei, Yao Qian, Jinyu Li, Furu Wei. から公開された研究論文 [SpeechT5: Unified-Modal Encoder-Decoder Pre-Training for Spoken Language Processing](https://arxiv.org/abs/2110.07205)
|
||||
1. **[SpeechToTextTransformer](https://huggingface.co/docs/transformers/model_doc/speech_to_text)** (Facebook から), Changhan Wang, Yun Tang, Xutai Ma, Anne Wu, Dmytro Okhonko, Juan Pino から公開された研究論文: [fairseq S2T: Fast Speech-to-Text Modeling with fairseq](https://arxiv.org/abs/2010.05171)
|
||||
1. **[SpeechToTextTransformer2](https://huggingface.co/docs/transformers/model_doc/speech_to_text_2)** (Facebook から), Changhan Wang, Anne Wu, Juan Pino, Alexei Baevski, Michael Auli, Alexis Conneau から公開された研究論文: [Large-Scale Self- and Semi-Supervised Learning for Speech Translation](https://arxiv.org/abs/2104.06678)
|
||||
|
@ -528,7 +528,7 @@ Flax、PyTorch、TensorFlowをcondaでインストールする方法は、それ
|
|||
1. **[VITS](https://huggingface.co/docs/transformers/model_doc/vits)** (Kakao Enterprise から) Jaehyeon Kim, Jungil Kong, Juhee Son. から公開された研究論文 [Conditional Variational Autoencoder with Adversarial Learning for End-to-End Text-to-Speech](https://arxiv.org/abs/2106.06103)
|
||||
1. **[ViViT](https://huggingface.co/docs/transformers/model_doc/vivit)** (from Google Research) released with the paper [ViViT: A Video Vision Transformer](https://arxiv.org/abs/2103.15691) by Anurag Arnab, Mostafa Dehghani, Georg Heigold, Chen Sun, Mario Lučić, Cordelia Schmid.
|
||||
1. **[Wav2Vec2](https://huggingface.co/docs/transformers/model_doc/wav2vec2)** (Facebook AI から) Alexei Baevski, Henry Zhou, Abdelrahman Mohamed, Michael Auli から公開された研究論文: [wav2vec 2.0: A Framework for Self-Supervised Learning of Speech Representations](https://arxiv.org/abs/2006.11477)
|
||||
1. **[Wav2Vec2-BERT](https://huggingface.co/docs/transformers/main/model_doc/wav2vec2-bert)** (from Meta AI) released with the paper [Seamless: Multilingual Expressive and Streaming Speech Translation](https://ai.meta.com/research/publications/seamless-multilingual-expressive-and-streaming-speech-translation/) by the Seamless Communication team.
|
||||
1. **[Wav2Vec2-BERT](https://huggingface.co/docs/transformers/model_doc/wav2vec2-bert)** (from Meta AI) released with the paper [Seamless: Multilingual Expressive and Streaming Speech Translation](https://ai.meta.com/research/publications/seamless-multilingual-expressive-and-streaming-speech-translation/) by the Seamless Communication team.
|
||||
1. **[Wav2Vec2-Conformer](https://huggingface.co/docs/transformers/model_doc/wav2vec2-conformer)** (Facebook AI から) Changhan Wang, Yun Tang, Xutai Ma, Anne Wu, Sravya Popuri, Dmytro Okhonko, Juan Pino から公開された研究論文: [FAIRSEQ S2T: Fast Speech-to-Text Modeling with FAIRSEQ](https://arxiv.org/abs/2010.05171)
|
||||
1. **[Wav2Vec2Phoneme](https://huggingface.co/docs/transformers/model_doc/wav2vec2_phoneme)** (Facebook AI から) Qiantong Xu, Alexei Baevski, Michael Auli から公開された研究論文: [Simple and Effective Zero-shot Cross-lingual Phoneme Recognition](https://arxiv.org/abs/2109.11680)
|
||||
1. **[WavLM](https://huggingface.co/docs/transformers/model_doc/wavlm)** (Microsoft Research から) Sanyuan Chen, Chengyi Wang, Zhengyang Chen, Yu Wu, Shujie Liu, Zhuo Chen, Jinyu Li, Naoyuki Kanda, Takuya Yoshioka, Xiong Xiao, Jian Wu, Long Zhou, Shuo Ren, Yanmin Qian, Yao Qian, Jian Wu, Michael Zeng, Furu Wei から公開された研究論文: [WavLM: Large-Scale Self-Supervised Pre-Training for Full Stack Speech Processing](https://arxiv.org/abs/2110.13900)
|
||||
|
|
|
@ -382,7 +382,7 @@ Flax, PyTorch, TensorFlow 설치 페이지에서 이들을 conda로 설치하는
|
|||
1. **[ProphetNet](https://huggingface.co/docs/transformers/model_doc/prophetnet)** (Microsoft Research 에서) Yu Yan, Weizhen Qi, Yeyun Gong, Dayiheng Liu, Nan Duan, Jiusheng Chen, Ruofei Zhang and Ming Zhou 의 [ProphetNet: Predicting Future N-gram for Sequence-to-Sequence Pre-training](https://arxiv.org/abs/2001.04063) 논문과 함께 발표했습니다.
|
||||
1. **[PVT](https://huggingface.co/docs/transformers/model_doc/pvt)** (Nanjing University, The University of Hong Kong etc. 에서 제공)은 Wenhai Wang, Enze Xie, Xiang Li, Deng-Ping Fan, Kaitao Song, Ding Liang, Tong Lu, Ping Luo, Ling Shao.의 [Pyramid Vision Transformer: A Versatile Backbone for Dense Prediction without Convolutions](https://arxiv.org/pdf/2102.12122.pdf)논문과 함께 발표했습니다.
|
||||
1. **[QDQBert](https://huggingface.co/docs/transformers/model_doc/qdqbert)** (NVIDIA 에서) Hao Wu, Patrick Judd, Xiaojie Zhang, Mikhail Isaev and Paulius Micikevicius 의 [Integer Quantization for Deep Learning Inference: Principles and Empirical Evaluation](https://arxiv.org/abs/2004.09602) 논문과 함께 발표했습니다.
|
||||
1. **[Qwen2](https://huggingface.co/docs/transformers/main/model_doc/qwen2)** (the Qwen team, Alibaba Group 에서 제공)은 Jinze Bai, Shuai Bai, Yunfei Chu, Zeyu Cui, Kai Dang, Xiaodong Deng, Yang Fan, Wenbin Ge, Yu Han, Fei Huang, Binyuan Hui, Luo Ji, Mei Li, Junyang Lin, Runji Lin, Dayiheng Liu, Gao Liu, Chengqiang Lu, Keming Lu, Jianxin Ma, Rui Men, Xingzhang Ren, Xuancheng Ren, Chuanqi Tan, Sinan Tan, Jianhong Tu, Peng Wang, Shijie Wang, Wei Wang, Shengguang Wu, Benfeng Xu, Jin Xu, An Yang, Hao Yang, Jian Yang, Shusheng Yang, Yang Yao, Bowen Yu, Hongyi Yuan, Zheng Yuan, Jianwei Zhang, Xingxuan Zhang, Yichang Zhang, Zhenru Zhang, Chang Zhou, Jingren Zhou, Xiaohuan Zhou and Tianhang Zhu.의 [Qwen Technical Report](https://arxiv.org/abs/2309.16609)논문과 함께 발표했습니다.
|
||||
1. **[Qwen2](https://huggingface.co/docs/transformers/model_doc/qwen2)** (the Qwen team, Alibaba Group 에서 제공)은 Jinze Bai, Shuai Bai, Yunfei Chu, Zeyu Cui, Kai Dang, Xiaodong Deng, Yang Fan, Wenbin Ge, Yu Han, Fei Huang, Binyuan Hui, Luo Ji, Mei Li, Junyang Lin, Runji Lin, Dayiheng Liu, Gao Liu, Chengqiang Lu, Keming Lu, Jianxin Ma, Rui Men, Xingzhang Ren, Xuancheng Ren, Chuanqi Tan, Sinan Tan, Jianhong Tu, Peng Wang, Shijie Wang, Wei Wang, Shengguang Wu, Benfeng Xu, Jin Xu, An Yang, Hao Yang, Jian Yang, Shusheng Yang, Yang Yao, Bowen Yu, Hongyi Yuan, Zheng Yuan, Jianwei Zhang, Xingxuan Zhang, Yichang Zhang, Zhenru Zhang, Chang Zhou, Jingren Zhou, Xiaohuan Zhou and Tianhang Zhu.의 [Qwen Technical Report](https://arxiv.org/abs/2309.16609)논문과 함께 발표했습니다.
|
||||
1. **[RAG](https://huggingface.co/docs/transformers/model_doc/rag)** (Facebook 에서) Patrick Lewis, Ethan Perez, Aleksandara Piktus, Fabio Petroni, Vladimir Karpukhin, Naman Goyal, Heinrich Küttler, Mike Lewis, Wen-tau Yih, Tim Rocktäschel, Sebastian Riedel, Douwe Kiela 의 [Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks](https://arxiv.org/abs/2005.11401) 논문과 함께 발표했습니다.
|
||||
1. **[REALM](https://huggingface.co/docs/transformers/model_doc/realm.html)** (Google Research 에서) Kelvin Guu, Kenton Lee, Zora Tung, Panupong Pasupat and Ming-Wei Chang 의 [REALM: Retrieval-Augmented Language Model Pre-Training](https://arxiv.org/abs/2002.08909) 논문과 함께 발표했습니다.
|
||||
1. **[Reformer](https://huggingface.co/docs/transformers/model_doc/reformer)** (Google Research 에서) Nikita Kitaev, Łukasz Kaiser, Anselm Levskaya 의 [Reformer: The Efficient Transformer](https://arxiv.org/abs/2001.04451) 논문과 함께 발표했습니다.
|
||||
|
@ -400,7 +400,7 @@ Flax, PyTorch, TensorFlow 설치 페이지에서 이들을 conda로 설치하는
|
|||
1. **[Segment Anything](https://huggingface.co/docs/transformers/model_doc/sam)** (Meta AI 에서 제공)은 Alexander Kirillov, Eric Mintun, Nikhila Ravi, Hanzi Mao, Chloe Rolland, Laura Gustafson, Tete Xiao, Spencer Whitehead, Alex Berg, Wan-Yen Lo, Piotr Dollar, Ross Girshick.의 [Segment Anything](https://arxiv.org/pdf/2304.02643v1.pdf)논문과 함께 발표했습니다.
|
||||
1. **[SEW](https://huggingface.co/docs/transformers/model_doc/sew)** (ASAPP 에서) Felix Wu, Kwangyoun Kim, Jing Pan, Kyu Han, Kilian Q. Weinberger, Yoav Artzi 의 [Performance-Efficiency Trade-offs in Unsupervised Pre-training for Speech Recognition](https://arxiv.org/abs/2109.06870) 논문과 함께 발표했습니다.
|
||||
1. **[SEW-D](https://huggingface.co/docs/transformers/model_doc/sew_d)** (ASAPP 에서) Felix Wu, Kwangyoun Kim, Jing Pan, Kyu Han, Kilian Q. Weinberger, Yoav Artzi 의 [Performance-Efficiency Trade-offs in Unsupervised Pre-training for Speech Recognition](https://arxiv.org/abs/2109.06870) 논문과 함께 발표했습니다.
|
||||
1. **[SigLIP](https://huggingface.co/docs/transformers/main/model_doc/siglip)** (Google AI 에서 제공)은 Xiaohua Zhai, Basil Mustafa, Alexander Kolesnikov, Lucas Beyer.의 [Sigmoid Loss for Language Image Pre-Training](https://arxiv.org/abs/2303.15343)논문과 함께 발표했습니다.
|
||||
1. **[SigLIP](https://huggingface.co/docs/transformers/model_doc/siglip)** (Google AI 에서 제공)은 Xiaohua Zhai, Basil Mustafa, Alexander Kolesnikov, Lucas Beyer.의 [Sigmoid Loss for Language Image Pre-Training](https://arxiv.org/abs/2303.15343)논문과 함께 발표했습니다.
|
||||
1. **[SpeechT5](https://huggingface.co/docs/transformers/model_doc/speecht5)** (Microsoft Research 에서 제공)은 Junyi Ao, Rui Wang, Long Zhou, Chengyi Wang, Shuo Ren, Yu Wu, Shujie Liu, Tom Ko, Qing Li, Yu Zhang, Zhihua Wei, Yao Qian, Jinyu Li, Furu Wei.의 [SpeechT5: Unified-Modal Encoder-Decoder Pre-Training for Spoken Language Processing](https://arxiv.org/abs/2110.07205)논문과 함께 발표했습니다.
|
||||
1. **[SpeechToTextTransformer](https://huggingface.co/docs/transformers/model_doc/speech_to_text)** (Facebook 에서) Changhan Wang, Yun Tang, Xutai Ma, Anne Wu, Dmytro Okhonko, Juan Pino 의 [fairseq S2T: Fast Speech-to-Text Modeling with fairseq](https://arxiv.org/abs/2010.05171) 논문과 함께 발표했습니다.
|
||||
1. **[SpeechToTextTransformer2](https://huggingface.co/docs/transformers/model_doc/speech_to_text_2)** (Facebook 에서) Changhan Wang, Anne Wu, Juan Pino, Alexei Baevski, Michael Auli, Alexis Conneau 의 [Large-Scale Self- and Semi-Supervised Learning for Speech Translation](https://arxiv.org/abs/2104.06678) 논문과 함께 발표했습니다.
|
||||
|
@ -443,7 +443,7 @@ Flax, PyTorch, TensorFlow 설치 페이지에서 이들을 conda로 설치하는
|
|||
1. **[VITS](https://huggingface.co/docs/transformers/model_doc/vits)** (Kakao Enterprise 에서 제공)은 Jaehyeon Kim, Jungil Kong, Juhee Son.의 [Conditional Variational Autoencoder with Adversarial Learning for End-to-End Text-to-Speech](https://arxiv.org/abs/2106.06103)논문과 함께 발표했습니다.
|
||||
1. **[ViViT](https://huggingface.co/docs/transformers/model_doc/vivit)** (from Google Research) released with the paper [ViViT: A Video Vision Transformer](https://arxiv.org/abs/2103.15691) by Anurag Arnab, Mostafa Dehghani, Georg Heigold, Chen Sun, Mario Lučić, Cordelia Schmid.
|
||||
1. **[Wav2Vec2](https://huggingface.co/docs/transformers/model_doc/wav2vec2)** (Facebook AI 에서) Alexei Baevski, Henry Zhou, Abdelrahman Mohamed, Michael Auli 의 [wav2vec 2.0: A Framework for Self-Supervised Learning of Speech Representations](https://arxiv.org/abs/2006.11477) 논문과 함께 발표했습니다.
|
||||
1. **[Wav2Vec2-BERT](https://huggingface.co/docs/transformers/main/model_doc/wav2vec2-bert)** (from Meta AI) released with the paper [Seamless: Multilingual Expressive and Streaming Speech Translation](https://ai.meta.com/research/publications/seamless-multilingual-expressive-and-streaming-speech-translation/) by the Seamless Communication team.
|
||||
1. **[Wav2Vec2-BERT](https://huggingface.co/docs/transformers/model_doc/wav2vec2-bert)** (from Meta AI) released with the paper [Seamless: Multilingual Expressive and Streaming Speech Translation](https://ai.meta.com/research/publications/seamless-multilingual-expressive-and-streaming-speech-translation/) by the Seamless Communication team.
|
||||
1. **[Wav2Vec2-Conformer](https://huggingface.co/docs/transformers/model_doc/wav2vec2-conformer)** (Facebook AI 에서) Changhan Wang, Yun Tang, Xutai Ma, Anne Wu, Sravya Popuri, Dmytro Okhonko, Juan Pino 의 [FAIRSEQ S2T: Fast Speech-to-Text Modeling with FAIRSEQ](https://arxiv.org/abs/2010.05171) 논문과 함께 발표했습니다.
|
||||
1. **[Wav2Vec2Phoneme](https://huggingface.co/docs/transformers/model_doc/wav2vec2_phoneme)** (Facebook AI 에서) Qiantong Xu, Alexei Baevski, Michael Auli 의 [Simple and Effective Zero-shot Cross-lingual Phoneme Recognition](https://arxiv.org/abs/2109.11680) 논문과 함께 발표했습니다.
|
||||
1. **[WavLM](https://huggingface.co/docs/transformers/model_doc/wavlm)** (Microsoft Research 에서) Sanyuan Chen, Chengyi Wang, Zhengyang Chen, Yu Wu, Shujie Liu, Zhuo Chen, Jinyu Li, Naoyuki Kanda, Takuya Yoshioka, Xiong Xiao, Jian Wu, Long Zhou, Shuo Ren, Yanmin Qian, Yao Qian, Jian Wu, Michael Zeng, Furu Wei 의 [WavLM: Large-Scale Self-Supervised Pre-Training for Full Stack Speech Processing](https://arxiv.org/abs/2110.13900) 논문과 함께 발표했습니다.
|
||||
|
|
|
@ -406,7 +406,7 @@ conda install conda-forge::transformers
|
|||
1. **[ProphetNet](https://huggingface.co/docs/transformers/model_doc/prophetnet)** (来自 Microsoft Research) 伴随论文 [ProphetNet: Predicting Future N-gram for Sequence-to-Sequence Pre-training](https://arxiv.org/abs/2001.04063) 由 Yu Yan, Weizhen Qi, Yeyun Gong, Dayiheng Liu, Nan Duan, Jiusheng Chen, Ruofei Zhang and Ming Zhou 发布。
|
||||
1. **[PVT](https://huggingface.co/docs/transformers/model_doc/pvt)** (来自 Nanjing University, The University of Hong Kong etc.) 伴随论文 [Pyramid Vision Transformer: A Versatile Backbone for Dense Prediction without Convolutions](https://arxiv.org/pdf/2102.12122.pdf) 由 Wenhai Wang, Enze Xie, Xiang Li, Deng-Ping Fan, Kaitao Song, Ding Liang, Tong Lu, Ping Luo, Ling Shao 发布。
|
||||
1. **[QDQBert](https://huggingface.co/docs/transformers/model_doc/qdqbert)** (来自 NVIDIA) 伴随论文 [Integer Quantization for Deep Learning Inference: Principles and Empirical Evaluation](https://arxiv.org/abs/2004.09602) 由 Hao Wu, Patrick Judd, Xiaojie Zhang, Mikhail Isaev and Paulius Micikevicius 发布。
|
||||
1. **[Qwen2](https://huggingface.co/docs/transformers/main/model_doc/qwen2)** (来自 the Qwen team, Alibaba Group) 伴随论文 [Qwen Technical Report](https://arxiv.org/abs/2309.16609) 由 Jinze Bai, Shuai Bai, Yunfei Chu, Zeyu Cui, Kai Dang, Xiaodong Deng, Yang Fan, Wenbin Ge, Yu Han, Fei Huang, Binyuan Hui, Luo Ji, Mei Li, Junyang Lin, Runji Lin, Dayiheng Liu, Gao Liu, Chengqiang Lu, Keming Lu, Jianxin Ma, Rui Men, Xingzhang Ren, Xuancheng Ren, Chuanqi Tan, Sinan Tan, Jianhong Tu, Peng Wang, Shijie Wang, Wei Wang, Shengguang Wu, Benfeng Xu, Jin Xu, An Yang, Hao Yang, Jian Yang, Shusheng Yang, Yang Yao, Bowen Yu, Hongyi Yuan, Zheng Yuan, Jianwei Zhang, Xingxuan Zhang, Yichang Zhang, Zhenru Zhang, Chang Zhou, Jingren Zhou, Xiaohuan Zhou and Tianhang Zhu 发布。
|
||||
1. **[Qwen2](https://huggingface.co/docs/transformers/model_doc/qwen2)** (来自 the Qwen team, Alibaba Group) 伴随论文 [Qwen Technical Report](https://arxiv.org/abs/2309.16609) 由 Jinze Bai, Shuai Bai, Yunfei Chu, Zeyu Cui, Kai Dang, Xiaodong Deng, Yang Fan, Wenbin Ge, Yu Han, Fei Huang, Binyuan Hui, Luo Ji, Mei Li, Junyang Lin, Runji Lin, Dayiheng Liu, Gao Liu, Chengqiang Lu, Keming Lu, Jianxin Ma, Rui Men, Xingzhang Ren, Xuancheng Ren, Chuanqi Tan, Sinan Tan, Jianhong Tu, Peng Wang, Shijie Wang, Wei Wang, Shengguang Wu, Benfeng Xu, Jin Xu, An Yang, Hao Yang, Jian Yang, Shusheng Yang, Yang Yao, Bowen Yu, Hongyi Yuan, Zheng Yuan, Jianwei Zhang, Xingxuan Zhang, Yichang Zhang, Zhenru Zhang, Chang Zhou, Jingren Zhou, Xiaohuan Zhou and Tianhang Zhu 发布。
|
||||
1. **[RAG](https://huggingface.co/docs/transformers/model_doc/rag)** (来自 Facebook) 伴随论文 [Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks](https://arxiv.org/abs/2005.11401) 由 Patrick Lewis, Ethan Perez, Aleksandara Piktus, Fabio Petroni, Vladimir Karpukhin, Naman Goyal, Heinrich Küttler, Mike Lewis, Wen-tau Yih, Tim Rocktäschel, Sebastian Riedel, Douwe Kiela 发布。
|
||||
1. **[REALM](https://huggingface.co/docs/transformers/model_doc/realm.html)** (来自 Google Research) 伴随论文 [REALM: Retrieval-Augmented Language Model Pre-Training](https://arxiv.org/abs/2002.08909) 由 Kelvin Guu, Kenton Lee, Zora Tung, Panupong Pasupat and Ming-Wei Chang 发布。
|
||||
1. **[Reformer](https://huggingface.co/docs/transformers/model_doc/reformer)** (来自 Google Research) 伴随论文 [Reformer: The Efficient Transformer](https://arxiv.org/abs/2001.04451) 由 Nikita Kitaev, Łukasz Kaiser, Anselm Levskaya 发布。
|
||||
|
@ -424,7 +424,7 @@ conda install conda-forge::transformers
|
|||
1. **[Segment Anything](https://huggingface.co/docs/transformers/model_doc/sam)** (来自 Meta AI) 伴随论文 [Segment Anything](https://arxiv.org/pdf/2304.02643v1.pdf) 由 Alexander Kirillov, Eric Mintun, Nikhila Ravi, Hanzi Mao, Chloe Rolland, Laura Gustafson, Tete Xiao, Spencer Whitehead, Alex Berg, Wan-Yen Lo, Piotr Dollar, Ross Girshick 发布。
|
||||
1. **[SEW](https://huggingface.co/docs/transformers/model_doc/sew)** (来自 ASAPP) 伴随论文 [Performance-Efficiency Trade-offs in Unsupervised Pre-training for Speech Recognition](https://arxiv.org/abs/2109.06870) 由 Felix Wu, Kwangyoun Kim, Jing Pan, Kyu Han, Kilian Q. Weinberger, Yoav Artzi 发布。
|
||||
1. **[SEW-D](https://huggingface.co/docs/transformers/model_doc/sew_d)** (来自 ASAPP) 伴随论文 [Performance-Efficiency Trade-offs in Unsupervised Pre-training for Speech Recognition](https://arxiv.org/abs/2109.06870) 由 Felix Wu, Kwangyoun Kim, Jing Pan, Kyu Han, Kilian Q. Weinberger, Yoav Artzi 发布。
|
||||
1. **[SigLIP](https://huggingface.co/docs/transformers/main/model_doc/siglip)** (来自 Google AI) 伴随论文 [Sigmoid Loss for Language Image Pre-Training](https://arxiv.org/abs/2303.15343) 由 Xiaohua Zhai, Basil Mustafa, Alexander Kolesnikov, Lucas Beyer 发布。
|
||||
1. **[SigLIP](https://huggingface.co/docs/transformers/model_doc/siglip)** (来自 Google AI) 伴随论文 [Sigmoid Loss for Language Image Pre-Training](https://arxiv.org/abs/2303.15343) 由 Xiaohua Zhai, Basil Mustafa, Alexander Kolesnikov, Lucas Beyer 发布。
|
||||
1. **[SpeechT5](https://huggingface.co/docs/transformers/model_doc/speecht5)** (来自 Microsoft Research) 伴随论文 [SpeechT5: Unified-Modal Encoder-Decoder Pre-Training for Spoken Language Processing](https://arxiv.org/abs/2110.07205) 由 Junyi Ao, Rui Wang, Long Zhou, Chengyi Wang, Shuo Ren, Yu Wu, Shujie Liu, Tom Ko, Qing Li, Yu Zhang, Zhihua Wei, Yao Qian, Jinyu Li, Furu Wei 发布。
|
||||
1. **[SpeechToTextTransformer](https://huggingface.co/docs/transformers/model_doc/speech_to_text)** (来自 Facebook), 伴随论文 [fairseq S2T: Fast Speech-to-Text Modeling with fairseq](https://arxiv.org/abs/2010.05171) 由 Changhan Wang, Yun Tang, Xutai Ma, Anne Wu, Dmytro Okhonko, Juan Pino 发布。
|
||||
1. **[SpeechToTextTransformer2](https://huggingface.co/docs/transformers/model_doc/speech_to_text_2)** (来自 Facebook) 伴随论文 [Large-Scale Self- and Semi-Supervised Learning for Speech Translation](https://arxiv.org/abs/2104.06678) 由 Changhan Wang, Anne Wu, Juan Pino, Alexei Baevski, Michael Auli, Alexis Conneau 发布。
|
||||
|
@ -467,7 +467,7 @@ conda install conda-forge::transformers
|
|||
1. **[VITS](https://huggingface.co/docs/transformers/model_doc/vits)** (来自 Kakao Enterprise) 伴随论文 [Conditional Variational Autoencoder with Adversarial Learning for End-to-End Text-to-Speech](https://arxiv.org/abs/2106.06103) 由 Jaehyeon Kim, Jungil Kong, Juhee Son 发布。
|
||||
1. **[ViViT](https://huggingface.co/docs/transformers/model_doc/vivit)** (来自 Google Research) released with the paper [ViViT: A Video Vision Transformer](https://arxiv.org/abs/2103.15691) 由 Anurag Arnab, Mostafa Dehghani, Georg Heigold, Chen Sun, Mario Lučić, Cordelia Schmid.
|
||||
1. **[Wav2Vec2](https://huggingface.co/docs/transformers/model_doc/wav2vec2)** (来自 Facebook AI) 伴随论文 [wav2vec 2.0: A Framework for Self-Supervised Learning of Speech Representations](https://arxiv.org/abs/2006.11477) 由 Alexei Baevski, Henry Zhou, Abdelrahman Mohamed, Michael Auli 发布。
|
||||
1. **[Wav2Vec2-BERT](https://huggingface.co/docs/transformers/main/model_doc/wav2vec2-bert)** (from Meta AI) released with the paper [Seamless: Multilingual Expressive and Streaming Speech Translation](https://ai.meta.com/research/publications/seamless-multilingual-expressive-and-streaming-speech-translation/) by the Seamless Communication team.
|
||||
1. **[Wav2Vec2-BERT](https://huggingface.co/docs/transformers/model_doc/wav2vec2-bert)** (from Meta AI) released with the paper [Seamless: Multilingual Expressive and Streaming Speech Translation](https://ai.meta.com/research/publications/seamless-multilingual-expressive-and-streaming-speech-translation/) by the Seamless Communication team.
|
||||
1. **[Wav2Vec2-Conformer](https://huggingface.co/docs/transformers/model_doc/wav2vec2-conformer)** (来自 Facebook AI) 伴随论文 [FAIRSEQ S2T: Fast Speech-to-Text Modeling with FAIRSEQ](https://arxiv.org/abs/2010.05171) 由 Changhan Wang, Yun Tang, Xutai Ma, Anne Wu, Sravya Popuri, Dmytro Okhonko, Juan Pino 发布。
|
||||
1. **[Wav2Vec2Phoneme](https://huggingface.co/docs/transformers/model_doc/wav2vec2_phoneme)** (来自 Facebook AI) 伴随论文 [Simple and Effective Zero-shot Cross-lingual Phoneme Recognition](https://arxiv.org/abs/2109.11680) 由 Qiantong Xu, Alexei Baevski, Michael Auli 发布。
|
||||
1. **[WavLM](https://huggingface.co/docs/transformers/model_doc/wavlm)** (from Microsoft Research) released with the paper [WavLM: Large-Scale Self-Supervised Pre-Training for Full Stack Speech Processing](https://arxiv.org/abs/2110.13900) by Sanyuan Chen, Chengyi Wang, Zhengyang Chen, Yu Wu, Shujie Liu, Zhuo Chen, Jinyu Li, Naoyuki Kanda, Takuya Yoshioka, Xiong Xiao, Jian Wu, Long Zhou, Shuo Ren, Yanmin Qian, Yao Qian, Jian Wu, Michael Zeng, Furu Wei.
|
||||
|
|
|
@ -418,7 +418,7 @@ conda install conda-forge::transformers
|
|||
1. **[ProphetNet](https://huggingface.co/docs/transformers/model_doc/prophetnet)** (from Microsoft Research) released with the paper [ProphetNet: Predicting Future N-gram for Sequence-to-Sequence Pre-training](https://arxiv.org/abs/2001.04063) by Yu Yan, Weizhen Qi, Yeyun Gong, Dayiheng Liu, Nan Duan, Jiusheng Chen, Ruofei Zhang and Ming Zhou.
|
||||
1. **[PVT](https://huggingface.co/docs/transformers/model_doc/pvt)** (from Nanjing University, The University of Hong Kong etc.) released with the paper [Pyramid Vision Transformer: A Versatile Backbone for Dense Prediction without Convolutions](https://arxiv.org/pdf/2102.12122.pdf) by Wenhai Wang, Enze Xie, Xiang Li, Deng-Ping Fan, Kaitao Song, Ding Liang, Tong Lu, Ping Luo, Ling Shao.
|
||||
1. **[QDQBert](https://huggingface.co/docs/transformers/model_doc/qdqbert)** (from NVIDIA) released with the paper [Integer Quantization for Deep Learning Inference: Principles and Empirical Evaluation](https://arxiv.org/abs/2004.09602) by Hao Wu, Patrick Judd, Xiaojie Zhang, Mikhail Isaev and Paulius Micikevicius.
|
||||
1. **[Qwen2](https://huggingface.co/docs/transformers/main/model_doc/qwen2)** (from the Qwen team, Alibaba Group) released with the paper [Qwen Technical Report](https://arxiv.org/abs/2309.16609) by Jinze Bai, Shuai Bai, Yunfei Chu, Zeyu Cui, Kai Dang, Xiaodong Deng, Yang Fan, Wenbin Ge, Yu Han, Fei Huang, Binyuan Hui, Luo Ji, Mei Li, Junyang Lin, Runji Lin, Dayiheng Liu, Gao Liu, Chengqiang Lu, Keming Lu, Jianxin Ma, Rui Men, Xingzhang Ren, Xuancheng Ren, Chuanqi Tan, Sinan Tan, Jianhong Tu, Peng Wang, Shijie Wang, Wei Wang, Shengguang Wu, Benfeng Xu, Jin Xu, An Yang, Hao Yang, Jian Yang, Shusheng Yang, Yang Yao, Bowen Yu, Hongyi Yuan, Zheng Yuan, Jianwei Zhang, Xingxuan Zhang, Yichang Zhang, Zhenru Zhang, Chang Zhou, Jingren Zhou, Xiaohuan Zhou and Tianhang Zhu.
|
||||
1. **[Qwen2](https://huggingface.co/docs/transformers/model_doc/qwen2)** (from the Qwen team, Alibaba Group) released with the paper [Qwen Technical Report](https://arxiv.org/abs/2309.16609) by Jinze Bai, Shuai Bai, Yunfei Chu, Zeyu Cui, Kai Dang, Xiaodong Deng, Yang Fan, Wenbin Ge, Yu Han, Fei Huang, Binyuan Hui, Luo Ji, Mei Li, Junyang Lin, Runji Lin, Dayiheng Liu, Gao Liu, Chengqiang Lu, Keming Lu, Jianxin Ma, Rui Men, Xingzhang Ren, Xuancheng Ren, Chuanqi Tan, Sinan Tan, Jianhong Tu, Peng Wang, Shijie Wang, Wei Wang, Shengguang Wu, Benfeng Xu, Jin Xu, An Yang, Hao Yang, Jian Yang, Shusheng Yang, Yang Yao, Bowen Yu, Hongyi Yuan, Zheng Yuan, Jianwei Zhang, Xingxuan Zhang, Yichang Zhang, Zhenru Zhang, Chang Zhou, Jingren Zhou, Xiaohuan Zhou and Tianhang Zhu.
|
||||
1. **[RAG](https://huggingface.co/docs/transformers/model_doc/rag)** (from Facebook) released with the paper [Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks](https://arxiv.org/abs/2005.11401) by Patrick Lewis, Ethan Perez, Aleksandara Piktus, Fabio Petroni, Vladimir Karpukhin, Naman Goyal, Heinrich Küttler, Mike Lewis, Wen-tau Yih, Tim Rocktäschel, Sebastian Riedel, Douwe Kiela.
|
||||
1. **[REALM](https://huggingface.co/docs/transformers/model_doc/realm.html)** (from Google Research) released with the paper [REALM: Retrieval-Augmented Language Model Pre-Training](https://arxiv.org/abs/2002.08909) by Kelvin Guu, Kenton Lee, Zora Tung, Panupong Pasupat and Ming-Wei Chang.
|
||||
1. **[Reformer](https://huggingface.co/docs/transformers/model_doc/reformer)** (from Google Research) released with the paper [Reformer: The Efficient Transformer](https://arxiv.org/abs/2001.04451) by Nikita Kitaev, Łukasz Kaiser, Anselm Levskaya.
|
||||
|
@ -436,7 +436,7 @@ conda install conda-forge::transformers
|
|||
1. **[Segment Anything](https://huggingface.co/docs/transformers/model_doc/sam)** (from Meta AI) released with the paper [Segment Anything](https://arxiv.org/pdf/2304.02643v1.pdf) by Alexander Kirillov, Eric Mintun, Nikhila Ravi, Hanzi Mao, Chloe Rolland, Laura Gustafson, Tete Xiao, Spencer Whitehead, Alex Berg, Wan-Yen Lo, Piotr Dollar, Ross Girshick.
|
||||
1. **[SEW](https://huggingface.co/docs/transformers/model_doc/sew)** (from ASAPP) released with the paper [Performance-Efficiency Trade-offs in Unsupervised Pre-training for Speech Recognition](https://arxiv.org/abs/2109.06870) by Felix Wu, Kwangyoun Kim, Jing Pan, Kyu Han, Kilian Q. Weinberger, Yoav Artzi.
|
||||
1. **[SEW-D](https://huggingface.co/docs/transformers/model_doc/sew_d)** (from ASAPP) released with the paper [Performance-Efficiency Trade-offs in Unsupervised Pre-training for Speech Recognition](https://arxiv.org/abs/2109.06870) by Felix Wu, Kwangyoun Kim, Jing Pan, Kyu Han, Kilian Q. Weinberger, Yoav Artzi.
|
||||
1. **[SigLIP](https://huggingface.co/docs/transformers/main/model_doc/siglip)** (from Google AI) released with the paper [Sigmoid Loss for Language Image Pre-Training](https://arxiv.org/abs/2303.15343) by Xiaohua Zhai, Basil Mustafa, Alexander Kolesnikov, Lucas Beyer.
|
||||
1. **[SigLIP](https://huggingface.co/docs/transformers/model_doc/siglip)** (from Google AI) released with the paper [Sigmoid Loss for Language Image Pre-Training](https://arxiv.org/abs/2303.15343) by Xiaohua Zhai, Basil Mustafa, Alexander Kolesnikov, Lucas Beyer.
|
||||
1. **[SpeechT5](https://huggingface.co/docs/transformers/model_doc/speecht5)** (from Microsoft Research) released with the paper [SpeechT5: Unified-Modal Encoder-Decoder Pre-Training for Spoken Language Processing](https://arxiv.org/abs/2110.07205) by Junyi Ao, Rui Wang, Long Zhou, Chengyi Wang, Shuo Ren, Yu Wu, Shujie Liu, Tom Ko, Qing Li, Yu Zhang, Zhihua Wei, Yao Qian, Jinyu Li, Furu Wei.
|
||||
1. **[SpeechToTextTransformer](https://huggingface.co/docs/transformers/model_doc/speech_to_text)** (from Facebook), released together with the paper [fairseq S2T: Fast Speech-to-Text Modeling with fairseq](https://arxiv.org/abs/2010.05171) by Changhan Wang, Yun Tang, Xutai Ma, Anne Wu, Dmytro Okhonko, Juan Pino.
|
||||
1. **[SpeechToTextTransformer2](https://huggingface.co/docs/transformers/model_doc/speech_to_text_2)** (from Facebook) released with the paper [Large-Scale Self- and Semi-Supervised Learning for Speech Translation](https://arxiv.org/abs/2104.06678) by Changhan Wang, Anne Wu, Juan Pino, Alexei Baevski, Michael Auli, Alexis Conneau.
|
||||
|
@ -479,7 +479,7 @@ conda install conda-forge::transformers
|
|||
1. **[VITS](https://huggingface.co/docs/transformers/model_doc/vits)** (from Kakao Enterprise) released with the paper [Conditional Variational Autoencoder with Adversarial Learning for End-to-End Text-to-Speech](https://arxiv.org/abs/2106.06103) by Jaehyeon Kim, Jungil Kong, Juhee Son.
|
||||
1. **[ViViT](https://huggingface.co/docs/transformers/model_doc/vivit)** (from Google Research) released with the paper [ViViT: A Video Vision Transformer](https://arxiv.org/abs/2103.15691) by Anurag Arnab, Mostafa Dehghani, Georg Heigold, Chen Sun, Mario Lučić, Cordelia Schmid.
|
||||
1. **[Wav2Vec2](https://huggingface.co/docs/transformers/model_doc/wav2vec2)** (from Facebook AI) released with the paper [wav2vec 2.0: A Framework for Self-Supervised Learning of Speech Representations](https://arxiv.org/abs/2006.11477) by Alexei Baevski, Henry Zhou, Abdelrahman Mohamed, Michael Auli.
|
||||
1. **[Wav2Vec2-BERT](https://huggingface.co/docs/transformers/main/model_doc/wav2vec2-bert)** (from Meta AI) released with the paper [Seamless: Multilingual Expressive and Streaming Speech Translation](https://ai.meta.com/research/publications/seamless-multilingual-expressive-and-streaming-speech-translation/) by the Seamless Communication team.
|
||||
1. **[Wav2Vec2-BERT](https://huggingface.co/docs/transformers/model_doc/wav2vec2-bert)** (from Meta AI) released with the paper [Seamless: Multilingual Expressive and Streaming Speech Translation](https://ai.meta.com/research/publications/seamless-multilingual-expressive-and-streaming-speech-translation/) by the Seamless Communication team.
|
||||
1. **[Wav2Vec2-Conformer](https://huggingface.co/docs/transformers/model_doc/wav2vec2-conformer)** (from Facebook AI) released with the paper [FAIRSEQ S2T: Fast Speech-to-Text Modeling with FAIRSEQ](https://arxiv.org/abs/2010.05171) by Changhan Wang, Yun Tang, Xutai Ma, Anne Wu, Sravya Popuri, Dmytro Okhonko, Juan Pino.
|
||||
1. **[Wav2Vec2Phoneme](https://huggingface.co/docs/transformers/model_doc/wav2vec2_phoneme)** (from Facebook AI) released with the paper [Simple and Effective Zero-shot Cross-lingual Phoneme Recognition](https://arxiv.org/abs/2109.11680) by Qiantong Xu, Alexei Baevski, Michael Auli.
|
||||
1. **[WavLM](https://huggingface.co/docs/transformers/model_doc/wavlm)** (from Microsoft Research) released with the paper [WavLM: Large-Scale Self-Supervised Pre-Training for Full Stack Speech Processing](https://arxiv.org/abs/2110.13900) by Sanyuan Chen, Chengyi Wang, Zhengyang Chen, Yu Wu, Shujie Liu, Zhuo Chen, Jinyu Li, Naoyuki Kanda, Takuya Yoshioka, Xiong Xiao, Jian Wu, Long Zhou, Shuo Ren, Yanmin Qian, Yao Qian, Jian Wu, Michael Zeng, Furu Wei.
|
||||
|
|
|
@ -28,7 +28,7 @@ The abstract from the paper is the following:
|
|||
|
||||
- Usage of SigLIP is similar to [CLIP](clip). The main difference is the training loss, which does not require a global view of all the pairwise similarities of images and texts within a batch. One needs to apply the sigmoid activation function to the logits, rather than the softmax.
|
||||
- Training is not yet supported. If you want to fine-tune SigLIP or train from scratch, refer to the loss function from [OpenCLIP](https://github.com/mlfoundations/open_clip/blob/73ad04ae7fb93ede1c02dc9040a828634cb1edf1/src/open_clip/loss.py#L307), which leverages various `torch.distributed` utilities.
|
||||
- When using the standalone [`SiglipTokenizer`], make sure to pass `padding="max_length"` as that's how the model was trained. The multimodal [`SiglipProcessor`] takes care of this behind the scenes.
|
||||
- When using the standalone [`SiglipTokenizer`] or [`SiglipProcessor`], make sure to pass `padding="max_length"` as that's how the model was trained.
|
||||
|
||||
<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/siglip_table.jpeg"
|
||||
alt="drawing" width="600"/>
|
||||
|
@ -82,7 +82,8 @@ If you want to do the pre- and postprocessing yourself, here's how to do that:
|
|||
>>> image = Image.open(requests.get(url, stream=True).raw)
|
||||
|
||||
>>> texts = ["a photo of 2 cats", "a photo of 2 dogs"]
|
||||
>>> inputs = processor(text=texts, images=image, return_tensors="pt")
|
||||
>>> # important: we pass `padding=max_length` since the model was trained with this
|
||||
>>> inputs = processor(text=texts, images=image, padding="max_length", return_tensors="pt")
|
||||
|
||||
>>> with torch.no_grad():
|
||||
... outputs = model(**inputs)
|
||||
|
|
|
@ -62,7 +62,7 @@ from transformers.utils import check_min_version, send_example_telemetry
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
Array = Any
|
||||
Dataset = datasets.arrow_dataset.Dataset
|
||||
|
|
|
@ -60,7 +60,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risk.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=2.14.0", "To fix: pip install -r examples/flax/speech-recogintion/requirements.txt")
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ from transformers.utils import check_min_version, send_example_telemetry
|
|||
|
||||
logger = logging.getLogger(__name__)
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
Array = Any
|
||||
Dataset = datasets.arrow_dataset.Dataset
|
||||
|
|
|
@ -56,7 +56,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
logger = logging.getLogger(__name__)
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/token-classification/requirements.txt")
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ from transformers.utils.versions import require_version
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=1.14.0", "To fix: pip install -r examples/pytorch/audio-classification/requirements.txt")
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ from transformers.utils.versions import require_version
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/contrastive-image-text/requirements.txt")
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ from transformers.utils.versions import require_version
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/image-classification/requirements.txt")
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ from transformers.utils.versions import require_version
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/image-pretraining/requirements.txt")
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ Any model supported by the AutoModelForMaskedImageModeling API can be used.
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/image-pretraining/requirements.txt")
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ Any model supported by the AutoModelForMaskedImageModeling API can be used.
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/image-pretraining/requirements.txt")
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/language-modeling/requirements.txt")
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/language-modeling/requirements.txt")
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
logger = get_logger(__name__)
|
||||
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/language-modeling/requirements.txt")
|
||||
|
|
|
@ -48,7 +48,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/language-modeling/requirements.txt")
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ from transformers.utils import PaddingStrategy, check_min_version, send_example_
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ from transformers.utils import PaddingStrategy, check_min_version, send_example_
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
logger = get_logger(__name__)
|
||||
# You should update this to your particular problem to have better documentation of `model_type`
|
||||
|
|
|
@ -50,7 +50,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/question-answering/requirements.txt")
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/question-answering/requirements.txt")
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/question-answering/requirements.txt")
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/question-answering/requirements.txt")
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/question-answering/requirements.txt")
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ from transformers.utils.versions import require_version
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=2.0.0", "To fix: pip install -r examples/pytorch/semantic-segmentation/requirements.txt")
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=1.18.0", "To fix: pip install -r examples/pytorch/speech-recognition/requirements.txt")
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=1.18.0", "To fix: pip install -r examples/pytorch/speech-recognition/requirements.txt")
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=1.18.0", "To fix: pip install -r examples/pytorch/speech-recognition/requirements.txt")
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/summarization/requirements.txt")
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
logger = get_logger(__name__)
|
||||
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/summarization/requirements.txt")
|
||||
|
|
|
@ -48,7 +48,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/text-classification/requirements.txt")
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/text-classification/requirements.txt")
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/text-classification/requirements.txt")
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/token-classification/requirements.txt")
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
logger = get_logger(__name__)
|
||||
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/token-classification/requirements.txt")
|
||||
|
|
|
@ -53,7 +53,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/translation/requirements.txt")
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
logger = get_logger(__name__)
|
||||
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/translation/requirements.txt")
|
||||
|
|
|
@ -52,7 +52,7 @@ from transformers.utils.versions import require_version
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version(
|
||||
"datasets>=1.8.0", "To fix: pip install -r examples/tensorflow/contrastive-image-text/requirements.txt"
|
||||
|
|
|
@ -55,7 +55,7 @@ from transformers.utils.versions import require_version
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/image-classification/requirements.txt")
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ from transformers.utils import PaddingStrategy, check_min_version, send_example_
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ from transformers.utils import CONFIG_NAME, TF2_WEIGHTS_NAME, check_min_version,
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
# region Checking dependencies
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/summarization/requirements.txt")
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ from transformers.utils import check_min_version, send_example_telemetry
|
|||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
task_to_keys = {
|
||||
"cola": ("sentence", None),
|
||||
|
|
|
@ -57,7 +57,7 @@ from transformers.utils.versions import require_version
|
|||
|
||||
# region Dependencies and constants
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.37.0.dev0")
|
||||
check_min_version("4.37.0")
|
||||
|
||||
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/summarization/requirements.txt")
|
||||
|
||||
|
|
4
setup.py
4
setup.py
|
@ -158,7 +158,7 @@ _deps = [
|
|||
"ruff==0.1.5",
|
||||
"sacrebleu>=1.4.12,<2.0.0",
|
||||
"sacremoses",
|
||||
"safetensors>=0.3.1",
|
||||
"safetensors>=0.4.1",
|
||||
"sagemaker>=2.31.0",
|
||||
"scikit-learn",
|
||||
"sentencepiece>=0.1.91,!=0.1.92",
|
||||
|
@ -428,7 +428,7 @@ install_requires = [
|
|||
|
||||
setup(
|
||||
name="transformers",
|
||||
version="4.37.0.dev0", # expected format is one of x.y.z.dev0, or x.y.z.rc1 or x.y.z (no to dashes, yes to dots)
|
||||
version="4.37.2", # expected format is one of x.y.z.dev0, or x.y.z.rc1 or x.y.z (no to dashes, yes to dots)
|
||||
author="The Hugging Face team (past and future) with the help of all our contributors (https://github.com/huggingface/transformers/graphs/contributors)",
|
||||
author_email="transformers@huggingface.co",
|
||||
description="State-of-the-art Machine Learning for JAX, PyTorch and TensorFlow",
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
# to defer the actual importing for when the objects are requested. This way `import transformers` provides the names
|
||||
# in the namespace without actually importing anything (and especially none of the backends).
|
||||
|
||||
__version__ = "4.37.0.dev0"
|
||||
__version__ = "4.37.2"
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
|
@ -772,7 +772,6 @@ _import_structure = {
|
|||
"SiglipConfig",
|
||||
"SiglipProcessor",
|
||||
"SiglipTextConfig",
|
||||
"SiglipTokenizer",
|
||||
"SiglipVisionConfig",
|
||||
],
|
||||
"models.speech_encoder_decoder": ["SpeechEncoderDecoderConfig"],
|
||||
|
@ -1124,6 +1123,7 @@ else:
|
|||
_import_structure["models.reformer"].append("ReformerTokenizer")
|
||||
_import_structure["models.rembert"].append("RemBertTokenizer")
|
||||
_import_structure["models.seamless_m4t"].append("SeamlessM4TTokenizer")
|
||||
_import_structure["models.siglip"].append("SiglipTokenizer")
|
||||
_import_structure["models.speech_to_text"].append("Speech2TextTokenizer")
|
||||
_import_structure["models.speecht5"].append("SpeechT5Tokenizer")
|
||||
_import_structure["models.t5"].append("T5Tokenizer")
|
||||
|
@ -5494,7 +5494,6 @@ if TYPE_CHECKING:
|
|||
SiglipConfig,
|
||||
SiglipProcessor,
|
||||
SiglipTextConfig,
|
||||
SiglipTokenizer,
|
||||
SiglipVisionConfig,
|
||||
)
|
||||
from .models.speech_encoder_decoder import SpeechEncoderDecoderConfig
|
||||
|
@ -5843,6 +5842,7 @@ if TYPE_CHECKING:
|
|||
from .models.reformer import ReformerTokenizer
|
||||
from .models.rembert import RemBertTokenizer
|
||||
from .models.seamless_m4t import SeamlessM4TTokenizer
|
||||
from .models.siglip import SiglipTokenizer
|
||||
from .models.speech_to_text import Speech2TextTokenizer
|
||||
from .models.speecht5 import SpeechT5Tokenizer
|
||||
from .models.t5 import T5Tokenizer
|
||||
|
|
|
@ -330,10 +330,11 @@ def convert_pt_checkpoint_to_tf(
|
|||
if compare_with_pt_model:
|
||||
tfo = tf_model(tf_model.dummy_inputs, training=False) # build the network
|
||||
|
||||
weights_only_kwarg = {"weights_only": True} if is_torch_greater_or_equal_than_1_13 else {}
|
||||
state_dict = torch.load(
|
||||
pytorch_checkpoint_path,
|
||||
map_location="cpu",
|
||||
weights_only=is_torch_greater_or_equal_than_1_13,
|
||||
**weights_only_kwarg,
|
||||
)
|
||||
pt_model = pt_model_class.from_pretrained(
|
||||
pretrained_model_name_or_path=None, config=config, state_dict=state_dict
|
||||
|
|
|
@ -64,7 +64,7 @@ deps = {
|
|||
"ruff": "ruff==0.1.5",
|
||||
"sacrebleu": "sacrebleu>=1.4.12,<2.0.0",
|
||||
"sacremoses": "sacremoses",
|
||||
"safetensors": "safetensors>=0.3.1",
|
||||
"safetensors": "safetensors>=0.4.1",
|
||||
"sagemaker": "sagemaker>=2.31.0",
|
||||
"scikit-learn": "scikit-learn",
|
||||
"sentencepiece": "sentencepiece>=0.1.91,!=0.1.92",
|
||||
|
|
|
@ -171,12 +171,16 @@ class AssistedCandidateGenerator(CandidateGenerator):
|
|||
"""
|
||||
input_ids = input_ids.to(self.assistant_model.device)
|
||||
|
||||
# Don't generate more than `max_length - 1` candidates since the target model generates one extra token.
|
||||
new_cur_len = input_ids.shape[-1]
|
||||
max_new_tokens = min(int(self.num_assistant_tokens), self.generation_config.max_length - new_cur_len - 1)
|
||||
if max_new_tokens == 0:
|
||||
return input_ids, None
|
||||
|
||||
# 1. If it is not the first round of candidate generation, prepare the inputs based on the input_ids length
|
||||
# (which implicitly contains the number of accepted candidates from the previous round)
|
||||
has_past_key_values = self.assistant_kwargs.get("past_key_values", None) is not None
|
||||
if has_past_key_values:
|
||||
new_cur_len = input_ids.shape[-1]
|
||||
|
||||
new_cache_size = new_cur_len - 1
|
||||
self.assistant_kwargs["past_key_values"] = _crop_past_key_values(
|
||||
self.assistant_model, self.assistant_kwargs["past_key_values"], new_cache_size - 1
|
||||
|
@ -190,7 +194,7 @@ class AssistedCandidateGenerator(CandidateGenerator):
|
|||
# 2. Forecast next N tokens using the assistant model.
|
||||
assistant_generation_kwargs = {
|
||||
self.input_ids_key: input_ids,
|
||||
"max_new_tokens": int(self.num_assistant_tokens),
|
||||
"max_new_tokens": max_new_tokens,
|
||||
"generation_config": self.generation_config,
|
||||
"logits_processor": self.logits_processor,
|
||||
}
|
||||
|
|
|
@ -95,6 +95,7 @@ class LogitsProcessorList(list):
|
|||
scores = processor(input_ids, scores, **kwargs)
|
||||
else:
|
||||
scores = processor(input_ids, scores)
|
||||
|
||||
return scores
|
||||
|
||||
|
||||
|
@ -1657,6 +1658,9 @@ class SuppressTokensAtBeginLogitsProcessor(LogitsProcessor):
|
|||
self.begin_suppress_tokens = list(begin_suppress_tokens)
|
||||
self.begin_index = begin_index
|
||||
|
||||
def set_begin_index(self, begin_index):
|
||||
self.begin_index = begin_index
|
||||
|
||||
@add_start_docstrings(LOGITS_PROCESSOR_INPUTS_DOCSTRING)
|
||||
def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor) -> torch.FloatTensor:
|
||||
if input_ids.shape[1] == self.begin_index:
|
||||
|
@ -1778,6 +1782,7 @@ class WhisperTimeStampLogitsProcessor(LogitsProcessor):
|
|||
max_initial_timestamp_index (`int`, *optional*, defaults to 1):
|
||||
Used to set the maximum value of the initial timestamp. This is used to prevent the model from
|
||||
predicting timestamps that are too far in the future.
|
||||
begin_index (`Optional`, *optional*): Token index of the first token that is generated by the model.
|
||||
_detect_timestamp_from_logprob (`bool`, *optional*): Whether timestamps can be predicted from logprobs over all timestamps.
|
||||
|
||||
Examples:
|
||||
|
@ -1810,11 +1815,11 @@ class WhisperTimeStampLogitsProcessor(LogitsProcessor):
|
|||
"""
|
||||
|
||||
def __init__(
|
||||
self, generate_config, _detect_timestamp_from_logprob: Optional[bool] = None
|
||||
self, generate_config, begin_index: Optional[int] = None, _detect_timestamp_from_logprob: Optional[bool] = None
|
||||
): # support for the kwargs
|
||||
self.eos_token_id = generate_config.eos_token_id
|
||||
self.no_timestamps_token_id = generate_config.no_timestamps_token_id
|
||||
self.timestamp_begin = generate_config.no_timestamps_token_id + 1
|
||||
self.eos_token_id = generate_config.eos_token_id or generate_config.bos_token_id
|
||||
|
||||
# this variable is mostly just used for testing
|
||||
self._detect_timestamp_from_logprob = (
|
||||
|
@ -1823,10 +1828,17 @@ class WhisperTimeStampLogitsProcessor(LogitsProcessor):
|
|||
else getattr(generate_config, "_detect_timestamp_from_logprob", True)
|
||||
)
|
||||
|
||||
self.begin_index = (
|
||||
len(generate_config.forced_decoder_ids) + 1 if generate_config.forced_decoder_ids is not None else 1
|
||||
num_forced_ids = (
|
||||
len(generate_config.forced_decoder_ids) if generate_config.forced_decoder_ids is not None else 0
|
||||
)
|
||||
self.begin_index = begin_index or (num_forced_ids + 1)
|
||||
|
||||
self.max_initial_timestamp_index = getattr(generate_config, "max_initial_timestamp_index", None)
|
||||
# TODO(Patrick): Make sure that official models have max_initial_timestamp_index set to 50
|
||||
# self.max_initial_timestamp_index = 50
|
||||
|
||||
def set_begin_index(self, begin_index):
|
||||
self.begin_index = begin_index
|
||||
|
||||
@add_start_docstrings(LOGITS_PROCESSOR_INPUTS_DOCSTRING)
|
||||
def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor) -> torch.FloatTensor:
|
||||
|
@ -1878,6 +1890,60 @@ class WhisperTimeStampLogitsProcessor(LogitsProcessor):
|
|||
return scores
|
||||
|
||||
|
||||
class WhisperNoSpeechDetection(LogitsProcessor):
|
||||
r"""This processor can be used to detect silence when using Whisper. It should take as input unprocessed logits to follow the original implementation"""
|
||||
|
||||
def __init__(self, no_speech_token: int, begin_index: int, scores_is_logprobs: bool = False):
|
||||
self.no_speech_token = no_speech_token
|
||||
# offset between <start-of-transcription> token, <SOT>, in paper and first generated token
|
||||
# is equal to the position of the first generated token index
|
||||
self.start_of_trans_offset = begin_index
|
||||
|
||||
# `self.begin_index` is a running value that is changed on the fly
|
||||
self.begin_index = begin_index
|
||||
self._no_speech_prob = [0.0]
|
||||
self.is_scores_logprobs = scores_is_logprobs
|
||||
|
||||
# overwritten dynamically
|
||||
self.model = None
|
||||
self.inputs = None
|
||||
|
||||
def set_model(self, model):
|
||||
self.model = model
|
||||
|
||||
def set_inputs(self, inputs):
|
||||
self.inputs = {**self.model.prepare_inputs_for_generation(**inputs), **inputs}
|
||||
self.inputs["input_features"] = self.inputs.pop("inputs")
|
||||
|
||||
@property
|
||||
def no_speech_prob(self):
|
||||
return self._no_speech_prob
|
||||
|
||||
def set_begin_index(self, begin_index):
|
||||
self.begin_index = begin_index
|
||||
|
||||
@add_start_docstrings(LOGITS_PROCESSOR_INPUTS_DOCSTRING)
|
||||
def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor) -> torch.FloatTensor:
|
||||
if input_ids.shape[1] == self.begin_index:
|
||||
if self.start_of_trans_offset > 1:
|
||||
with torch.no_grad():
|
||||
logits = self.model(**self.inputs).logits
|
||||
|
||||
no_speech_index = self.begin_index - self.start_of_trans_offset
|
||||
no_speech_scores = logits[:, no_speech_index]
|
||||
else:
|
||||
no_speech_scores = scores
|
||||
|
||||
if self.is_scores_logprobs:
|
||||
probs = no_speech_scores.exp()
|
||||
else:
|
||||
probs = no_speech_scores.float().softmax(dim=-1)
|
||||
|
||||
self._no_speech_prob = probs[:, self.no_speech_token]
|
||||
|
||||
return scores
|
||||
|
||||
|
||||
class ClassifierFreeGuidanceLogitsProcessor(LogitsProcessor):
|
||||
r"""
|
||||
[`LogitsProcessor`] for classifier free guidance (CFG). The scores are split over the batch dimension,
|
||||
|
|
|
@ -289,6 +289,11 @@ BeamSampleDecoderOnlyOutput = GenerateBeamDecoderOnlyOutput
|
|||
BeamSearchEncoderDecoderOutput = GenerateBeamEncoderDecoderOutput
|
||||
BeamSampleEncoderDecoderOutput = GenerateBeamEncoderDecoderOutput
|
||||
|
||||
GreedySearchOutput = Union[GreedySearchEncoderDecoderOutput, GreedySearchDecoderOnlyOutput]
|
||||
SampleOutput = Union[SampleEncoderDecoderOutput, SampleDecoderOnlyOutput]
|
||||
BeamSearchOutput = Union[BeamSearchEncoderDecoderOutput, BeamSearchDecoderOnlyOutput]
|
||||
BeamSampleOutput = Union[BeamSampleEncoderDecoderOutput, BeamSampleDecoderOnlyOutput]
|
||||
ContrastiveSearchOutput = Union[ContrastiveSearchEncoderDecoderOutput, ContrastiveSearchDecoderOnlyOutput]
|
||||
|
||||
# Typing shortcuts
|
||||
GenerateNonBeamOutput = Union[GenerateDecoderOnlyOutput, GenerateEncoderDecoderOutput]
|
||||
|
@ -518,6 +523,8 @@ class GenerationMixin:
|
|||
# exception: Donut checkpoints have task-specific decoder starts and don't expect a BOS token
|
||||
elif self.config.model_type == "vision-encoder-decoder" and "donut" in self.name_or_path.lower():
|
||||
pass
|
||||
elif self.config.model_type in ["whisper"]:
|
||||
pass
|
||||
# user input but doesn't start with decoder_start_token_id -> prepend decoder_start_token_id (and adjust
|
||||
# decoder_attention_mask if provided)
|
||||
elif (decoder_input_ids[:, 0] != decoder_start_token_id).all().item():
|
||||
|
@ -4393,7 +4400,7 @@ class GenerationMixin:
|
|||
else:
|
||||
selected_tokens = new_logits.argmax(dim=-1)
|
||||
|
||||
candidate_new_tokens = candidate_input_ids[:, -candidate_length:]
|
||||
candidate_new_tokens = candidate_input_ids[:, cur_len:]
|
||||
n_matches = ((~(candidate_new_tokens == selected_tokens[:, :-1])).cumsum(dim=-1) < 1).sum()
|
||||
|
||||
# Ensure we don't generate beyond max_len or an EOS token
|
||||
|
@ -4529,12 +4536,13 @@ def _speculative_sampling(
|
|||
|
||||
NOTE: Unless otherwise stated, the variable names match those in the paper.
|
||||
"""
|
||||
new_candidate_input_ids = candidate_input_ids[:, -candidate_length:]
|
||||
# Gets the probabilities from the logits. q_i and p_i denote the assistant and model probabilities of the tokens
|
||||
# selected by the assistant, respectively.
|
||||
q = candidate_logits.softmax(dim=-1)
|
||||
q_i = q[:, torch.arange(candidate_length), candidate_input_ids[:, -candidate_length:]].squeeze(0, 1)
|
||||
q_i = q[:, torch.arange(candidate_length), new_candidate_input_ids].squeeze(0, 1)
|
||||
p = new_logits.softmax(dim=-1)
|
||||
p_i = p[:, torch.arange(candidate_length), candidate_input_ids[:, -candidate_length:]].squeeze(0, 1)
|
||||
p_i = p[:, torch.arange(candidate_length), new_candidate_input_ids].squeeze(0, 1)
|
||||
probability_ratio = p_i / q_i
|
||||
|
||||
# When probability_ratio > 1 (i.e. q_i(x) < p_i(x), or "assistant probability of the candidate token is smaller
|
||||
|
@ -4542,28 +4550,33 @@ def _speculative_sampling(
|
|||
# (= keep with p = probability_ratio). Keep all the tokens until the first rejection
|
||||
r_i = torch.rand_like(probability_ratio)
|
||||
is_accepted = r_i <= probability_ratio
|
||||
n_matches = (~is_accepted.cumsum(dim=-1) < 1).sum() # this is `n` in algorithm 1
|
||||
n_matches = ((~is_accepted).cumsum(dim=-1) < 1).sum() # this is `n` in algorithm 1
|
||||
|
||||
# Ensure we don't generate beyond max_len or an EOS token (not in algorithm 1, but needed for correct behavior)
|
||||
if last_assistant_token_is_eos and n_matches == candidate_length:
|
||||
# Output length is assumed to be `n_matches + 1`. Since we won't generate another token with the target model
|
||||
# due to acceptance on EOS we fix `n_matches`
|
||||
n_matches -= 1
|
||||
n_matches = min(n_matches, max_matches)
|
||||
|
||||
# Next token selection: if there is a rejection, adjust the distribution from the main model before sampling.
|
||||
gamma = candidate_logits.shape[1]
|
||||
p_n_plus_1 = p[:, n_matches, :]
|
||||
if n_matches < gamma:
|
||||
q_n_plus_1 = q[:, n_matches, :]
|
||||
p_prime = torch.clamp((p_n_plus_1 - q_n_plus_1), min=0).softmax(dim=-1)
|
||||
valid_tokens = new_candidate_input_ids[:, : n_matches + 1]
|
||||
else:
|
||||
p_prime = p_n_plus_1
|
||||
t = torch.multinomial(p_prime, num_samples=1).squeeze(1)[None, :]
|
||||
n_matches = min(n_matches, max_matches)
|
||||
|
||||
# The selected tokens include the matches (if any) plus the next sampled tokens
|
||||
if n_matches > 0:
|
||||
valid_tokens = torch.cat((candidate_input_ids[:, -n_matches:], t), dim=-1)
|
||||
else:
|
||||
valid_tokens = t
|
||||
# Next token selection: if there is a rejection, adjust the distribution from the main model before sampling.
|
||||
gamma = min(candidate_logits.shape[1], max_matches)
|
||||
p_n_plus_1 = p[:, n_matches, :]
|
||||
if n_matches < gamma:
|
||||
q_n_plus_1 = q[:, n_matches, :]
|
||||
p_prime = torch.clamp((p_n_plus_1 - q_n_plus_1), min=0)
|
||||
p_prime.div_(p_prime.sum())
|
||||
else:
|
||||
p_prime = p_n_plus_1
|
||||
t = torch.multinomial(p_prime, num_samples=1).squeeze(1)[None, :]
|
||||
|
||||
# The selected tokens include the matches (if any) plus the next sampled tokens
|
||||
if n_matches > 0:
|
||||
valid_tokens = torch.cat((new_candidate_input_ids[:, :n_matches], t), dim=-1)
|
||||
else:
|
||||
valid_tokens = t
|
||||
|
||||
return valid_tokens, n_matches
|
||||
|
||||
|
|
|
@ -27,10 +27,13 @@ from flax.traverse_util import flatten_dict, unflatten_dict
|
|||
|
||||
import transformers
|
||||
|
||||
from . import is_safetensors_available
|
||||
from . import is_safetensors_available, is_torch_available
|
||||
from .utils import logging
|
||||
|
||||
|
||||
if is_torch_available():
|
||||
import torch
|
||||
|
||||
if is_safetensors_available():
|
||||
from safetensors import safe_open
|
||||
from safetensors.flax import load_file as safe_load_file
|
||||
|
@ -48,17 +51,6 @@ def load_pytorch_checkpoint_in_flax_state_dict(
|
|||
flax_model, pytorch_checkpoint_path, is_sharded, allow_missing_keys=False
|
||||
):
|
||||
"""Load pytorch checkpoints in a flax model"""
|
||||
try:
|
||||
import torch # noqa: F401
|
||||
|
||||
from .pytorch_utils import is_torch_greater_or_equal_than_1_13 # noqa: F401
|
||||
except (ImportError, ModuleNotFoundError):
|
||||
logger.error(
|
||||
"Loading a PyTorch model in Flax, requires both PyTorch and Flax to be installed. Please see"
|
||||
" https://pytorch.org/ and https://flax.readthedocs.io/en/latest/installation.html for installation"
|
||||
" instructions."
|
||||
)
|
||||
raise
|
||||
|
||||
if not is_sharded:
|
||||
pt_path = os.path.abspath(pytorch_checkpoint_path)
|
||||
|
@ -66,12 +58,25 @@ def load_pytorch_checkpoint_in_flax_state_dict(
|
|||
|
||||
if pt_path.endswith(".safetensors"):
|
||||
pt_state_dict = {}
|
||||
with safe_open(pt_path, framework="pt") as f:
|
||||
with safe_open(pt_path, framework="flax") as f:
|
||||
for k in f.keys():
|
||||
pt_state_dict[k] = f.get_tensor(k)
|
||||
else:
|
||||
pt_state_dict = torch.load(pt_path, map_location="cpu", weights_only=is_torch_greater_or_equal_than_1_13)
|
||||
logger.info(f"PyTorch checkpoint contains {sum(t.numel() for t in pt_state_dict.values()):,} parameters.")
|
||||
try:
|
||||
import torch # noqa: F401
|
||||
|
||||
from .pytorch_utils import is_torch_greater_or_equal_than_1_13 # noqa: F401
|
||||
except (ImportError, ModuleNotFoundError):
|
||||
logger.error(
|
||||
"Loading a PyTorch model in Flax, requires both PyTorch and Flax to be installed. Please see"
|
||||
" https://pytorch.org/ and https://flax.readthedocs.io/en/latest/installation.html for installation"
|
||||
" instructions."
|
||||
)
|
||||
raise
|
||||
|
||||
weights_only_kwarg = {"weights_only": True} if is_torch_greater_or_equal_than_1_13 else {}
|
||||
pt_state_dict = torch.load(pt_path, map_location="cpu", **weights_only_kwarg)
|
||||
logger.info(f"PyTorch checkpoint contains {sum(t.numel() for t in pt_state_dict.values()):,} parameters.")
|
||||
|
||||
flax_state_dict = convert_pytorch_state_dict_to_flax(pt_state_dict, flax_model)
|
||||
else:
|
||||
|
@ -149,21 +154,17 @@ def rename_key_and_reshape_tensor(
|
|||
|
||||
def convert_pytorch_state_dict_to_flax(pt_state_dict, flax_model):
|
||||
# convert pytorch tensor to numpy
|
||||
# numpy currently does not support bfloat16, need to go over float32 in this case to not lose precision
|
||||
try:
|
||||
import torch # noqa: F401
|
||||
except (ImportError, ModuleNotFoundError):
|
||||
logger.error(
|
||||
"Loading a PyTorch model in Flax, requires both PyTorch and Flax to be installed. Please see"
|
||||
" https://pytorch.org/ and https://flax.readthedocs.io/en/latest/installation.html for installation"
|
||||
" instructions."
|
||||
)
|
||||
raise
|
||||
from_bin = is_torch_available() and isinstance(next(iter(pt_state_dict.values())), torch.Tensor)
|
||||
bfloat16 = torch.bfloat16 if from_bin else "bfloat16"
|
||||
|
||||
weight_dtypes = {k: v.dtype for k, v in pt_state_dict.items()}
|
||||
pt_state_dict = {
|
||||
k: v.numpy() if not v.dtype == torch.bfloat16 else v.float().numpy() for k, v in pt_state_dict.items()
|
||||
}
|
||||
|
||||
if from_bin:
|
||||
for k, v in pt_state_dict.items():
|
||||
# numpy currently does not support bfloat16, need to go over float32 in this case to not lose precision
|
||||
if v.dtype == bfloat16:
|
||||
v = v.float()
|
||||
pt_state_dict[k] = v.numpy()
|
||||
|
||||
model_prefix = flax_model.base_model_prefix
|
||||
|
||||
|
@ -191,7 +192,7 @@ def convert_pytorch_state_dict_to_flax(pt_state_dict, flax_model):
|
|||
# Need to change some parameters name to match Flax names
|
||||
for pt_key, pt_tensor in pt_state_dict.items():
|
||||
pt_tuple_key = tuple(pt_key.split("."))
|
||||
is_bfloat_16 = weight_dtypes[pt_key] == torch.bfloat16
|
||||
is_bfloat_16 = weight_dtypes[pt_key] == bfloat16
|
||||
|
||||
# remove base model prefix if necessary
|
||||
has_base_model_prefix = pt_tuple_key[0] == model_prefix
|
||||
|
@ -229,7 +230,6 @@ def convert_pytorch_state_dict_to_flax(pt_state_dict, flax_model):
|
|||
flax_state_dict[("params",) + flax_key] = (
|
||||
jnp.asarray(flax_tensor) if not is_bfloat_16 else jnp.asarray(flax_tensor, dtype=jnp.bfloat16)
|
||||
)
|
||||
|
||||
else:
|
||||
# also add unexpected weight so that warning is thrown
|
||||
flax_state_dict[flax_key] = (
|
||||
|
@ -253,7 +253,8 @@ def convert_pytorch_sharded_state_dict_to_flax(shard_filenames, flax_model):
|
|||
flax_state_dict = {}
|
||||
for shard_file in shard_filenames:
|
||||
# load using msgpack utils
|
||||
pt_state_dict = torch.load(shard_file, weights_only=is_torch_greater_or_equal_than_1_13)
|
||||
weights_only_kwarg = {"weights_only": True} if is_torch_greater_or_equal_than_1_13 else {}
|
||||
pt_state_dict = torch.load(shard_file, **weights_only_kwarg)
|
||||
pt_state_dict = {k: v.numpy() for k, v in pt_state_dict.items()}
|
||||
|
||||
model_prefix = flax_model.base_model_prefix
|
||||
|
|
|
@ -188,7 +188,8 @@ def load_pytorch_checkpoint_in_tf2_model(
|
|||
if pt_path.endswith(".safetensors"):
|
||||
state_dict = safe_load_file(pt_path)
|
||||
else:
|
||||
state_dict = torch.load(pt_path, map_location="cpu", weights_only=is_torch_greater_or_equal_than_1_13)
|
||||
weights_only_kwarg = {"weights_only": True} if is_torch_greater_or_equal_than_1_13 else {}
|
||||
state_dict = torch.load(pt_path, map_location="cpu", **weights_only_kwarg)
|
||||
|
||||
pt_state_dict.update(state_dict)
|
||||
|
||||
|
|
|
@ -482,11 +482,8 @@ def load_sharded_checkpoint(model, folder, strict=True, prefer_safe=True):
|
|||
error_message += f"\nMissing key(s): {str_unexpected_keys}."
|
||||
raise RuntimeError(error_message)
|
||||
|
||||
loader = (
|
||||
safe_load_file
|
||||
if load_safe
|
||||
else partial(torch.load, map_location="cpu", weights_only=is_torch_greater_or_equal_than_1_13)
|
||||
)
|
||||
weights_only_kwarg = {"weights_only": True} if is_torch_greater_or_equal_than_1_13 else {}
|
||||
loader = safe_load_file if load_safe else partial(torch.load, map_location="cpu", **weights_only_kwarg)
|
||||
|
||||
for shard_file in shard_files:
|
||||
state_dict = loader(os.path.join(folder, shard_file))
|
||||
|
@ -530,10 +527,11 @@ def load_state_dict(checkpoint_file: Union[str, os.PathLike]):
|
|||
and is_zipfile(checkpoint_file)
|
||||
):
|
||||
extra_args = {"mmap": True}
|
||||
weights_only_kwarg = {"weights_only": True} if is_torch_greater_or_equal_than_1_13 else {}
|
||||
return torch.load(
|
||||
checkpoint_file,
|
||||
map_location=map_location,
|
||||
weights_only=is_torch_greater_or_equal_than_1_13,
|
||||
**weights_only_kwarg,
|
||||
**extra_args,
|
||||
)
|
||||
except Exception as e:
|
||||
|
|
|
@ -379,7 +379,7 @@ else:
|
|||
"SeamlessM4TTokenizerFast" if is_tokenizers_available() else None,
|
||||
),
|
||||
),
|
||||
("siglip", ("SiglipTokenizer", None)),
|
||||
("siglip", ("SiglipTokenizer" if is_sentencepiece_available() else None, None)),
|
||||
("speech_to_text", ("Speech2TextTokenizer" if is_sentencepiece_available() else None, None)),
|
||||
("speech_to_text_2", ("Speech2Text2Tokenizer", None)),
|
||||
("speecht5", ("SpeechT5Tokenizer" if is_sentencepiece_available() else None, None)),
|
||||
|
|
|
@ -526,8 +526,8 @@ def attention_mask_func(attention_scores, ltor_mask):
|
|||
return attention_scores
|
||||
|
||||
|
||||
# Copied from transformers.models.llama.modeling_llama.LlamaRotaryEmbedding with LlamaRotary->GPTNeoXRotary
|
||||
class GPTNeoXRotaryEmbedding(nn.Module):
|
||||
# Copied from transformers.models.llama.modeling_llama.LlamaRotaryEmbedding.__init__
|
||||
def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None):
|
||||
super().__init__()
|
||||
|
||||
|
@ -549,8 +549,8 @@ class GPTNeoXRotaryEmbedding(nn.Module):
|
|||
freqs = torch.outer(t, self.inv_freq)
|
||||
# Different from paper, but it uses a different permutation in order to obtain the same calculation
|
||||
emb = torch.cat((freqs, freqs), dim=-1)
|
||||
self.register_buffer("cos_cached", emb.cos().to(dtype), persistent=False)
|
||||
self.register_buffer("sin_cached", emb.sin().to(dtype), persistent=False)
|
||||
self.register_buffer("cos_cached", emb.cos(), persistent=False)
|
||||
self.register_buffer("sin_cached", emb.sin(), persistent=False)
|
||||
|
||||
def forward(self, x, seq_len=None):
|
||||
# x: [bs, num_attention_heads, seq_len, head_size]
|
||||
|
@ -558,15 +558,15 @@ class GPTNeoXRotaryEmbedding(nn.Module):
|
|||
self._set_cos_sin_cache(seq_len=seq_len, device=x.device, dtype=x.dtype)
|
||||
|
||||
return (
|
||||
self.cos_cached[:seq_len].to(dtype=x.dtype),
|
||||
self.sin_cached[:seq_len].to(dtype=x.dtype),
|
||||
self.cos_cached[:seq_len],
|
||||
self.sin_cached[:seq_len],
|
||||
)
|
||||
|
||||
|
||||
# Copied from transformers.models.llama.modeling_llama.LlamaLinearScalingRotaryEmbedding with Llama->GPTNeoX
|
||||
class GPTNeoXLinearScalingRotaryEmbedding(GPTNeoXRotaryEmbedding):
|
||||
"""GPTNeoXRotaryEmbedding extended with linear scaling. Credits to the Reddit user /u/kaiokendev"""
|
||||
|
||||
# Copied from transformers.models.llama.modeling_llama.LlamaLinearScalingRotaryEmbedding.__init__
|
||||
def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, scaling_factor=1.0):
|
||||
self.scaling_factor = scaling_factor
|
||||
super().__init__(dim, max_position_embeddings, base, device)
|
||||
|
@ -579,14 +579,14 @@ class GPTNeoXLinearScalingRotaryEmbedding(GPTNeoXRotaryEmbedding):
|
|||
freqs = torch.outer(t, self.inv_freq)
|
||||
# Different from paper, but it uses a different permutation in order to obtain the same calculation
|
||||
emb = torch.cat((freqs, freqs), dim=-1)
|
||||
self.register_buffer("cos_cached", emb.cos().to(dtype), persistent=False)
|
||||
self.register_buffer("sin_cached", emb.sin().to(dtype), persistent=False)
|
||||
self.register_buffer("cos_cached", emb.cos(), persistent=False)
|
||||
self.register_buffer("sin_cached", emb.sin(), persistent=False)
|
||||
|
||||
|
||||
# Copied from transformers.models.llama.modeling_llama.LlamaDynamicNTKScalingRotaryEmbedding with Llama->GPTNeoX
|
||||
class GPTNeoXDynamicNTKScalingRotaryEmbedding(GPTNeoXRotaryEmbedding):
|
||||
"""GPTNeoXRotaryEmbedding extended with Dynamic NTK scaling. Credits to the Reddit users /u/bloc97 and /u/emozilla"""
|
||||
|
||||
# Copied from transformers.models.llama.modeling_llama.LlamaDynamicNTKScalingRotaryEmbedding.__init__
|
||||
def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, scaling_factor=1.0):
|
||||
self.scaling_factor = scaling_factor
|
||||
super().__init__(dim, max_position_embeddings, base, device)
|
||||
|
@ -606,8 +606,8 @@ class GPTNeoXDynamicNTKScalingRotaryEmbedding(GPTNeoXRotaryEmbedding):
|
|||
freqs = torch.outer(t, self.inv_freq)
|
||||
# Different from paper, but it uses a different permutation in order to obtain the same calculation
|
||||
emb = torch.cat((freqs, freqs), dim=-1)
|
||||
self.register_buffer("cos_cached", emb.cos().to(dtype), persistent=False)
|
||||
self.register_buffer("sin_cached", emb.sin().to(dtype), persistent=False)
|
||||
self.register_buffer("cos_cached", emb.cos(), persistent=False)
|
||||
self.register_buffer("sin_cached", emb.sin(), persistent=False)
|
||||
|
||||
|
||||
def rotate_half(x):
|
||||
|
|
|
@ -235,6 +235,7 @@ class GPTNeoXJapaneseAttention(nn.Module):
|
|||
|
||||
# Copied from transformers.models.gpt_neox.modeling_gpt_neox.GPTNeoXRotaryEmbedding with GPTNeoXRotaryEmbedding->RotaryEmbedding
|
||||
class RotaryEmbedding(nn.Module):
|
||||
# Copied from transformers.models.llama.modeling_llama.LlamaRotaryEmbedding.__init__
|
||||
def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None):
|
||||
super().__init__()
|
||||
|
||||
|
@ -256,8 +257,8 @@ class RotaryEmbedding(nn.Module):
|
|||
freqs = torch.outer(t, self.inv_freq)
|
||||
# Different from paper, but it uses a different permutation in order to obtain the same calculation
|
||||
emb = torch.cat((freqs, freqs), dim=-1)
|
||||
self.register_buffer("cos_cached", emb.cos().to(dtype), persistent=False)
|
||||
self.register_buffer("sin_cached", emb.sin().to(dtype), persistent=False)
|
||||
self.register_buffer("cos_cached", emb.cos(), persistent=False)
|
||||
self.register_buffer("sin_cached", emb.sin(), persistent=False)
|
||||
|
||||
def forward(self, x, seq_len=None):
|
||||
# x: [bs, num_attention_heads, seq_len, head_size]
|
||||
|
@ -265,8 +266,8 @@ class RotaryEmbedding(nn.Module):
|
|||
self._set_cos_sin_cache(seq_len=seq_len, device=x.device, dtype=x.dtype)
|
||||
|
||||
return (
|
||||
self.cos_cached[:seq_len].to(dtype=x.dtype),
|
||||
self.sin_cached[:seq_len].to(dtype=x.dtype),
|
||||
self.cos_cached[:seq_len],
|
||||
self.sin_cached[:seq_len],
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ from typing import TYPE_CHECKING
|
|||
from ...utils import (
|
||||
OptionalDependencyNotAvailable,
|
||||
_LazyModule,
|
||||
is_sentencepiece_available,
|
||||
is_torch_available,
|
||||
is_vision_available,
|
||||
)
|
||||
|
@ -29,9 +30,17 @@ _import_structure = {
|
|||
"SiglipVisionConfig",
|
||||
],
|
||||
"processing_siglip": ["SiglipProcessor"],
|
||||
"tokenization_siglip": ["SiglipTokenizer"],
|
||||
}
|
||||
|
||||
try:
|
||||
if not is_sentencepiece_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["tokenization_siglip"] = ["SiglipTokenizer"]
|
||||
|
||||
|
||||
try:
|
||||
if not is_vision_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
|
@ -63,7 +72,14 @@ if TYPE_CHECKING:
|
|||
SiglipVisionConfig,
|
||||
)
|
||||
from .processing_siglip import SiglipProcessor
|
||||
from .tokenization_siglip import SiglipTokenizer
|
||||
|
||||
try:
|
||||
if not is_sentencepiece_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .tokenization_siglip import SiglipTokenizer
|
||||
|
||||
try:
|
||||
if not is_vision_available():
|
||||
|
|
|
@ -1123,7 +1123,8 @@ class SiglipModel(SiglipPreTrainedModel):
|
|||
>>> image = Image.open(requests.get(url, stream=True).raw)
|
||||
|
||||
>>> texts = ["a photo of 2 cats", "a photo of 2 dogs"]
|
||||
>>> inputs = processor(text=texts, images=image, return_tensors="pt")
|
||||
>>> # important: we pass `padding=max_length` since the model was trained with this
|
||||
>>> inputs = processor(text=texts, images=image, padding="max_length", return_tensors="pt")
|
||||
|
||||
>>> with torch.no_grad():
|
||||
... outputs = model(**inputs)
|
||||
|
|
|
@ -50,9 +50,9 @@ class SiglipProcessor(ProcessorMixin):
|
|||
self,
|
||||
text: Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None,
|
||||
images: ImageInput = None,
|
||||
padding: Union[bool, str, PaddingStrategy] = "max_length",
|
||||
padding: Union[bool, str, PaddingStrategy] = False,
|
||||
truncation: Union[bool, str, TruncationStrategy] = None,
|
||||
max_length=None,
|
||||
max_length: int = None,
|
||||
return_tensors: Optional[Union[str, TensorType]] = TensorType.PYTORCH,
|
||||
) -> BatchFeature:
|
||||
"""
|
||||
|
@ -71,7 +71,7 @@ class SiglipProcessor(ProcessorMixin):
|
|||
The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
|
||||
tensor. In case of a NumPy array/PyTorch tensor, each image should be of shape (C, H, W), where C is a
|
||||
number of channels, H and W are image height and width.
|
||||
padding (`bool`, `str` or [`~utils.PaddingStrategy`], *optional*, defaults to `max_length`):
|
||||
padding (`bool`, `str` or [`~utils.PaddingStrategy`], *optional*, defaults to `False`):
|
||||
Select a strategy to pad the returned sequences (according to the model's padding side and padding
|
||||
index) among:
|
||||
- `True` or `'longest'`: Pad to the longest sequence in the batch (or no padding if only a single
|
||||
|
|
|
@ -1334,10 +1334,11 @@ class Wav2Vec2PreTrainedModel(PreTrainedModel):
|
|||
cache_dir=cache_dir,
|
||||
)
|
||||
|
||||
weights_only_kwarg = {"weights_only": True} if is_torch_greater_or_equal_than_1_13 else {}
|
||||
state_dict = torch.load(
|
||||
weight_path,
|
||||
map_location="cpu",
|
||||
weights_only=is_torch_greater_or_equal_than_1_13,
|
||||
**weights_only_kwarg,
|
||||
)
|
||||
|
||||
except EnvironmentError:
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -13,10 +13,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
""" PyTorch Whisper model."""
|
||||
|
||||
import copy
|
||||
import math
|
||||
import warnings
|
||||
from typing import Optional, Tuple, Union
|
||||
|
||||
import numpy as np
|
||||
|
@ -27,7 +24,6 @@ from torch import nn
|
|||
from torch.nn import CrossEntropyLoss
|
||||
|
||||
from ...activations import ACT2FN
|
||||
from ...generation.logits_process import WhisperTimeStampLogitsProcessor
|
||||
from ...modeling_attn_mask_utils import _prepare_4d_causal_attention_mask, _prepare_4d_causal_attention_mask_for_sdpa
|
||||
from ...modeling_outputs import (
|
||||
BaseModelOutput,
|
||||
|
@ -47,7 +43,7 @@ from ...utils import (
|
|||
replace_return_docstrings,
|
||||
)
|
||||
from .configuration_whisper import WhisperConfig
|
||||
from .tokenization_whisper import TASK_IDS, TO_LANGUAGE_CODE
|
||||
from .generation_whisper import WhisperGenerationMixin
|
||||
|
||||
|
||||
if is_flash_attn_2_available():
|
||||
|
@ -231,87 +227,15 @@ def _compute_mask_indices(
|
|||
return spec_aug_mask
|
||||
|
||||
|
||||
def _median_filter(inputs: torch.Tensor, filter_width: int) -> torch.Tensor:
|
||||
"""
|
||||
Applies a median filter of width `filter_width` along the last dimension of the input.
|
||||
|
||||
The `inputs` tensor is assumed to be 3- or 4-dimensional.
|
||||
"""
|
||||
if filter_width <= 0 or filter_width % 2 != 1:
|
||||
raise ValueError("`filter_width` should be an odd number")
|
||||
|
||||
pad_width = filter_width // 2
|
||||
if inputs.shape[-1] <= pad_width:
|
||||
return inputs
|
||||
|
||||
# Pad the left and right edges.
|
||||
inputs = nn.functional.pad(inputs, (pad_width, pad_width, 0, 0), mode="reflect")
|
||||
|
||||
# sort() is faster than torch.median (https://github.com/pytorch/pytorch/issues/51450)
|
||||
result = inputs.unfold(-1, filter_width, 1).sort()[0][..., pad_width]
|
||||
return result
|
||||
|
||||
|
||||
def _dynamic_time_warping(matrix: np.ndarray):
|
||||
"""
|
||||
Measures similarity between two temporal sequences: the input audio and the output tokens. Used to generate
|
||||
token-level timestamps.
|
||||
"""
|
||||
output_length, input_length = matrix.shape
|
||||
cost = np.ones((output_length + 1, input_length + 1), dtype=np.float32) * np.inf
|
||||
trace = -np.ones((output_length + 1, input_length + 1), dtype=np.float32)
|
||||
|
||||
cost[0, 0] = 0
|
||||
for j in range(1, input_length + 1):
|
||||
for i in range(1, output_length + 1):
|
||||
c0 = cost[i - 1, j - 1]
|
||||
c1 = cost[i - 1, j]
|
||||
c2 = cost[i, j - 1]
|
||||
|
||||
if c0 < c1 and c0 < c2:
|
||||
c, t = c0, 0
|
||||
elif c1 < c0 and c1 < c2:
|
||||
c, t = c1, 1
|
||||
else:
|
||||
c, t = c2, 2
|
||||
|
||||
cost[i, j] = matrix[i - 1, j - 1] + c
|
||||
trace[i, j] = t
|
||||
|
||||
# backtrace
|
||||
i = trace.shape[0] - 1
|
||||
j = trace.shape[1] - 1
|
||||
trace[0, :] = 2
|
||||
trace[:, 0] = 1
|
||||
|
||||
text_indices = []
|
||||
time_indices = []
|
||||
while i > 0 or j > 0:
|
||||
text_indices.append(i - 1)
|
||||
time_indices.append(j - 1)
|
||||
if trace[i, j] == 0:
|
||||
i -= 1
|
||||
j -= 1
|
||||
elif trace[i, j] == 1:
|
||||
i -= 1
|
||||
elif trace[i, j] == 2:
|
||||
j -= 1
|
||||
else:
|
||||
raise RuntimeError(
|
||||
f"Internal error in dynamic time warping. Unexpected trace[{i}, {j}]. Please file a bug report."
|
||||
)
|
||||
|
||||
text_indices = np.array(text_indices)[::-1]
|
||||
time_indices = np.array(time_indices)[::-1]
|
||||
return text_indices, time_indices
|
||||
|
||||
|
||||
class WhisperPositionalEmbedding(nn.Embedding):
|
||||
def __init__(self, num_positions: int, embedding_dim: int, padding_idx: Optional[int] = None):
|
||||
super().__init__(num_positions, embedding_dim)
|
||||
|
||||
def forward(self, input_ids, past_key_values_length=0):
|
||||
return self.weight[past_key_values_length : past_key_values_length + input_ids.shape[1]]
|
||||
def forward(self, input_ids, past_key_values_length=0, position_ids=None):
|
||||
if position_ids is None:
|
||||
return self.weight[past_key_values_length : past_key_values_length + input_ids.shape[1]]
|
||||
else:
|
||||
return self.weight[position_ids]
|
||||
|
||||
|
||||
class WhisperAttention(nn.Module):
|
||||
|
@ -1358,6 +1282,7 @@ class WhisperDecoder(WhisperPreTrainedModel):
|
|||
cross_attn_head_mask=None,
|
||||
past_key_values=None,
|
||||
inputs_embeds=None,
|
||||
position_ids=None,
|
||||
use_cache=None,
|
||||
output_attentions=None,
|
||||
output_hidden_states=None,
|
||||
|
@ -1461,9 +1386,13 @@ class WhisperDecoder(WhisperPreTrainedModel):
|
|||
|
||||
# embed positions
|
||||
if input_ids is not None:
|
||||
positions = self.embed_positions(input_ids, past_key_values_length=past_key_values_length)
|
||||
positions = self.embed_positions(
|
||||
input_ids, past_key_values_length=past_key_values_length, position_ids=position_ids
|
||||
)
|
||||
else:
|
||||
positions = self.embed_positions(inputs_embeds, past_key_values_length=past_key_values_length)
|
||||
positions = self.embed_positions(
|
||||
inputs_embeds, past_key_values_length=past_key_values_length, position_ids=position_ids
|
||||
)
|
||||
|
||||
hidden_states = inputs_embeds + positions
|
||||
hidden_states = nn.functional.dropout(hidden_states, p=self.dropout, training=self.training)
|
||||
|
@ -1645,6 +1574,7 @@ class WhisperModel(WhisperPreTrainedModel):
|
|||
encoder_outputs: Optional[Tuple[Tuple[torch.FloatTensor]]] = None,
|
||||
past_key_values: Optional[Tuple[Tuple[torch.FloatTensor]]] = None,
|
||||
decoder_inputs_embeds: Optional[Tuple[torch.FloatTensor]] = None,
|
||||
decoder_position_ids: Optional[Tuple[torch.LongTensor]] = None,
|
||||
use_cache: Optional[bool] = None,
|
||||
output_attentions: Optional[bool] = None,
|
||||
output_hidden_states: Optional[bool] = None,
|
||||
|
@ -1703,6 +1633,7 @@ class WhisperModel(WhisperPreTrainedModel):
|
|||
cross_attn_head_mask=cross_attn_head_mask,
|
||||
past_key_values=past_key_values,
|
||||
inputs_embeds=decoder_inputs_embeds,
|
||||
position_ids=decoder_position_ids,
|
||||
use_cache=use_cache,
|
||||
output_attentions=output_attentions,
|
||||
output_hidden_states=output_hidden_states,
|
||||
|
@ -1728,7 +1659,7 @@ class WhisperModel(WhisperPreTrainedModel):
|
|||
"The Whisper Model with a language modeling head. Can be used for automatic speech recognition.",
|
||||
WHISPER_START_DOCSTRING,
|
||||
)
|
||||
class WhisperForConditionalGeneration(WhisperPreTrainedModel):
|
||||
class WhisperForConditionalGeneration(WhisperGenerationMixin, WhisperPreTrainedModel):
|
||||
base_model_prefix = "model"
|
||||
_tied_weights_keys = ["proj_out.weight"]
|
||||
|
||||
|
@ -1776,6 +1707,7 @@ class WhisperForConditionalGeneration(WhisperPreTrainedModel):
|
|||
encoder_outputs: Optional[Tuple[Tuple[torch.FloatTensor]]] = None,
|
||||
past_key_values: Optional[Tuple[Tuple[torch.FloatTensor]]] = None,
|
||||
decoder_inputs_embeds: Optional[Tuple[torch.FloatTensor]] = None,
|
||||
decoder_position_ids: Optional[Tuple[torch.LongTensor]] = None,
|
||||
labels: Optional[torch.LongTensor] = None,
|
||||
use_cache: Optional[bool] = None,
|
||||
output_attentions: Optional[bool] = None,
|
||||
|
@ -1830,6 +1762,7 @@ class WhisperForConditionalGeneration(WhisperPreTrainedModel):
|
|||
cross_attn_head_mask=cross_attn_head_mask,
|
||||
past_key_values=past_key_values,
|
||||
decoder_inputs_embeds=decoder_inputs_embeds,
|
||||
decoder_position_ids=decoder_position_ids,
|
||||
use_cache=use_cache,
|
||||
output_attentions=output_attentions,
|
||||
output_hidden_states=output_hidden_states,
|
||||
|
@ -1860,647 +1793,6 @@ class WhisperForConditionalGeneration(WhisperPreTrainedModel):
|
|||
encoder_attentions=outputs.encoder_attentions,
|
||||
)
|
||||
|
||||
def generate(
|
||||
self,
|
||||
input_features: Optional[torch.Tensor] = None,
|
||||
generation_config=None,
|
||||
logits_processor=None,
|
||||
stopping_criteria=None,
|
||||
prefix_allowed_tokens_fn=None,
|
||||
synced_gpus=False,
|
||||
return_timestamps=None,
|
||||
task=None,
|
||||
language=None,
|
||||
is_multilingual=None,
|
||||
prompt_ids: Optional[torch.Tensor] = None,
|
||||
num_segment_frames: Optional[int] = None,
|
||||
return_token_timestamps: Optional[bool] = None,
|
||||
return_segments: bool = False,
|
||||
attention_mask: Optional[torch.Tensor] = None,
|
||||
time_precision: int = 0.02,
|
||||
return_dict_in_generate: Optional[bool] = None,
|
||||
**kwargs,
|
||||
):
|
||||
"""
|
||||
Transcribes or translates passed mel input features to a sequence of token ids.
|
||||
|
||||
<Tip warning={true}>
|
||||
|
||||
Most generation-controlling parameters are set in `generation_config` which, if not passed, will be set to the
|
||||
model's default generation configuration. You can override any `generation_config` by passing the corresponding
|
||||
parameters to generate(), e.g. `.generate(inputs, num_beams=4, do_sample=True)`.
|
||||
|
||||
For an overview of generation strategies and code examples, check out the [following
|
||||
guide](./generation_strategies).
|
||||
|
||||
</Tip>
|
||||
|
||||
Parameters:
|
||||
inputs (`torch.Tensor` of varying shape depending on the modality, *optional*):
|
||||
The sequence used as a prompt for the generation or as model inputs to the encoder. If `None` the
|
||||
method initializes it with `bos_token_id` and a batch size of 1. For decoder-only models `inputs`
|
||||
should of in the format of `input_ids`. For encoder-decoder models *inputs* can represent any of
|
||||
`input_ids`, `input_values`, `input_features`, or `pixel_values`.
|
||||
generation_config (`~generation.GenerationConfig`, *optional*):
|
||||
The generation configuration to be used as base parametrization for the generation call. `**kwargs`
|
||||
passed to generate matching the attributes of `generation_config` will override them. If
|
||||
`generation_config` is not provided, the default will be used, which had the following loading
|
||||
priority: 1) from the `generation_config.json` model file, if it exists; 2) from the model
|
||||
configuration. Please note that unspecified parameters will inherit [`~generation.GenerationConfig`]'s
|
||||
default values, whose documentation should be checked to parameterize generation.
|
||||
logits_processor (`LogitsProcessorList`, *optional*):
|
||||
Custom logits processors that complement the default logits processors built from arguments and
|
||||
generation config. If a logit processor is passed that is already created with the arguments or a
|
||||
generation config an error is thrown. This feature is intended for advanced users.
|
||||
stopping_criteria (`StoppingCriteriaList`, *optional*):
|
||||
Custom stopping criteria that complement the default stopping criteria built from arguments and a
|
||||
generation config. If a stopping criteria is passed that is already created with the arguments or a
|
||||
generation config an error is thrown. This feature is intended for advanced users.
|
||||
prefix_allowed_tokens_fn (`Callable[[int, torch.Tensor], List[int]]`, *optional*):
|
||||
If provided, this function constraints the beam search to allowed tokens only at each step. If not
|
||||
provided no constraint is applied. This function takes 2 arguments: the batch ID `batch_id` and
|
||||
`input_ids`. It has to return a list with the allowed tokens for the next generation step conditioned
|
||||
on the batch ID `batch_id` and the previously generated tokens `inputs_ids`. This argument is useful
|
||||
for constrained generation conditioned on the prefix, as described in [Autoregressive Entity
|
||||
Retrieval](https://arxiv.org/abs/2010.00904).
|
||||
synced_gpus (`bool`, *optional*, defaults to `False`):
|
||||
Whether to continue running the while loop until max_length (needed for ZeRO stage 3)
|
||||
return_timestamps (`bool`, *optional*):
|
||||
Whether to return the timestamps with the text. This enables the `WhisperTimestampsLogitsProcessor`.
|
||||
task (`str`, *optional*):
|
||||
Task to use for generation, either "translate" or "transcribe". The `model.config.forced_decoder_ids`
|
||||
will be updated accordingly.
|
||||
language (`str`, *optional*):
|
||||
Language token to use for generation, can be either in the form of `<|en|>`, `en` or `english`. You can
|
||||
find all the possible language tokens in the `model.generation_config.lang_to_id` dictionary.
|
||||
is_multilingual (`bool`, *optional*):
|
||||
Whether or not the model is multilingual.
|
||||
prompt_ids (`torch.Tensor`, *optional*):
|
||||
Rank-1 tensor of token IDs created by passing text to [`~WhisperProcessor.get_prompt_ids`] that is
|
||||
provided as a prompt to each chunk. This can be used to provide or "prompt-engineer" a context for
|
||||
transcription, e.g. custom vocabularies or proper nouns to make it more likely to predict those words
|
||||
correctly. It cannot be used in conjunction with `decoder_start_token_id` as it overwrites this value.
|
||||
return_token_timestamps (`bool`, *optional*):
|
||||
Whether to return token-level timestamps with the text. This can be used with or without the
|
||||
`return_timestamps` option. To get word-level timestamps, use the tokenizer to group the tokens into
|
||||
words.
|
||||
return_segments (`bool`, *optional*, defaults to `False`):
|
||||
Whether to additionally return a list of all segments. Note that this option can only be enabled
|
||||
when doing long-form transcription.
|
||||
attention_mask (`torch.Tensor`, *optional*):
|
||||
`attention_mask` needs to be passed when doing long-form transcription using a batch size > 1.
|
||||
time_precision (`int`, *optional*, defaults to 0.02):
|
||||
The duration of output token in seconds. *E.g.* 0.02 means that a generated token on average accounts
|
||||
for 20 ms.
|
||||
return_dict_in_generate (`bool`, *optional*, defaults to `False`):
|
||||
Whether or not to return a [`~utils.ModelOutput`] instead of just returning the generated tokens.
|
||||
Note that when doing long-form transcription, `return_dict_in_generate` can only be enabled when
|
||||
`return_segments` is set True. In this case the generation outputs of each segment is added to each
|
||||
segment.
|
||||
kwargs (`Dict[str, Any]`, *optional*):
|
||||
Ad hoc parametrization of `generate_config` and/or additional model-specific kwargs that will be
|
||||
forwarded to the `forward` function of the model. If the model is an encoder-decoder model, encoder
|
||||
specific kwargs should not be prefixed and decoder specific kwargs should be prefixed with *decoder_*.
|
||||
|
||||
Return:
|
||||
[`~utils.ModelOutput`] or `torch.LongTensor` or `Dict[str, Any]`: A [`~utils.ModelOutput`] (if `return_dict_in_generate=True`
|
||||
or when `config.return_dict_in_generate=True`) or a `torch.FloatTensor` or a dict of segments when `return_segments=True`.
|
||||
|
||||
If the passed input is > 30 seconds / > 3000 mel input features and `return_segments=True` then a dictionary of generated sequence ids, called `sequences` and a list of each generated segment is returned.
|
||||
|
||||
else if the passed input is <= 30 seconds / >= 3000 mel input features, the possible [`~utils.ModelOutput`] types are:
|
||||
|
||||
- [`~generation.GenerateEncoderDecoderOutput`],
|
||||
- [`~generation.GenerateBeamEncoderDecoderOutput`]
|
||||
|
||||
else only the generated output sequence ids are returned.
|
||||
|
||||
Example:
|
||||
|
||||
- *Longform transcription*: To transcribe or translate audios longer than 30 seconds, process the audio files without truncation and pass all mel features at once to generate.
|
||||
|
||||
```python
|
||||
>>> import torch
|
||||
>>> from transformers import AutoProcessor, WhisperForConditionalGeneration
|
||||
>>> from datasets import load_dataset, Audio
|
||||
|
||||
>>> processor = AutoProcessor.from_pretrained("openai/whisper-tiny.en")
|
||||
>>> model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny.en")
|
||||
>>> model.cuda()
|
||||
|
||||
>>> # load audios > 30 seconds
|
||||
>>> ds = load_dataset("distil-whisper/meanwhile", "default")["test"]
|
||||
>>> # resample to 16kHz
|
||||
>>> ds = ds.cast_column("audio", Audio(sampling_rate=16000))
|
||||
>>> # take first 8 audios and retrieve array
|
||||
>>> audio = ds[:8]["audio"]
|
||||
>>> audio = [x["array"] for x in audio]
|
||||
|
||||
>>> # make sure to NOT truncate the input audio, to return the `attention_mask` and to pad to the longest audio
|
||||
>>> inputs = processor(audio, return_tensors="pt", truncation=False, padding="longest", return_attention_mask=True, sampling_rate=16_000)
|
||||
>>> inputs = inputs.to("cuda", torch.float32)
|
||||
|
||||
>>> # transcribe audio to ids
|
||||
>>> generated_ids = model.generate(**inputs)
|
||||
|
||||
>>> transcription = processor.batch_decode(generated_ids, skip_special_tokens=True)
|
||||
>>> transcription[0]
|
||||
' Folks, if you watch the show, you know, I spent a lot of time right over there. Patiently and astutely scrutinizing the boxwood and mahogany chest set of the day's biggest stories developing the central headline pawns, definitely maneuvering an oso topical night to F6, fainting a classic Sicilian, nade door variation on the news, all the while seeing eight moves deep and patiently marshalling the latest press releases into a fisher's shows in Lip Nitsky attack that culminates in the elegant lethal slow-played, all-passant checkmate that is my nightly monologue. But sometimes, sometimes, folks, I. CHEERING AND APPLAUSE Sometimes I startle away, cubside down in the monkey bars of a condemned playground on a super fun site. Get all hept up on goofballs. Rummage that were discarded tag bag of defective toys. Yank out a fist bowl of disembodied doll limbs, toss them on a stained kid's place mat from a defunct dennies. set up a table inside a rusty cargo container down by the Wharf and challenged toothless drifters to the godless bughouse blitz of tournament that is my segment. Meanwhile!'
|
||||
```
|
||||
|
||||
- *Shortform transcription*: If passed mel input features are < 30 seconds, the whole audio will be transcribed with a single call to generate.
|
||||
|
||||
```python
|
||||
>>> import torch
|
||||
>>> from transformers import AutoProcessor, WhisperForConditionalGeneration
|
||||
>>> from datasets import load_dataset
|
||||
|
||||
>>> processor = AutoProcessor.from_pretrained("openai/whisper-tiny.en")
|
||||
>>> model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny.en")
|
||||
|
||||
>>> ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
|
||||
|
||||
>>> inputs = processor(ds[0]["audio"]["array"], return_tensors="pt")
|
||||
>>> input_features = inputs.input_features
|
||||
|
||||
>>> generated_ids = model.generate(inputs=input_features)
|
||||
|
||||
>>> transcription = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
||||
>>> transcription
|
||||
' Mr. Quilter is the apostle of the middle classes, and we are glad to welcome his gospel.'
|
||||
```
|
||||
|
||||
"""
|
||||
|
||||
if "inputs" in kwargs:
|
||||
input_features = kwargs.pop("inputs")
|
||||
warnings.warn(
|
||||
"The input name `inputs` is deprecated. Please make sure to use `input_features` instead.",
|
||||
FutureWarning,
|
||||
)
|
||||
|
||||
if generation_config is None:
|
||||
generation_config = copy.deepcopy(self.generation_config)
|
||||
|
||||
return_dict_in_generate = (
|
||||
return_dict_in_generate
|
||||
if return_dict_in_generate is not None
|
||||
else generation_config.return_dict_in_generate
|
||||
)
|
||||
|
||||
input_stride = self.model.encoder.conv1.stride[0] * self.model.encoder.conv2.stride[0]
|
||||
if num_segment_frames is None:
|
||||
num_segment_frames = input_stride * self.config.max_source_positions
|
||||
|
||||
# 1. Check whether we're in shortform or longform mode
|
||||
if input_features is not None:
|
||||
total_input_frames = input_features.shape[-1]
|
||||
elif "encoder_outputs" in kwargs:
|
||||
encoder_outputs_shape = (
|
||||
kwargs["encoder_outputs"][0].shape
|
||||
if isinstance(kwargs["encoder_outputs"], BaseModelOutput)
|
||||
else kwargs["encoder_outputs"].shape
|
||||
)
|
||||
total_input_frames = encoder_outputs_shape[1] * input_stride
|
||||
else:
|
||||
raise ValueError("Make sure to provide either `input_features` or `encoder_outputs` to `generate`.")
|
||||
|
||||
is_shortform = total_input_frames <= num_segment_frames
|
||||
|
||||
# 2. Make sure the generation config is correctly set depending on whether timestamps are to be returned or not
|
||||
if return_timestamps is True:
|
||||
if not hasattr(generation_config, "no_timestamps_token_id"):
|
||||
raise ValueError(
|
||||
"You are trying to return timestamps, but the generation config is not properly set. "
|
||||
"Make sure to initialize the generation config with the correct attributes that are needed such as `no_timestamps_token_id`. "
|
||||
"For more details on how to generate the approtiate config, refer to https://github.com/huggingface/transformers/issues/21878#issuecomment-1451902363"
|
||||
)
|
||||
generation_config.return_timestamps = return_timestamps
|
||||
elif not is_shortform:
|
||||
if return_timestamps is False:
|
||||
raise ValueError(
|
||||
"You have passed more than 3000 mel input features (> 30 seconds) which automatically enables long-form generation which "
|
||||
"requires the model to predict timestamp tokens. Please either pass `return_timestamps=True` or make sure to pass no more than 3000 mel input features."
|
||||
)
|
||||
|
||||
if not hasattr(generation_config, "no_timestamps_token_id"):
|
||||
raise ValueError(
|
||||
"You have passed more than 3000 mel input features (> 30 seconds) which automatically enables long-form generation which "
|
||||
"requires the generation config to have `no_timestamps_token_id` correctly. "
|
||||
"Make sure to initialize the generation config with the correct attributes that are needed such as `no_timestamps_token_id`. "
|
||||
"For more details on how to generate the approtiate config, refer to https://github.com/huggingface/transformers/issues/21878#issuecomment-1451902363"
|
||||
"or make sure to pass no more than 3000 mel input features."
|
||||
)
|
||||
|
||||
logger.info("Setting `return_timestamps=True` for long-form generation.")
|
||||
generation_config.return_timestamps = True
|
||||
else:
|
||||
generation_config.return_timestamps = False
|
||||
|
||||
# 3. Make sure to correctly set language-related parameters
|
||||
if is_multilingual is not None:
|
||||
if not hasattr(generation_config, "is_multilingual"):
|
||||
raise ValueError(
|
||||
"The generation config is outdated and is thus not compatible with the `is_multilingual` argument "
|
||||
"to `generate`. Please update the generation config as per the instructions "
|
||||
"https://github.com/huggingface/transformers/issues/25084#issuecomment-1664398224"
|
||||
)
|
||||
generation_config.is_multilingual = is_multilingual
|
||||
|
||||
if hasattr(generation_config, "is_multilingual") and not generation_config.is_multilingual:
|
||||
if task is not None or language is not None:
|
||||
raise ValueError(
|
||||
"Cannot specify `task` or `language` for an English-only model. If the model is intended to be "
|
||||
"multilingual, pass `is_multilingual=True` to generate, or update the generation config."
|
||||
)
|
||||
|
||||
if language is not None:
|
||||
if not hasattr(generation_config, "lang_to_id"):
|
||||
raise ValueError(
|
||||
"The generation config is outdated and is thus not compatible with the `language` argument "
|
||||
"to `generate`. Either set the language using the `forced_decoder_ids` in the model config, "
|
||||
"or update the generation config as per the instructions https://github.com/huggingface/transformers/issues/25084#issuecomment-1664398224"
|
||||
)
|
||||
language = language.lower()
|
||||
generation_config.language = language
|
||||
if task is not None:
|
||||
if not hasattr(generation_config, "task_to_id"):
|
||||
raise ValueError(
|
||||
"The generation config is outdated and is thus not compatible with the `task` argument "
|
||||
"to `generate`. Either set the task using the `forced_decoder_ids` in the model config, "
|
||||
"or update the generation config as per the instructions https://github.com/huggingface/transformers/issues/25084#issuecomment-1664398224"
|
||||
)
|
||||
generation_config.task = task
|
||||
|
||||
# 4. Add forced decoder ids depending on passed `language`, `task`,`prompt_ids`, `return_token_timestamps` and `return_timestamps`
|
||||
forced_decoder_ids = None
|
||||
# Legacy code for backward compatibility
|
||||
if hasattr(self.config, "forced_decoder_ids") and self.config.forced_decoder_ids is not None:
|
||||
forced_decoder_ids = self.config.forced_decoder_ids
|
||||
elif (
|
||||
hasattr(self.generation_config, "forced_decoder_ids")
|
||||
and self.generation_config.forced_decoder_ids is not None
|
||||
):
|
||||
forced_decoder_ids = self.generation_config.forced_decoder_ids
|
||||
else:
|
||||
forced_decoder_ids = kwargs.get("forced_decoder_ids", None)
|
||||
|
||||
if task is not None or language is not None or (forced_decoder_ids is None and prompt_ids is not None):
|
||||
forced_decoder_ids = []
|
||||
if hasattr(generation_config, "language"):
|
||||
if generation_config.language in generation_config.lang_to_id.keys():
|
||||
language_token = generation_config.language
|
||||
elif generation_config.language in TO_LANGUAGE_CODE.keys():
|
||||
language_token = f"<|{TO_LANGUAGE_CODE[generation_config.language]}|>"
|
||||
elif generation_config.language in TO_LANGUAGE_CODE.values():
|
||||
language_token = f"<|{generation_config.language}|>"
|
||||
else:
|
||||
is_language_code = len(generation_config.language) == 2
|
||||
raise ValueError(
|
||||
f"Unsupported language: {generation_config.language}. Language should be one of:"
|
||||
f" {list(TO_LANGUAGE_CODE.values()) if is_language_code else list(TO_LANGUAGE_CODE.keys())}."
|
||||
)
|
||||
if language_token not in generation_config.lang_to_id:
|
||||
raise ValueError(
|
||||
f"{language_token} is not supported by this specific model as it is not in the `generation_config.lang_to_id`."
|
||||
"(You should just add it to the generation config)"
|
||||
)
|
||||
forced_decoder_ids.append((1, generation_config.lang_to_id[language_token]))
|
||||
else:
|
||||
forced_decoder_ids.append((1, None)) # automatically detect the language
|
||||
|
||||
if hasattr(generation_config, "task"):
|
||||
if generation_config.task in TASK_IDS:
|
||||
forced_decoder_ids.append((2, generation_config.task_to_id[generation_config.task]))
|
||||
else:
|
||||
raise ValueError(
|
||||
f"The `{generation_config.task}`task is not supported. The task should be one of `{TASK_IDS}`"
|
||||
)
|
||||
elif hasattr(generation_config, "task_to_id"):
|
||||
forced_decoder_ids.append((2, generation_config.task_to_id["transcribe"])) # defaults to transcribe
|
||||
if hasattr(generation_config, "no_timestamps_token_id") and not generation_config.return_timestamps:
|
||||
idx = forced_decoder_ids[-1][0] + 1 if forced_decoder_ids else 1
|
||||
forced_decoder_ids.append((idx, generation_config.no_timestamps_token_id))
|
||||
|
||||
if forced_decoder_ids is not None:
|
||||
generation_config.forced_decoder_ids = forced_decoder_ids
|
||||
|
||||
if prompt_ids is not None:
|
||||
if kwargs.get("decoder_start_token_id") is not None:
|
||||
raise ValueError(
|
||||
"When specifying `prompt_ids`, you cannot also specify `decoder_start_token_id` as it gets overwritten."
|
||||
)
|
||||
prompt_ids = prompt_ids.tolist()
|
||||
decoder_start_token_id, *text_prompt_ids = prompt_ids
|
||||
# Slicing the text prompt ids in a manner consistent with the OpenAI implementation
|
||||
# to accomodate context space for the prefix (see https://github.com/openai/whisper/blob/c09a7ae299c4c34c5839a76380ae407e7d785914/whisper/decoding.py#L599)
|
||||
text_prompt_ids = text_prompt_ids[-self.config.max_target_positions // 2 - 1 :]
|
||||
# Set the decoder_start_token_id to <|startofprev|>
|
||||
kwargs.update({"decoder_start_token_id": decoder_start_token_id})
|
||||
|
||||
# If the user passes `max_new_tokens`, increase its number to account for the prompt
|
||||
if kwargs.get("max_new_tokens", None) is not None:
|
||||
kwargs["max_new_tokens"] += len(text_prompt_ids)
|
||||
if kwargs["max_new_tokens"] >= self.config.max_target_positions:
|
||||
raise ValueError(
|
||||
f"The length of the sliced `prompt_ids` is {len(text_prompt_ids)}, and the `max_new_tokens` "
|
||||
f"{kwargs['max_new_tokens'] - len(text_prompt_ids)}. Thus, the combined length of the sliced "
|
||||
f"`prompt_ids` and `max_new_tokens` is: {kwargs['max_new_tokens']}. This exceeds the "
|
||||
f"`max_target_positions` of the Whisper model: {self.config.max_target_positions}. "
|
||||
"You should either reduce the length of your prompt, or reduce the value of `max_new_tokens`, "
|
||||
f"so that their combined length is less that {self.config.max_target_positions}."
|
||||
)
|
||||
|
||||
# Reformat the forced_decoder_ids to incorporate the prompt
|
||||
non_prompt_forced_decoder_ids = (
|
||||
kwargs.pop("forced_decoder_ids", None) or generation_config.forced_decoder_ids
|
||||
)
|
||||
forced_decoder_ids = [
|
||||
*text_prompt_ids,
|
||||
generation_config.decoder_start_token_id,
|
||||
*[token for _rank, token in non_prompt_forced_decoder_ids],
|
||||
]
|
||||
forced_decoder_ids = [(rank + 1, token) for rank, token in enumerate(forced_decoder_ids)]
|
||||
generation_config.forced_decoder_ids = forced_decoder_ids
|
||||
|
||||
if return_token_timestamps:
|
||||
kwargs["output_attentions"] = True
|
||||
return_dict_in_generate = True
|
||||
kwargs["output_scores"] = True
|
||||
|
||||
if getattr(generation_config, "task", None) == "translate":
|
||||
logger.warning("Token-level timestamps may not be reliable for task 'translate'.")
|
||||
if not hasattr(generation_config, "alignment_heads"):
|
||||
raise ValueError(
|
||||
"Model generation config has no `alignment_heads`, token-level timestamps not available. "
|
||||
"See https://gist.github.com/hollance/42e32852f24243b748ae6bc1f985b13a on how to add this property to the generation config."
|
||||
)
|
||||
|
||||
if kwargs.get("num_frames") is not None:
|
||||
generation_config.num_frames = kwargs.pop("num_frames")
|
||||
|
||||
if generation_config.return_timestamps is True:
|
||||
last_forced_decoder_ids = (
|
||||
generation_config.forced_decoder_ids[-1][-1]
|
||||
if hasattr(self.config, "forced_decoder_ids") and self.config.forced_decoder_ids
|
||||
else None
|
||||
)
|
||||
if last_forced_decoder_ids == self.generation_config.no_timestamps_token_id:
|
||||
# remove no_timestamp to be forcefully generated if we want to return timestamps
|
||||
# this is also important to make sure `WhisperTimeStampLogitsProcessor` functions correctly
|
||||
forced_decoder_ids = generation_config.forced_decoder_ids[:-1]
|
||||
# Make sure that if list is empty we set it to None
|
||||
generation_config.forced_decoder_ids = None if len(forced_decoder_ids) == 0 else forced_decoder_ids
|
||||
|
||||
timestamp_processor = [WhisperTimeStampLogitsProcessor(generation_config)]
|
||||
logits_processor = (
|
||||
timestamp_processor if logits_processor is None else timestamp_processor + logits_processor
|
||||
)
|
||||
|
||||
# 5. If we're in shortform mode, simple generate the whole input at once and return the output
|
||||
if is_shortform:
|
||||
outputs = super().generate(
|
||||
input_features,
|
||||
generation_config,
|
||||
logits_processor,
|
||||
stopping_criteria,
|
||||
prefix_allowed_tokens_fn,
|
||||
synced_gpus,
|
||||
return_dict_in_generate=return_dict_in_generate,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
if return_token_timestamps and hasattr(generation_config, "alignment_heads"):
|
||||
num_frames = getattr(generation_config, "num_frames", None)
|
||||
outputs["token_timestamps"] = self._extract_token_timestamps(
|
||||
outputs, generation_config.alignment_heads, num_frames=num_frames
|
||||
)
|
||||
|
||||
return outputs
|
||||
|
||||
# 6. Else we're in longform mode which is more complex. We need to chunk the audio input depending on when the model generated
|
||||
# timestamp tokens
|
||||
# 6.1 Set running parameters for while loop
|
||||
if not return_segments and return_dict_in_generate:
|
||||
raise ValueError(
|
||||
"Make sure to set `return_segments=True` to return generation outputs as part of the `'segments' key.`"
|
||||
)
|
||||
|
||||
# if input is longer than 30 seconds we default to long-form generation
|
||||
timestamp_begin = self.generation_config.no_timestamps_token_id + 1
|
||||
# input stride is mel frames per encoder output vector which is the product of all conv strides
|
||||
batch_size = input_features.shape[0]
|
||||
|
||||
if batch_size > 1 and attention_mask is None:
|
||||
raise ValueError(
|
||||
"When doing long-form audio transcription, make sure to pass an `attention_mask`. You can retrieve the `attention_mask` by doing `processor(audio, ..., return_attention_mask=True)` "
|
||||
)
|
||||
elif batch_size > 1:
|
||||
max_frames = attention_mask.sum(-1).cpu().to(torch.long)
|
||||
seek = torch.zeros((batch_size,), dtype=torch.long)
|
||||
else:
|
||||
max_frames = torch.ones((1,), dtype=torch.long) * total_input_frames
|
||||
seek = torch.zeros((1,), dtype=torch.long)
|
||||
|
||||
current_segments = [[] for _ in range(batch_size)]
|
||||
cur_to_prev_index_map = list(range(batch_size))
|
||||
|
||||
# batch size can decrease during the run
|
||||
cur_bsz = prev_bsz = batch_size
|
||||
|
||||
# 6.2 Transcribe audio until we reach the end of all input audios
|
||||
while (seek < max_frames).any():
|
||||
prev_bsz = cur_bsz
|
||||
|
||||
# 6.3 NOTE: When in longform transcription mode and batch size > 1 we need to dynamically reduce the batch size during the loop
|
||||
# in case one audio finished earlier than another one. Thus, we need to keep a table of "previous-index-2-current-index" in order
|
||||
# to know which original audio is being decoded
|
||||
new_cur_to_prev_index_map = []
|
||||
for i in range(prev_bsz):
|
||||
prev_i = cur_to_prev_index_map[i]
|
||||
if seek[prev_i] >= max_frames[prev_i]:
|
||||
cut_index = i + (cur_bsz - prev_bsz)
|
||||
cur_bsz -= 1
|
||||
input_features = torch.cat([input_features[:cut_index], input_features[cut_index + 1 :]], dim=0)
|
||||
else:
|
||||
# cut out index that goes away
|
||||
new_cur_to_prev_index_map.append(prev_i)
|
||||
|
||||
# 6.4 Set updated index map, duration of previously decoded chunks and number of max frames of current decoding chunk
|
||||
cur_to_prev_index_map = new_cur_to_prev_index_map
|
||||
time_offset = seek * time_precision / input_stride
|
||||
seek_num_frames = (max_frames - seek).clamp(max=num_segment_frames)
|
||||
|
||||
# 6.5 Make sure that all inputs are padded to the same input length
|
||||
segment_input = []
|
||||
for i in range(cur_bsz):
|
||||
prev_i = cur_to_prev_index_map[i]
|
||||
segment_input_slice = input_features[
|
||||
i : i + 1, :, seek[prev_i] : seek[prev_i] + seek_num_frames[prev_i]
|
||||
]
|
||||
|
||||
if segment_input_slice.shape[-1] < num_segment_frames:
|
||||
# pad to 3000 if necessary
|
||||
segment_input_slice = F.pad(
|
||||
segment_input_slice, pad=(0, num_segment_frames - segment_input_slice.shape[-1])
|
||||
)
|
||||
|
||||
segment_input.append(segment_input_slice)
|
||||
|
||||
segment_input = torch.cat(segment_input, dim=0)
|
||||
|
||||
# 6.6 Batch generate current chunk
|
||||
seek_outputs = super().generate(
|
||||
segment_input,
|
||||
generation_config,
|
||||
logits_processor,
|
||||
stopping_criteria,
|
||||
prefix_allowed_tokens_fn,
|
||||
synced_gpus,
|
||||
return_dict_in_generate=return_dict_in_generate,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
if return_token_timestamps and hasattr(generation_config, "alignment_heads"):
|
||||
num_frames = getattr(generation_config, "num_frames", None)
|
||||
seek_outputs["token_timestamps"] = self._extract_token_timestamps(
|
||||
seek_outputs, generation_config.alignment_heads, num_frames=num_frames
|
||||
)
|
||||
|
||||
if return_dict_in_generate:
|
||||
seek_sequences = seek_outputs["sequences"]
|
||||
seek_outputs = [
|
||||
{k: v[i] for k, v in seek_outputs.items()}
|
||||
for i in range(next(iter(seek_outputs.values())).size(0))
|
||||
]
|
||||
else:
|
||||
seek_sequences = seek_outputs
|
||||
|
||||
# 6.7 Loop over each decoded audio individually as each decoding can be of a different length
|
||||
for i, seek_sequence in enumerate(seek_sequences):
|
||||
prev_i = cur_to_prev_index_map[i]
|
||||
|
||||
# make sure we cut a predicted EOS token if we are not finished with the generation yet
|
||||
is_not_final = (seek[prev_i] + num_segment_frames) < max_frames[prev_i]
|
||||
if is_not_final and seek_sequence[-1] == self.generation_config.eos_token_id:
|
||||
seek_sequence = seek_sequence[:-1]
|
||||
|
||||
# remove all padding tokens
|
||||
if seek_sequence[-1] == self.generation_config.pad_token_id:
|
||||
num_paddings = (seek_sequence == self.generation_config.pad_token_id).sum()
|
||||
seek_sequence = seek_sequence[:-num_paddings]
|
||||
|
||||
segments, segment_offset = self._retrieve_segment(
|
||||
seek_sequence=seek_sequence,
|
||||
seek_outputs=seek_outputs,
|
||||
time_offset=time_offset,
|
||||
timestamp_begin=timestamp_begin,
|
||||
seek_num_frames=seek_num_frames,
|
||||
cur_bsz=cur_bsz,
|
||||
time_precision=time_precision,
|
||||
input_stride=input_stride,
|
||||
prev_idx=prev_i,
|
||||
idx=i,
|
||||
)
|
||||
|
||||
current_segments[prev_i] += segments
|
||||
seek[prev_i] += segment_offset
|
||||
|
||||
# 7. Once all segments are added to the list of all segments, called `current_segments`, we extract the predicted
|
||||
# output tokens from the list of dicts. If we use batch size > 1, we make sure to pad the output
|
||||
sequences = []
|
||||
max_total_length = 0
|
||||
for current_segment_list in current_segments:
|
||||
sequences.append(torch.cat([d["tokens"] for d in current_segment_list], dim=-1))
|
||||
max_total_length = max(max_total_length, len(sequences[-1]))
|
||||
|
||||
for i in range(batch_size):
|
||||
sequences[i] = F.pad(
|
||||
sequences[i], pad=(0, max_total_length - len(sequences[i])), value=self.generation_config.pad_token_id
|
||||
)
|
||||
|
||||
sequences = torch.stack(sequences, dim=0)
|
||||
|
||||
# 8. If we return all segments, the predicted output sequences are put under `"sequences"`.
|
||||
if return_segments:
|
||||
return {"sequences": sequences, "segments": current_segments}
|
||||
|
||||
return sequences
|
||||
|
||||
@staticmethod
|
||||
def _retrieve_segment(
|
||||
seek_sequence,
|
||||
seek_outputs,
|
||||
time_offset,
|
||||
timestamp_begin,
|
||||
seek_num_frames,
|
||||
cur_bsz,
|
||||
time_precision,
|
||||
input_stride,
|
||||
prev_idx,
|
||||
idx,
|
||||
):
|
||||
# find the predicted "end of segment" predictions of Whisper
|
||||
# "end of segment" predictions occur whenever Whisper predicts a timestamp token
|
||||
timestamp_tokens: torch.Tensor = seek_sequence.ge(timestamp_begin)
|
||||
single_timestamp_ending = timestamp_tokens[-2:].tolist() == cur_bsz * [[False, True]]
|
||||
timestamp_segment_indices = torch.where(timestamp_tokens[:-1] & timestamp_tokens[1:])[0]
|
||||
|
||||
# If whisper predicted a "end of segment" via a timestep token, let's go ever each
|
||||
# "end of segment" prediction and slice the decoding into segments accordingly
|
||||
if len(timestamp_segment_indices) > 0:
|
||||
# if the output contains two consecutive timestamp tokens
|
||||
slices = timestamp_segment_indices.tolist()
|
||||
segments = []
|
||||
if single_timestamp_ending:
|
||||
slices.append(len(seek_sequence))
|
||||
|
||||
last_slice = 0
|
||||
# Add each segment to list of all segments
|
||||
for current_slice in slices:
|
||||
sliced_tokens = seek_sequence[last_slice + 1 : current_slice + 1]
|
||||
start_timestamp_pos = sliced_tokens[0].item() - timestamp_begin
|
||||
end_timestamp_pos = sliced_tokens[-1].item() - timestamp_begin
|
||||
segments.append(
|
||||
{
|
||||
"start": time_offset[prev_idx] + start_timestamp_pos * time_precision,
|
||||
"end": time_offset[prev_idx] + end_timestamp_pos * time_precision,
|
||||
"tokens": sliced_tokens,
|
||||
"result": seek_outputs[idx],
|
||||
}
|
||||
)
|
||||
last_slice = current_slice
|
||||
|
||||
if single_timestamp_ending:
|
||||
# single timestamp at the end means no speech after the last timestamp.
|
||||
segment_offset = seek_num_frames[prev_idx]
|
||||
else:
|
||||
# otherwise, ignore the unfinished segment and seek to the last timestamp
|
||||
# here we throw away all predictions after the last predicted "end of segment"
|
||||
# since we are cutting right in the middle of an audio
|
||||
last_timestamp_pos = seek_sequence[last_slice].item() - timestamp_begin
|
||||
segment_offset = last_timestamp_pos * input_stride
|
||||
else:
|
||||
# If whisper does not predict any "end of segment" token, then
|
||||
# the whole decoding is considered a segment and we add it to the list of segments
|
||||
timestamps = seek_sequence[timestamp_tokens.nonzero().flatten()]
|
||||
last_timestamp_pos = seek_num_frames[prev_idx]
|
||||
if timestamps.numel() > 0 and timestamps[-1].item() != timestamp_begin:
|
||||
# no consecutive timestamps but it has a timestamp; use the last one.
|
||||
last_timestamp_pos = timestamps[-1].item() - timestamp_begin
|
||||
|
||||
segments = [
|
||||
{
|
||||
"start": time_offset[prev_idx],
|
||||
"end": time_offset[prev_idx] + last_timestamp_pos * time_precision,
|
||||
"tokens": seek_sequence,
|
||||
"result": seek_outputs[idx],
|
||||
}
|
||||
]
|
||||
segment_offset = seek_num_frames[prev_idx]
|
||||
|
||||
return segments, segment_offset
|
||||
|
||||
def prepare_inputs_for_generation(
|
||||
self,
|
||||
decoder_input_ids,
|
||||
|
@ -2508,8 +1800,13 @@ class WhisperForConditionalGeneration(WhisperPreTrainedModel):
|
|||
use_cache=None,
|
||||
encoder_outputs=None,
|
||||
attention_mask=None,
|
||||
decoder_attention_mask=None,
|
||||
**kwargs,
|
||||
):
|
||||
decoder_position_ids = None
|
||||
if decoder_attention_mask is not None:
|
||||
decoder_position_ids = (decoder_attention_mask.cumsum(-1) - 1).clamp(min=0)
|
||||
|
||||
if past_key_values is not None:
|
||||
past_length = past_key_values[0][0].shape[2]
|
||||
|
||||
|
@ -2522,12 +1819,16 @@ class WhisperForConditionalGeneration(WhisperPreTrainedModel):
|
|||
|
||||
decoder_input_ids = decoder_input_ids[:, remove_prefix_length:]
|
||||
|
||||
if decoder_position_ids is not None and decoder_position_ids.shape[1] > decoder_input_ids.shape[1]:
|
||||
decoder_position_ids = decoder_position_ids[:, remove_prefix_length:]
|
||||
|
||||
return {
|
||||
"encoder_outputs": encoder_outputs,
|
||||
"past_key_values": past_key_values,
|
||||
"decoder_input_ids": decoder_input_ids,
|
||||
"use_cache": use_cache,
|
||||
"decoder_attention_mask": None,
|
||||
"decoder_attention_mask": decoder_attention_mask,
|
||||
"decoder_position_ids": decoder_position_ids,
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
|
@ -2539,99 +1840,6 @@ class WhisperForConditionalGeneration(WhisperPreTrainedModel):
|
|||
)
|
||||
return reordered_past
|
||||
|
||||
def _extract_token_timestamps(self, generate_outputs, alignment_heads, time_precision=0.02, num_frames=None):
|
||||
"""
|
||||
Calculates token-level timestamps using the encoder-decoder cross-attentions and dynamic time-warping (DTW) to
|
||||
map each output token to a position in the input audio. If `num_frames` is specified, the encoder-decoder
|
||||
cross-attentions will be cropped before applying DTW.
|
||||
|
||||
Returns:
|
||||
tensor containing the timestamps in seconds for each predicted token
|
||||
"""
|
||||
# Create a list with `decoder_layers` elements, each a tensor of shape
|
||||
# (batch size, attention_heads, output length, input length).
|
||||
cross_attentions = []
|
||||
for i in range(self.config.decoder_layers):
|
||||
cross_attentions.append(torch.cat([x[i] for x in generate_outputs.cross_attentions], dim=2))
|
||||
|
||||
# Select specific cross-attention layers and heads. This is a tensor
|
||||
# of shape (batch size, num selected, output length, input length).
|
||||
weights = torch.stack([cross_attentions[l][:, h] for l, h in alignment_heads])
|
||||
weights = weights.permute([1, 0, 2, 3])
|
||||
|
||||
if "beam_indices" in generate_outputs:
|
||||
# If beam search has been used, the output sequences may have been generated for more timesteps than their sequence_lengths
|
||||
# since the beam search strategy chooses the most probable sequences at the end of the search.
|
||||
# In that case, the cross_attentions weights are too long and we have to make sure that they have the right output_length
|
||||
weight_length = (generate_outputs.beam_indices != -1).sum(-1).max()
|
||||
weights = weights[:, :, :weight_length]
|
||||
|
||||
# If beam index is still -1, it means that the associated token id is EOS
|
||||
# We need to replace the index with 0 since index_select gives an error if any of the indexes is -1.
|
||||
beam_indices = generate_outputs.beam_indices[:, :weight_length]
|
||||
beam_indices = beam_indices.masked_fill(beam_indices == -1, 0)
|
||||
|
||||
# Select the cross attention from the right beam for each output sequences
|
||||
weights = torch.stack(
|
||||
[
|
||||
torch.index_select(weights[:, :, i, :], dim=0, index=beam_indices[:, i])
|
||||
for i in range(beam_indices.shape[1])
|
||||
],
|
||||
dim=2,
|
||||
)
|
||||
|
||||
timestamps = torch.zeros_like(generate_outputs.sequences, dtype=torch.float32)
|
||||
batch_size = timestamps.shape[0]
|
||||
|
||||
if num_frames is not None:
|
||||
# two cases:
|
||||
# 1. num_frames is the same for each sample -> compute the DTW matrix for each sample in parallel
|
||||
# 2. num_frames is different, compute the DTW matrix for each sample sequentially
|
||||
|
||||
# we're using np.unique because num_frames can be int/list/tuple
|
||||
if len(np.unique(num_frames)) == 1:
|
||||
# if num_frames is the same, no need to recompute matrix, std and mean for each element of the batch
|
||||
num_frames = num_frames if isinstance(num_frames, int) else num_frames[0]
|
||||
|
||||
weights = weights[..., : num_frames // 2]
|
||||
else:
|
||||
# num_frames is of shape (batch_size,) whereas batch_size is truely batch_size*num_return_sequences
|
||||
repeat_time = batch_size if isinstance(num_frames, int) else batch_size // len(num_frames)
|
||||
num_frames = np.repeat(num_frames, repeat_time)
|
||||
|
||||
if num_frames is None or isinstance(num_frames, int):
|
||||
# Normalize and smoothen the weights.
|
||||
std = torch.std(weights, dim=-2, keepdim=True, unbiased=False)
|
||||
mean = torch.mean(weights, dim=-2, keepdim=True)
|
||||
weights = (weights - mean) / std
|
||||
weights = _median_filter(weights, self.config.median_filter_width)
|
||||
|
||||
# Average the different cross-attention heads.
|
||||
weights = weights.mean(dim=1)
|
||||
|
||||
# Perform dynamic time warping on each element of the batch.
|
||||
for batch_idx in range(batch_size):
|
||||
if num_frames is not None and isinstance(num_frames, (tuple, list, np.ndarray)):
|
||||
matrix = weights[batch_idx, ..., : num_frames[batch_idx] // 2]
|
||||
|
||||
# Normalize and smoothen the weights.
|
||||
std = torch.std(matrix, dim=-2, keepdim=True, unbiased=False)
|
||||
mean = torch.mean(matrix, dim=-2, keepdim=True)
|
||||
matrix = (matrix - mean) / std
|
||||
matrix = _median_filter(matrix, self.config.median_filter_width)
|
||||
|
||||
# Average the different cross-attention heads.
|
||||
matrix = matrix.mean(dim=0)
|
||||
else:
|
||||
matrix = weights[batch_idx]
|
||||
|
||||
text_indices, time_indices = _dynamic_time_warping(-matrix.cpu().double().numpy())
|
||||
jumps = np.pad(np.diff(text_indices), (1, 0), constant_values=1).astype(bool)
|
||||
jump_times = time_indices[jumps] * time_precision
|
||||
timestamps[batch_idx, 1:] = torch.tensor(jump_times)
|
||||
|
||||
return timestamps
|
||||
|
||||
|
||||
class WhisperDecoderWrapper(WhisperPreTrainedModel):
|
||||
"""
|
||||
|
|
|
@ -530,10 +530,21 @@ class WhisperTokenizer(PreTrainedTokenizer):
|
|||
"""
|
||||
timestamp_begin = self.all_special_ids[-1] + 1
|
||||
outputs = [[]]
|
||||
|
||||
cur_max_timestamp = 0.0
|
||||
prev_segments_len = 0.0
|
||||
|
||||
for token in token_ids:
|
||||
if token >= timestamp_begin:
|
||||
timestamp = f"<|{(token - timestamp_begin) * time_precision:.2f}|>"
|
||||
outputs.append(timestamp)
|
||||
timestamp = float((token - timestamp_begin) * time_precision)
|
||||
|
||||
if timestamp < cur_max_timestamp:
|
||||
# next segment has started
|
||||
prev_segments_len += cur_max_timestamp
|
||||
|
||||
cur_max_timestamp = timestamp
|
||||
|
||||
outputs.append(f"<|{(timestamp + prev_segments_len):.2f}|>")
|
||||
outputs.append([])
|
||||
else:
|
||||
outputs[-1].append(token)
|
||||
|
@ -631,7 +642,7 @@ class WhisperTokenizer(PreTrainedTokenizer):
|
|||
skip_special_tokens: bool = False,
|
||||
clean_up_tokenization_spaces: bool = None,
|
||||
output_offsets: bool = False,
|
||||
time_precision=0.02,
|
||||
time_precision: float = 0.02,
|
||||
decode_with_timestamps: bool = False,
|
||||
normalize: bool = False,
|
||||
basic_normalize: bool = False,
|
||||
|
|
|
@ -224,10 +224,21 @@ class WhisperTokenizerFast(PreTrainedTokenizerFast):
|
|||
"""
|
||||
timestamp_begin = self.all_special_ids[-1] + 1
|
||||
outputs = [[]]
|
||||
|
||||
cur_max_timestamp = 0.0
|
||||
prev_segments_len = 0.0
|
||||
|
||||
for token in token_ids:
|
||||
if token >= timestamp_begin:
|
||||
timestamp = f"<|{(token - timestamp_begin) * time_precision:.2f}|>"
|
||||
outputs.append(timestamp)
|
||||
timestamp = float((token - timestamp_begin) * time_precision)
|
||||
|
||||
if timestamp < cur_max_timestamp:
|
||||
# next segment has started
|
||||
prev_segments_len += cur_max_timestamp
|
||||
|
||||
cur_max_timestamp = timestamp
|
||||
|
||||
outputs.append(f"<|{(timestamp + prev_segments_len):.2f}|>")
|
||||
outputs.append([])
|
||||
else:
|
||||
outputs[-1].append(token)
|
||||
|
@ -330,7 +341,7 @@ class WhisperTokenizerFast(PreTrainedTokenizerFast):
|
|||
skip_special_tokens: bool = False,
|
||||
clean_up_tokenization_spaces: bool = None,
|
||||
output_offsets: bool = False,
|
||||
time_precision=0.02,
|
||||
time_precision: float = 0.02,
|
||||
decode_with_timestamps: bool = False,
|
||||
normalize: bool = False,
|
||||
basic_normalize: bool = False,
|
||||
|
|
|
@ -517,8 +517,11 @@ class AutomaticSpeechRecognitionPipeline(ChunkPipeline):
|
|||
out["stride"] = stride
|
||||
|
||||
else:
|
||||
input_values = model_inputs.pop("input_values")
|
||||
outputs = self.model(input_values=input_values, attention_mask=attention_mask)
|
||||
inputs = {
|
||||
self.model.main_input_name: model_inputs.pop(self.model.main_input_name),
|
||||
"attention_mask": attention_mask,
|
||||
}
|
||||
outputs = self.model(**inputs)
|
||||
logits = outputs.logits
|
||||
|
||||
if self.type == "ctc_with_lm":
|
||||
|
|
|
@ -317,6 +317,7 @@ class ProcessorMixin(PushToHubMixin):
|
|||
user_agent=user_agent,
|
||||
revision=revision,
|
||||
subfolder=subfolder,
|
||||
_raise_exceptions_for_missing_entries=False,
|
||||
)
|
||||
except EnvironmentError:
|
||||
# Raise any environment error raise by `cached_file`. It will have a helpful error message adapted to
|
||||
|
@ -331,6 +332,13 @@ class ProcessorMixin(PushToHubMixin):
|
|||
f" directory containing a {PROCESSOR_NAME} file"
|
||||
)
|
||||
|
||||
# Existing processors on the Hub created before #27761 being merged don't have `processor_config.json` (if not
|
||||
# updated afterward), and we need to keep `from_pretrained` work. So here it fallbacks to the empty dict.
|
||||
# (`cached_file` called using `_raise_exceptions_for_missing_entries=False` to avoid exception)
|
||||
# However, for models added in the future, we won't get the expected error if this file is missing.
|
||||
if resolved_processor_file is None:
|
||||
return {}, kwargs
|
||||
|
||||
try:
|
||||
# Load processor dict
|
||||
with open(resolved_processor_file, "r", encoding="utf-8") as reader:
|
||||
|
@ -456,17 +464,7 @@ class ProcessorMixin(PushToHubMixin):
|
|||
kwargs["token"] = token
|
||||
|
||||
args = cls._get_arguments_from_pretrained(pretrained_model_name_or_path, **kwargs)
|
||||
|
||||
# Existing processors on the Hub created before #27761 being merged don't have `processor_config.json` (if not
|
||||
# updated afterward), and we need to keep `from_pretrained` work. So here it fallbacks to the empty dict.
|
||||
# However, for models added in the future, we won't get the expected error if this file is missing.
|
||||
try:
|
||||
processor_dict, kwargs = cls.get_processor_dict(pretrained_model_name_or_path, **kwargs)
|
||||
except EnvironmentError as e:
|
||||
if "does not appear to have a file named processor_config.json." in str(e):
|
||||
processor_dict, kwargs = {}, kwargs
|
||||
else:
|
||||
raise
|
||||
processor_dict, kwargs = cls.get_processor_dict(pretrained_model_name_or_path, **kwargs)
|
||||
|
||||
return cls.from_args_and_dict(args, processor_dict, **kwargs)
|
||||
|
||||
|
|
|
@ -2088,6 +2088,7 @@ class Trainer:
|
|||
)
|
||||
|
||||
if os.path.isfile(weights_file) or os.path.isfile(safe_weights_file) or is_fsdp_ckpt:
|
||||
weights_only_kwarg = {"weights_only": True} if is_torch_greater_or_equal_than_1_13 else {}
|
||||
# If the model is on the GPU, it still works!
|
||||
if is_sagemaker_mp_enabled():
|
||||
if os.path.isfile(os.path.join(resume_from_checkpoint, "user_content.pt")):
|
||||
|
@ -2106,7 +2107,7 @@ class Trainer:
|
|||
state_dict = torch.load(
|
||||
weights_file,
|
||||
map_location="cpu",
|
||||
weights_only=is_torch_greater_or_equal_than_1_13,
|
||||
**weights_only_kwarg,
|
||||
)
|
||||
# Required for smp to not auto-translate state_dict from hf to smp (is already smp).
|
||||
state_dict["_smp_is_partial"] = False
|
||||
|
@ -2123,7 +2124,7 @@ class Trainer:
|
|||
state_dict = torch.load(
|
||||
weights_file,
|
||||
map_location="cpu",
|
||||
weights_only=is_torch_greater_or_equal_than_1_13,
|
||||
**weights_only_kwarg,
|
||||
)
|
||||
|
||||
# workaround for FSDP bug https://github.com/pytorch/pytorch/issues/82963
|
||||
|
@ -2176,6 +2177,7 @@ class Trainer:
|
|||
or os.path.exists(best_safe_adapter_model_path)
|
||||
):
|
||||
has_been_loaded = True
|
||||
weights_only_kwarg = {"weights_only": True} if is_torch_greater_or_equal_than_1_13 else {}
|
||||
if is_sagemaker_mp_enabled():
|
||||
if os.path.isfile(os.path.join(self.state.best_model_checkpoint, "user_content.pt")):
|
||||
# If the 'user_content.pt' file exists, load with the new smp api.
|
||||
|
@ -2195,7 +2197,7 @@ class Trainer:
|
|||
state_dict = torch.load(
|
||||
best_model_path,
|
||||
map_location="cpu",
|
||||
weights_only=is_torch_greater_or_equal_than_1_13,
|
||||
**weights_only_kwarg,
|
||||
)
|
||||
|
||||
state_dict["_smp_is_partial"] = False
|
||||
|
@ -2228,7 +2230,7 @@ class Trainer:
|
|||
state_dict = torch.load(
|
||||
best_model_path,
|
||||
map_location="cpu",
|
||||
weights_only=is_torch_greater_or_equal_than_1_13,
|
||||
**weights_only_kwarg,
|
||||
)
|
||||
|
||||
# If the model is on the GPU, it still works!
|
||||
|
@ -2415,9 +2417,11 @@ class Trainer:
|
|||
os.rename(staging_output_dir, output_dir)
|
||||
|
||||
# Ensure rename completed in cases where os.rename is not atomic
|
||||
fd = os.open(output_dir, os.O_RDONLY)
|
||||
os.fsync(fd)
|
||||
os.close(fd)
|
||||
# And can only happen on non-windows based systems
|
||||
if os.name != "nt":
|
||||
fd = os.open(output_dir, os.O_RDONLY)
|
||||
os.fsync(fd)
|
||||
os.close(fd)
|
||||
|
||||
# Maybe delete some older checkpoints.
|
||||
if self.args.should_save:
|
||||
|
@ -2905,13 +2909,19 @@ class Trainer:
|
|||
is_main_process=self.args.should_save,
|
||||
state_dict=model.state_dict(),
|
||||
save_function=xm.save,
|
||||
safe_serialization=self.args.save_safetensors,
|
||||
)
|
||||
else:
|
||||
logger.info("Trainer.model is not a `PreTrainedModel`, only saving its state dict.")
|
||||
state_dict = model.state_dict()
|
||||
xm.save(state_dict, os.path.join(output_dir, WEIGHTS_NAME))
|
||||
else:
|
||||
model.save_pretrained(output_dir, is_main_process=self.args.should_save, save_function=xm.save)
|
||||
model.save_pretrained(
|
||||
output_dir,
|
||||
is_main_process=self.args.should_save,
|
||||
save_function=xm.save,
|
||||
safe_serialization=self.args.save_safetensors,
|
||||
)
|
||||
if self.tokenizer is not None and self.args.should_save:
|
||||
self.tokenizer.save_pretrained(output_dir)
|
||||
|
||||
|
|
|
@ -1844,11 +1844,6 @@ class TrainingArguments:
|
|||
device = torch.device("cuda", local_rank)
|
||||
self._n_gpu = 1
|
||||
torch.cuda.set_device(device)
|
||||
elif is_torch_xpu_available() and "ACCELERATE_USE_XPU" not in os.environ:
|
||||
os.environ["ACCELERATE_USE_XPU"] = "true"
|
||||
self.distributed_state = PartialState(timeout=timedelta(seconds=self.ddp_timeout))
|
||||
device = torch.device("xpu:0")
|
||||
self._n_gpu = 1
|
||||
elif is_sagemaker_dp_enabled():
|
||||
self.distributed_state = PartialState(_use_sagemaker_dp=True)
|
||||
self._n_gpu = 1
|
||||
|
@ -1877,12 +1872,6 @@ class TrainingArguments:
|
|||
elif is_sagemaker_dp_enabled() or is_sagemaker_mp_enabled():
|
||||
# Already set _n_gpu
|
||||
pass
|
||||
elif self.distributed_state.distributed_type == DistributedType.MULTI_XPU:
|
||||
if "ACCELERATE_USE_XPU" not in os.environ:
|
||||
os.environ["ACCELERATE_USE_XPU"] = "true"
|
||||
self._n_gpu = 1
|
||||
device = torch.device("xpu:0")
|
||||
torch.xpu.set_device(device)
|
||||
elif self.distributed_state.distributed_type == DistributedType.NO:
|
||||
if self.use_mps_device:
|
||||
warnings.warn(
|
||||
|
|
|
@ -184,6 +184,13 @@ class SeamlessM4TTokenizer(metaclass=DummyObject):
|
|||
requires_backends(self, ["sentencepiece"])
|
||||
|
||||
|
||||
class SiglipTokenizer(metaclass=DummyObject):
|
||||
_backends = ["sentencepiece"]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
requires_backends(self, ["sentencepiece"])
|
||||
|
||||
|
||||
class Speech2TextTokenizer(metaclass=DummyObject):
|
||||
_backends = ["sentencepiece"]
|
||||
|
||||
|
|
|
@ -88,6 +88,7 @@ if is_torch_available():
|
|||
TopKLogitsWarper,
|
||||
TopPLogitsWarper,
|
||||
)
|
||||
from transformers.generation.utils import _speculative_sampling
|
||||
|
||||
|
||||
class GenerationTesterMixin:
|
||||
|
@ -2391,6 +2392,43 @@ class UtilsFunctionsTest(unittest.TestCase):
|
|||
|
||||
self.assertTrue(torch.allclose(expected_output, output, atol=1e-12))
|
||||
|
||||
def test_speculative_sampling(self):
|
||||
# assume vocab size 10, input length 5 + 3 generated candidates
|
||||
candidate_input_ids = torch.tensor([[8, 0, 3, 9, 8, 1, 4, 5]]) # input tokens
|
||||
candidate_logits = torch.tensor(
|
||||
[
|
||||
[
|
||||
[-10.0, 10.0, -10.0, -10.0, -10.0, -10.0, -10.0, -10.0, -10.0, -10.0], # generated 1
|
||||
[-10.0, -10.0, -10.0, -10.0, 10.0, -10.0, -10.0, -10.0, -10.0, -10.0], # generated 4
|
||||
[-10.0, -10.0, -10.0, -10.0, -10.0, 10.0, -10.0, -10.0, -10.0, -10.0], # generated 5
|
||||
]
|
||||
]
|
||||
)
|
||||
candidate_length = 3
|
||||
inf = float("inf")
|
||||
new_logits = torch.tensor(
|
||||
[
|
||||
[
|
||||
[-10.0, 10.0, -10.0, -10.0, -10.0, -10.0, -10.0, -10.0, -10.0, -10.0], # accepts 1
|
||||
[-10.0, -10.0, -10.0, -10.0, 10.0, -10.0, -10.0, -10.0, -10.0, -10.0], # accepts 4
|
||||
[-inf, -inf, -inf, -inf, -inf, -inf, -inf, -inf, 10.0, -inf], # rejects 5, accepts 8
|
||||
[-10.0, -10.0, -10.0, -10.0, -10.0, -10.0, -10.0, -10.0, -10.0, -10.0], # N/A
|
||||
]
|
||||
]
|
||||
)
|
||||
last_assistant_token_is_eos = False
|
||||
max_matches = 5
|
||||
validated_tokens, n_matches = _speculative_sampling(
|
||||
candidate_input_ids,
|
||||
candidate_logits,
|
||||
candidate_length,
|
||||
new_logits,
|
||||
last_assistant_token_is_eos,
|
||||
max_matches,
|
||||
)
|
||||
self.assertTrue(n_matches.item() == 2)
|
||||
self.assertTrue(validated_tokens.tolist()[0] == [1, 4, 8])
|
||||
|
||||
|
||||
@require_torch
|
||||
class GenerationIntegrationTests(unittest.TestCase, GenerationIntegrationTestsMixin):
|
||||
|
|
|
@ -355,3 +355,13 @@ class GPTNeoXLanguageGenerationTest(unittest.TestCase):
|
|||
output_str = tokenizer.batch_decode(output_ids)[0]
|
||||
|
||||
self.assertEqual(output_str, expected_output)
|
||||
|
||||
def pythia_integration_test(self):
|
||||
model_name_or_path = "EleutherAI/pythia-70m"
|
||||
model = GPTNeoXForCausalLM.from_pretrained(model_name_or_path, torch_dtype=torch.float16).to(torch_device)
|
||||
EXPECTED_LOGITS = torch.tensor([1069.0000, 228.7500, 1072.0000, 1072.0000, 1069.0000, 1068.0000, 1068.0000, 1071.0000, 1071.0000, 1071.0000, 1073.0000, 1070.0000, 1071.0000, 1075.0000, 1073.0000, 1075.0000, 1074.0000, 1069.0000, 1072.0000, 1071.0000, 1071.0000, 1071.0000, 1070.0000, 1069.0000, 1069.0000, 1069.0000, 1070.0000, 1075.0000, 1073.0000, 1074.0000]) # fmt: skip
|
||||
input_ids = [29, 93, 303, 64, 5478, 49651, 10394, 187, 34, 12939, 875]
|
||||
# alternative: tokenizer('<|im_start|>system\nA chat between')
|
||||
input_ids = torch.as_tensor(input_ids)[None].to(torch_device)
|
||||
outputs = model(input_ids)["logits"][:, -1][0, :30]
|
||||
self.assertTrue(torch.allclose(EXPECTED_LOGITS, outputs, atol=1e-5))
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -298,6 +298,23 @@ class AutomaticSpeechRecognitionPipelineTests(unittest.TestCase):
|
|||
output = speech_recognizer(filename)
|
||||
self.assertEqual(output, {"text": "A MAN SAID TO THE UNIVERSE SIR I EXIST"})
|
||||
|
||||
@require_torch
|
||||
@slow
|
||||
def test_torch_large_with_input_features(self):
|
||||
speech_recognizer = pipeline(
|
||||
task="automatic-speech-recognition",
|
||||
model="hf-audio/wav2vec2-bert-CV16-en",
|
||||
framework="pt",
|
||||
)
|
||||
waveform = np.tile(np.arange(1000, dtype=np.float32), 34)
|
||||
output = speech_recognizer(waveform)
|
||||
self.assertEqual(output, {"text": ""})
|
||||
|
||||
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation").sort("id")
|
||||
filename = ds[40]["file"]
|
||||
output = speech_recognizer(filename)
|
||||
self.assertEqual(output, {"text": "a man said to the universe sir i exist"})
|
||||
|
||||
@slow
|
||||
@require_torch
|
||||
@slow
|
||||
|
@ -1135,7 +1152,7 @@ class AutomaticSpeechRecognitionPipelineTests(unittest.TestCase):
|
|||
@slow
|
||||
def test_whisper_longform(self):
|
||||
# fmt: off
|
||||
EXPECTED_RESULT = """ Folks, if you watch the show, you know, I spent a lot of time right over there. Patiently and astutely scrutinizing the boxwood and mahogany chest set of the day's biggest stories developing the central headline pawns, definitely maneuvering an oso topical night to F6, fainting a classic Sicilian, nade door variation on the news, all the while seeing eight moves deep and patiently marshalling the latest press releases into a fisher's shows in Lip Nitsky attack that culminates in the elegant lethal slow-played, all-passant checkmate that is my nightly monologue. But sometimes, sometimes, folks, I. CHEERING AND APPLAUSE Sometimes I startle away, cubside down in the monkey bars of a condemned playground on a super fun site. Get all hept up on goofballs. Rummage that were discarded tag bag of defective toys. Yank out of fist bowl of disembodied doll limbs, toss them on a stained kid's place mat from a defunct denny's, set up a table inside a rusty cargo container down by the Wharf and challenged toothless drifters to the godless bughouse blitz of tournament that is my segment. Meanwhile!"""
|
||||
EXPECTED_RESULT = """ Folks, if you watch the show, you know, I spent a lot of time right over there. Patiently and astutely scrutinizing the boxwood and mahogany chest set of the day's biggest stories developing the central headline pawns, definitely maneuvering an oso topical night to F6, fainting a classic Sicilian, nade door variation on the news, all the while seeing eight moves deep and patiently marshalling the latest press releases into a fisher's shows in Lip Nitsky attack that culminates in the elegant lethal slow-played, all-passant checkmate that is my nightly monologue. But sometimes, sometimes, folks, I. CHEERING AND APPLAUSE Sometimes I startle away, cubside down in the monkey bars of a condemned playground on a super fun site. Get all hept up on goofballs. Rummage that were discarded tag bag of defective toys. Yank out a fist bowl of disembodied doll limbs, toss them on a stained kid's place mat from a defunct dennies. set up a table inside a rusty cargo container down by the Wharf and challenged toothless drifters to the godless bughouse blitz of tournament that is my segment. Meanwhile."""
|
||||
# fmt: on
|
||||
|
||||
processor = AutoProcessor.from_pretrained("openai/whisper-tiny.en")
|
||||
|
|
|
@ -23,13 +23,14 @@ from transformers import BertConfig, BertModel, is_flax_available, is_torch_avai
|
|||
from transformers.testing_utils import (
|
||||
TOKEN,
|
||||
USER,
|
||||
CaptureLogger,
|
||||
is_pt_flax_cross_test,
|
||||
is_staging_test,
|
||||
require_flax,
|
||||
require_safetensors,
|
||||
require_torch,
|
||||
)
|
||||
from transformers.utils import FLAX_WEIGHTS_NAME, SAFE_WEIGHTS_NAME
|
||||
from transformers.utils import FLAX_WEIGHTS_NAME, SAFE_WEIGHTS_NAME, logging
|
||||
|
||||
|
||||
if is_flax_available():
|
||||
|
@ -42,6 +43,9 @@ if is_flax_available():
|
|||
|
||||
os.environ["XLA_PYTHON_CLIENT_MEM_FRACTION"] = "0.12" # assumed parallelism: 8
|
||||
|
||||
if is_torch_available():
|
||||
import torch
|
||||
|
||||
|
||||
@require_flax
|
||||
@is_staging_test
|
||||
|
@ -251,7 +255,6 @@ class FlaxModelUtilsTest(unittest.TestCase):
|
|||
|
||||
self.assertTrue(check_models_equal(flax_model, safetensors_model))
|
||||
|
||||
@require_torch
|
||||
@require_safetensors
|
||||
@is_pt_flax_cross_test
|
||||
def test_safetensors_load_from_hub_from_safetensors_pt(self):
|
||||
|
@ -265,7 +268,27 @@ class FlaxModelUtilsTest(unittest.TestCase):
|
|||
safetensors_model = FlaxBertModel.from_pretrained("hf-internal-testing/tiny-bert-pt-safetensors")
|
||||
self.assertTrue(check_models_equal(flax_model, safetensors_model))
|
||||
|
||||
@require_safetensors
|
||||
@require_torch
|
||||
@is_pt_flax_cross_test
|
||||
def test_safetensors_load_from_hub_from_safetensors_pt_bf16(self):
|
||||
"""
|
||||
This test checks that we can load safetensors from a checkpoint that only has those on the Hub.
|
||||
saved in the "pt" format.
|
||||
"""
|
||||
import torch
|
||||
|
||||
model = BertModel.from_pretrained("hf-internal-testing/tiny-bert-pt-safetensors")
|
||||
model.to(torch.bfloat16)
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
model.save_pretrained(tmp)
|
||||
flax_model = FlaxBertModel.from_pretrained(tmp)
|
||||
|
||||
# Can load from the PyTorch-formatted checkpoint
|
||||
safetensors_model = FlaxBertModel.from_pretrained("hf-internal-testing/tiny-bert-pt-safetensors-bf16")
|
||||
self.assertTrue(check_models_equal(flax_model, safetensors_model))
|
||||
|
||||
@require_safetensors
|
||||
@is_pt_flax_cross_test
|
||||
def test_safetensors_load_from_local_from_safetensors_pt(self):
|
||||
|
@ -284,39 +307,6 @@ class FlaxModelUtilsTest(unittest.TestCase):
|
|||
|
||||
self.assertTrue(check_models_equal(flax_model, safetensors_model))
|
||||
|
||||
@require_safetensors
|
||||
def test_safetensors_load_from_hub_from_safetensors_pt_without_torch_installed(self):
|
||||
"""
|
||||
This test checks that we cannot load safetensors from a checkpoint that only has safetensors
|
||||
saved in the "pt" format if torch isn't installed.
|
||||
"""
|
||||
if is_torch_available():
|
||||
# This test verifies that a correct error message is shown when loading from a pt safetensors
|
||||
# PyTorch shouldn't be installed for this to work correctly.
|
||||
return
|
||||
|
||||
# Cannot load from the PyTorch-formatted checkpoint without PyTorch installed
|
||||
with self.assertRaises(ModuleNotFoundError):
|
||||
_ = FlaxBertModel.from_pretrained("hf-internal-testing/tiny-bert-pt-safetensors")
|
||||
|
||||
@require_safetensors
|
||||
def test_safetensors_load_from_local_from_safetensors_pt_without_torch_installed(self):
|
||||
"""
|
||||
This test checks that we cannot load safetensors from a checkpoint that only has safetensors
|
||||
saved in the "pt" format if torch isn't installed.
|
||||
"""
|
||||
if is_torch_available():
|
||||
# This test verifies that a correct error message is shown when loading from a pt safetensors
|
||||
# PyTorch shouldn't be installed for this to work correctly.
|
||||
return
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
location = snapshot_download("hf-internal-testing/tiny-bert-pt-safetensors", cache_dir=tmp)
|
||||
|
||||
# Cannot load from the PyTorch-formatted checkpoint without PyTorch installed
|
||||
with self.assertRaises(ModuleNotFoundError):
|
||||
_ = FlaxBertModel.from_pretrained(location)
|
||||
|
||||
@require_safetensors
|
||||
def test_safetensors_load_from_hub_msgpack_before_safetensors(self):
|
||||
"""
|
||||
|
@ -347,6 +337,7 @@ class FlaxModelUtilsTest(unittest.TestCase):
|
|||
|
||||
@require_safetensors
|
||||
@require_torch
|
||||
@is_pt_flax_cross_test
|
||||
def test_safetensors_flax_from_torch(self):
|
||||
hub_model = FlaxBertModel.from_pretrained("hf-internal-testing/tiny-bert-flax-only")
|
||||
model = BertModel.from_pretrained("hf-internal-testing/tiny-bert-pt-only")
|
||||
|
@ -372,3 +363,41 @@ class FlaxModelUtilsTest(unittest.TestCase):
|
|||
# This should not raise even if there are two types of sharded weights
|
||||
# This should discard the safetensors weights in favor of the msgpack sharded weights
|
||||
FlaxBertModel.from_pretrained("hf-internal-testing/tiny-bert-flax-safetensors-msgpack-sharded")
|
||||
|
||||
@require_safetensors
|
||||
def test_safetensors_from_pt_bf16(self):
|
||||
# This should not raise; should be able to load bf16-serialized torch safetensors without issue
|
||||
# and without torch.
|
||||
logger = logging.get_logger("transformers.modeling_flax_utils")
|
||||
|
||||
with CaptureLogger(logger) as cl:
|
||||
FlaxBertModel.from_pretrained("hf-internal-testing/tiny-bert-pt-safetensors-bf16")
|
||||
|
||||
self.assertTrue(
|
||||
"Some of the weights of FlaxBertModel were initialized in bfloat16 precision from the model checkpoint"
|
||||
in cl.out
|
||||
)
|
||||
|
||||
@require_torch
|
||||
@require_safetensors
|
||||
@is_pt_flax_cross_test
|
||||
def test_from_pt_bf16(self):
|
||||
model = BertModel.from_pretrained("hf-internal-testing/tiny-bert-pt-only")
|
||||
model.to(torch.bfloat16)
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp_dir:
|
||||
model.save_pretrained(tmp_dir, safe_serialization=False)
|
||||
|
||||
logger = logging.get_logger("transformers.modeling_flax_utils")
|
||||
|
||||
with CaptureLogger(logger) as cl:
|
||||
new_model = FlaxBertModel.from_pretrained("hf-internal-testing/tiny-bert-pt-safetensors-bf16")
|
||||
|
||||
self.assertTrue(
|
||||
"Some of the weights of FlaxBertModel were initialized in bfloat16 precision from the model checkpoint"
|
||||
in cl.out
|
||||
)
|
||||
|
||||
flat_params_1 = flatten_dict(new_model.params)
|
||||
for value in flat_params_1.values():
|
||||
self.assertEqual(value.dtype, "bfloat16")
|
||||
|
|
Loading…
Reference in New Issue