Building a Knowledge Bank for AI Characters with Convai | Step-By-Step Guide

By
Convai Team
November 12, 2024

Large language models (LLMs) like GPT-4 and Claude 3.5 Sonnet are great for generating text, translating languages, and enabling AI-powered virtual characters to engage in informative conversations.

However, despite their impressive capabilities, LLMs can sometimes generate inaccurate or inconsistent responses, especially when dealing with complex, domain-specific information. 

This limitation can be particularly problematic in serious applications, such as educational games or training simulations, where the accuracy and reliability of character interactions are crucial.

This is where knowledge banks come in! They are a repository of information that improves the interactions between users and characters, making the virtual world more factual and realistic.

When you ground character responses in a curated knowledge base, you ensure that virtual characters provide accurate and relevant information. This, in turn, improves the overall user experience and elevates the immersion in virtual worlds and other interactive applications.

Convai's Knowledge Bank lets you create domain-expert virtual characters. This feature allows you to upload documents as the foundation for your character’s knowledge to deliver reliable and relevant responses. 

The AI characters you create with the knowledge bank feature in the Convai Playground can possess domain expertise about various complex subjects and generate topical and relevant conversations with users about them. 

In this article, you will:

  • Learn the key components of a knowledge bank for NPCs using Convai
  • Walk through a step-by-step guide to creating a knowledge bank for an NPC that’s a product specialist using Convai's platform
  • Find out best practices and advanced techniques for optimizing NPC interactions

Our goal is to ensure you have a solid understanding of using Convai's Knowledge Bank feature to create more knowledgeable, engaging, and responsive AI characters than ever before.

What is a Knowledge Bank?

A knowledge bank is a central repository containing all the information and facts necessary for a character to engage in coherent and contextually relevant interactions. This data can include scripts, dialogues, lore, and any other contextual information that can be used to improve the character’s responses and actions.

Tailoring the content of the knowledge bank—defining key attributes, such as the character’s goals, motivations, and relationships—you can create AI characters with areas of expertise.

For example, a knowledge bank filled with historical facts and anecdotes could create a wise and knowledgeable historian or a museum guide. Check out a simple demo we created using Convai’s Knowledge Bank feature, with an AI character created using Unreal Engine’s Metahuman, that acts as a museum guide:

The relationship between knowledge banks and the overall character development process is integral. Creating and populating the knowledge bank is a foundational step during the development phase. This ensures the character has the information to function effectively within the story’s narrative.

Key Components of a Knowledge Bank

Building a knowledge bank for a character involves several key components that collectively improve its ability to interact meaningfully with players. These components include:

Facts and Information about the Character’s Background, World, and Role

A knowledge bank stores detailed information about the character’s background, the game world, and its specific role. 

This includes historical events, geographical data, lore, demographical data (name, age, occupation, etc.), and other contextual information the character can reference to provide accurate and immersive responses.

We dive more deeply into add knowledge banks to AI NPCs in our video about integrating AI Characters into the Matrix City Sample Scene by Unreal Engine. Read our detailed blog on adding AI Characters to virtual worlds inside Unreal Engine to learn more, or watch the full tutorial to get started:

Dialogue Snippets and Response Templates

These pre-written phrases and sentences can respond quickly to common queries or initiate conversations with players. Templates can also ensure consistency in the AI character’s responses.

Convai Knowledge Bank dashboard in the Playground.

Integration with External Data Sources

The knowledge bank may need to integrate with external data sources to gather information. For example, an AI NPC shopkeeper might need to retrieve prices from an external database, or a quest-giver might need to generate procedural objectives based on the player's actions.

📑 Bookmark Resource: How AI Companions are Revolutionizing the Gaming Industry — and More.

How to Add Knowledge to Your Virtual AI Character with Convai’s Knowledge Bank Feature

In this section, you’ll learn how to use Convai’s Knowledge Bank feature to facilitate the interaction between a virtual product specialist, Dr. Maya Patel, and a user. 

For healthcare products, you always want to ensure that AI-powered characters deliver the most accurate information—this is a prime use case for knowledge banks.

We also created a video tutorial you could follow along with:

Step 1: Create a Virtual Human in Convai

Sign in to your Convai Account and create a new character using the Character Creator Tool. Add the character’s name, the preferred voice based on your goal, and the character's backstory.

Here, we are naming our character Dr. Maya Patel

Here’s the AI character’s backstory: Dr. Maya Patel is a product specialist for a pharmaceutical product called "Pain Pas Plus", an industry-standard pain relief drug for patients of all ages.

Step 2: Ask the character a question to reveal their lack of knowledge

Ask the AI character a question related to the area of expertise you want to update. Here, we ask Dr. Patel about the dosage form and strengths of her company’s product, “Pain Pas Plus” since this is a question a customer would likely ask. 

