Skip to main content

Character Level Language Models 🕺🏽

Project description

PYPI Package Link

Character-Level Language Models Repo 🕺🏽

This repository contains multiple character-level language models (charLLM). Each language model is designed to generate text at the character level, providing a granular level of control and flexibility.

🌟 Available Language Models

  • Character-Level MLP LLM (First MLP LLM)
  • GPT-2 (under process)

Character-Level MLP

The Character-Level MLP language model is implemented based on the approach described in the paper "A Neural Probabilistic Language Model" by Bential et al. (2002). It utilizes a multilayer perceptron architecture to generate text at the character level.

Installation

With PIP

This repository is tested on Python 3.8+, and PyTorch 2.0.0+.

First, create a virtual environment with the version of Python you're going to use and activate it.

Then, you will need to install PyTorch.

When backends has been installed, CharLLMs can be installed using pip as follows:

pip install charLLM

With GIT

CharLLMs can be installed using conda as follows:

git clone https://github.com/RAravindDS/Neural-Probabilistic-Language-Model.git

Quick Tour

To use the Character-Level MLP language model, follow these steps:

  1. Install the package dependencies.
  2. Import the CharMLP class from the charLLM module.
  3. Create an instance of the CharMLP class.
  4. Train the model on a suitable dataset.
  5. Generate text using the trained model.

Demo for NPLM (A Neural Probabilistic Language Model)

# Import the class 
>>> from charLLM import NPLM # Neural Probabilistic Language Model
>>> text_path = "path-to-text-file.txt" 
>>> model_parameters = {
    "block_size" :3, 
    "train_size" :0.8, 
    'epochs' :10000, 
    'batch_size' :32, 
    'hidden_layer' :100, 
    'embedding_dimension' :50,
    'learning_rate' :0.1 
    }
>>> obj = NPLM(text_path, model_parameters)  # Initialize the class 
>>> obj.train_model() 
## It outputs the val_loss and image 
>>> obj.sampling(words_needed=10) #It samples 10 tokens. 

Model Output Graph

Feel free to explore the repository and experiment with the different language models provided.

Contributions

Contributions to this repository are welcome. If you have implemented a novel character-level language model or would like to enhance the existing models, please consider contributing to the project.

License

This repository is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

charLLM-0.0.6.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

charLLM-0.0.6-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file charLLM-0.0.6.tar.gz.

File metadata

  • Download URL: charLLM-0.0.6.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for charLLM-0.0.6.tar.gz
Algorithm Hash digest
SHA256 b5cf753ed70c2dba335a8c82ec04355ca13ec4a00fe24df171ca2194511e0c7b
MD5 16f5d75b75aa7e4814ab64019dd781c5
BLAKE2b-256 e643804ec69b447f7377130f24af7f94faa44a197ce502df52d935e87f69008a

See more details on using hashes here.

File details

Details for the file charLLM-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: charLLM-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for charLLM-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 1a545d68efc77150d84de816e7c32e3b7c24ec70d29c050e80fbbf418e6e9233
MD5 2e9ba3815bdabf3f6755e09091bf26f4
BLAKE2b-256 1175bd5a9ac2ef1adebf48fe8670087d33f685aba16e9085ad4b849cc9d9b084

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page