GithubHelp home page GithubHelp logo

rishabhmisra / book-buddy-interactive-storytelling-using-a-gemma-based-rag Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jigyasa-grover/book-buddy-interactive-storytelling-using-a-gemma-based-rag

0.0 0.0 0.0 398 KB

Book Buddy: Interactive Storytelling using a Gemma-based RAG šŸ“–

Jupyter Notebook 100.00%

book-buddy-interactive-storytelling-using-a-gemma-based-rag's Introduction

Book Buddy: Interactive Storytelling using a Gemma-based RAG šŸ“–

image

In the realm of AI-driven interactive storytelling, the fusion of Retrieval Augmented Generation (RAG) and Google's Gemma language model opens new avenues for creating engaging narratives and educational experiences. RAG, often likened to an "open-book" approach for AI, empowers models like Gemma to access and synthesize vast amounts of information to answer specific queries or weave intricate tales.

RAG and Gemma šŸ¤šŸ»

Retrieval-Augmented Generation (RAG) leverages a dual-model approach: a retriever to fetch relevant information and a generator to craft responses in natural language. This method not only enhances the accuracy of AI-generated content but also reduces computational overhead compared to traditional fine-tuning methods.

Gemma, a lightweight, text-to-text, decoder-only large language model, is known for its precision and efficiency, emerges as an ideal candidate for such tasks, making it a potent tool for interactive storytelling.

image

A generic RAG architecture, courtesy (arxiv) 'Retrieval-Augmented Generation for AI-Generated Content: A Survey'.

Crafting Interactive Narratives šŸ°

Imagine a scenario where readers can interact with a virtual "Book Buddy," a character powered by Gemma-based RAG. This AI companion can dynamically respond to queries from the storylines and provide detailed explanations on demand. Whether guiding readers through complex plotlines or explaining background lore, Gemma excels in delivering coherent, engaging content tailored to user interactions.

Let's Build "Book Buddy" šŸ› ļø

To delve deeper into the capabilities of Gemma-based RAG for interactive storytelling, let's embark on a hands-on journey that creates a dynamic system capable of answering questions about the classic text "Alice's Adventures in Wonderland" by Lewis Carroll, available from Project Gutenberg.

