Coder Social home page Coder Social logo

Comments (6)

Guillem96 avatar Guillem96 commented on July 23, 2024

Same here

from keybert.

MaartenGr avatar MaartenGr commented on July 23, 2024

Could you share the full error message? Also, did you try installing KeyBERT from the main branch?

from keybert.

cdolek avatar cdolek commented on July 23, 2024

Keybert version as installed via poetry:

pip list | grep keybert
keybert                            0.8.4

Full error message:

...
...
     63 embeddings = embedding_model.encode(docs, convert_to_tensor=True)
     65 # Extract keywords
---> 66 keywords = kw_model.extract_keywords(
     67     docs,
     68     embeddings=embeddings,
     69     threshold=.75,
     70 )
     71 logger.info(f"Keywords: {keywords}")
     72 return keywords

File ~/miniconda3/envs/_____/lib/python3.10/site-packages/keybert/_llm.py:107, in KeyLLM.extract_keywords(self, docs, check_vocab, candidate_keywords, threshold, embeddings)
    105     else:
    106         selected_keywords = None
--> 107     in_cluster_keywords = self.llm.extract_keywords(
    108         selected_docs,
    109         selected_keywords
    110     )
    111     in_cluster_keywords = {
    112         doc_id: in_cluster_keywords[index] 
    113         for index, cluster in enumerate(clusters)
    114         for doc_id in cluster
    115     }
    117 # Update out cluster keywords with in cluster keywords

File ~/miniconda3/envs/_____/lib/python3.10/site-packages/keybert/llm/_openai.py:189, in OpenAI.extract_keywords(self, documents, candidate_keywords)
    187     else:
    188         response = self.client.completions.create(model=self.model, prompt=prompt, **self.generator_kwargs)
--> 189     keywords = response.choices[0].message.content.strip()
    190 keywords = [keyword.strip() for keyword in keywords.split(\",\")]
    191 all_keywords.append(keywords)

File ~/miniconda3/envs/_____/lib/python3.10/site-packages/pydantic/main.py:792, in BaseModel.__getattr__(self, item)
    789     return super().__getattribute__(item)  # Raises AttributeError if appropriate
    790 else:
    791     # this is the current error
--> 792     raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}')

AttributeError: 'CompletionChoice' object has no attribute 'message'"

from keybert.

MaartenGr avatar MaartenGr commented on July 23, 2024

@cdolek Thanks for sharing. I have a feeling that this is not the full error message since there are multiple steps missing in the message. It is not possible that line 107 itself raises this error as it points towards another line in the code. Could you see whether you can get the full error message?

Also, did you try installing KeyBERT from the main branch? I believe there was a fix there implemented a while ago.

from keybert.

cdolek avatar cdolek commented on July 23, 2024

@MaartenGr I installed keybert as a package not by cloning the main branch. I just checked if the version of package matched with the repo. But, I can try cloning as well.

Updated the error message above to include full output.

from keybert.

MaartenGr avatar MaartenGr commented on July 23, 2024

@cdolek Yes, based on the error message, cloning from the main branch might just fix the issue.

from keybert.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.