Giter Club home page Giter Club logo

dnd-answers's Introduction

Using GPT4 to answer D&D questions

This repository contains a Python Notebook demonstrating how to use the GPT-4 model to answer questions about Dungeons and Dragons 5e. With the power of LLMs and embeddings stored in a vector database, this D&D Assistant can answer the most heated questions your players might argue about.

The code takes text inputs and outputs answers, consulting the snippets of the SRD that the model finds most relevant.

There is also a demo of using the function calling api to retrieve spell descriptions.

View the notebook here

How It Works

  1. Loading the Rules: The 5e SRD rules text is loaded from a Markdown document.
  2. Chunking Text: The SRD text is then split into manageable chunks so that the embeddings model can understand it easily.
  3. Creating Embeddings: Each chunk of the SRD text is then run through an embeddings model.
  4. Storing Embeddings: The generated embeddings are stored in a vector database for quick and easy retrieval.
  5. Answering Questions: When a question is asked, the model generates an embedding for the question and searches the database for the most similar embeddings (i.e., the most relevant SRD text chunks). The selected chunks are passed into a prompt for a GPT-4 model, which uses the context to answer the user's question.

Dependencies

  • Qdrant for vector database management
  • Sentence Transformers for generating embeddings
  • OpenAI for LLM backend

Contributions

Pull requests accepted for improvements to the demo.

License

This repository is licenced under MIT unless otherwise stated.

The D&D 5e SRD rules text used in this demonstration is dual licensed by Wizards of the Coast under the terms of CC-BY-4.0 or OGL 1.0a. Full details available at: https://dnd.wizards.com/resources/systems-reference-document

dnd-answers's People

Contributors

crspeller avatar ergs0204 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.