DistilGPT2 Fine-tuned Test

Model Description

This repository contains a DistilGPT2 model that has been fine-tuned on the tatsu-lab/alpaca dataset. The Alpaca dataset is known for its collection of instruction-following examples, making this model capable of generating responses that adhere to given instructions.

The base model, DistilGPT2, is a distilled version of GPT-2, making it smaller and faster while retaining much of the original's language generation capabilities. By fine-tuning it on the Alpaca dataset, we aim to enhance its ability to understand and execute various natural language instructions.

Intended Uses

This model is intended for text generation tasks, specifically those that involve following instructions or generating creative content based on a prompt. It can be used for:

  • Instruction Following: Generating responses to specific commands or queries.
  • Creative Writing: Assisting with story generation, poetry, or other forms of creative text.
  • Question Answering (Generative): Providing answers to questions where the answer might require synthesis of information or generation of a coherent response.
  • Chatbots: As a component in conversational AI systems for generating contextually relevant replies.

Limitations and Bias

As with any large language model, this model may exhibit biases present in its training data (both DistilGPT2's original training data and the Alpaca dataset). It may also generate nonsensical, factually incorrect, or harmful content. It is crucial to monitor its outputs and use it responsibly. It should not be used for critical applications without thorough validation.

How to Get Started

Installation

Make sure you have the transformers library installed:

pip install transformers torch

Code Example

from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
import torch

# Specify the model ID on Hugging Face Hub
model_id = "your-username/my-fine-tuned-distilgpt2-alpaca" # <-- REPLACE WITH YOUR ACTUAL HUGGING FACE MODEL ID

# Determine the device (GPU if available, otherwise CPU)
device = 0 if torch.cuda.is_available() else -1

print(f"Loading model from Hugging Face Hub: {model_id}")

# Load the tokenizer and model
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)

# Create a text generation pipeline
generator = pipeline('text-generation', model=model, tokenizer=tokenizer, device=device)

# Example 1: Simple instruction
prompt_1 = "Instruction: Write a short positive affirmation.\nInput: None\nOutput:"
print(f"\nPrompt 1: {prompt_1}")
output_1 = generator(prompt_1, max_new_tokens=30, num_return_sequences=1, do_sample=True, top_k=50, top_p=0.95)
print("Generated Output 1:")
print(output_1[0]['generated_text'])

# Example 2: More complex instruction with input
prompt_2 = "Instruction: Summarize the following text in one sentence.\nInput: Photosynthesis is the process by which green plants and some other organisms convert light energy into chemical energy. This chemical energy is stored in carbohydrate molecules, such as sugars, which are synthesized from carbon dioxide and water. Most life on Earth ultimately depends on photosynthesis as a source of energy.\nOutput:"
print(f"\nPrompt 2: {prompt_2}")
output_2 = generator(prompt_2, max_new_tokens=50, num_return_sequences=1, do_sample=True, top_k=50, top_p=0.95)
print("Generated Output 2:")
print(output_2[0]['generated_text'])

# Example 3: Creative writing prompt
prompt_3 = "Instruction: Continue the story:\nInput: A lone astronaut floated through the silent cosmos, gazing at the distant blue marble. Suddenly, a faint light shimmered...\nOutput:"
print(f"\nPrompt 3: {prompt_3}")
output_3 = generator(prompt_3, max_new_tokens=70, num_return_sequences=1, do_sample=True, top_k=50, top_p=0.95)
print("Generated Output 3:")
print(output_3[0]['generated_text'])

Training Data

The model was fine-tuned using the tatsu-lab/alpaca dataset. This dataset consists of 52K instruction-following demonstrations generated by OpenAI's text-davinci-003 instruction-tuned language model. Each instance in the dataset is composed of an instruction, an optional input, and a desired output.

Example from the Alpaca dataset:

{
  "instruction": "Identify the odd one out.",
  "input": "Lion, Tiger, Bear, Salmon",
  "output": "Salmon"
}
Downloads last month
9
Safetensors
Model size
81.9M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Rootpye/distilgpt2_finetuned_test

Finetuned
(769)
this model

Dataset used to train Rootpye/distilgpt2_finetuned_test