neuml / txtai

💡 All-in-one open-source embeddings database for semantic search, LLM orchestration and language model workflows
https://neuml.github.io/txtai
Apache License 2.0
9.52k stars 611 forks source link

Translation: AttributeError: 'ModelInfo' object has no attribute 'modelId' #750

Closed adieyal closed 4 months ago

adieyal commented 4 months ago

Translation stopped working for me and I'm not sure what changed.

from txtai.pipeline import Translation

# Create and run pipeline
translate = Translation()
translate("This is a test translation into Spanish", "es")
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[17], line 4
      1 from txtai.pipeline import Translation
      3 # Create and run pipeline
----> 4 translate = Translation()
      5 translate("This is a test translation into Spanish", "es")

File ~/Development/notebooks/.venv/lib/python3.10/site-packages/txtai/pipeline/text/translation.py:54, in Translation.__init__(self, path, quantize, gpu, batch, langdetect, findmodels)
     52 # Language models
     53 self.models = {}
---> 54 self.ids = self.modelids()

File ~/Development/notebooks/.venv/lib/python3.10/site-packages/txtai/pipeline/text/translation.py:115, in Translation.modelids(self)
    107 def modelids(self):
    108     """
    109     Runs a query to get a list of available language models from the Hugging Face API.
    110 
    111     Returns:
    112         list of source-target language model ids
    113     """
--> 115     ids = [x.modelId for x in HfApi().list_models(author="Helsinki-NLP")] if self.findmodels else []
    116     return set(ids)

File ~/Development/notebooks/.venv/lib/python3.10/site-packages/txtai/pipeline/text/translation.py:115, in <listcomp>(.0)
    107 def modelids(self):
    108     """
    109     Runs a query to get a list of available language models from the Hugging Face API.
    110 
    111     Returns:
    112         list of source-target language model ids
    113     """
--> 115     ids = [x.modelId for x in HfApi().list_models(author="Helsinki-NLP")] if self.findmodels else []
    116     return set(ids)

AttributeError: 'ModelInfo' object has no attribute 'modelId'
> pip freeze | grep -e  huggingface -e txtai

huggingface-hub==0.24.0
txtai==7.3.0

It looks like the last version of huggingface-hub that used modelId was v0.18 It isn't available in v0.19 or later

davidmezzetti commented 4 months ago

Hugging Face must have changed something on the server side. Because this build just ran with huggingface-hub==0.24.0 yesterday and was fine.

https://github.com/neuml/txtai/actions/runs/10029750031/job/27718304694

davidmezzetti commented 4 months ago

Update: It looks like this change is the root of this issue.

https://github.com/huggingface/huggingface_hub/pull/2405

adieyal commented 4 months ago

Good to know - I temporarily patched translation.py after i couldn't find a version of huggingface-hub that worked.

davidmezzetti commented 4 months ago

It appears that whatever change happened was reverted upstream.

Nonetheless, I'll still plan to update the API call to use the latest. But at least it sounds like it's not an emergency.

julien-c commented 4 months ago

sorry about the breaking change on our side!

(we have reverted the change server side for now, but we plan to re-apply it in the future)