By leveraging Gemma's capabilities, we can prototype interactive narratives that respond intelligently to user prompts, offering a personalized storytelling experience. Whether deployed in educational settings to elucidate historical events or within gaming environments to create dynamic quests, the versatility of Gemma-based RAG enriches the user experience through immersive, responsive storytelling.

  • Setting up the environment šŸŒ³
  • Loading and splitting the data šŸ“š
  • Loading the embedding model šŸ¤³šŸ»
  • Storing the embeddings in a vector database šŸ§³
  • Setting up the retriever šŸ”¬
  • Setting up the generator šŸŽ”
  • Setting up the conversational retrieval chain ā›“ļø
  • Asking Book Buddy a question šŸ™‹šŸ»ā€ā™€ļø
  • Tying it all in šŸŽ€
  • Testing BookBuddy šŸ§Ŗ
    Question:  Who has written Aliceā€™s Adventures in Wonderland?
    Answer:   Lewis Carroll.
    
    Current Chat History:  [('Who has written Aliceā€™s Adventures in Wonderland?', ' Lewis Carroll.')]
    
    Question:  What game does Alice play?
    Answer:   Alice plays a game of croquet in Wonderland.
    
    Current Chat History:  [('Who has written Aliceā€™s Adventures in Wonderland?', ' Lewis Carroll.'), ('What game does Alice play?', ' Alice plays a game of croquet in Wonderland.')]
    
    Question:  Who said - Off with their heads?
    Answer:   The Queen of Hearts said "Off with their heads".
    
    Current Chat History:  [('Who has written Aliceā€™s Adventures in Wonderland?', ' Lewis Carroll.'), ('What game does Alice play?', ' Alice plays a game of croquet in Wonderland.'), ('Who said - Off with their heads?', ' The Queen of Hearts said "Off with their heads".')]
    
    Question:  What was the last part of the cat to disappear?
    Answer:   The grin.
    
    Current Chat History:  [('Who has written Aliceā€™s Adventures in Wonderland?', ' Lewis Carroll.'), ('What game does Alice play?', ' Alice plays a game of croquet in Wonderland.'), ('Who said - Off with their heads?', ' The Queen of Hearts said "Off with their heads".'), ('What was the last part of the cat to disappear?', ' The grin.')]
    
    Question:  What is written on the potion bottle that Alice drinks?
    Answer:   The potion bottle says "Drink me."
    
    Current Chat History:  [('Who has written Aliceā€™s Adventures in Wonderland?', ' Lewis Carroll.'), ('What game does Alice play?', ' Alice plays a game of croquet in Wonderland.'), ('Who said - Off with their heads?', ' The Queen of Hearts said "Off with their heads".'), ('What was the last part of the cat to disappear?', ' The grin.'), ('What is written on the potion bottle that Alice drinks?', ' The potion bottle says "Drink me."')]
    
    Question:  Who fell asleep at the Tea Party?
    Answer: The person who fell asleep at the Tea Party is the Dormouse.
    
    Current Chat History:  [('Who has written Aliceā€™s Adventures in Wonderland?', ' Lewis Carroll.'), ('What game does Alice play?', ' Alice plays a game of croquet in Wonderland.'), ('Who said - Off with their heads?', ' The Queen of Hearts said "Off with their heads".'), ('What was the last part of the cat to disappear?', ' The grin.'), ('What is written on the potion bottle that Alice drinks?', ' The potion bottle says "Drink me."'), ('Who fell asleep at the Tea Party?', 'The person who fell asleep at the Tea Party is the Dormouse.')]
    
    Question:  What is rule 42 and why is it important for Alice?
    Answer:   Rule 42 is the oldest rule in the book and it dictates that all persons more than a mile high must leave the court. This impacts Alice because she is not a mile high and therefore must leave the court.
    
    Current Chat History:  [('Who has written Aliceā€™s Adventures in Wonderland?', ' Lewis Carroll.'), ('What game does Alice play?', ' Alice plays a game of croquet in Wonderland.'), ('Who said - Off with their heads?', ' The Queen of Hearts said "Off with their heads".'), ('What was the last part of the cat to disappear?', ' The grin.'), ('What is written on the potion bottle that Alice drinks?', ' The potion bottle says "Drink me."'), ('Who fell asleep at the Tea Party?', 'The person who fell asleep at the Tea Party is the Dormouse.'), ('What is rule 42 and why is it important for Alice?', ' Rule 42 is the oldest rule in the book and it dictates that all persons more than a mile high must leave the court. This impacts Alice because she is not a mile high and therefore must leave the court.')]
    
    Question:  From what is the Caterpillar in Aliceā€™s Adventures in Wonderland smoking?
    Answer:    A hookah.
    
    Current Chat History:  [('Who has written Aliceā€™s Adventures in Wonderland?', ' Lewis Carroll.'), ('What game does Alice play?', ' Alice plays a game of croquet in Wonderland.'), ('Who said - Off with their heads?', ' The Queen of Hearts said "Off with their heads".'), ('What was the last part of the cat to disappear?', ' The grin.'), ('What is written on the potion bottle that Alice drinks?', ' The potion bottle says "Drink me."'), ('Who fell asleep at the Tea Party?', 'The person who fell asleep at the Tea Party is the Dormouse.'), ('What is rule 42 and why is it important for Alice?', ' Rule 42 is the oldest rule in the book and it dictates that all persons more than a mile high must leave the court. This impacts Alice because she is not a mile high and therefore must leave the court.'), ('From what is the Caterpillar in Aliceā€™s Adventures in Wonderland smoking?', '  A hookah.')]
    
    Question:  Which character serves as herald to the King and Queen of Hearts?
    Answer:   The White Rabbit.
    
    Current Chat History:  [('Who has written Aliceā€™s Adventures in Wonderland?', ' Lewis Carroll.'), ('What game does Alice play?', ' Alice plays a game of storytelling in Wonderland.'), ('Who said - Off with their heads?', ' The Rabbit said "Off with their heads".'), ('Where was the cat from?', ' The context does not contain any information regarding who said "Off with their heads", so I cannot answer this question from the provided context.'), ('What was the last part of the cat to disappear?', ' The grin.'), ('What is written on the potion bottle that Alice drinks?', ' The potion bottle says "Drink me."'), ('Who fell asleep at the Tea Party?', '\n\nThe person who fell asleep at the Tea Party is the Dormouse.'), ('What is rule 42 and why is it important for Alice?', ' Rule 42 is the oldest rule in the book and it dictates that all persons more than a mile high must leave the court. This impacts Alice because she is not a mile high and therefore must leave the court.'), ('From what is the Caterpillar in Aliceā€™s Adventures in Wonderland smoking?', '  A hookah.'), ('Which character serves as herald to the King and Queen of Hearts?', ' The White Rabbit.')]
    

book-buddy-interactive-storytelling-using-a-gemma-based-rag's People

Contributors

jigyasa-grover avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.