# Feature AI-181 - Create semantic index with embeddings for work packages

Project: Stream AI
Status: review approved
URL: https://community.openproject.org/work_packages/AI-181

## Planning

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Target versions | 18.1.0 |
| List |  |
| Roadmap |  |
| Relevance |  |

## OPEN POINTS / FEEDBACK

| ID | Subject | Status | Decision |
| --- | --- | --- | --- |
| AI-196 | How to handle embedding models with more than 4000 dimensions by default? | new |  |

## Features and Chunks

| ID | Subject | Type | Status | Assignee | Target versions | Spent time |
| --- | --- | --- | --- | --- | --- | --- |
| AI-194 | Document indexing and that at most 4000 dimensions can be used | Implementation | new | Joel Koch |  |  |

## Bugs and other work packages

_No work packages_

## Technical Details

| Attribute | Value |
| --- | --- |
| Module | Artificial Intelligence / Semantic Search (SemS) |
| Feature Flag | Semantic search |
| Requires doc change | No |
| Enterprise plan | Enterprise / Professional (PRO) |

## Details

| Attribute | Value |
| --- | --- |
| Pull preview |  |
| Mockups |  |

## People

| Attribute | Value |
| --- | --- |
| Assignee | Joel Koch |
| Accountable |  |
| Product manager |  |
| Developers |  |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Estimates and progress

| Attribute | Value |
| --- | --- |
| Work |  |
| Labor costs |  |

## Description

**As** an Admin  
**I want to** create an semantic index with embeddings for all work packages  
**so that** semantic search can find relevant work packages.

<br>

For background also see:

*   [https://community.openproject.org/projects/AI/work\_packages/AI-170/activity](https://community.openproject.org/projects/AI/work_packages/AI-170/activity)
    
*   [https://community.openproject.org/projects/AI/work\_packages/AI-178/activity](https://community.openproject.org/projects/AI/work_packages/AI-178/activity)
    
*   [https://community.openproject.org/projects/AI/work\_packages/AI-186/activity](https://community.openproject.org/projects/AI/work_packages/AI-186/activity)
    

**Acceptance criteria**

*   multiple semantic indexes can be created
    
*   one semantic index can be activated
    
*   each semantic index links to embeddings of work packages
    
*   work packages are embedded in batches when a semantic index is created
    
*   embedding model can at most use 4000 dimensions
    

**Technical notes**

*   Add model for embeddings for work packages
    
    *   vectors must be casted to string literal for insertion and padded to match 4000 dimensions
        
    *   do nothing when `pgvector` not available
        
*   create table to store embeddings for work packages
    
    *   use halfvec (half-precision float) with 4000 dimensions for the embedding column
        
    *   add HNSW index on the embedding column to speed up queries
        
*   add all jobs to good job batch to be able to report progress
    
*   HTML tags should be removed from content of work packages
    
    *   might need special care to keep whitespace, e.g. for tables
        
*   cut content of embedded work packages so that they fit into the context window of the model
    
    *   to be safe, assume 1 character per token
        
*   watch out for race condition when work package gets deleted while embedding call is made
    

**Permissions and visibility considerations**

*   _To whom is this feature visible?_
    
    *   _admins_
        
*   _When is it not visible?_
    
    *   pgvector not available
        
    *   LLMs disabled for instance
        
    *   Semantic search disabled
        
    *   No embedding model configured
        

**Translation considerations**

*   _Key terms and phrases in the key languages_
    

**Out of scope**

*   Progress and error reporting will be done in a separate work package
    

**Info for QA**

**This is purely backend functionality and can&#x27;t be tested via UI. The code reviewing developer would need to test this via ruby console**
