Comments (10)
Yes it does! Thank you very much!
from fastt5.
I was facing the same issue - the resolution lies in the order of the quantized model paths.
It should be encoder, decoder, init-decoder.
from fastt5.
what's your onnxruntime
version and does the models
folder have all the 3 quantized models?
from fastt5.
The models folder has the 3 quantized model files. I am not sure what is my onnxruntime
version. How can I find it?
from fastt5.
pip3 show onnxruntime
if you are using the latest version of fastt5 you should have onnxruntime v1.7.0
from fastt5.
Name: onnxruntime
Version: 1.7.0
Summary: ONNX Runtime is a runtime accelerator for Machine Learning models
Home-page: https://onnxruntime.ai
Author: Microsoft Corporation
Author-email: [email protected]
License: MIT License
Location: /Users/itaimarks/Code/email-cleaner/.venv/lib/python3.7/site-packages
Requires: numpy, protobuf
Required-by: fastt5
from fastt5.
can you provide the reproducible code? also, are you running it on a docker containerized environment?
from fastt5.
Yes running in containerized environment, and generating the onnx
files in the Dockerfile
.
from fastT5 import (
generate_onnx_representation,
quantize,
)
import shutil
import os
model_path = "models/email_cleaner"
onnx_model_paths = generate_onnx_representation(model_path)
quant_model_paths = quantize(onnx_model_paths)
print(quant_model_paths)
for file in quant_model_paths:
shutil.move(file, model_path + "/" + os.path.basename(file))
for file in onnx_model_paths:
os.remove(file)
def init_cleaner_model(model_path):
try:
start = time.time()
app.logger.info(f"Loading Cleaner T5 model from: {model_path}")
tokenizer = AutoTokenizer.from_pretrained(model_path)
os = platform.platform()
if os.startswith("Darwin"):
app.logger.info(f"OS: {os}, Using vanilla T5 model")
model = T5ForConditionalGeneration.from_pretrained(model_path)
else:
app.logger.info(f"OS: {os}, Using FastT5 model")
quant_model_paths = glob.glob(model_path + "/*-quantized.onnx")
model_sessions = get_onnx_runtime_sessions(quant_model_paths)
model = OnnxT5(model_path, model_sessions)
app.logger.info(
f"Loading cleaner model and tokenizer took {time.time() - start} seconds"
)
return model, tokenizer
except Exception as ex:
app.logger.error(ex, exc_info=True)
return None
from fastt5.
I tried fastt5 on a Linux container for simple QG rest API with flask, and it worked fine. I've linked the drive files for the project you can take a look if you are interested. meanwhile, I'll look into your code.
from fastt5.
I think the order of quantized models
has changed while using glob.glob()
to get the model path. You might be feeding only 2 inputs (of encoder) to init decoder (it needs 3 input values).
Make sure to provide the quantized models path in this order to get_onnx_runtime_sessions
.
LMK if this solves your issue.
from fastt5.
Related Issues (20)
- Support for py3.10 HOT 1
- Fails to convert T0-3B HOT 2
- Mt5 model loading fails HOT 11
- Is it suit for other translation model like "Helsinki-NLP / opus-mt-en-de"? HOT 1
- Decoder's encoder_attention_mask input should be called decoder_attention_mask HOT 1
- Thank You and Demo Running in the Browser HOT 2
- M2M100 to ONNX
- Upgrade ONNX runtime HOT 1
- fastt5 not working with FastAPI gunicorn and docker HOT 1
- No such file or directory: '/content/encoder.embed_tokens.weight' HOT 3
- In the source code, the use of attention_mask is contradictory HOT 1
- Issue with onnxruntime HOT 4
- flan-t5 support HOT 5
- GPU support
- Segmentation fault (core dumped) HOT 5
- Is fastT5 qunatization slower than pytorch dynamic quantization?
- TypeError: quantize_dynamic() got an unexpected keyword argument 'activation_type' HOT 1
- Dead kernel
- TypeError: quantize_dynamic() got an unexpected keyword argument 'activation_type' HOT 4
- Does UMT5 Supports? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fastt5.