Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'torch_xla' #5907

Closed
vyaslkv opened this issue Jul 20, 2020 · 24 comments
Closed

ModuleNotFoundError: No module named 'torch_xla' #5907

vyaslkv opened this issue Jul 20, 2020 · 24 comments

Comments

@vyaslkv
Copy link

vyaslkv commented Jul 20, 2020

from transformers import AutoTokenizer, AutoModelWithLMHead

tokenizer = AutoTokenizer.from_pretrained("mrm8488/t5-base-finetuned-wikiSQL-sql-to-en")

model = AutoModelWithLMHead.from_pretrained("mrm8488/t5-base-finetuned-wikiSQL-sql-to-en")

@patil-suraj
Copy link
Contributor

Hi @vyaslkv , what is your transformers version ? I tried this from master branch and it worked.

@vyaslkv
Copy link
Author

vyaslkv commented Jul 20, 2020

'3.0.2' Thanks for the quick reply, which version worked for you

@vyaslkv
Copy link
Author

vyaslkv commented Jul 20, 2020

I also tried with the master branch by uninstalling the transformers and then using the repo

@vyaslkv
Copy link
Author

vyaslkv commented Jul 20, 2020

worked!! Thanks @patil-suraj :)

@vyaslkv
Copy link
Author

vyaslkv commented Jul 20, 2020

can you give me an example how to use this a short one

@vyaslkv
Copy link
Author

vyaslkv commented Jul 20, 2020

Screenshot 2020-07-20 at 7 07 12 PM

@vyaslkv
Copy link
Author

vyaslkv commented Jul 20, 2020

ValueError: You have to specify either decoder_input_ids or decoder_inputs_embeds

@patil-suraj
Copy link
Contributor

You should use .generate method for generation.

model.generate(input_ids=inputs['input_ids'], attention_mask=inputs['attention_mask'])

pinging @mrm8488 for exact generate arguments.

@vyaslkv
Copy link
Author

vyaslkv commented Jul 20, 2020

Screenshot 2020-07-20 at 8 55 41 PM

@vyaslkv
Copy link
Author

vyaslkv commented Jul 20, 2020

is this correct? generating the text out of it the tokenizer decode part?

@mrm8488
Copy link
Contributor

mrm8488 commented Jul 20, 2020

I will write a in the model card the exact arguments to use it ASAP and post it here.

@patil-suraj
Copy link
Contributor

Also @vyaslkv it would nice if you post code instead of screenshot so we can copy paste and try the code faster ;)

@mrm8488
Copy link
Contributor

mrm8488 commented Jul 20, 2020

git clone https://github.com/huggingface/transformers.git
pip install ./transformers
from transformers import AutoModelWithLMHead, AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("mrm8488/t5-base-finetuned-wikiSQL-sql-to-en")
model = AutoModelWithLMHead.from_pretrained("mrm8488/t5-base-finetuned-wikiSQL-sql-to-en")

def get_explanation(query):
  input_text = "translante Sql to English: %s </s>" % query
  features = tokenizer([input_text], return_tensors='pt')

  output = model.generate(input_ids=features['input_ids'], 
               attention_mask=features['attention_mask'])
  
  return tokenizer.decode(output[0])

query = "SELECT COUNT Params form model where location=HF-Hub"

get_explanation(query)

@vyaslkv
Copy link
Author

vyaslkv commented Jul 20, 2020

@mrm8488 can you also make something like nlp to sql

@vyaslkv
Copy link
Author

vyaslkv commented Jul 20, 2020

@mrm8488 it doesn't work for longer queries or is there any particular format I should give

@mrm8488
Copy link
Contributor

mrm8488 commented Jul 20, 2020

@mrm8488 can you also make something like nlp to sql

I already did it.

@mrm8488
Copy link
Contributor

mrm8488 commented Jul 20, 2020

@mrm8488 it doesn't work for longer queries or is there any particular format I should give

The max number of f tokens is 128 but I am currently working on the 256 version

@vyaslkv
Copy link
Author

vyaslkv commented Jul 20, 2020

@mrm8488 can you send me the link of nlp to sql

@mrm8488
Copy link
Contributor

mrm8488 commented Jul 20, 2020

@mrm8488
Copy link
Contributor

mrm8488 commented Jul 20, 2020

Model card: 61e8be9

@vyaslkv
Copy link
Author

vyaslkv commented Jul 20, 2020

@mrm8488 I think this is sql to English not English to SQL correct me If I am wrong

@mrm8488
Copy link
Contributor

mrm8488 commented Jul 20, 2020

English to SQL is t5-base-finetuned-wikiSQL or English to SQL is t5-small-finetuned-wikiSQL

@mrm8488
Copy link
Contributor

mrm8488 commented Jul 20, 2020

https://github.com/mrm8488/shared_colab_notebooks/blob/master/T5_finetuned_wikiSQL_demo.ipynb

@LysandreJik
Copy link
Member

The main issue is solved, closing this for now. Feel free to re-open if the problem persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants