allenai / allennlp

An open-source NLP research library, built on PyTorch.
http://www.allennlp.org
Apache License 2.0
11.76k stars 2.25k forks source link

Coference results don't match demo #3967

Closed shuyanzhou closed 4 years ago

shuyanzhou commented 4 years ago

System (please complete the following information):

Question I use the model following allennlp-pretrained

from allennlp.models.archival import load_archive
from allennlp.predictors import Predictor
archive = load_archive("https://allennlp.s3.amazonaws.com/models/coref-model-2020.02.10.tar.gz")
predictor = Predictor.from_archive(archive, "coreference-resolution")

and I use the following code to print clustered spans:

result = predictor.predict(doc)
tk_doc = result["document"]
clusters = result["clusters"]

for idx, cluster in enumerate(clusters):
    print(f"===========")
    for (st, ed) in cluster:
        print(tk_doc[st:ed + 1])

The results cannot match the demo

My text file is:

Arthur Bach is a spoiled alcoholic from New York City who likes to be driven in his chauffeured limousine through Central Park . He is heir to his father Stanford 's $ 750 million fortune , which he is told will only be his if he marries the upper class Susan Johnson . He does not love Susan , but his family feels she will make him finally grow up . Arthur reluctantly agrees to the arranged marriage , but he meets a working-class Queens waitress , Linda Marolla , and despite her being a shoplifter , is attracted to her . Arthur struggles with his promise to marry Susan . While visiting his grandmother Martha , Arthur shares his feelings for Linda , but is warned again that he will be disowned . His valet , Hobson , who has been more like a father to him than Arthur 's real father , realizes that Arthur is beginning to grow up and secretly encourages Linda to attend Arthur 's engagement party , telling Linda he recognizes when a young man is in love . Hobson is hospitalized and Arthur rushes to his side . After several weeks , Hobson dies and then Arthur , who has been sober that whole time , goes on a drinking binge . On his wedding day , he visits the diner where Linda works and proposes to her . At the church , he jilts Susan , resulting in her abusive father , Burt Johnson -LRB- -LRB- -LRB- Stephen Elliott , attempting to stab Arthur with a cheese knife , though he is prevented by Martha . Arthur tells those in the church that there will be no wedding and passes out . Linda attends to his wounds and they discuss living a life of poverty . A horrified Martha tells Arthur that he can have his fortune because no Bach has ever been working class . Arthur declines , but at the last minute , talks privately to Martha . When he returns to Linda 's side , he tells her that he declined again Martha 's dinner invitation , he means , but he did take the money . Arthur 's pleased chauffeur Bitterman drives the couple through Central Park .

matt-gardner commented 4 years ago

Can you look over #3918 and see if what's mentioned there resolves your issue?

shuyanzhou commented 4 years ago

@matt-gardner Awesome! Solved with using model from https://github.com/allenai/allennlp-demo/blob/master/models.json.