> For the complete documentation index, see [llms.txt](https://cleyrop.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cleyrop.gitbook.io/docs/documentation-fr-en/data-and-ai-project/studio-ai/corpus-de-documents.md).

# Document corpus

A corpus is a set of unstructured text documents that serves as a knowledge base for AI assistants.

The documents are **vectorized** and stored in a database optimized for semantic search thanks to the **RAG** (Retrieval-Augmented Generation).

A corpus therefore makes it possible to extract insights and generate content in natural language from internal documents.

***

## Create a corpus

1. From AI Studio, open the Corpus tab.
2. Click `+ Create` .
3. Choose the **main language** (French, English) or enable **automatic detection** (English, French, Spanish, German).
4. Select the documents to include
5. Enrich the metadata if necessary.
6. Give the corpus a name and description.
7. Click Create: the embedding process starts.

   Once the status changes to *Valid*, the corpus becomes usable in the project.

{% hint style="warning" %}
The **files** to be queried must be **placed in Work Data** before starting corpus creation

Supported formats: **PDF, DOCX, TXT, PPTX**

The embedding model used is BGE-M3
{% endhint %}

#### Enrich Metadata

**Automatically extracted**

* Path, format, title, author, subject, keywords, creator, producer, creation/modification date, file name, language, number of pages.

**Enriched (optional)**

You can add metadata by:

* condition (e.g. if the path contains “contracts”),
* extraction (text present in the document),
* or a combination of both.

This metadata will then be used as filters in AI assistants to refine searches.

{% hint style="info" %}
A valid corpus is accessible to all project members from the AI assistants.
{% endhint %}

### Corpus states and statuses <a href="#etats-dun-corpus" id="etats-dun-corpus"></a>

#### States

A corpus can be in one of the following states:

* **Created** : the corpus has been created but the files have not yet been vectorized
* **Valid:** the corpus is valid and can be used by platform users to create assistants and query them. At least one document has been successfully vectorized
* **Error** : the corpus is in error and cannot be used by platform users. No file has been successfully vectorized.

#### File statuses <a href="#statuts-dun-fichier" id="statuts-dun-fichier"></a>

Corpus documents can have several statuses:

* **Created** the file has been selected but has not yet been vectorized
* **In progress** : vectorization is in progress
* **Success** : vectorization was completed successfully
* **Failure** : vectorization failed

## Query a corpus with an AI assistant

Once the corpus has been created:

1. Associate it with an assistant when creating or editing it.
2. Users can **ask questions in natural language.**
3. The assistant analyzes the corpus **vectorized** and provides an answer based on the content of the documents.
4. Metadata makes it possible to **filter** documents and obtain targeted answers.

## Edit a corpus

You can enrich or clean up a corpus at any time.

#### Add documents

1. Select the corpus to enrich.
2. Click **Add documents.**
3. Select the files to integrate (documents already present are grayed out).
4. Start the integration: the files are vectorized and the metadata updated.

Each addition is logged with:

* date and time,
* status (*success* or *failure*).

#### Delete documents

1. Select the corpus to edit.
2. Click Delete documents.
3. Choose the files to remove.
4. Confirm the deletion.<br>

Deleted documents are removed from assistant results and their metadata deleted.

The deletion history remains available for consultation (date, time, status).

{% hint style="info" %}
As long as a deletion or addition is in progress, no new action can be started on the corpus.
{% endhint %}

## Delete a corpus

To delete a corpus, click the 🗑️ icon on the corresponding card in the Corpus tab.

Deletion is permanent and immediately removes the knowledge base from the project.

***

## Best practices

* Group documents by theme (e.g. “Client Contracts”, “Internal Procedures”).
* Check the language and quality of the files to optimize vectorization.
* Avoid excessively large or noisy files (imperfect OCR, scans).
* Update your corpora regularly to keep AI responses relevant.
