MaartenGr commited on
Commit
a73e7b6
1 Parent(s): b24da6e

Update readme

Browse files
Files changed (1) hide show
  1. README.md +78 -0
README.md CHANGED
@@ -11,6 +11,29 @@ pipeline_tag: text-classification
11
  This is a [BERTopic](https://github.com/MaartenGr/BERTopic) model.
12
  BERTopic is a flexible and modular topic modeling framework that allows for the generation of easily interpretable topics from large datasets.
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  ## Usage
15
 
16
  To use this model, please install BERTopic:
@@ -28,6 +51,12 @@ topic_model = BERTopic.load("MaartenGr/BERTopic_ArXiv")
28
  topic_model.get_topic_info()
29
  ```
30
 
 
 
 
 
 
 
31
  ## Topic overview
32
 
33
  * Number of topics: 107
@@ -148,6 +177,55 @@ topic_model.get_topic_info()
148
 
149
  </details>
150
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  ## Training hyperparameters
152
 
153
  * calculate_probabilities: False
 
11
  This is a [BERTopic](https://github.com/MaartenGr/BERTopic) model.
12
  BERTopic is a flexible and modular topic modeling framework that allows for the generation of easily interpretable topics from large datasets.
13
 
14
+ This pre-trained model demonstrates the use of several representation models that can be used within BERTopic. This model was trained on ~30000 ArXiv abstracts with the following topic representation methods (`bertopic.representation`):
15
+
16
+ * POS
17
+ * `PartOfSpeech("en_core_web_lg")`
18
+ * KeyBERTInspired
19
+ * `KeyBERTInspired()`
20
+ * MMR
21
+ * `MaximalMarginalRelevance(diversity=0.3)`
22
+ * KeyBERT + MMR
23
+ * `[KeyBERTInspired(), MaximalMarginalRelevance(diversity=0.3)]`
24
+ * OpenAI_Label
25
+ * `OpenAI(model="gpt-3.5-turbo", exponential_backoff=True, chat=True, diversity=0.1)`
26
+ * OpenAI_Summary
27
+ * `[KeyBERTInspired(), summarization_model]`
28
+
29
+ An example of the default c-TF-IDF representations:
30
+
31
+ !["multiaspect.png"](visualization_multiaspect.png)
32
+
33
+ An example of labels generated by ChatGPT (`gpt-3.5-turbo`):
34
+
35
+ !["multiaspect.png"](visualization_multiaspect_openai.png)
36
+
37
  ## Usage
38
 
39
  To use this model, please install BERTopic:
 
51
  topic_model.get_topic_info()
52
  ```
53
 
54
+ To view all different topic representations (keywords, labels, summary, etc.) you can run the following:
55
+
56
+ ```python
57
+ topic_model.get_topic(1, full=True)
58
+ ```
59
+
60
  ## Topic overview
61
 
62
  * Number of topics: 107
 
177
 
178
  </details>
179
 
180
+ ## Training Procedure
181
+
182
+ The model was trained as follows:
183
+
184
+ ```python
185
+ from cuml.manifold import UMAP
186
+ from cuml.cluster import HDBSCAN
187
+ from bertopic import BERTopic
188
+ from sklearn.feature_extraction.text import CountVectorizer
189
+ from bertopic.representation import PartOfSpeech, KeyBERTInspired, MaximalMarginalRelevance, OpenAI
190
+
191
+ # Prepare sub-models
192
+ embedding_model = SentenceTransformer('sentence-transformers/all-mpnet-base-v2')
193
+ umap_model = UMAP(n_components=5, n_neighbors=50, random_state=42, metric="cosine", verbose=True)
194
+ hdbscan_model = HDBSCAN(min_samples=20, gen_min_span_tree=True, prediction_data=False, min_cluster_size=20, verbose=True)
195
+ vectorizer_model = CountVectorizer(stop_words="english", ngram_range=(1, 3), min_df=5)
196
+
197
+ # Summarization with ChatGPT
198
+ summarization_prompt = """
199
+ I have a topic that is described by the following keywords: [KEYWORDS]
200
+ In this topic, the following documents are a small but representative subset of all documents in the topic:
201
+ [DOCUMENTS]
202
+
203
+ Based on the information above, please give a description of this topic in the following format:
204
+ topic: <description>
205
+ """
206
+ summarization_model = OpenAI(model="gpt-3.5-turbo", chat=True, prompt=summarization_prompt, nr_docs=5, exponential_backoff=True, diversity=0.1)
207
+
208
+ # Representation models
209
+ representation_models = {
210
+ "POS": PartOfSpeech("en_core_web_lg"),
211
+ "KeyBERTInspired": KeyBERTInspired(),
212
+ "MMR": MaximalMarginalRelevance(diversity=0.3),
213
+ "KeyBERT + MMR": [KeyBERTInspired(), MaximalMarginalRelevance(diversity=0.3)],
214
+ "OpenAI_Label": OpenAI(model="gpt-3.5-turbo", exponential_backoff=True, chat=True, diversity=0.1),
215
+ "OpenAI_Summary": [KeyBERTInspired(), summarization_model],
216
+ }
217
+
218
+ # Fit BERTopic
219
+ topic_model= BERTopic(
220
+ embedding_model=embedding_model,
221
+ umap_model=umap_model,
222
+ hdbscan_model=hdbscan_model,
223
+ vectorizer_model=vectorizer_model,
224
+ representation_model=representation_models,
225
+ verbose=True
226
+ ).fit(docs)
227
+ ```
228
+
229
  ## Training hyperparameters
230
 
231
  * calculate_probabilities: False