Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Text Generation with Hugging Face Transformers This project demonstrates how to use a pre-trained language model to generate new, coherent text based on an initial prompt. The project leverages the Hugging Face Transformers library and serves as a practical application of Generative AI concepts.

Key Features Pre-trained Model: Utilizes the powerful distilgpt2 model for high-quality text generation without training from scratch.

Customizable Generation: Shows how to control the generation process's creativity and length using parameters like temperature and top_p.

Practical Application: Applies an advanced Natural Language Processing (NLP) concept in a simple and effective project.

Technologies Used Python: The core programming language.

Hugging Face Transformers: The main library for interacting with language models.

PyTorch/TensorFlow: The backend library for running the model.

Google Colab: The development environment used.

How to Run the Project Install Dependencies:

Python

!pip install transformers torch Generate Text:

Python

from transformers import pipeline

generator = pipeline('text-generation', model='distilgpt2')

starting_text = "Once upon a time, in a world where AI robots ruled,"

generated_text = generator( starting_text, max_length=150, num_return_sequences=3, do_sample=True, temperature=0.7, top_k=50, top_p=0.95 )

for i, text_output in enumerate(generated_text): print(f"--- Generated Text {i+1} ---") print(text_output['generated_text'])

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages