METADATA 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. Metadata-Version: 2.4
  2. Name: transformers
  3. Version: 5.5.4
  4. Summary: Transformers: the model-definition framework for state-of-the-art machine learning models in text, vision, audio, and multimodal models, for both inference and training.
  5. Home-page: https://github.com/huggingface/transformers
  6. Author: The Hugging Face team (past and future) with the help of all our contributors (https://github.com/huggingface/transformers/graphs/contributors)
  7. Author-email: transformers@huggingface.co
  8. License: Apache 2.0 License
  9. Keywords: machine-learning nlp python pytorch transformer llm vlm deep-learning inference training model-hub pretrained-models llama gemma qwen
  10. Classifier: Development Status :: 5 - Production/Stable
  11. Classifier: Intended Audience :: Developers
  12. Classifier: Intended Audience :: Education
  13. Classifier: Intended Audience :: Science/Research
  14. Classifier: Operating System :: OS Independent
  15. Classifier: Programming Language :: Python :: 3
  16. Classifier: Programming Language :: Python :: 3.10
  17. Classifier: Programming Language :: Python :: 3.11
  18. Classifier: Programming Language :: Python :: 3.12
  19. Classifier: Programming Language :: Python :: 3.13
  20. Classifier: Programming Language :: Python :: 3.14
  21. Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
  22. Requires-Python: >=3.10.0
  23. Description-Content-Type: text/markdown
  24. License-File: LICENSE
  25. Requires-Dist: huggingface-hub<2.0,>=1.5.0
  26. Requires-Dist: numpy>=1.17
  27. Requires-Dist: packaging>=20.0
  28. Requires-Dist: pyyaml>=5.1
  29. Requires-Dist: regex>=2025.10.22
  30. Requires-Dist: tokenizers<=0.23.0,>=0.22.0
  31. Requires-Dist: typer
  32. Requires-Dist: safetensors>=0.4.3
  33. Requires-Dist: tqdm>=4.27
  34. Provides-Extra: torch
  35. Requires-Dist: torch>=2.4; extra == "torch"
  36. Requires-Dist: accelerate>=1.1.0; extra == "torch"
  37. Provides-Extra: vision
  38. Requires-Dist: torchvision; extra == "vision"
  39. Requires-Dist: Pillow<=15.0,>=10.0.1; extra == "vision"
  40. Provides-Extra: audio
  41. Requires-Dist: torchaudio; extra == "audio"
  42. Requires-Dist: librosa; extra == "audio"
  43. Requires-Dist: pyctcdecode>=0.4.0; extra == "audio"
  44. Requires-Dist: phonemizer; extra == "audio"
  45. Provides-Extra: video
  46. Requires-Dist: av; extra == "video"
  47. Provides-Extra: timm
  48. Requires-Dist: timm>=1.0.23; extra == "timm"
  49. Provides-Extra: quality
  50. Requires-Dist: datasets>=2.15.0; extra == "quality"
  51. Requires-Dist: ruff==0.14.10; extra == "quality"
  52. Requires-Dist: GitPython<3.1.19; extra == "quality"
  53. Requires-Dist: urllib3<2.0.0; extra == "quality"
  54. Requires-Dist: libcst; extra == "quality"
  55. Requires-Dist: rich; extra == "quality"
  56. Requires-Dist: ty==0.0.20; extra == "quality"
  57. Requires-Dist: tomli; extra == "quality"
  58. Provides-Extra: docs
  59. Requires-Dist: hf-doc-builder; extra == "docs"
  60. Provides-Extra: kernels
  61. Requires-Dist: kernels<0.13,>=0.12.0; extra == "kernels"
  62. Provides-Extra: sentencepiece
  63. Requires-Dist: sentencepiece!=0.1.92,>=0.1.91; extra == "sentencepiece"
  64. Requires-Dist: protobuf; extra == "sentencepiece"
  65. Provides-Extra: tiktoken
  66. Requires-Dist: tiktoken; extra == "tiktoken"
  67. Requires-Dist: blobfile; extra == "tiktoken"
  68. Provides-Extra: mistral-common
  69. Requires-Dist: mistral-common[image]>=1.10.0; extra == "mistral-common"
  70. Provides-Extra: chat-template
  71. Requires-Dist: jinja2>=3.1.0; extra == "chat-template"
  72. Requires-Dist: jmespath>=1.0.1; extra == "chat-template"
  73. Provides-Extra: sklearn
  74. Requires-Dist: scikit-learn; extra == "sklearn"
  75. Provides-Extra: accelerate
  76. Requires-Dist: accelerate>=1.1.0; extra == "accelerate"
  77. Provides-Extra: retrieval
  78. Requires-Dist: faiss-cpu; extra == "retrieval"
  79. Requires-Dist: datasets>=2.15.0; extra == "retrieval"
  80. Provides-Extra: sagemaker
  81. Requires-Dist: sagemaker>=2.31.0; extra == "sagemaker"
  82. Provides-Extra: deepspeed
  83. Requires-Dist: deepspeed>=0.9.3; extra == "deepspeed"
  84. Requires-Dist: accelerate>=1.1.0; extra == "deepspeed"
  85. Provides-Extra: optuna
  86. Requires-Dist: optuna; extra == "optuna"
  87. Provides-Extra: integrations
  88. Requires-Dist: kernels<0.13,>=0.12.0; extra == "integrations"
  89. Requires-Dist: optuna; extra == "integrations"
  90. Requires-Dist: codecarbon>=2.8.1; extra == "integrations"
  91. Requires-Dist: ray[tune]>=2.7.0; extra == "integrations"
  92. Provides-Extra: ray
  93. Requires-Dist: ray[tune]>=2.7.0; extra == "ray"
  94. Provides-Extra: codecarbon
  95. Requires-Dist: codecarbon>=2.8.1; extra == "codecarbon"
  96. Provides-Extra: serving
  97. Requires-Dist: openai>=1.98.0; extra == "serving"
  98. Requires-Dist: pydantic>=2; extra == "serving"
  99. Requires-Dist: uvicorn; extra == "serving"
  100. Requires-Dist: fastapi; extra == "serving"
  101. Requires-Dist: starlette; extra == "serving"
  102. Requires-Dist: rich; extra == "serving"
  103. Requires-Dist: torch>=2.4; extra == "serving"
  104. Requires-Dist: accelerate>=1.1.0; extra == "serving"
  105. Provides-Extra: num2words
  106. Requires-Dist: num2words; extra == "num2words"
  107. Provides-Extra: benchmark
  108. Requires-Dist: optimum-benchmark>=0.3.0; extra == "benchmark"
  109. Provides-Extra: ja
  110. Requires-Dist: fugashi>=1.0; extra == "ja"
  111. Requires-Dist: ipadic<2.0,>=1.0.0; extra == "ja"
  112. Requires-Dist: unidic_lite>=1.0.7; extra == "ja"
  113. Requires-Dist: unidic>=1.0.2; extra == "ja"
  114. Requires-Dist: rhoknp<1.3.1,>=1.1.0; extra == "ja"
  115. Requires-Dist: sudachipy>=0.6.6; extra == "ja"
  116. Requires-Dist: sudachidict_core>=20220729; extra == "ja"
  117. Provides-Extra: open-telemetry
  118. Requires-Dist: opentelemetry-api; extra == "open-telemetry"
  119. Requires-Dist: opentelemetry-exporter-otlp; extra == "open-telemetry"
  120. Requires-Dist: opentelemetry-sdk; extra == "open-telemetry"
  121. Provides-Extra: testing
  122. Requires-Dist: pytest<9.0.0,>=7.2.0; extra == "testing"
  123. Requires-Dist: pytest-asyncio>=1.2.0; extra == "testing"
  124. Requires-Dist: pytest-random-order; extra == "testing"
  125. Requires-Dist: pytest-rich; extra == "testing"
  126. Requires-Dist: pytest-xdist; extra == "testing"
  127. Requires-Dist: pytest-order; extra == "testing"
  128. Requires-Dist: pytest-rerunfailures<16.0; extra == "testing"
  129. Requires-Dist: pytest-timeout; extra == "testing"
  130. Requires-Dist: pytest-env; extra == "testing"
  131. Requires-Dist: timeout-decorator; extra == "testing"
  132. Requires-Dist: parameterized>=0.9; extra == "testing"
  133. Requires-Dist: psutil; extra == "testing"
  134. Requires-Dist: dill<0.3.5; extra == "testing"
  135. Requires-Dist: evaluate>=0.4.6; extra == "testing"
  136. Requires-Dist: rouge-score!=0.0.7,!=0.0.8,!=0.1,!=0.1.1; extra == "testing"
  137. Requires-Dist: nltk<=3.8.1; extra == "testing"
  138. Requires-Dist: sacremoses; extra == "testing"
  139. Requires-Dist: rjieba; extra == "testing"
  140. Requires-Dist: beautifulsoup4; extra == "testing"
  141. Requires-Dist: tensorboard; extra == "testing"
  142. Requires-Dist: sacrebleu<2.0.0,>=1.4.12; extra == "testing"
  143. Requires-Dist: filelock; extra == "testing"
  144. Requires-Dist: hf-doc-builder; extra == "testing"
  145. Requires-Dist: datasets>=2.15.0; extra == "testing"
  146. Requires-Dist: ruff==0.14.10; extra == "testing"
  147. Requires-Dist: GitPython<3.1.19; extra == "testing"
  148. Requires-Dist: urllib3<2.0.0; extra == "testing"
  149. Requires-Dist: libcst; extra == "testing"
  150. Requires-Dist: rich; extra == "testing"
  151. Requires-Dist: ty==0.0.20; extra == "testing"
  152. Requires-Dist: tomli; extra == "testing"
  153. Requires-Dist: faiss-cpu; extra == "testing"
  154. Requires-Dist: datasets>=2.15.0; extra == "testing"
  155. Requires-Dist: sentencepiece!=0.1.92,>=0.1.91; extra == "testing"
  156. Requires-Dist: protobuf; extra == "testing"
  157. Requires-Dist: openai>=1.98.0; extra == "testing"
  158. Requires-Dist: pydantic>=2; extra == "testing"
  159. Requires-Dist: uvicorn; extra == "testing"
  160. Requires-Dist: fastapi; extra == "testing"
  161. Requires-Dist: starlette; extra == "testing"
  162. Requires-Dist: rich; extra == "testing"
  163. Requires-Dist: torch>=2.4; extra == "testing"
  164. Requires-Dist: accelerate>=1.1.0; extra == "testing"
  165. Requires-Dist: mistral-common[image]>=1.10.0; extra == "testing"
  166. Provides-Extra: deepspeed-testing
  167. Requires-Dist: deepspeed>=0.9.3; extra == "deepspeed-testing"
  168. Requires-Dist: accelerate>=1.1.0; extra == "deepspeed-testing"
  169. Requires-Dist: pytest<9.0.0,>=7.2.0; extra == "deepspeed-testing"
  170. Requires-Dist: pytest-asyncio>=1.2.0; extra == "deepspeed-testing"
  171. Requires-Dist: pytest-random-order; extra == "deepspeed-testing"
  172. Requires-Dist: pytest-rich; extra == "deepspeed-testing"
  173. Requires-Dist: pytest-xdist; extra == "deepspeed-testing"
  174. Requires-Dist: pytest-order; extra == "deepspeed-testing"
  175. Requires-Dist: pytest-rerunfailures<16.0; extra == "deepspeed-testing"
  176. Requires-Dist: pytest-timeout; extra == "deepspeed-testing"
  177. Requires-Dist: pytest-env; extra == "deepspeed-testing"
  178. Requires-Dist: timeout-decorator; extra == "deepspeed-testing"
  179. Requires-Dist: parameterized>=0.9; extra == "deepspeed-testing"
  180. Requires-Dist: psutil; extra == "deepspeed-testing"
  181. Requires-Dist: dill<0.3.5; extra == "deepspeed-testing"
  182. Requires-Dist: evaluate>=0.4.6; extra == "deepspeed-testing"
  183. Requires-Dist: rouge-score!=0.0.7,!=0.0.8,!=0.1,!=0.1.1; extra == "deepspeed-testing"
  184. Requires-Dist: nltk<=3.8.1; extra == "deepspeed-testing"
  185. Requires-Dist: sacremoses; extra == "deepspeed-testing"
  186. Requires-Dist: rjieba; extra == "deepspeed-testing"
  187. Requires-Dist: beautifulsoup4; extra == "deepspeed-testing"
  188. Requires-Dist: tensorboard; extra == "deepspeed-testing"
  189. Requires-Dist: sacrebleu<2.0.0,>=1.4.12; extra == "deepspeed-testing"
  190. Requires-Dist: filelock; extra == "deepspeed-testing"
  191. Requires-Dist: hf-doc-builder; extra == "deepspeed-testing"
  192. Requires-Dist: datasets>=2.15.0; extra == "deepspeed-testing"
  193. Requires-Dist: ruff==0.14.10; extra == "deepspeed-testing"
  194. Requires-Dist: GitPython<3.1.19; extra == "deepspeed-testing"
  195. Requires-Dist: urllib3<2.0.0; extra == "deepspeed-testing"
  196. Requires-Dist: libcst; extra == "deepspeed-testing"
  197. Requires-Dist: rich; extra == "deepspeed-testing"
  198. Requires-Dist: ty==0.0.20; extra == "deepspeed-testing"
  199. Requires-Dist: tomli; extra == "deepspeed-testing"
  200. Requires-Dist: faiss-cpu; extra == "deepspeed-testing"
  201. Requires-Dist: datasets>=2.15.0; extra == "deepspeed-testing"
  202. Requires-Dist: sentencepiece!=0.1.92,>=0.1.91; extra == "deepspeed-testing"
  203. Requires-Dist: protobuf; extra == "deepspeed-testing"
  204. Requires-Dist: openai>=1.98.0; extra == "deepspeed-testing"
  205. Requires-Dist: pydantic>=2; extra == "deepspeed-testing"
  206. Requires-Dist: uvicorn; extra == "deepspeed-testing"
  207. Requires-Dist: fastapi; extra == "deepspeed-testing"
  208. Requires-Dist: starlette; extra == "deepspeed-testing"
  209. Requires-Dist: rich; extra == "deepspeed-testing"
  210. Requires-Dist: torch>=2.4; extra == "deepspeed-testing"
  211. Requires-Dist: accelerate>=1.1.0; extra == "deepspeed-testing"
  212. Requires-Dist: mistral-common[image]>=1.10.0; extra == "deepspeed-testing"
  213. Requires-Dist: optuna; extra == "deepspeed-testing"
  214. Requires-Dist: sentencepiece!=0.1.92,>=0.1.91; extra == "deepspeed-testing"
  215. Requires-Dist: protobuf; extra == "deepspeed-testing"
  216. Provides-Extra: all
  217. Requires-Dist: torch>=2.4; extra == "all"
  218. Requires-Dist: accelerate>=1.1.0; extra == "all"
  219. Requires-Dist: torchvision; extra == "all"
  220. Requires-Dist: Pillow<=15.0,>=10.0.1; extra == "all"
  221. Requires-Dist: torchaudio; extra == "all"
  222. Requires-Dist: librosa; extra == "all"
  223. Requires-Dist: pyctcdecode>=0.4.0; extra == "all"
  224. Requires-Dist: phonemizer; extra == "all"
  225. Requires-Dist: av; extra == "all"
  226. Requires-Dist: kernels<0.13,>=0.12.0; extra == "all"
  227. Requires-Dist: timm>=1.0.23; extra == "all"
  228. Requires-Dist: sentencepiece!=0.1.92,>=0.1.91; extra == "all"
  229. Requires-Dist: protobuf; extra == "all"
  230. Requires-Dist: tiktoken; extra == "all"
  231. Requires-Dist: blobfile; extra == "all"
  232. Requires-Dist: jinja2>=3.1.0; extra == "all"
  233. Requires-Dist: jmespath>=1.0.1; extra == "all"
  234. Requires-Dist: num2words; extra == "all"
  235. Requires-Dist: mistral-common[image]>=1.10.0; extra == "all"
  236. Provides-Extra: dev
  237. Requires-Dist: torch>=2.4; extra == "dev"
  238. Requires-Dist: accelerate>=1.1.0; extra == "dev"
  239. Requires-Dist: torchvision; extra == "dev"
  240. Requires-Dist: Pillow<=15.0,>=10.0.1; extra == "dev"
  241. Requires-Dist: torchaudio; extra == "dev"
  242. Requires-Dist: librosa; extra == "dev"
  243. Requires-Dist: pyctcdecode>=0.4.0; extra == "dev"
  244. Requires-Dist: phonemizer; extra == "dev"
  245. Requires-Dist: av; extra == "dev"
  246. Requires-Dist: kernels<0.13,>=0.12.0; extra == "dev"
  247. Requires-Dist: timm>=1.0.23; extra == "dev"
  248. Requires-Dist: sentencepiece!=0.1.92,>=0.1.91; extra == "dev"
  249. Requires-Dist: protobuf; extra == "dev"
  250. Requires-Dist: tiktoken; extra == "dev"
  251. Requires-Dist: blobfile; extra == "dev"
  252. Requires-Dist: jinja2>=3.1.0; extra == "dev"
  253. Requires-Dist: jmespath>=1.0.1; extra == "dev"
  254. Requires-Dist: num2words; extra == "dev"
  255. Requires-Dist: mistral-common[image]>=1.10.0; extra == "dev"
  256. Requires-Dist: pytest<9.0.0,>=7.2.0; extra == "dev"
  257. Requires-Dist: pytest-asyncio>=1.2.0; extra == "dev"
  258. Requires-Dist: pytest-random-order; extra == "dev"
  259. Requires-Dist: pytest-rich; extra == "dev"
  260. Requires-Dist: pytest-xdist; extra == "dev"
  261. Requires-Dist: pytest-order; extra == "dev"
  262. Requires-Dist: pytest-rerunfailures<16.0; extra == "dev"
  263. Requires-Dist: pytest-timeout; extra == "dev"
  264. Requires-Dist: pytest-env; extra == "dev"
  265. Requires-Dist: timeout-decorator; extra == "dev"
  266. Requires-Dist: parameterized>=0.9; extra == "dev"
  267. Requires-Dist: psutil; extra == "dev"
  268. Requires-Dist: dill<0.3.5; extra == "dev"
  269. Requires-Dist: evaluate>=0.4.6; extra == "dev"
  270. Requires-Dist: rouge-score!=0.0.7,!=0.0.8,!=0.1,!=0.1.1; extra == "dev"
  271. Requires-Dist: nltk<=3.8.1; extra == "dev"
  272. Requires-Dist: sacremoses; extra == "dev"
  273. Requires-Dist: rjieba; extra == "dev"
  274. Requires-Dist: beautifulsoup4; extra == "dev"
  275. Requires-Dist: tensorboard; extra == "dev"
  276. Requires-Dist: sacrebleu<2.0.0,>=1.4.12; extra == "dev"
  277. Requires-Dist: filelock; extra == "dev"
  278. Requires-Dist: hf-doc-builder; extra == "dev"
  279. Requires-Dist: datasets>=2.15.0; extra == "dev"
  280. Requires-Dist: ruff==0.14.10; extra == "dev"
  281. Requires-Dist: GitPython<3.1.19; extra == "dev"
  282. Requires-Dist: urllib3<2.0.0; extra == "dev"
  283. Requires-Dist: libcst; extra == "dev"
  284. Requires-Dist: rich; extra == "dev"
  285. Requires-Dist: ty==0.0.20; extra == "dev"
  286. Requires-Dist: tomli; extra == "dev"
  287. Requires-Dist: faiss-cpu; extra == "dev"
  288. Requires-Dist: datasets>=2.15.0; extra == "dev"
  289. Requires-Dist: sentencepiece!=0.1.92,>=0.1.91; extra == "dev"
  290. Requires-Dist: protobuf; extra == "dev"
  291. Requires-Dist: openai>=1.98.0; extra == "dev"
  292. Requires-Dist: pydantic>=2; extra == "dev"
  293. Requires-Dist: uvicorn; extra == "dev"
  294. Requires-Dist: fastapi; extra == "dev"
  295. Requires-Dist: starlette; extra == "dev"
  296. Requires-Dist: rich; extra == "dev"
  297. Requires-Dist: torch>=2.4; extra == "dev"
  298. Requires-Dist: accelerate>=1.1.0; extra == "dev"
  299. Requires-Dist: mistral-common[image]>=1.10.0; extra == "dev"
  300. Requires-Dist: fugashi>=1.0; extra == "dev"
  301. Requires-Dist: ipadic<2.0,>=1.0.0; extra == "dev"
  302. Requires-Dist: unidic_lite>=1.0.7; extra == "dev"
  303. Requires-Dist: unidic>=1.0.2; extra == "dev"
  304. Requires-Dist: rhoknp<1.3.1,>=1.1.0; extra == "dev"
  305. Requires-Dist: sudachipy>=0.6.6; extra == "dev"
  306. Requires-Dist: sudachidict_core>=20220729; extra == "dev"
  307. Requires-Dist: scikit-learn; extra == "dev"
  308. Dynamic: author
  309. Dynamic: author-email
  310. Dynamic: classifier
  311. Dynamic: description
  312. Dynamic: description-content-type
  313. Dynamic: home-page
  314. Dynamic: keywords
  315. Dynamic: license
  316. Dynamic: license-file
  317. Dynamic: provides-extra
  318. Dynamic: requires-dist
  319. Dynamic: requires-python
  320. Dynamic: summary
  321. <!---
  322. Copyright 2020 The HuggingFace Team. All rights reserved.
  323. Licensed under the Apache License, Version 2.0 (the "License");
  324. you may not use this file except in compliance with the License.
  325. You may obtain a copy of the License at
  326. http://www.apache.org/licenses/LICENSE-2.0
  327. Unless required by applicable law or agreed to in writing, software
  328. distributed under the License is distributed on an "AS IS" BASIS,
  329. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  330. See the License for the specific language governing permissions and
  331. limitations under the License.
  332. -->
  333. <p align="center">
  334. <picture>
  335. <source media="(prefers-color-scheme: dark)" srcset="https://huggingface.co/datasets/huggingface/documentation-images/raw/main/transformers-logo-dark.svg">
  336. <source media="(prefers-color-scheme: light)" srcset="https://huggingface.co/datasets/huggingface/documentation-images/raw/main/transformers-logo-light.svg">
  337. <img alt="Hugging Face Transformers Library" src="https://huggingface.co/datasets/huggingface/documentation-images/raw/main/transformers-logo-light.svg" width="352" height="59" style="max-width: 100%;">
  338. </picture>
  339. <br/>
  340. <br/>
  341. </p>
  342. <p align="center">
  343. <a href="https://huggingface.com/models"><img alt="Checkpoints on Hub" src="https://img.shields.io/endpoint?url=https://huggingface.co/api/shields/models&color=brightgreen"></a>
  344. <a href="https://circleci.com/gh/huggingface/transformers"><img alt="Build" src="https://img.shields.io/circleci/build/github/huggingface/transformers/main"></a>
  345. <a href="https://github.com/huggingface/transformers/blob/main/LICENSE"><img alt="GitHub" src="https://img.shields.io/github/license/huggingface/transformers.svg?color=blue"></a>
  346. <a href="https://huggingface.co/docs/transformers/index"><img alt="Documentation" src="https://img.shields.io/website/http/huggingface.co/docs/transformers/index.svg?down_color=red&down_message=offline&up_message=online"></a>
  347. <a href="https://github.com/huggingface/transformers/releases"><img alt="GitHub release" src="https://img.shields.io/github/release/huggingface/transformers.svg"></a>
  348. <a href="https://github.com/huggingface/transformers/blob/main/CODE_OF_CONDUCT.md"><img alt="Contributor Covenant" src="https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg"></a>
  349. <a href="https://zenodo.org/badge/latestdoi/155220641"><img src="https://zenodo.org/badge/155220641.svg" alt="DOI"></a>
  350. </p>
  351. <h4 align="center">
  352. <p>
  353. <b>English</b> |
  354. <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_zh-hans.md">简体中文</a> |
  355. <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_zh-hant.md">繁體中文</a> |
  356. <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_ko.md">한국어</a> |
  357. <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_es.md">Español</a> |
  358. <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_ja.md">日本語</a> |
  359. <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_hd.md">हिन्दी</a> |
  360. <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_ru.md">Русский</a> |
  361. <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_pt-br.md">Português</a> |
  362. <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_te.md">తెలుగు</a> |
  363. <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_fr.md">Français</a> |
  364. <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_de.md">Deutsch</a> |
  365. <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_it.md">Italiano</a> |
  366. <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_vi.md">Tiếng Việt</a> |
  367. <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_ar.md">العربية</a> |
  368. <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_ur.md">اردو</a> |
  369. <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_bn.md">বাংলা</a> |
  370. </p>
  371. </h4>
  372. <h3 align="center">
  373. <p>State-of-the-art pretrained models for inference and training</p>
  374. </h3>
  375. <h3 align="center">
  376. <img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/transformers_as_a_model_definition.png"/>
  377. </h3>
  378. Transformers acts as the model-definition framework for state-of-the-art machine learning with text, computer
  379. vision, audio, video, and multimodal models, for both inference and training.
  380. It centralizes the model definition so that this definition is agreed upon across the ecosystem. `transformers` is the
  381. pivot across frameworks: if a model definition is supported, it will be compatible with the majority of training
  382. frameworks (Axolotl, Unsloth, DeepSpeed, FSDP, PyTorch-Lightning, ...), inference engines (vLLM, SGLang, TGI, ...),
  383. and adjacent modeling libraries (llama.cpp, mlx, ...) which leverage the model definition from `transformers`.
  384. We pledge to help support new state-of-the-art models and democratize their usage by having their model definition be
  385. simple, customizable, and efficient.
  386. There are over 1M+ Transformers [model checkpoints](https://huggingface.co/models?library=transformers&sort=trending) on the [Hugging Face Hub](https://huggingface.com/models) you can use.
  387. Explore the [Hub](https://huggingface.com/) today to find a model and use Transformers to help you get started right away.
  388. ## Installation
  389. Transformers works with Python 3.10+, and [PyTorch](https://pytorch.org/get-started/locally/) 2.4+.
  390. Create and activate a virtual environment with [venv](https://docs.python.org/3/library/venv.html) or [uv](https://docs.astral.sh/uv/), a fast Rust-based Python package and project manager.
  391. ```py
  392. # venv
  393. python -m venv .my-env
  394. source .my-env/bin/activate
  395. # uv
  396. uv venv .my-env
  397. source .my-env/bin/activate
  398. ```
  399. Install Transformers in your virtual environment.
  400. ```py
  401. # pip
  402. pip install "transformers[torch]"
  403. # uv
  404. uv pip install "transformers[torch]"
  405. ```
  406. Install Transformers from source if you want the latest changes in the library or are interested in contributing. However, the *latest* version may not be stable. Feel free to open an [issue](https://github.com/huggingface/transformers/issues) if you encounter an error.
  407. ```shell
  408. git clone https://github.com/huggingface/transformers.git
  409. cd transformers
  410. # pip
  411. pip install '.[torch]'
  412. # uv
  413. uv pip install '.[torch]'
  414. ```
  415. ## Quickstart
  416. Get started with Transformers right away with the [Pipeline](https://huggingface.co/docs/transformers/pipeline_tutorial) API. The `Pipeline` is a high-level inference class that supports text, audio, vision, and multimodal tasks. It handles preprocessing the input and returns the appropriate output.
  417. Instantiate a pipeline and specify model to use for text generation. The model is downloaded and cached so you can easily reuse it again. Finally, pass some text to prompt the model.
  418. ```py
  419. from transformers import pipeline
  420. pipeline = pipeline(task="text-generation", model="Qwen/Qwen2.5-1.5B")
  421. pipeline("the secret to baking a really good cake is ")
  422. [{'generated_text': 'the secret to baking a really good cake is 1) to use the right ingredients and 2) to follow the recipe exactly. the recipe for the cake is as follows: 1 cup of sugar, 1 cup of flour, 1 cup of milk, 1 cup of butter, 1 cup of eggs, 1 cup of chocolate chips. if you want to make 2 cakes, how much sugar do you need? To make 2 cakes, you will need 2 cups of sugar.'}]
  423. ```
  424. To chat with a model, the usage pattern is the same. The only difference is you need to construct a chat history (the input to `Pipeline`) between you and the system.
  425. > [!TIP]
  426. > You can also chat with a model directly from the command line, as long as [`transformers serve` is running](https://huggingface.co/docs/transformers/main/en/serving).
  427. > ```shell
  428. > transformers chat Qwen/Qwen2.5-0.5B-Instruct
  429. > ```
  430. ```py
  431. import torch
  432. from transformers import pipeline
  433. chat = [
  434. {"role": "system", "content": "You are a sassy, wise-cracking robot as imagined by Hollywood circa 1986."},
  435. {"role": "user", "content": "Hey, can you tell me any fun things to do in New York?"}
  436. ]
  437. pipeline = pipeline(task="text-generation", model="meta-llama/Meta-Llama-3-8B-Instruct", dtype=torch.bfloat16, device_map="auto")
  438. response = pipeline(chat, max_new_tokens=512)
  439. print(response[0]["generated_text"][-1]["content"])
  440. ```
  441. Expand the examples below to see how `Pipeline` works for different modalities and tasks.
  442. <details>
  443. <summary>Automatic speech recognition</summary>
  444. ```py
  445. from transformers import pipeline
  446. pipeline = pipeline(task="automatic-speech-recognition", model="openai/whisper-large-v3")
  447. pipeline("https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/mlk.flac")
  448. {'text': ' I have a dream that one day this nation will rise up and live out the true meaning of its creed.'}
  449. ```
  450. </details>
  451. <details>
  452. <summary>Image classification</summary>
  453. <h3 align="center">
  454. <a><img src="https://huggingface.co/datasets/Narsil/image_dummy/raw/main/parrots.png"></a>
  455. </h3>
  456. ```py
  457. from transformers import pipeline
  458. pipeline = pipeline(task="image-classification", model="facebook/dinov2-small-imagenet1k-1-layer")
  459. pipeline("https://huggingface.co/datasets/Narsil/image_dummy/raw/main/parrots.png")
  460. [{'label': 'macaw', 'score': 0.997848391532898},
  461. {'label': 'sulphur-crested cockatoo, Kakatoe galerita, Cacatua galerita',
  462. 'score': 0.0016551691805943847},
  463. {'label': 'lorikeet', 'score': 0.00018523589824326336},
  464. {'label': 'African grey, African gray, Psittacus erithacus',
  465. 'score': 7.85409429227002e-05},
  466. {'label': 'quail', 'score': 5.502637941390276e-05}]
  467. ```
  468. </details>
  469. <details>
  470. <summary>Visual question answering</summary>
  471. <h3 align="center">
  472. <a><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/idefics-few-shot.jpg"></a>
  473. </h3>
  474. ```py
  475. from transformers import pipeline
  476. pipeline = pipeline(task="visual-question-answering", model="Salesforce/blip-vqa-base")
  477. pipeline(
  478. image="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/idefics-few-shot.jpg",
  479. question="What is in the image?",
  480. )
  481. [{'answer': 'statue of liberty'}]
  482. ```
  483. </details>
  484. ## Why should I use Transformers?
  485. 1. Easy-to-use state-of-the-art models:
  486. - High performance on natural language understanding & generation, computer vision, audio, video, and multimodal tasks.
  487. - Low barrier to entry for researchers, engineers, and developers.
  488. - Few user-facing abstractions with just three classes to learn.
  489. - A unified API for using all our pretrained models.
  490. 1. Lower compute costs, smaller carbon footprint:
  491. - Share trained models instead of training from scratch.
  492. - Reduce compute time and production costs.
  493. - Dozens of model architectures with 1M+ pretrained checkpoints across all modalities.
  494. 1. Choose the right framework for every part of a model's lifetime:
  495. - Train state-of-the-art models in 3 lines of code.
  496. - Move a single model between PyTorch/JAX/TF2.0 frameworks at will.
  497. - Pick the right framework for training, evaluation, and production.
  498. 1. Easily customize a model or an example to your needs:
  499. - We provide examples for each architecture to reproduce the results published by its original authors.
  500. - Model internals are exposed as consistently as possible.
  501. - Model files can be used independently of the library for quick experiments.
  502. <a target="_blank" href="https://huggingface.co/enterprise">
  503. <img alt="Hugging Face Enterprise Hub" src="https://github.com/user-attachments/assets/247fb16d-d251-4583-96c4-d3d76dda4925">
  504. </a><br>
  505. ## Why shouldn't I use Transformers?
  506. - This library is not a modular toolbox of building blocks for neural nets. The code in the model files is not refactored with additional abstractions on purpose, so that researchers can quickly iterate on each of the models without diving into additional abstractions/files.
  507. - The training API is optimized to work with PyTorch models provided by Transformers. For generic machine learning loops, you should use another library like [Accelerate](https://huggingface.co/docs/accelerate).
  508. - The [example scripts](https://github.com/huggingface/transformers/tree/main/examples) are only *examples*. They may not necessarily work out-of-the-box on your specific use case and you'll need to adapt the code for it to work.
  509. ## 100 projects using Transformers
  510. Transformers is more than a toolkit to use pretrained models, it's a community of projects built around it and the
  511. Hugging Face Hub. We want Transformers to enable developers, researchers, students, professors, engineers, and anyone
  512. else to build their dream projects.
  513. In order to celebrate Transformers 100,000 stars, we wanted to put the spotlight on the
  514. community with the [awesome-transformers](./awesome-transformers.md) page which lists 100
  515. incredible projects built with Transformers.
  516. If you own or use a project that you believe should be part of the list, please open a PR to add it!
  517. ## Example models
  518. You can test most of our models directly on their [Hub model pages](https://huggingface.co/models).
  519. Expand each modality below to see a few example models for various use cases.
  520. <details>
  521. <summary>Audio</summary>
  522. - Audio classification with [CLAP](https://huggingface.co/laion/clap-htsat-fused)
  523. - Automatic speech recognition with [Parakeet](https://huggingface.co/nvidia/parakeet-ctc-1.1b#transcribing-using-transformers-%F0%9F%A4%97), [Whisper](https://huggingface.co/openai/whisper-large-v3-turbo), [GLM-ASR](https://huggingface.co/zai-org/GLM-ASR-Nano-2512) and [Moonshine-Streaming](https://huggingface.co/UsefulSensors/moonshine-streaming-medium)
  524. - Keyword spotting with [Wav2Vec2](https://huggingface.co/superb/wav2vec2-base-superb-ks)
  525. - Speech to speech generation with [Moshi](https://huggingface.co/kyutai/moshiko-pytorch-bf16)
  526. - Text to audio with [MusicGen](https://huggingface.co/facebook/musicgen-large)
  527. - Text to speech with [CSM](https://huggingface.co/sesame/csm-1b)
  528. </details>
  529. <details>
  530. <summary>Computer vision</summary>
  531. - Automatic mask generation with [SAM](https://huggingface.co/facebook/sam-vit-base)
  532. - Depth estimation with [DepthPro](https://huggingface.co/apple/DepthPro-hf)
  533. - Image classification with [DINO v2](https://huggingface.co/facebook/dinov2-base)
  534. - Keypoint detection with [SuperPoint](https://huggingface.co/magic-leap-community/superpoint)
  535. - Keypoint matching with [SuperGlue](https://huggingface.co/magic-leap-community/superglue_outdoor)
  536. - Object detection with [RT-DETRv2](https://huggingface.co/PekingU/rtdetr_v2_r50vd)
  537. - Pose Estimation with [VitPose](https://huggingface.co/usyd-community/vitpose-base-simple)
  538. - Universal segmentation with [OneFormer](https://huggingface.co/shi-labs/oneformer_ade20k_swin_large)
  539. - Video classification with [VideoMAE](https://huggingface.co/MCG-NJU/videomae-large)
  540. </details>
  541. <details>
  542. <summary>Multimodal</summary>
  543. - Audio or text to text with [Voxtral](https://huggingface.co/mistralai/Voxtral-Mini-3B-2507), [Audio Flamingo](https://huggingface.co/nvidia/audio-flamingo-3-hf)
  544. - Document question answering with [LayoutLMv3](https://huggingface.co/microsoft/layoutlmv3-base)
  545. - Image or text to text with [Qwen-VL](https://huggingface.co/Qwen/Qwen2.5-VL-3B-Instruct)
  546. - Image captioning [BLIP-2](https://huggingface.co/Salesforce/blip2-opt-2.7b)
  547. - OCR-based document understanding with [GOT-OCR2](https://huggingface.co/stepfun-ai/GOT-OCR-2.0-hf)
  548. - Table question answering with [TAPAS](https://huggingface.co/google/tapas-base)
  549. - Unified multimodal understanding and generation with [Emu3](https://huggingface.co/BAAI/Emu3-Gen)
  550. - Vision to text with [Llava-OneVision](https://huggingface.co/llava-hf/llava-onevision-qwen2-0.5b-ov-hf)
  551. - Visual question answering with [Llava](https://huggingface.co/llava-hf/llava-1.5-7b-hf)
  552. - Visual referring expression segmentation with [Kosmos-2](https://huggingface.co/microsoft/kosmos-2-patch14-224)
  553. </details>
  554. <details>
  555. <summary>NLP</summary>
  556. - Masked word completion with [ModernBERT](https://huggingface.co/answerdotai/ModernBERT-base)
  557. - Named entity recognition with [Gemma](https://huggingface.co/google/gemma-2-2b)
  558. - Question answering with [Mixtral](https://huggingface.co/mistralai/Mixtral-8x7B-v0.1)
  559. - Summarization with [BART](https://huggingface.co/facebook/bart-large-cnn)
  560. - Translation with [T5](https://huggingface.co/google-t5/t5-base)
  561. - Text generation with [Llama](https://huggingface.co/meta-llama/Llama-3.2-1B)
  562. - Text classification with [Qwen](https://huggingface.co/Qwen/Qwen2.5-0.5B)
  563. </details>
  564. ## Citation
  565. We now have a [paper](https://www.aclweb.org/anthology/2020.emnlp-demos.6/) you can cite for the 🤗 Transformers library:
  566. ```bibtex
  567. @inproceedings{wolf-etal-2020-transformers,
  568. title = "Transformers: State-of-the-Art Natural Language Processing",
  569. author = "Thomas Wolf and Lysandre Debut and Victor Sanh and Julien Chaumond and Clement Delangue and Anthony Moi and Pierric Cistac and Tim Rault and Rémi Louf and Morgan Funtowicz and Joe Davison and Sam Shleifer and Patrick von Platen and Clara Ma and Yacine Jernite and Julien Plu and Canwen Xu and Teven Le Scao and Sylvain Gugger and Mariama Drame and Quentin Lhoest and Alexander M. Rush",
  570. booktitle = "Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations",
  571. month = oct,
  572. year = "2020",
  573. address = "Online",
  574. publisher = "Association for Computational Linguistics",
  575. url = "https://www.aclweb.org/anthology/2020.emnlp-demos.6",
  576. pages = "38--45"
  577. }
  578. ```