Skip to content

Adriana394/nlp-text-generation-pytorch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Model-based Text Generation Project with Hugging Face Transformers

This repository contains an example project for model-based text generation using the Hugging Face Transformers library with a Causal Language Model (CLM). The project demonstrates how to load a pre-trained CLM and use it to generate continuous text based on input prompts.

Before running the code, make sure to have the following dependencies installed:

Python (recommended version 3.x)

PyTorch (version corresponding to your CUDA version if available)

Hugging Face Transformers library

Usage

Load Model and Tokenizer: The example uses a pre-trained model (gpt2-xl) and its corresponding tokenizer. The model will be automatically downloaded from the Hugging Face model hub.

Text Generation: The code demonstrates how to use the loaded model to generate text predictions. The input is used as part of a prompt-based text generation process.

Customization

Replace Model: You can replace the model with another one available in the Hugging Face model hub, e.g., gpt2, gpt2-medium, gpt2-large, etc.

Adjust Parameters: Experiment with different model parameters like max_length, num_return_sequences, and num_beams to control text generation.

License

This project is available under the MIT License.

About

Simple text generation with PyTorch

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published