jeniyat / StackOverflowNER

Source Code and Data for Software Domain NER
MIT License
145 stars 37 forks source link

The results are random #16

Open namelucky opened 2 years ago

namelucky commented 2 years ago

I downloaded the pretrained model you provided and loaded it.(https : //drive.google.com/drive/folders/1iEEMr2DYofulK2F5pSErOPf5ggrEqtJt?usp=sharing) Why is the result random?

import torch
from transformers import AutoModelForTokenClassification, AutoTokenizer
pretrained_model ='./utils_fine_tune/word_piece_ner/'
tokenizer = AutoTokenizer.from_pretrained(pretrained_model)
model = AutoModelForTokenClassification.from_pretrained(pretrained_model)
sequence=" Is there any mechanism to enforce a singleton policy without having to make the derived class' constructors private manually?"
print(tokenizer.decode(tokenizer.encode(sequence)))
tokens = tokenizer.tokenize(tokenizer.decode(tokenizer.encode(sequence)))
inputs = tokenizer.encode(sequence, return_tensors="pt")
outputs = model(inputs)
outputs= outputs.logits
predictions = torch.argmax(outputs, dim=2)
for token, prediction in zip(tokens, predictions[0].numpy()):
     print((token, model.config.id2label[prediction]))

image

jiabo-code1 commented 2 years ago

@namelucky Hi! I've tried to get the utils_fine_tune.zip and the data_ctc.zip from the link: https://drive.google.com/drive/folders/1iEEMr2DYofulK2F5pSErOPf5ggrEqtJt?usp=sharing. But I didn't find any other file in this website except for word_piece_ner and word_piece_seg. Maybe I didn't figured out the usage of the files in this link.Could you share a copy of these files with me?My email adress is JiaboWang@bupt.edu.cn; Thank you very much! 捕获

zhangdanni1129 commented 2 years ago

@namelucky @KhaZix7 hello,namelucky,KhaZix7.I am trying to get the utils_fine_tune.zip and the data_ctc.zip too, and it seems that all the link is not avaliable,can anyone share a copy?thank you so much. My email address is wx_szd@163.com

philippeitis commented 2 years ago

@KhaZix7 @zhangdanni1129 I have uploaded a copy of the files to https://huggingface.co/itisphilippe/StackOverflowNER

zhangdanni1129 commented 2 years ago

@KhaZix7 @zhangdanni1129 I have uploaded a copy of the files to https://huggingface.co/itisphilippe/StackOverflowNER

Thank you soooooo much!

ivankot88 commented 1 year ago

Hi, @namelucky it looks like you downloaded pre-trained model, but without classifier's weights. I have the same problem, when I run code. The website HuggingFace displays, that this model belongs to the category "Feature Extraction". @jeniyat could you please share weights for classifier head too?