BERTopic (Can't retrieve unregistered extension attribute 'trf_data'. Did you forget to call the set_extension method?)
#13019
Unanswered
FranValero97
asked this question in
Help: Installation
Replies: 1 comment 3 replies
-
|
You'll need to use one of spaCy's Transformer models in conjunction with
|
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
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_extensionmethod?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)
Visualizar los tópicos
fig = topic_model.visualize_topics()
fig.show()
Beta Was this translation helpful? Give feedback.
All reactions