google-research / bleurt

BLEURT is a metric for Natural Language Generation based on transfer learning.
https://arxiv.org/abs/2004.04696
Apache License 2.0
697 stars 85 forks source link

Python API Error (UnrecognizedFlagError: Unknown command line flag 'f') #13

Closed FerdiantJoshua closed 4 years ago

FerdiantJoshua commented 4 years ago

Hello,

I have installed the BLEURT according to steps mentioned in README. I also have run all installation tests, and everything works fine. Then, I am trying to use the Python API, following the mentioned script:

from bleurt import score

checkpoint = "bleurt/test_checkpoint"
references = ["This is a test."]
candidates = ["This is the test."]

scorer = score.BleurtScorer(checkpoint)
scores = scorer.score(references, candidates)
assert type(scores) == list and len(scores) == 1
print(scores)

I have checked that my Tensorflow is >=1.15, and tf-slim is >=1.1. I am using Python3.6 in Google Colab, in Tesla K80 GPU. However I got this error:

UnrecognizedFlagError                     Traceback (most recent call last)

<ipython-input-2-8427261da7b2> in <module>()
      6 
      7 scorer = score.BleurtScorer(checkpoint)
----> 8 scores = scorer.score(references, candidates)
      9 assert type(scores) == list and len(scores) == 1
     10 print(scores)

2 frames

/usr/local/lib/python3.6/dist-packages/bleurt/score.py in score(self, references, candidates, batch_size)
    164     """
    165     if not batch_size:
--> 166       batch_size = FLAGS.bleurt_batch_size
    167 
    168     candidates, references = list(candidates), list(references)

/usr/local/lib/python3.6/dist-packages/tensorflow/python/platform/flags.py in __getattr__(self, name)
     83     # a flag.
     84     if not wrapped.is_parsed():
---> 85       wrapped(_sys.argv)
     86     return wrapped.__getattr__(name)
     87 

/usr/local/lib/python3.6/dist-packages/absl/flags/_flagvalues.py in __call__(self, argv, known_only)
    631       suggestions = _helpers.get_flag_suggestions(name, list(self))
    632       raise _exceptions.UnrecognizedFlagError(
--> 633           name, value, suggestions=suggestions)
    634 
    635     self.mark_as_parsed()

UnrecognizedFlagError: Unknown command line flag 'f'

Could you suggest any way around? Thank you!

machelreid commented 4 years ago

I think #7 may solve your issue.

FerdiantJoshua commented 4 years ago

Okay, it's a pity a missed that previous issue. Thank you very much!