Update README.md
Browse files
README.md
CHANGED
|
@@ -6,11 +6,6 @@ tags:
|
|
| 6 |
- bigartm
|
| 7 |
- multilingual
|
| 8 |
- feature-extraction
|
| 9 |
-
datasets:
|
| 10 |
-
- wikimedia/wikipedia
|
| 11 |
-
language:
|
| 12 |
-
- ru
|
| 13 |
-
- en
|
| 14 |
---
|
| 15 |
|
| 16 |
# REDUP multilingual topic model
|
|
@@ -118,15 +113,14 @@ def document(document_id: str, tokens: list[str], lang: str):
|
|
| 118 |
|
| 119 |
|
| 120 |
async def main(root: str):
|
| 121 |
-
|
| 122 |
"artifact_root": root,
|
| 123 |
-
"work_dir": "/tmp/topicmodel",
|
| 124 |
})
|
| 125 |
pack = SimpleNamespace(documents=[
|
| 126 |
document("doc-en", ["hello", "world"], "en"),
|
| 127 |
document("doc-ru", ["привет", "мир"], "ru"),
|
| 128 |
])
|
| 129 |
-
result = await
|
| 130 |
for embedding in result["embeddings"]:
|
| 131 |
# length-125 topic distribution
|
| 132 |
print(len(embedding["values"]), sum(embedding["values"]))
|
|
@@ -142,19 +136,15 @@ Point the service config at the downloaded directory:
|
|
| 142 |
```yaml
|
| 143 |
TopicModel:
|
| 144 |
artifact_root: /path/from/snapshot_download
|
| 145 |
-
work_dir: /tmp/topicmodel
|
| 146 |
```
|
| 147 |
|
| 148 |
-
### Tokenizer
|
| 149 |
|
| 150 |
```python
|
| 151 |
-
from redup_topicmodel.topicmodel.bpe import
|
| 152 |
-
from redup_topicmodel.topicmodel.artm_loader import load_artm_model_inference
|
| 153 |
|
| 154 |
-
|
| 155 |
-
print(
|
| 156 |
-
|
| 157 |
-
model = load_artm_model_inference(f"{root}/artm")
|
| 158 |
```
|
| 159 |
|
| 160 |
## Limitations
|
|
|
|
| 6 |
- bigartm
|
| 7 |
- multilingual
|
| 8 |
- feature-extraction
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
---
|
| 10 |
|
| 11 |
# REDUP multilingual topic model
|
|
|
|
| 113 |
|
| 114 |
|
| 115 |
async def main(root: str):
|
| 116 |
+
model = TopicModel({
|
| 117 |
"artifact_root": root,
|
|
|
|
| 118 |
})
|
| 119 |
pack = SimpleNamespace(documents=[
|
| 120 |
document("doc-en", ["hello", "world"], "en"),
|
| 121 |
document("doc-ru", ["привет", "мир"], "ru"),
|
| 122 |
])
|
| 123 |
+
result = await model.get_documents_embedding("example", pack)
|
| 124 |
for embedding in result["embeddings"]:
|
| 125 |
# length-125 topic distribution
|
| 126 |
print(len(embedding["values"]), sum(embedding["values"]))
|
|
|
|
| 136 |
```yaml
|
| 137 |
TopicModel:
|
| 138 |
artifact_root: /path/from/snapshot_download
|
|
|
|
| 139 |
```
|
| 140 |
|
| 141 |
+
### Tokenizer only
|
| 142 |
|
| 143 |
```python
|
| 144 |
+
from redup_topicmodel.topicmodel.bpe import Tokenizers
|
|
|
|
| 145 |
|
| 146 |
+
tokenizers = Tokenizers.load(f"{root}/tokenizers.json.gz")
|
| 147 |
+
print(tokenizers["en"].encode("hello world"))
|
|
|
|
|
|
|
| 148 |
```
|
| 149 |
|
| 150 |
## Limitations
|