File size: 25,560 Bytes
0e9a03e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
<!---
Copyright 2020 The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!---
A useful guide for English-Traditional Japanese translation of Hugging Face documentation
- Use square quotes, e.g.,ãåŒçšã
Dictionary
API: API(翻蚳ããªã)
add: 远å
checkpoint: ãã§ãã¯ãã€ã³ã
code: ã³ãŒã
community: ã³ãã¥ããã£
confidence: ä¿¡é ŒåºŠ
dataset: ããŒã¿ã»ãã
documentation: ããã¥ã¡ã³ã
example: äŸ
finetune: 埮調æŽ
Hugging Face: Hugging Face(翻蚳ããªã)
implementation: å®è£
inference: æšè«
library: ã©ã€ãã©ãª
module: ã¢ãžã¥ãŒã«
NLP/Natural Language Processing: NLPãšè¡šç€ºãããå Žåã¯ç¿»èš³ããããNatural Language Processingãšè¡šç€ºãããå Žåã¯ç¿»èš³ããã
online demos: ãªã³ã©ã€ã³ãã¢
pipeline: pipeline(翻蚳ããªã)
pretrained/pretrain: åŠç¿æžã¿
Python data structures (e.g., list, set, dict): ãªã¹ããã»ããããã£ã¯ã·ã§ããªãšèš³ãããæ¬åŒ§å
ã¯åæè±èª
repository: repository(翻蚳ããªã)
summary: æŠèŠ
token-: token-(翻蚳ããªã)
Trainer: Trainer(翻蚳ããªã)
transformer: transformer(翻蚳ããªã)
tutorial: ãã¥ãŒããªã¢ã«
user: ãŠãŒã¶
-->
<p align="center">
<br>
<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers_logo_name.png" width="400"/>
<br>
</p>
<p align="center">
<a href="https://circleci.com/gh/huggingface/transformers"><img alt="Build" src="https://img.shields.io/circleci/build/github/huggingface/transformers/main"></a>
<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>
<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>
<a href="https://github.com/huggingface/transformers/releases"><img alt="GitHub release" src="https://img.shields.io/github/release/huggingface/transformers.svg"></a>
<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>
<a href="https://zenodo.org/badge/latestdoi/155220641"><img src="https://zenodo.org/badge/155220641.svg" alt="DOI"></a>
</p>
<h4 align="center">
<p>
<a href="https://github.com/huggingface/transformers/">English</a> |
<a href="https://github.com/huggingface/transformers/blob/main/i18n/README_zh-hans.md">ç®äœäžæ</a> |
<a href="https://github.com/huggingface/transformers/blob/main/i18n/README_zh-hant.md">ç¹é«äžæ</a> |
<a href="https://github.com/huggingface/transformers/blob/main/i18n/README_ko.md">íêµìŽ</a> |
<a href="https://github.com/huggingface/transformers/blob/main/i18n/README_es.md">Español</a> |
<b>æ¥æ¬èª</b> |
<a href="https://github.com/huggingface/transformers/blob/main/i18n/README_hd.md">à€¹à€¿à€šà¥à€Šà¥</a> |
<a href="https://github.com/huggingface/transformers/blob/main/i18n/README_ru.md">Ð ÑÑÑкОй</a> |
<a href="https://github.com/huggingface/transformers/blob/main/i18n/README_pt-br.md">Рortuguês</a> |
<a href="https://github.com/huggingface/transformers/blob/main/i18n/README_te.md">à°€à±à°²à±à°à±</a> |
<a href="https://github.com/huggingface/transformers/blob/main/i18n/README_fr.md">Français</a> |
<a href="https://github.com/huggingface/transformers/blob/main/i18n/README_de.md">Deutsch</a> |
<a href="https://github.com/huggingface/transformers/blob/main/i18n/README_vi.md">Tiếng Viá»t</a> |
<a href="https://github.com/huggingface/transformers/blob/main/i18n/README_ar.md">Ø§ÙØ¹Ø±ØšÙØ©</a> |
<a href="https://github.com/huggingface/transformers/blob/main/i18n/README_ur.md">اردÙ</a> |
</p>
</h4>
<h3 align="center">
<p>JAXãPyTorchãTensorFlowã®ããã®æå
ç«¯æ©æ¢°åŠç¿</p>
</h3>
<h3 align="center">
<a href="https://hf.co/course"><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/course_banner.png"></a>
</h3>
ð€Transformersã¯ãããã¹ããèŠèŠãé³å£°ãªã©ã®ç°ãªãã¢ããªãã£ã«å¯ŸããŠã¿ã¹ã¯ãå®è¡ããããã«ãäºåã«åŠç¿ãããæ°åã®ã¢ãã«ãæäŸããŸãã
ãããã®ã¢ãã«ã¯æ¬¡ã®ãããªå Žåã«é©çšã§ããŸã:
* ð ããã¹ãã¯ãããã¹ãã®åé¡ãæ
å ±æœåºã質åå¿çãèŠçŽã翻蚳ãããã¹ãçæãªã©ã®ã¿ã¹ã¯ã®ããã«ã100以äžã®èšèªã«å¯Ÿå¿ããŠããŸãã
* ðŒïž ç»ååé¡ãç©äœæ€åºãã»ã°ã¡ã³ããŒã·ã§ã³ãªã©ã®ã¿ã¹ã¯ã®ããã®ç»åã
* ð£ïž é³å£°ã¯ãé³å£°èªèãé³å£°åé¡ãªã©ã®ã¿ã¹ã¯ã«äœ¿çšããŸãã
ãã©ã³ã¹ãã©ãŒããŒã¢ãã«ã¯ãããŒãã«è³ªåå¿çãå
åŠæåèªèãã¹ãã£ã³ææžããã®æ
å ±æœåºããããªåé¡ãèŠèŠç質åå¿çãªã©ã**è€æ°ã®ã¢ããªãã£ãçµã¿åããã**ã¿ã¹ã¯ãå®è¡å¯èœã§ãã
ð€Transformersã¯ãäžããããããã¹ãã«å¯ŸããŠãããã®äºååŠç¿ãããã¢ãã«ãçŽ æ©ãããŠã³ããŒãããŠäœ¿çšããããªãèªèº«ã®ããŒã¿ã»ããã§ãããã埮調æŽããç§ãã¡ã®[model hub](https://huggingface.co/models)ã§ã³ãã¥ããã£ãšå
±æããããã®APIãæäŸããŸããåæã«ãã¢ãŒããã¯ãã£ãå®çŸ©ããåPythonã¢ãžã¥ãŒã«ã¯å®å
šã«ã¹ã¿ã³ãã¢ãã³ã§ãããè¿
éãªç ç©¶å®éšãå¯èœã«ããããã«å€æŽããããšãã§ããŸãã
ð€Transformersã¯[Jax](https://jax.readthedocs.io/en/latest/)ã[PyTorch](https://pytorch.org/)ã[TensorFlow](https://www.tensorflow.org/)ãšãã3倧ãã£ãŒãã©ãŒãã³ã°ã©ã€ãã©ãªãŒã«æ¯ããããããããã®ã©ã€ãã©ãªãã·ãŒã ã¬ã¹ã«çµ±åããŠããŸããçæ¹ã§ã¢ãã«ãåŠç¿ããŠãããããçæ¹ã§æšè«çšã«ããŒãããã®ã¯ç°¡åãªããšã§ãã
## ãªã³ã©ã€ã³ãã¢
[model hub](https://huggingface.co/models)ãããã»ãšãã©ã®ã¢ãã«ã®ããŒãžã§çŽæ¥ãã¹ãããããšãã§ããŸãããŸãããããªãã¯ã¢ãã«ããã©ã€ããŒãã¢ãã«ã«å¯ŸããŠã[ãã©ã€ããŒãã¢ãã«ã®ãã¹ãã£ã³ã°ãããŒãžã§ãã³ã°ãæšè«API](https://huggingface.co/pricing)ãæäŸããŠããŸãã
以äžã¯ãã®äžäŸã§ã:
èªç¶èšèªåŠçã«ãŠ:
- [BERTã«ãããã¹ã¯ãã¯ãŒãè£å®](https://huggingface.co/google-bert/bert-base-uncased?text=Paris+is+the+%5BMASK%5D+of+France)
- [Electraã«ããååå®äœèªè](https://huggingface.co/dbmdz/electra-large-discriminator-finetuned-conll03-english?text=My+name+is+Sarah+and+I+live+in+London+city)
- [GPT-2ã«ããããã¹ãçæ](https://huggingface.co/openai-community/gpt2?text=A+long+time+ago%2C+)
- [RoBERTaã«ããèªç¶èšèªæšè«](https://huggingface.co/FacebookAI/roberta-large-mnli?text=The+dog+was+lost.+Nobody+lost+any+animal)
- [BARTã«ããèŠçŽ](https://huggingface.co/facebook/bart-large-cnn?text=The+tower+is+324+metres+%281%2C063+ft%29+tall%2C+about+the+same+height+as+an+81-storey+building%2C+and+the+tallest+structure+in+Paris.+Its+base+is+square%2C+measuring+125+metres+%28410+ft%29+on+each+side.+During+its+construction%2C+the+Eiffel+Tower+surpassed+the+Washington+Monument+to+become+the+tallest+man-made+structure+in+the+world%2C+a+title+it+held+for+41+years+until+the+Chrysler+Building+in+New+York+City+was+finished+in+1930.+It+was+the+first+structure+to+reach+a+height+of+300+metres.+Due+to+the+addition+of+a+broadcasting+aerial+at+the+top+of+the+tower+in+1957%2C+it+is+now+taller+than+the+Chrysler+Building+by+5.2+metres+%2817+ft%29.+Excluding+transmitters%2C+the+Eiffel+Tower+is+the+second+tallest+free-standing+structure+in+France+after+the+Millau+Viaduct)
- [DistilBERTã«ãã質åå¿ç](https://huggingface.co/distilbert/distilbert-base-uncased-distilled-squad?text=Which+name+is+also+used+to+describe+the+Amazon+rainforest+in+English%3F&context=The+Amazon+rainforest+%28Portuguese%3A+Floresta+Amaz%C3%B4nica+or+Amaz%C3%B4nia%3B+Spanish%3A+Selva+Amaz%C3%B3nica%2C+Amazon%C3%ADa+or+usually+Amazonia%3B+French%3A+For%C3%AAt+amazonienne%3B+Dutch%3A+Amazoneregenwoud%29%2C+also+known+in+English+as+Amazonia+or+the+Amazon+Jungle%2C+is+a+moist+broadleaf+forest+that+covers+most+of+the+Amazon+basin+of+South+America.+This+basin+encompasses+7%2C000%2C000+square+kilometres+%282%2C700%2C000+sq+mi%29%2C+of+which+5%2C500%2C000+square+kilometres+%282%2C100%2C000+sq+mi%29+are+covered+by+the+rainforest.+This+region+includes+territory+belonging+to+nine+nations.+The+majority+of+the+forest+is+contained+within+Brazil%2C+with+60%25+of+the+rainforest%2C+followed+by+Peru+with+13%25%2C+Colombia+with+10%25%2C+and+with+minor+amounts+in+Venezuela%2C+Ecuador%2C+Bolivia%2C+Guyana%2C+Suriname+and+French+Guiana.+States+or+departments+in+four+nations+contain+%22Amazonas%22+in+their+names.+The+Amazon+represents+over+half+of+the+planet%27s+remaining+rainforests%2C+and+comprises+the+largest+and+most+biodiverse+tract+of+tropical+rainforest+in+the+world%2C+with+an+estimated+390+billion+individual+trees+divided+into+16%2C000+species)
- [T5ã«ãã翻蚳](https://huggingface.co/google-t5/t5-base?text=My+name+is+Wolfgang+and+I+live+in+Berlin)
ã³ã³ãã¥ãŒã¿ããžã§ã³ã«ãŠ:
- [ViTã«ããç»ååé¡](https://huggingface.co/google/vit-base-patch16-224)
- [DETRã«ããç©äœæ€åº](https://huggingface.co/facebook/detr-resnet-50)
- [SegFormerã«ããã»ãã³ãã£ãã¯ã»ã°ã¡ã³ããŒã·ã§ã³](https://huggingface.co/nvidia/segformer-b0-finetuned-ade-512-512)
- [DETRã«ããããããã£ãã¯ã»ã°ã¡ã³ããŒã·ã§ã³](https://huggingface.co/facebook/detr-resnet-50-panoptic)
ãªãŒãã£ãªã«ãŠ:
- [Wav2Vec2ã«ããèªåé³å£°èªè](https://huggingface.co/facebook/wav2vec2-base-960h)
- [Wav2Vec2ã«ããããŒã¯ãŒãæ€çŽ¢](https://huggingface.co/superb/wav2vec2-base-superb-ks)
ãã«ãã¢ãŒãã«ãªã¿ã¹ã¯ã«ãŠ:
- [ViLTã«ããèŠèŠç質åå¿ç](https://huggingface.co/dandelin/vilt-b32-finetuned-vqa)
Hugging FaceããŒã ã«ãã£ãŠäœããã **[ãã©ã³ã¹ãã©ãŒããŒã䜿ã£ãæžã蟌ã¿](https://transformer.huggingface.co)** ã¯ããã®ãªããžããªã®ããã¹ãçææ©èœã®å
¬åŒãã¢ã§ããã
## Hugging FaceããŒã ã«ããã«ã¹ã¿ã ã»ãµããŒãããåžæã®å Žå
<a target="_blank" href="https://huggingface.co/support">
<img alt="HuggingFace Expert Acceleration Program" src="https://cdn-media.huggingface.co/marketing/transformers/new-support-improved.png" style="max-width: 600px; border: 1px solid #eee; border-radius: 4px; box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);">
</a><br>
## ã¯ã€ãã¯ãã¢ãŒ
äžããããå
¥åïŒããã¹ããç»åãé³å£°ã...ïŒã«å¯ŸããŠããã«ã¢ãã«ã䜿ãããã«ãæã
ã¯`pipeline`ãšããAPIãæäŸããŠãããŸããpipelineã¯ãåŠç¿æžã¿ã®ã¢ãã«ãšããã®ã¢ãã«ã®åŠç¿æã«äœ¿çšãããååŠçãã°ã«ãŒãåãããã®ã§ãã以äžã¯ãè¯å®çãªããã¹ããšåŠå®çãªããã¹ããåé¡ããããã«pipelineã䜿çšããæ¹æ³ã§ã:
```python
>>> from transformers import pipeline
# Allocate a pipeline for sentiment-analysis
>>> classifier = pipeline('sentiment-analysis')
>>> classifier('We are very happy to introduce pipeline to the transformers repository.')
[{'label': 'POSITIVE', 'score': 0.9996980428695679}]
```
2è¡ç®ã®ã³ãŒãã§ã¯ãpipelineã§äœ¿çšãããäºååŠç¿æžã¿ã¢ãã«ãããŠã³ããŒãããŠãã£ãã·ã¥ãã3è¡ç®ã§ã¯äžããããããã¹ãã«å¯ŸããŠãã®ã¢ãã«ãè©äŸ¡ããŸããããã§ã¯ãçãã¯99.97%ã®ä¿¡é ŒåºŠã§ãããžãã£ããã§ãã
èªç¶èšèªåŠçã ãã§ãªããã³ã³ãã¥ãŒã¿ããžã§ã³ãé³å£°åŠçã«ãããŠããå€ãã®ã¿ã¹ã¯ã«ã¯ãããããèšç·Žããã`pipeline`ãçšæãããŠãããäŸãã°ãç»åããæ€åºãããç©äœãç°¡åã«æœåºããããšãã§ãã:
``` python
>>> import requests
>>> from PIL import Image
>>> from transformers import pipeline
# Download an image with cute cats
>>> url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/coco_sample.png"
>>> image_data = requests.get(url, stream=True).raw
>>> image = Image.open(image_data)
# Allocate a pipeline for object detection
>>> object_detector = pipeline('object-detection')
>>> object_detector(image)
[{'score': 0.9982201457023621,
'label': 'remote',
'box': {'xmin': 40, 'ymin': 70, 'xmax': 175, 'ymax': 117}},
{'score': 0.9960021376609802,
'label': 'remote',
'box': {'xmin': 333, 'ymin': 72, 'xmax': 368, 'ymax': 187}},
{'score': 0.9954745173454285,
'label': 'couch',
'box': {'xmin': 0, 'ymin': 1, 'xmax': 639, 'ymax': 473}},
{'score': 0.9988006353378296,
'label': 'cat',
'box': {'xmin': 13, 'ymin': 52, 'xmax': 314, 'ymax': 470}},
{'score': 0.9986783862113953,
'label': 'cat',
'box': {'xmin': 345, 'ymin': 23, 'xmax': 640, 'ymax': 368}}]
```
ããã§ã¯ãç»åããæ€åºããããªããžã§ã¯ãã®ãªã¹ããåŸããããªããžã§ã¯ããå²ãããã¯ã¹ãšä¿¡é ŒåºŠã¹ã³ã¢ã衚瀺ãããŸããå·ŠåŽãå
ç»åãå³åŽãäºæž¬çµæã衚瀺ãããã®ã§ã:
<h3 align="center">
<a><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/coco_sample.png" width="400"></a>
<a><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/coco_sample_post_processed.png" width="400"></a>
</h3>
[ãã®ãã¥ãŒããªã¢ã«](https://huggingface.co/docs/transformers/task_summary)ã§ã¯ã`pipeline`APIã§ãµããŒããããŠããã¿ã¹ã¯ã«ã€ããŠè©³ãã説æããŠããŸãã
`pipeline`ã«å ããŠãäžããããã¿ã¹ã¯ã«åŠç¿æžã¿ã®ã¢ãã«ãããŠã³ããŒãããŠäœ¿çšããããã«å¿
èŠãªã®ã¯ã3è¡ã®ã³ãŒãã ãã§ãã以äžã¯PyTorchã®ããŒãžã§ã³ã§ã:
```python
>>> from transformers import AutoTokenizer, AutoModel
>>> tokenizer = AutoTokenizer.from_pretrained("google-bert/bert-base-uncased")
>>> model = AutoModel.from_pretrained("google-bert/bert-base-uncased")
>>> inputs = tokenizer("Hello world!", return_tensors="pt")
>>> outputs = model(**inputs)
```
ãããŠãã¡ãã¯TensorFlowãšåçã®ã³ãŒããšãªããŸã:
```python
>>> from transformers import AutoTokenizer, TFAutoModel
>>> tokenizer = AutoTokenizer.from_pretrained("google-bert/bert-base-uncased")
>>> model = TFAutoModel.from_pretrained("google-bert/bert-base-uncased")
>>> inputs = tokenizer("Hello world!", return_tensors="tf")
>>> outputs = model(**inputs)
```
ããŒã¯ãã€ã¶ã¯åŠç¿æžã¿ã¢ãã«ãæåŸ
ãããã¹ãŠã®ååŠçãæ
åœããåäžã®æåå (äžèšã®äŸã®ããã«) ãŸãã¯ãªã¹ãã«å¯ŸããŠçŽæ¥åŒã³åºãããšãã§ããŸããããã¯äžæµã®ã³ãŒãã§äœ¿çšã§ããèŸæžãåºåããŸãããŸããåçŽã« ** åŒæ°å±éæŒç®åã䜿çšããŠã¢ãã«ã«çŽæ¥æž¡ãããšãã§ããŸãã
ã¢ãã«èªäœã¯éåžžã®[Pytorch `nn.Module`](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) ãŸã㯠[TensorFlow `tf.keras.Model`](https://www.tensorflow.org/api_docs/python/tf/keras/Model) (ããã¯ãšã³ãã«ãã£ãŠç°ãªã)ã§ãéåžžéã䜿çšããããšãå¯èœã§ãã[ãã®ãã¥ãŒããªã¢ã«](https://huggingface.co/docs/transformers/training)ã§ã¯ããã®ãããªã¢ãã«ãåŸæ¥ã®PyTorchãTensorFlowã®åŠç¿ã«ãŒãã«çµ±åããæ¹æ³ããç§ãã¡ã®`Trainer`APIã䜿ã£ãŠæ°ããããŒã¿ã»ããã§çŽ æ©ã埮調æŽãè¡ãæ¹æ³ã«ã€ããŠèª¬æããŸãã
## ãªãtransformersã䜿ãå¿
èŠãããã®ã§ããããïŒ
1. 䜿ããããææ°ã¢ãã«:
- èªç¶èšèªçè§£ã»çæãã³ã³ãã¥ãŒã¿ããžã§ã³ããªãŒãã£ãªã®åã¿ã¹ã¯ã§é«ãããã©ãŒãã³ã¹ãçºæ®ããŸãã
- æè²è
ãå®åè
ã«ãšã£ãŠã®äœãåå
¥éå£ã
- åŠç¿ããã¯ã©ã¹ã¯3ã€ã ãã§ããŠãŒã¶ãçŽé¢ããæœè±¡åã¯ã»ãšãã©ãããŸããã
- åŠç¿æžã¿ã¢ãã«ãå©çšããããã®çµ±äžãããAPIã
1. äœãèšç®ã³ã¹ããå°ãªãã«ãŒãã³ãããããªã³ã:
- ç ç©¶è
ã¯ãåžžã«åãã¬ãŒãã³ã°ãè¡ãã®ã§ã¯ãªãããã¬ãŒãã³ã°ãããã¢ãã«ãå
±æããããšãã§ããŸãã
- å®åå®¶ã¯ãèšç®æéãçç£ã³ã¹ããåæžããããšãã§ããŸãã
- ãã¹ãŠã®ã¢ããªãã£ã«ãããŠã60,000以äžã®äºååŠç¿æžã¿ã¢ãã«ãæã€æ°å€ãã®ã¢ãŒããã¯ãã£ãæäŸããŸãã
1. ã¢ãã«ã®ã©ã€ãã¿ã€ã ã®ããããéšåã§é©åãªãã¬ãŒã ã¯ãŒã¯ãéžæå¯èœ:
- 3è¡ã®ã³ãŒãã§æå
端ã®ã¢ãã«ããã¬ãŒãã³ã°ã
- TF2.0/PyTorch/JAXãã¬ãŒã ã¯ãŒã¯éã§1ã€ã®ã¢ãã«ãèªåšã«ç§»åãããã
- åŠç¿ãè©äŸ¡ãçç£ã«é©ãããã¬ãŒã ã¯ãŒã¯ãã·ãŒã ã¬ã¹ã«éžæã§ããŸãã
1. ã¢ãã«ããµã³ãã«ãããŒãºã«åãããŠç°¡åã«ã«ã¹ã¿ãã€ãºå¯èœ:
- åèè
ãçºè¡šããçµæãåçŸããããã«ãåã¢ãŒããã¯ãã£ã®äŸãæäŸããŠããŸãã
- ã¢ãã«å
éšã¯å¯èœãªéãäžè²«ããŠå
¬éãããŠããŸãã
- ã¢ãã«ãã¡ã€ã«ã¯ã©ã€ãã©ãªãšã¯ç¬ç«ããŠå©çšããããšãã§ããè¿
éãªå®éšãå¯èœã§ãã
## ãªãtransformersã䜿ã£ãŠã¯ãããªãã®ã§ããããïŒ
- ãã®ã©ã€ãã©ãªã¯ããã¥ãŒã©ã«ãããã®ããã®ãã«ãã£ã³ã°ãããã¯ã®ã¢ãžã¥ãŒã«åŒããŒã«ããã¯ã¹ã§ã¯ãããŸãããã¢ãã«ãã¡ã€ã«ã®ã³ãŒãã¯ãç ç©¶è
ã远å ã®æœè±¡å/ãã¡ã€ã«ã«é£ã³èŸŒãããšãªããåã¢ãã«ãçŽ æ©ãå埩ã§ããããã«ãæå³çã«è¿œå ã®æœè±¡åã§ãªãã¡ã¯ã¿ãªã³ã°ãããŠããŸããã
- åŠç¿APIã¯ã©ã®ãããªã¢ãã«ã§ãåäœããããã§ã¯ãªããã©ã€ãã©ãªãæäŸããã¢ãã«ã§åäœããããã«æé©åãããŠããŸããäžè¬çãªæ©æ¢°åŠç¿ã®ã«ãŒãã«ã¯ãå¥ã®ã©ã€ãã©ãª(ãããã[Accelerate](https://huggingface.co/docs/accelerate))ã䜿çšããå¿
èŠããããŸãã
- ç§ãã¡ã¯ã§ããã ãå€ãã®äœ¿çšäŸã玹ä»ããããåªåããŠããŸããã[examples ãã©ã«ã](https://github.com/huggingface/transformers/tree/main/examples) ã«ããã¹ã¯ãªããã¯ãããŸã§äŸã§ããããªãã®ç¹å®ã®åé¡ã«å¯ŸããŠããã«åäœããããã§ã¯ãªããããªãã®ããŒãºã«åãããããã«æ°è¡ã®ã³ãŒãã倿Žããå¿
èŠãããããšãäºæ³ãããŸãã
## ã€ã³ã¹ããŒã«
### pipã«ãŠ
ãã®ãªããžããªã¯ãPython 3.9+, Flax 0.4.1+, PyTorch 2.1+, TensorFlow 2.6+ ã§ãã¹ããããŠããŸãã
ð€Transformersã¯[ä»®æ³ç°å¢](https://docs.python.org/3/library/venv.html)ã«ã€ã³ã¹ããŒã«ããå¿
èŠããããŸããPythonã®ä»®æ³ç°å¢ã«æ
£ããŠããªãå Žåã¯ã[ãŠãŒã¶ãŒã¬ã€ã](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/)ã確èªããŠãã ããã
ãŸãã䜿çšããããŒãžã§ã³ã®Pythonã§ä»®æ³ç°å¢ãäœæããã¢ã¯ãã£ããŒãããŸãã
ãã®åŸãFlax, PyTorch, TensorFlowã®ãã¡å°ãªããšã1ã€ãã€ã³ã¹ããŒã«ããå¿
èŠããããŸãã
[TensorFlowã€ã³ã¹ããŒã«ããŒãž](https://www.tensorflow.org/install/)ã[PyTorchã€ã³ã¹ããŒã«ããŒãž](https://pytorch.org/get-started/locally/#start-locally)ã[Flax](https://github.com/google/flax#quick-install)ã[Jax](https://github.com/google/jax#installation)ã€ã³ã¹ããŒã«ããŒãžã§ãã䜿ãã®ãã©ãããã©ãŒã å¥ã®ã€ã³ã¹ããŒã«ã³ãã³ããåç
§ããŠãã ããã
ãããã®ããã¯ãšã³ãã®ãããããã€ã³ã¹ããŒã«ãããŠããå Žåãð€Transformersã¯ä»¥äžã®ããã«pipã䜿çšããŠã€ã³ã¹ããŒã«ããããšãã§ããŸã:
```bash
pip install transformers
```
ãããµã³ãã«ã詊ãããããŸãã¯ã³ãŒãã®æå
端ãå¿
èŠã§ãæ°ãããªãªãŒã¹ãåŸ
ãŠãªãå Žåã¯ã[ã©ã€ãã©ãªããœãŒã¹ããã€ã³ã¹ããŒã«](https://huggingface.co/docs/transformers/installation#installing-from-source)ããå¿
èŠããããŸãã
### condaã«ãŠ
ð€Transformersã¯ä»¥äžã®ããã«condaã䜿ã£ãŠèšçœ®ããããšãã§ããŸã:
```shell script
conda install conda-forge::transformers
```
> **_泚æ:_** `huggingface` ãã£ã³ãã«ãã `transformers` ãã€ã³ã¹ããŒã«ããããšã¯éæšå¥šã§ãã
FlaxãPyTorchãTensorFlowãcondaã§ã€ã³ã¹ããŒã«ããæ¹æ³ã¯ãããããã®ã€ã³ã¹ããŒã«ããŒãžã«åŸã£ãŠãã ããã
> **_泚æ:_** Windowsã§ã¯ããã£ãã·ã¥ã®æ©æµãåããããã«ãããããããŒã¢ãŒããæå¹ã«ããããä¿ãããããšããããŸãããã®ãããªå Žåã¯ã[ãã®issue](https://github.com/huggingface/huggingface_hub/issues/1062)ã§ãç¥ãããã ããã
## ã¢ãã«ã¢ãŒããã¯ãã£
ð€TransformersãæäŸãã **[å
šã¢ãã«ãã§ãã¯ãã€ã³ã](https://huggingface.co/models)** ã¯ã[ãŠãŒã¶ãŒ](https://huggingface.co/users)ã[çµç¹](https://huggingface.co/organizations)ã«ãã£ãŠçŽæ¥ã¢ããããŒããããhuggingface.co [model hub](https://huggingface.co)ããã·ãŒã ã¬ã¹ã«çµ±åãããŠããŸãã
çŸåšã®ãã§ãã¯ãã€ã³ãæ°: 
ð€Transformersã¯çŸåšã以äžã®ã¢ãŒããã¯ãã£ãæäŸããŠããŸã: ããããã®ãã€ã¬ãã«ãªèŠçŽã¯[ãã¡ã](https://huggingface.co/docs/transformers/model_summary)ãåç
§ããŠãã ãã.
åã¢ãã«ãFlaxãPyTorchãTensorFlowã§å®è£
ãããŠããããð€Tokenizersã©ã€ãã©ãªã«æ¯ããããé¢é£ããŒã¯ãã€ã¶ãæã£ãŠãããã¯ã[ãã®è¡š](https://huggingface.co/docs/transformers/index#supported-frameworks)ãåç
§ããŠãã ããã
ãããã®å®è£
ã¯ããã€ãã®ããŒã¿ã»ããã§ãã¹ããããŠãã(ãµã³ãã«ã¹ã¯ãªãããåç
§)ããªãªãžãã«ã®å®è£
ã®æ§èœãšäžèŽããã¯ãã§ãããæ§èœã®è©³çްã¯[documentation](https://github.com/huggingface/transformers/tree/main/examples)ã®Examplesã»ã¯ã·ã§ã³ã§èŠãããšãã§ããŸãã
## ããã«è©³ãã
| ã»ã¯ã·ã§ã³ | æŠèŠ |
|-|-|
| [ããã¥ã¡ã³ã](https://huggingface.co/docs/transformers/) | å®å
šãªAPIããã¥ã¡ã³ããšãã¥ãŒããªã¢ã« |
| [ã¿ã¹ã¯æŠèŠ](https://huggingface.co/docs/transformers/task_summary) | ð€TransformersããµããŒãããã¿ã¹ã¯ |
| [ååŠçãã¥ãŒããªã¢ã«](https://huggingface.co/docs/transformers/preprocessing) | ã¢ãã«çšã®ããŒã¿ãæºåããããã«`Tokenizer`ã¯ã©ã¹ãäœ¿çš |
| [ãã¬ãŒãã³ã°ãšåŸ®èª¿æŽ](https://huggingface.co/docs/transformers/training) | PyTorch/TensorFlowã®åŠç¿ã«ãŒããš`Trainer`APIã§ð€TransformersãæäŸããã¢ãã«ãäœ¿çš |
| [ã¯ã€ãã¯ãã¢ãŒ: 埮調æŽ/äœ¿çšæ¹æ³ã¹ã¯ãªãã](https://github.com/huggingface/transformers/tree/main/examples) | æ§ã
ãªã¿ã¹ã¯ã§ã¢ãã«ã®åŸ®èª¿æŽãè¡ãããã®ã¹ã¯ãªããäŸ |
| [ã¢ãã«ã®å
±æãšã¢ããããŒã](https://huggingface.co/docs/transformers/model_sharing) | 埮調æŽããã¢ãã«ãã¢ããããŒãããŠã³ãã¥ããã£ã§å
±æãã |
| [ãã€ã°ã¬ãŒã·ã§ã³](https://huggingface.co/docs/transformers/migration) | `pytorch-transformers`ãŸãã¯`pytorch-pretrained-bert`ããð€Transformers ã«ç§»è¡ãã |
## åŒçš
ð€ ãã©ã³ã¹ãã©ãŒããŒã©ã€ãã©ãªã«åŒçšã§ãã[è«æ](https://www.aclweb.org/anthology/2020.emnlp-demos.6/)ãåºæ¥ãŸãã:
```bibtex
@inproceedings{wolf-etal-2020-transformers,
title = "Transformers: State-of-the-Art Natural Language Processing",
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",
booktitle = "Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations",
month = oct,
year = "2020",
address = "Online",
publisher = "Association for Computational Linguistics",
url = "https://www.aclweb.org/anthology/2020.emnlp-demos.6",
pages = "38--45"
}
```
|