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

some issue in conde execution #6

Open
mjavedgohar opened this issue Apr 21, 2023 · 2 comments
Open

some issue in conde execution #6

mjavedgohar opened this issue Apr 21, 2023 · 2 comments

Comments

@mjavedgohar
Copy link

Hi @andyweizhao,

I am trying to execute the demo.py and main.py scripts but getting the following error in google colab notebook. can you please help me resolve this? and how can I test my own translation dataset?

image


TypeError Traceback (most recent call last)
in <cell line: 7>()
5 lp='cs-en'
6
----> 7 xmoverscores = scorer.compute_xmoverscore(alignment, projection, bias, source, translations)
8 #, ngram=ngram, layer=layer, dropout_rate=dropout_rate, bs=batch_size)
9

2 frames
/content/score_utils_2.py in get_bert_embedding(all_sens, model, tokenizer, idf_dict, batch_size, device)
52 batch_embedding = bert_encode(model, padded_sens[i:i+batch_size],
53 attention_mask=mask[i:i+batch_size])
---> 54 batch_embedding = torch.stack(batch_embedding)
55 embeddings.append(batch_embedding)
56 del batch_embedding

TypeError: stack(): argument 'tensors' (position 1) must be tuple of Tensors, not str

Thanks

@andyweizhao
Copy link
Collaborator

Hi, the reason for that issue is that Google Colab environment uses a newer version of the Transformer library that is incompatible to the code.

You could adapt the code to the newer version by making the following changes at https://github.com/AIPHES/ACL20-Reference-Free-MT-Evaluation/blob/master/score_utils.py#L20

From:

L20:     output, _, x_encoded_layers, _ = model(input_ids = x, token_type_ids = None, attention_mask = attention_mask)
L21:  return x_encoded_layers

To:

L20:     output = model(input_ids = x, token_type_ids = None, attention_mask = attention_mask)
L21:  return output. hidden_states

Regarding your own datasets, you could arrange the datasets into the format like this, and then change the data_path in demo.py and run it.

Hopefully this helps.

@mjavedgohar
Copy link
Author

mjavedgohar commented Apr 25, 2023 via email

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

2 participants