MaartenGr / MaartenGr/BERTopic
BERTopic (Can't retrieve unregistered extension attribute 'trf_data'. Did you forget to call the set_extension method?)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.8k
- Forks
- 920
- Avg merge
- 22h 24m
- Merged PRs (30d)
- 5
Description
Good morning, this is my code obtained from
the following page: https://spacy.io/universe/project/bertopic after running it I get the following error: Can't retrieve unregistered extension attribute 'trf_data'. Did you forget to call the set_extension method?
How can I solve this error?
Instalación de las bibliotecas necesarias
!pip install spacy
!pip install bertopic
!pip install scikit-learn
Descargar el modelo de spaCy en inglés (medium)
!python -m spacy download en_core_web_md
Cargar las bibliotecas y el modelo
import spacy
from bertopic import BERTopic
from sklearn.datasets import fetch_20newsgroups
Cargar los documentos de la base de datos de 20 Newsgroups
docs = fetch_20newsgroups(subset='all', remove=('headers', 'footers', 'quotes'))['data']
Cargar el modelo de spaCy en inglés (medium) excluyendo componentes innecesarios
nlp = spacy.load('en_core_web_md', exclude=['tagger', 'parser', 'ner', 'attribute_ruler', 'lemmatizer'])
Crear el modelo BERTopic con spaCy
topic_model = BERTopic(embedding_model=nlp)
topics, probs = topic_model.fit_transform(docs)
I have tried changing the version of spacy to one that is between version 3.3.0 and version 3.4.0, I still get the same error trying all of them spacy models (sm, md, lg, trf)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the spaCy BERTopic example at https://spacy.io/universe/project/bertopic and run the package installation, en_core_web_md loading, and topic_model.fit_transform(docs) steps shown in the issue. Compare the installed spaCy, BERTopic, and model versions while reproducing the trf_data error; done means the example completes without the unregistered extension-attribute failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, scikit-learn
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100