goodbai-nlp / AMRBART

Code for our paper "Graph Pre-training for AMR Parsing and Generation" in ACL2022
MIT License
92 stars 28 forks source link

input for huggingface AMRBART - AMR2Text #24

Open tingchihc opened 8 months ago

tingchihc commented 8 months ago

Hi,

I am very happy to see the pre-trained model in huggingface. I have a little question about AMRBART(AMR2Text) what is the input for this? does that mean we still need to follow AMR-process?

thanks,

goodbai-nlp commented 8 months ago

Yes, you need to follow AMR-process to linearize AMRs before feeding them into AMRBART-AMR2Text.

tingchihc commented 8 months ago

ok thanks

tingchihc commented 8 months ago

I want to use the hugging face AMR2text pre-trained model. This is my code.

from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
from model_interface.tokenization_bart import AMRBartTokenizer
import torch
from transformers import pipeline

pipe = pipeline("text2text-generation", model="xfbai/AMRBART-large-finetuned-AMR2.0-AMR2Text-v2", tokenizer= AMRBartTokenizer.from_pretrained("xfbai/AMRBART-large-finetuned-AMR2.0-AMR2Text-v2"))
text = "( <pointer:0> date-entity :month 9 :day 11 :year 2010 )"
ans = pipe(text)
print(ans)

the text is your example input data. However, the results look weird. The results is [{'generated_text': ' ( <pointer:0> date-entity :month 9 :day 11 : year 2010'}]

what's the problem in here?

goodbai-nlp commented 8 months ago

Hi, @ting-chih

Our code does not support transformer pipeline, you can try inference-text.sh to generate text from AMR graphs.

flipz357 commented 5 months ago

Maybe it's related this issue, for the huggingface inference api, the following error comes up:

Link: https://huggingface.co/xfbai/AMRBART-base?text=test

image

Would it be possible to fix, for allowing access through api?

goodbai-nlp commented 5 months ago

Hi, @flipz357

AMRBART does not support the huggingface inference api as we have modified the tokenizer and input format. You can follow the instructions here to inference on your own data, so that the quailty can be ensured.

flipz357 commented 5 months ago

I see, Thank you @goodbai-nlp!