Skip to content

Commit 7424b28

Browse files
authored
Merge pull request #1 from huggingface/master
merege from original repo
2 parents 6060b2f + 364920e commit 7424b28

File tree

88 files changed

+4476
-3890
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+4476
-3890
lines changed

.circleci/config.yml

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ jobs:
44
working_directory: ~/pytorch-transformers
55
docker:
66
- image: circleci/python:3.5
7-
resource_class: large
8-
parallelism: 4
7+
resource_class: xlarge
8+
parallelism: 1
99
steps:
1010
- checkout
1111
- run: sudo pip install --progress-bar off .
@@ -17,7 +17,7 @@ jobs:
1717
build_py2:
1818
working_directory: ~/pytorch-transformers
1919
resource_class: large
20-
parallelism: 4
20+
parallelism: 1
2121
docker:
2222
- image: circleci/python:2.7
2323
steps:
@@ -26,9 +26,27 @@ jobs:
2626
- run: sudo pip install pytest codecov pytest-cov
2727
- run: python -m pytest -sv ./pytorch_transformers/tests/ --cov
2828
- run: codecov
29+
deploy_doc:
30+
working_directory: ~/pytorch-transformers
31+
docker:
32+
- image: circleci/python:3.5
33+
steps:
34+
- add_ssh_keys:
35+
fingerprints:
36+
- "5b:7a:95:18:07:8c:aa:76:4c:60:35:88:ad:60:56:71"
37+
- checkout
38+
- run: sudo pip install --progress-bar off -r docs/requirements.txt
39+
- run: sudo pip install --progress-bar off -r requirements.txt
40+
- run: cd docs && make clean && make html && scp -r -oStrictHostKeyChecking=no _build/html/* $doc:$dir
41+
workflow_filters: &workflow_filters
42+
filters:
43+
branches:
44+
only:
45+
- master
2946
workflows:
30-
version: 2
31-
build_and_test:
32-
jobs:
33-
- build_py3
34-
- build_py2
47+
version: 2
48+
build_and_test:
49+
jobs:
50+
- build_py3
51+
- build_py2
52+
- deploy_doc: *workflow_filters

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,5 @@ runs
130130
examples/runs
131131

132132
# data
133-
data
133+
data
134+
serialization_dir

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ These implementations have been tested on several datasets (see the example scri
2121
| Section | Description |
2222
|-|-|
2323
| [Installation](#installation) | How to install the package |
24+
| [Online demo](#online-demo) | Experimenting with this repo’s text generation capabilities |
2425
| [Quick tour: Usage](#quick-tour) | Tokenizers & models usage: Bert and GPT-2 |
2526
| [Quick tour: Fine-tuning/usage scripts](#quick-tour-of-the-fine-tuningusage-scripts) | Using provided scripts: GLUE, SQuAD and Text generation |
2627
| [Migrating from pytorch-pretrained-bert to pytorch-transformers](#Migrating-from-pytorch-pretrained-bert-to-pytorch-transformers) | Migrating your code from pytorch-pretrained-bert to pytorch-transformers |
@@ -68,6 +69,14 @@ It contains an example of a conversion script from a Pytorch trained Transformer
6869
At some point in the future, you'll be able to seamlessly move from pre-training or fine-tuning models in PyTorch to productizing them in CoreML,
6970
or prototype a model or an app in CoreML then research its hyperparameters or architecture from PyTorch. Super exciting!
7071

72+
## Online demo
73+
74+
**[Write With Transformer](https://transformer.huggingface.co)**, built by the Hugging Face team at transformer.huggingface.co, is the official demo of this repo’s text generation capabilities.
75+
You can use it to experiment with completions generated by `GPT2Model`, `TransfoXLModel`, and `XLNetModel`.
76+
77+
> “🦄 Write with transformer is to writing what calculators are to calculus.”
78+
79+
![write_with_transformer](https://transformer.huggingface.co/front/assets/thumbnail-large.png)
7180

7281
## Quick tour
7382

@@ -95,7 +104,7 @@ for model_class, tokenizer_class, pretrained_weights in MODELS:
95104
model = model_class.from_pretrained(pretrained_weights)
96105

97106
# Encode text
98-
input_ids = torch.tensor([tokenizer.encode("Here is some text to encode")])
107+
input_ids = torch.tensor([tokenizer.encode("Here is some text to encode", add_special_tokens=True)]) # Add special tokens takes care of adding [CLS], [SEP], <s>... tokens in the right way for each model.
99108
with torch.no_grad():
100109
last_hidden_states = model(input_ids)[0] # Models outputs are now tuples
101110

docs/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ pip install recommonmark
3434

3535
## Building the documentation
3636

37+
Make sure that there is a symlink from the `example` file (in /examples) inside the source folder. Run the followig
38+
command to generate it:
39+
40+
```bash
41+
ln -s ../../examples/README.md source/examples.md
42+
```
43+
3744
Once you have setup `sphinx`, you can build the documentation by running the following command in the `/docs` folder:
3845

3946
```bash

docs/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ sphinxcontrib-jsmath==1.0.1
2626
sphinxcontrib-qthelp==1.0.2
2727
sphinxcontrib-serializinghtml==1.1.3
2828
urllib3==1.25.3
29+
sphinx-markdown-tables==0.0.9

docs/source/conf.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# The short X.Y version
2727
version = u''
2828
# The full version, including alpha/beta/rc tags
29-
release = u'1.0.0'
29+
release = u'1.2.0'
3030

3131

3232
# -- General configuration ---------------------------------------------------
@@ -43,7 +43,8 @@
4343
'sphinx.ext.coverage',
4444
'sphinx.ext.napoleon',
4545
'recommonmark',
46-
'sphinx.ext.viewcode'
46+
'sphinx.ext.viewcode',
47+
'sphinx_markdown_tables'
4748
]
4849

4950
# Add any paths that contain templates here, relative to this directory.

0 commit comments

Comments
 (0)