# Usage

## First step: Prepare your documents

Before uploading files to your knowledge base, it's crucial to understand how the AI will process them. The quality of your documents directly determines how well the LLM can answer questions.

### Understanding how AI processes your documents

When someone asks a question, the AI doesn't read your entire knowledge base from start to finish. That would take a lot of time and resources. Instead, when documents are uploaded to the knowledge base, they are automatically organised in a way that LLMs can understand. This happens through a process called 'chunking'.

The files are converted to text and cut into bite-sized 'chunks'. The chunks are organised by topic, making it possible for the LLM to quickly find and compare relevant information with incoming queries. In short:

1. **Break documents into chunks** - Like tearing pages out of a book and organising them by topic
2. **Search for relevant chunks** - Like looking through index cards to find the right information
3. **Use the most relevant chunks** - Like pulling out the most helpful pages to answer the question

Important to note is that when a question is asked, the LLM doesn't read the entire 'library', but only the chunks that its filing system deems the most relevant. As you can probably imagine, it is *crucial* that the right chunks are selected. Without them, the LLM doesn't have the information it needs and won't be able to answer the request properly. Because chunking happens automatically and uses simple rules (like cutting every x words), it doesn't always split documents at logical points. This means context can get lost and related information might end up in different chunks. You can help the LLM by creating documents that work well with this automatic chunking process.

### Document guidelines

#### Avoid complex PDFs

PDFs can be problematic for knowledge bases because they often contain complex formatting that doesn't translate well when chunked.

{% hint style="success" %}
**Do:** Markdown files or plain text files
{% endhint %}

{% hint style="warning" %}
**Avoid:** PDFs with multiple columns of text, tables, etc
{% endhint %}

#### Structure and formatting

Use clear headings and sections to break up your content.

{% hint style="success" %}
**Do:**

\# Product Information\
\## Pricing\
\[pricing information]\
\## Features\
\[features information]\
\## Support\
\[support information]
{% endhint %}

{% hint style="warning" %}
**Avoid:** Everything in one long paragraph
{% endhint %}

Use bullet points and lists to make information scannable.

{% hint style="success" %}
**Do:** Our products include:

* Phones
* Computers
* Tablets
* Accessories
  {% endhint %}

{% hint style="warning" %}
**Avoid:** Our products include phones, computers, tablets, and accessories
{% endhint %}

#### Write concise and focused text

Keep paragraphs short and focused on one topic.

{% hint style="success" %}
**Do:** Founded in 1995, we are a leading provider of business solutions with 25+ years of experience.
{% endhint %}

{% hint style="warning" %}
**Avoid:** Our company was founded in 1995 and has been serving customers for over 25 years. We started as a small family business and have grown to become one of the leading providers in our industry. We offer a wide range of products and services...
{% endhint %}

Ensure each section covers only one topic.

{% hint style="success" %}
**Do:** Separate sections for "Contact Information", "Pricing", and "Product Features"
{% endhint %}

{% hint style="warning" %}
**Avoid:** A section about "Contact Information" that also mentions pricing and product features
{% endhint %}

#### Write context-rich content

Include relevant details that provide complete information.

{% hint style="success" %}
**Do:** "Call our support team at 1-800-123-4567, Monday-Friday 9AM-5PM EST"
{% endhint %}

{% hint style="warning" %}
**Avoid:** "Call us for support"
{% endhint %}

#### Explain terminology and add synonyms

Define technical terms, jargon and acronyms.

{% hint style="success" %}
**Do:** "Use our API (Application Programming Interface) to integrate with your existing systems"
{% endhint %}

{% hint style="warning" %}
**Avoid:** "Use our API to integrate"
{% endhint %}

Include alternative terms and synonyms.

{% hint style="success" %}
**Do:** "Contact our support team (also called customer service, help desk, or technical support)"
{% endhint %}

{% hint style="warning" %}
**Avoid:** "Contact our support team"
{% endhint %}

## Managing your knowledge base

### Edit the knowledge base details

Click on the Edit button in the top right corner to edit the details of the knowledge base. The most important detail is the description. The description is used to generate an LLM intent that can be used in your App to recognize if a user talks about the contents of your knowledge base or not. Carefully tweak this description when you need to use an intent trigger based on this LLM intent.

<figure><img src="https://3356808761-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEBQHGJABNTj5ISSOTRxM%2Fuploads%2FOfLQjCuUrr7qJqlYDYTx%2Fimage.png?alt=media&#x26;token=51639129-b16d-4855-aee2-0c13140bfcc9" alt=""><figcaption><p>Edit knowledge base</p></figcaption></figure>

### Upload files to your knowledge base

On the knowledge base page you can add files by dragging files on the page or simply clicking the button "Upload files". The knowledge base supports the file types defined in the [limitations section](https://gitlab.com/botsquad/gitbook-manuals/-/blob/docs/studio/ai/knowledge-bases/knowledge-bases-overview.md#file-types).

If the upload is successful, a green checkmark icon is displayed in front of the file name. It might take a minute or so before it appears. If an explanation mark appears that means that the upload was not successful. You can click on the icon to review the explanation of the failure so you can take corrective measures.

<figure><img src="https://3356808761-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEBQHGJABNTj5ISSOTRxM%2Fuploads%2FjM70adb1KpkYPR5QFhKz%2Fimage.png?alt=media&#x26;token=7e77e027-0ff8-490c-867a-c8990953e8e2" alt=""><figcaption><p>Knowledge base files</p></figcaption></figure>

### Remove files from your knowledge base

Right click on the file name of one of your files in the knowledge base to open the context menu. Click on the delete button to remove the file from your knowledge base.

<figure><img src="https://3356808761-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEBQHGJABNTj5ISSOTRxM%2Fuploads%2F2oYfUwXEcCub0pjoBzoW%2Fimage.png?alt=media&#x26;token=0b92d561-e113-4554-842b-47cd53bf304d" alt=""><figcaption><p>Removing files from your knowledge base</p></figcaption></figure>

### Rename files

Files can be renamed for the sake of keeping track and organising your knowledge base. Use descriptive names that help you identify the content quickly.

### Metadata

Each file can contain one or more metadata items. These are used for the platform to keep track of the files on the Azure services that are used to provide the knowledge base services.

{% hint style="info" %}
Don't change or remove the metadata of your knowledge base files since they are used to keep track of your files in the storage facility at Azure
{% endhint %}

### Folders

Using the context menu by right clicking on a file you can create and manage folders. Files can be organised in folders. Folders don't have an effect on the workings of the knowledge bases. They are simply for you to organise and keep track of your files.

### Troubleshooting

When using a knowledge base, you can see which chunks the LLM used to generate its answer. This is especially useful when an answer doesn't make sense or you want to verify the source. The view this information, click the LLM request in the conversation view and click on the knowledge tab. There you can review how the LLM queried your knowledge base and which chunks it used. This helps you understand the reasoning behind the response and identify any issues with your documents or prompting.

<figure><img src="https://3356808761-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEBQHGJABNTj5ISSOTRxM%2Fuploads%2FIqb3mGnMgx9P4k0GkAVo%2Fimage.png?alt=media&#x26;token=eac444e1-076c-4b9c-b9ec-84063b479c09" alt=""><figcaption></figcaption></figure>

## Best practices

1. **Start with your most important information** - Upload the documents that answer the most common questions first
2. **Test with real questions** - Ask the types of questions your customers would ask and see if the LLM finds the right information
3. **Keep documents updated** - Remove outdated information and add new content regularly
4. **Use descriptive file names** - Make it easy to find and manage your files
5. **Organise with folders** - Group related documents together for easier management
