jina-ai / examples

Jina examples and demos to help you get started
https://docs.jina.ai
Apache License 2.0
455 stars 142 forks source link

Southpark, UniversalSentenceEncoder #249

Closed ghassen1302 closed 4 years ago

ghassen1302 commented 4 years ago

In southpark-search example I tried to modify

!TransformerTorchEncoder
with:
  pooling_strategy: auto
  pretrained_model_name_or_path: distilbert-base-cased
  max_length: 96

in encode.yml to

!UniversalSentenceEncoder
with:
   model_url: https://tfhub.dev/google/universal-sentence-encoder/4

which leads to this error

encoder@26858[C]:unknown exception: AttributeError("'UniversalSentenceEncoder' object has no attribute 'model_url'")
Traceback (most recent call last):
  File "/home/osboxes/anaconda3/lib/python3.8/site-packages/jina/peapods/pea.py", line 332, in run
    self.loop_body()
  File "/home/osboxes/anaconda3/lib/python3.8/site-packages/jina/peapods/pea.py", line 309, in loop_body
    self.load_executor()
  File "/home/osboxes/anaconda3/lib/python3.8/site-packages/jina/peapods/pea.py", line 192, in load_executor
    self.executor = BaseExecutor.load_config(self.args.uses if valid_local_config_source(self.args.uses) else self.args.uses_internal,
  File "/home/osboxes/anaconda3/lib/python3.8/site-packages/jina/executors/__init__.py", line 416, in load_config
    return yaml.load(tmp_s)
  File "/home/osboxes/anaconda3/lib/python3.8/site-packages/ruamel/yaml/main.py", line 343, in load
    return constructor.get_single_data()
  File "/home/osboxes/anaconda3/lib/python3.8/site-packages/ruamel/yaml/constructor.py", line 113, in get_single_data
    return self.construct_document(node)
  File "/home/osboxes/anaconda3/lib/python3.8/site-packages/ruamel/yaml/constructor.py", line 118, in construct_document
    data = self.construct_object(node)
  File "/home/osboxes/anaconda3/lib/python3.8/site-packages/ruamel/yaml/constructor.py", line 146, in construct_object
    data = self.construct_non_recursive_object(node)
  File "/home/osboxes/anaconda3/lib/python3.8/site-packages/ruamel/yaml/constructor.py", line 181, in construct_non_recursive_object
    data = constructor(self, node)
  File "/home/osboxes/anaconda3/lib/python3.8/site-packages/jina/executors/__init__.py", line 457, in from_yaml
    return cls._get_instance_from_yaml(constructor, node)[0]
  File "/home/osboxes/anaconda3/lib/python3.8/site-packages/jina/executors/__init__.py", line 490, in _get_instance_from_yaml
    obj = cls(**data.get('with', {}), metas=data.get('metas', {}), requests=data.get('requests', {}))
  File "/home/osboxes/anaconda3/lib/python3.8/site-packages/jina/executors/__init__.py", line 52, in __call__
    obj = type.__call__(cls, *args, **kwargs)
  File "/home/osboxes/anaconda3/lib/python3.8/site-packages/jina/executors/decorators.py", line 114, in arg_wrapper
    f = func(self, *args, **kwargs)
  File "/home/osboxes/anaconda3/lib/python3.8/site-packages/jina/executors/encoders/nlp/use.py", line 29, in __init__
    super().__init__(*args, **kwargs)
AttributeError: 'UniversalSentenceEncoder' object has no attribute 'model_url'
        encoder@26858[S]:terminated
        encoder@25942[C]:fail to start <class 'jina.peapods.pea.BasePea'> with name encoder

How can I fix it?

JoanFM commented 4 years ago

Hello @ghassen1302 ,

Can you please let me know what version of jina are you using?

ghassen1302 commented 4 years ago

I'm using version 0.4.1

JoanFM commented 4 years ago

I'm using version 0.4.1

Hey @ghassen1302, there was a problem with this version, would you update it to a recent version like 0.6.4?

ghassen1302 commented 4 years ago

It worked thanks