Skip to content

The results are random #16

Description

@namelucky

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

importtorchfromtransformersimportAutoModelForTokenClassification, AutoTokenizerpretrained_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.logitspredictions=torch.argmax(outputs, dim=2)
fortoken, predictioninzip(tokens, predictions[0].numpy()):
print((token, model.config.id2label[prediction]))

image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions