Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit d9c2b5c

Browse files
committed
updated README for HelloWorld and QA, and Podfile for QA - PT1.9
1 parent e1085bc commit d9c2b5c

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

HelloWorld/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The model we are going to use is [MobileNet v2](https://pytorch.org/hub/pytorch_
1414
> We highly recommend following the [Pytorch Github page](https://github.com/pytorch/pytorch) to set up the Python development environment on your local machine.
1515
1616
```shell
17-
pip install torchvision
17+
pip install torch torchvision
1818
```
1919

2020
Once we have TorchVision installed successfully, navigate to the HelloWorld folder and run `trace_model.py` to generate our model. The script contains the code of tracing and saving a [torchscript model](https://pytorch.org/tutorials/beginner/Intro_to_TorchScript_tutorial.html) that can be run on mobile devices.
@@ -23,7 +23,7 @@ Once we have TorchVision installed successfully, navigate to the HelloWorld fold
2323
python trace_model.py
2424
```
2525

26-
If everything works well, `model.pt` should be generated in the `HelloWorld` folder. Now copy the model file to our application folder `HelloWorld/model`.
26+
If everything works well, `model.pt` should be generated and saved in the `HelloWorld/HelloWorld/model`.
2727

2828
### Install LibTorch via Cocoapods
2929

QuestionAnswering/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ target 'QuestionAnswering' do
66
use_frameworks!
77

88
# Pods for QuestionAnswering
9-
pod 'LibTorch', '~>1.7.0'
9+
pod 'LibTorch', '~>1.9.0'
1010
end

QuestionAnswering/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ In this demo app, we'll show how to quantize and convert the Huggingface's Disti
88

99
## Prerequisites
1010

11-
* PyTorch 1.7 or later (Optional)
11+
* PyTorch 1.9 or later (Optional)
1212
* Python 3.8 (Optional)
13-
* iOS Pytorch pod library 1.7
13+
* iOS Cocoapods library LibTorch 1.9.0
1414
* Xcode 12 or later
1515

1616
## Quick Start
@@ -21,13 +21,13 @@ To Test Run the iOS QA demo app, run the following commands on a Terminal:
2121

2222
If you don't have PyTorch installed or want to have a quick try of the demo app, you can download the scripted QA model compressed in a zip file [here](https://drive.google.com/file/d/1RWZa_5oSQg5AfInkn344DN3FJ5WbbZbq/view?usp=sharing), then unzip, drag and drop it to the project, and continue to Step 2.
2323

24-
Be aware that the downloadable model file was created with PyTorch 1.7.0, matching the iOS LibTorch library 1.7.0 specified in the `Podfile`. If you use a different version of PyTorch to create your model by following the instructions below, make sure you specify the same iOS LibTorch version in the `Podfile` to avoid possible errors caused by the version mismatch. Furthermore, if you want to use the latest prototype features in the PyTorch master branch to create the model, follow the steps at [Building PyTorch iOS Libraries from Source](https://pytorch.org/mobile/ios/#build-pytorch-ios-libraries-from-source) on how to use the model in iOS.
24+
Be aware that the downloadable model file was created with PyTorch 1.9.0, matching the iOS LibTorch library 1.9.0 specified in the `Podfile`. If you use a different version of PyTorch to create your model by following the instructions below, make sure you specify the same iOS LibTorch version in the `Podfile` to avoid possible errors caused by the version mismatch. Furthermore, if you want to use the latest prototype features in the PyTorch master branch to create the model, follow the steps at [Building PyTorch iOS Libraries from Source](https://pytorch.org/mobile/ios/#build-pytorch-ios-libraries-from-source) on how to use the model in iOS.
2525

26-
With PyTorch 1.7 installed, first install the Huggingface `transformers` by running `pip install transformers` (the versions that have been tested are 4.0.0 and 4.1.1), then run `python convert_distilbert_qa.py`.
26+
With PyTorch 1.9.0 installed, first install the Huggingface `transformers` by running `pip install transformers`, then run `python convert_distilbert_qa.py`.
2727

2828
Note that a pre-defined question and text, resulting in the size of the input tokens (of question and text) being 360, is used in the `convert_distilbert_qa.py`, and 360 is the maximum token size for the user text and question in the app. If the token size of the inputs of the text and question is less than 360, padding will be needed to make the model work correctly.
2929

30-
After the script completes, drag and drop the model file qa360_quantized.pt to the iOS app project. [Dynamic quantization](https://pytorch.org/tutorials/intermediate/dynamic_quantization_bert_tutorial.html) is used to quantize the model to reduce its size to half, without causing inference difference in question answering - you can verify this changing the last 4 lines of code in `convert_distilbert_qa.py` from:
30+
After the script completes, drag and drop the model file `qa360_quantized.pt` to the iOS app project. [Dynamic quantization](https://pytorch.org/tutorials/intermediate/dynamic_quantization_bert_tutorial.html) is used to quantize the model to reduce its size to half, without causing inference difference in question answering - you can verify this changing the last 4 lines of code in `convert_distilbert_qa.py` from:
3131

3232
```
3333
model_dynamic_quantized = torch.quantization.quantize_dynamic(model, qconfig_spec={torch.nn.Linear}, dtype=torch.qint8)

0 commit comments

Comments
 (0)