https://github.com/altescy/textvae
VAE implementation for text generation with PyTorch
https://github.com/altescy/textvae
machine-learning nlp python pytorch vae
Last synced: 12 months ago
JSON representation
VAE implementation for text generation with PyTorch
- Host: GitHub
- URL: https://github.com/altescy/textvae
- Owner: altescy
- License: mit
- Created: 2022-10-09T15:20:57.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-12-09T08:34:44.000Z (over 3 years ago)
- Last Synced: 2025-01-26T11:42:14.568Z (about 1 year ago)
- Topics: machine-learning, nlp, python, pytorch, vae
- Language: Python
- Homepage:
- Size: 102 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
TextVAE
=======
[](https://github.com/altescy/textvae/actions/workflows/ci.yml)
[](https://github.com/altescy/textvae/blob/master/LICENSE)
VAE implementation for text generation with PyTorch
## Usage
Train VAE model (config example: [config.json](https://github.com/altescy/textvae/blob/main/tests/fixtures/configs/textvae.json)):
```bash
textvae train config.json --workdir output/
```
Reconstruct texts:
```python
from textvae import TextVAE
texts = ["this is a first sentence", "this is a second sentence"]
textvae = TextVAE.from_archive("output/archive.pkl")
for reconstructed_text in textvae.reconstruct(texts):
print(reconstructed_text)
```
Encode texts:
```python
from textvae import TextVAE
texts = ["this is a first sentence", "this is a second sentence"]
textvae = TextVAE.from_archive("output/archive.pkl")
for mean, logvar in textvae.encode(texts):
...
```