Skip to main content

Welcome to Text Recovery Project 👋

A python library for training a Transformer neural network to solve the Running Key Cipher, widely known in the field of cryptography.

Preview Animation

Hugging Face demo MkDocs link Python version Open In Colab PyPI version PyPi Downloads License Apache 2.0

🚀 Objective

The main goal of the project is to study the possibility of using Transformer neural network to “read” meaningful text in columns that can be compiled for a Running Key Cipher. You can read more about the problem here.

In addition, the second rather fun 😅 goal is to train a large enough model so that it can handle the case described below. Let there be an original sentence:

Hello, my name is Zendaya Maree Stoermer Coleman but you can just call me Zendaya.

The columns for this sentence will be compiled in such a way that the last seven contain from ten to thirteen letters of the English alphabet, and all the others from two to five. Thus, the last seven characters will be much harder to "read" compared to the rest. However, we can guess from the meaning of the sentence that this is the name Zendaya. In other words, the goal is also to train a model that can understand and correctly “read” the last word.

⚙ Installation

Trecover requires Python 3.8 or higher and supports both Windows and Linux platforms.

  1. Clone the repository:
git clone https://github.com/alex-snd/TRecover.git  && cd trecover
  1. Create a virtual environment:

    • Windows:
    python -m venv venv
    
    • Linux:
    python3 -m venv venv
    
  2. Activate the virtual environment:

    • Windows:
    venv\Scripts\activate.bat
    
    • Linux:
    source venv/bin/activate
    
  3. Install the package inside this virtual environment:

    • Just to run the demo:
    pip install -e ".[demo]"
    
    • To train the Transformer:
    pip install -e ".[train]"
    
    • For development and training:
    pip install -e ".[dev]"
    
  4. Initialize project's environment:

    trecover init
    

    For more options use:

    trecover init --help
    

👀 Demo

  • 🤗 Hugging Face
    You can play with a pre-trained model hosted here.
  • 🐳 Docker Compose
    • Pull from Docker Hub:
      docker-compose -f docker/compose/scalable-service.yml up
      
    • Build from source:
      docker-compose -f docker/compose/scalable-service-build.yml up
      
  • 💻 Local (requires docker)
    • Download pretrained model:
      trecover download artifacts
      
    • Launch the service:
      trecover up
      

🗃️ Data

The WikiText and WikiQA datasets were used to train the model, from which all characters except English letters were removed.
You can download the cleaned dataset:

trecover download data

💪 Train

To quickly start training the model, open the Jupyter Notebook.

  • 🕸️ Distributed
    TODO
  • 💻 Local
    After the dataset is loaded, you can start training the model:
    trecover train local \
    --project-name {project_name} \
    --exp-mark {exp_mark} \
    --train-dataset-size {train_dataset_size} \
    --val-dataset-size {val_dataset_size} \
    --vis-dataset-size {vis_dataset_size} \
    --test-dataset-size {test_dataset_size} \
    --batch-size {batch_size} \
    --n-workers {n_workers} \
    --min-noise {min_noise} \
    --max-noise {max_noise} \
    --lr {lr} \
    --n-epochs {n_epochs} \
    --epoch-seek {epoch_seek} \
    --accumulation-step {accumulation_step} \
    --penalty-coefficient {penalty_coefficient} \
    
    --pe-max-len {pe_max_len} \
    --n-layers {n_layers} \
    --d-model {d_model} \
    --n-heads {n_heads} \
    --d-ff {d_ff} \
    --dropout {dropout}
    
    For more information use trecover train local --help

TODO: what was done, tech stack.

🤝 Contributing

Contributions, issues and feature requests are welcome.
Feel free to check issues page if you want to contribute.

👏 Show your support

Please don't hesitate to ⭐️ this repository if you find it cool!

📜 License

Copyright © 2022 Alexander Shulga.
This project is Apache 2.0 licensed.

Metadata

Release files for trecover 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trecover 1.0.3
File Size Uploaded
trecover-1.0.3.tar.gz 59.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for trecover 1.0.3
File Interpreter ABI Platform
trecover-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 129.7 kB

Release files / trecover-1.0.3.tar.gz

Download URL trecover-1.0.3.tar.gz
Size 59.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e5bd79a6584fd8318cd28866ebb6593f0ceb832aadf42139e865e8109ad0cba1
BLAKE2b-256 checksum
How to use checksums
5578fb0a77a2db66c432c1212301c87b2222e894ac1cccd89096a5aa6923cc86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / trecover-1.0.3-py3-none-any.whl

Download URL trecover-1.0.3-py3-none-any.whl
Size 70.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ac37f76422adc8d126ff589b30c82655c7c38a8ca37c63839f311c8e313f53bd
BLAKE2b-256 checksum
How to use checksums
4773a444972f411adf39f2ae53b4c52f42cbb66a27836ec9b23e9e4e785b942f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page