This repository contains two end-to-end Generative AI projects built using Hugging Face Transformers and Python. These projects demonstrate practical implementation of modern NLP models for text generation and question answering tasks.
To build a Generative AI system that creates coherent and creative stories based on user prompts using pre-trained transformer-based language models.
- Pretrained Transformer-based Language Model (e.g., GPT-style architecture)
- Loaded using Hugging Face
pipeline("text-generation")
-
Load a pretrained text generation model.
-
Accept a prompt from the user.
-
Generate a continuation of the story.
-
Control creativity using:
max_lengthtemperaturetop_ktop_p
Input Prompt:
Once upon a time in a futuristic city
Generated Output:
Once upon a time in a futuristic city, robots and humans lived side by side...
- Generates creative and fluent text.
- Handles open-ended prompts well.
- Produces coherent short stories.
- May sometimes generate repetitive text.
- Longer outputs may lose coherence.
- Factually incorrect content possible (hallucinations).
- Understanding generative language models.
- Working with decoding strategies.
- Controlling creativity vs determinism.
To build an extractive question-answering system that returns factual answers from a given context paragraph.
bert-base-cased-squad2- Loaded using Hugging Face
pipeline("question-answering") - Based on BERT architecture trained on SQuAD2 dataset
- Load the Question Answering pipeline.
- Provide a context paragraph.
- Accept one or more questions.
- The model extracts the most relevant answer span from the context.
Artificial Intelligence is a branch of computer science.
Machine Learning is a subset of AI.
Python is widely used in AI development.
| Question | Model Answer | Confidence |
|---|---|---|
| What is Artificial Intelligence? | A branch of computer science | 0.98 |
| What is Machine Learning? | A subset of AI | 0.99 |
| Which language is used in AI? | Python | 0.97 |
- High accuracy for factual, direct questions.
- Extracts precise answer spans.
- Confidence score helps evaluate reliability.
- Cannot answer if information is not in context.
- Struggles with reasoning-based or inferential questions.
- Sensitive to poorly structured context.
- Understanding extractive QA systems.
- Working with contextual embeddings.
- Evaluating model confidence and performance.
| Feature | AI Storyteller | Ask Me Anything |
|---|---|---|
| Type | Generative AI | Extractive QA |
| Output Style | Creates new text | Extracts from context |
| Creativity | High | None |
| Accuracy | Variable | High (if answer exists in context) |
| Hallucination Risk | High | Very Low |
| Use Case | Chatbots, content creation | Search systems, knowledge assistants |
- Python
- Transformers (Hugging Face)
- PyTorch
- Jupyter Notebook
- Creative writing assistants
- Content generation
- Marketing copy generation
- Story-based games
- Customer support automation
- Document search systems
- FAQ bots
- Internal knowledge base systems