Let’s see Dr. Patel’s response:

At first glance, it seems Dr. Patel’s response is spot on for a product specialist, but when we look at the facts, she just made that up, and it sounds quite believable. This is a key challenge that generative models (LLMs) often encounter, called “hallucinations.” 

To curb this, we need to give the AI character a pool of facts from which to draw insights. This way, you ensure that when you deploy the character to interface with customers, she only responds with accurate and relevant information.

In this case, we have created a document with all the necessary facts and information for Dr. Patel to draw from. This includes the correct answer to the question: "Pain Pas Plus is available in 25mg, 50mg, and 100mg tablets.”

Now, let’s update Dr. Patel’s knowledge base with the document.

Step 3: Update the knowledge bank with new information

Convai allows you to upload the knowledge base as a text file (.txt), with a 1 MB size limit for the free plan and 100 MB for the Professional plan. If your knowledge base is in a Google Doc, you can download the document as a (.txt) file from File >> Download >> Plain Text (.txt). 

Once you have downloaded the file to your computer, you can upload it by clicking Select File on the Convai dashboard >>Upload.

Step 4: Connect the uploaded information to the character

Great! Once you upload the document, Convai will take a few seconds to minutes to process the document. If it's ready, you should see the document in the “Available files on your account” panel.

This means you can add multiple files to your AI character's knowledge base. 

Click on the Connect button to connect this information to your AI character.

Under the hood, the knowledge bank uses retrieval-augmented generation (RAG) to retrieve the knowledge for the character when a user sends a query—to augment the character’s personality and overall backstory with factual information.

Step 5: Ask the AI character the same question again to verify the update

Once the information is connected to the character, you can ask the same question again to see if the character is using the updated knowledge.

Awesome! Now we see that Dr. Patel responds more factually to the question.

Best Practices for Using Knowledge Bank Efficiently

When preparing files, follow these best practices to help your AI character understand and use Knowledge Bank information:

  1. Single file format: Upload your information as a single file, such as a text or PDF.
  2. Keep entries concise and focused: Each entry in your knowledge bank should focus on a single piece of information or concept. Avoid lengthy paragraphs (more than 5 lines long) or mixing multiple ideas in a single entry, as this can make it harder to parse and utilize the information effectively.
  3. Prioritize relevance: Focus on relevant information to the AI character’s role and interactions. Avoid including extraneous details that might confuse or mislead the character.
  4. Use tags and metadata: Assign relevant tags and metadata to your knowledge bank entries, such as character names, locations, or themes. This allows for quick filtering and searching, making finding and referencing specific information easier.
  5. Q&A format: Consider structuring your information in a question-and-answer format within the same paragraph. This helps the AI character understand the topic and how to respond appropriately.
  6. Use a consistent naming convention: Establish a consistent naming convention for your knowledge bank entries, such as "CharacterName_Backstory" or "Location_Description." This helps keep your knowledge bank organized.
  7. Categorize information: Divide your knowledge bank into clear categories and subcategories based on the type of information, such as character backstory, world lore, dialogue, and behavioral rules. This makes navigating and maintaining the knowledge bank easier as it grows.
  8. Implement version control: As your knowledge bank documents change, it's important to implement version control to track changes and maintain a history of updates. This can be especially useful when collaborating with other team members or managing multiple versions of your AI character’s knowledge.
  9. Regularly review and update: Periodically review your knowledge bank to ensure the information remains accurate, relevant, and up-to-date. Remove or update outdated entries, and add new information to keep your AI character’s knowledge base fresh.

Following these best practices and tips, you can build a well-structured and maintainable knowledge bank to support your AI character’s behavior.

👀 See Also: How to Enable Multilingual AI Support for Virtual Characters.

Conclusion

In this article, we have explored the concept of a knowledge bank and how it creates engaging and intelligent virtual characters. We have discussed the key components of a knowledge bank, including facts, dialogue snippets, and external integrations. 

You also learned how to add a knowledge bank to a character using Convai through a step-by-step guide. You saw the best practices and tips for effectively organizing and structuring your knowledge banks.

As the demand for more interactive NPCs continues to grow, the importance of knowledge banks will only increase. Knowledge banks allow developers to create more complex, consistent, and adaptable AI characters, creating more immersive and memorable virtual experiences.

We encourage you to start building your knowledge banks with Convai and explore the endless possibilities they offer for creating truly intelligent and engaging AI characters. 

With Convai's documentation and community, you'll be well on your way to creating AI characters that will captivate your users and bring your virtual world to life like never before. Also, subscribe to this YouTube channel and stay updated with our latest developments. Write to us at support@convai.com for collaborations or business-related engagement.