Skip to content

How to save the model trained on FARMReader to Transformer model and upload it on Transformer Hub? #2176

Discussion options

You must be logged in to vote

Hi @karndeepsingh here are two different ways to save a loaded model. In the screenshot, you can see what files are stored. I hope that helps. 👍

from haystack.nodes import FARMReader
reader = FARMReader(model_name_or_path="bert-base-uncased", use_gpu=True)
reader.save(directory="my_model")

from haystack.modeling.conversion.transformers import Converter
transformers_models = Converter.convert_to_transformers(reader.inferencer.model)
transformers_models[0].save_pretrained(save_directory="my_model_transformers")

Replies: 2 comments 10 replies

Comment options

You must be logged in to vote
1 reply
@karndeepsingh
Comment options

Comment options

You must be logged in to vote
9 replies
@karndeepsingh
Comment options

@bogdankostic
Comment options

@karndeepsingh
Comment options

@tstadel
Comment options

tstadel Mar 3, 2022
Collaborator

@karndeepsingh
Comment options

Answer selected by brandenchan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants