office-dynamixs-ai/doc/RAG_SERVICE.md

74 lines
1.7 KiB
Markdown

# The RAG ClusterService EJB
With the EJB `ClusterService` clients can index and retrieve embeddings.
## Index
A text chunk can be index by:
```java
clusterService.insertVector(workitem.getUniqueID(),
workitem.getModelVersion(),
workitem.getTaskID(),
chunk,
indexResult);
```
## Retrieval
The retrieval can be based on text embedding only or refined by workflow metadata like the modelVersion or the TaskId
```java
List<RetrievalResult> retrievalResultList = clusterService.searchEmbeddings(embeddings, 5);
```
You can refine the retrieval by providing additional workflow context
1. Task ID Range: Suche alle Tasks zwischen 1000-1999
```java
List<RetrievalResult> rangeResults = clusterService.searchEmbeddingsWithTaskRange(
queryEmbedding,
5,
null, // all Model Versions
1000,
1999
);
```
2. Wildcard Model Version: all products by wildcard search
```java
List<RetrievalResult> productResults = clusterService.searchEmbeddingsWithModelWildcard(
queryEmbedding,
5,
"product-de*", // product-de-1.0.0, product-de-2.0.0, etc.
null
);
```
3. Combination products and Task Range 1000-1999
```java
List<RetrievalResult> combinedResults = clusterService.searchEmbeddings(
queryEmbedding,
5,
Arrays.asList("product-de*"),
null, // no specific Task IDs
1000, // Task Range Start
1999 // Task Range End
);
```
4. Multiple Wildcards: all german models
```java
List<RetrievalResult> germanResults = clusterService.searchEmbeddings(
queryEmbedding,
5,
Arrays.asList("product-de*", "offer-de*", "invoice-de*"),
null, null, null
);
```