Skip to content

Commit ff1e3d8

Browse files
committed
fix(demo): improve RAG retrieval to include text content
IMAGE chunks have generic descriptions (e.g., "Image 1 from page 3") that embed poorly for semantic search but may match general queries. This caused TEXT chunks with actual document content to be excluded. - Add 'type' TAG field to schema for future type-based filtering - Increase maxResults from 5 to 15 to ensure TEXT chunks are retrieved - Lower minScore from 0.3 to 0.2 for broader retrieval (filtered in code) RAGService already separates TEXT vs IMAGE content for processing.
1 parent 3d1cc9d commit ff1e3d8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

demos/rag-multimodal/src/main/java/com/redis/vl/demo/rag/service/ServiceFactory.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ private SearchIndex createSearchIndex() {
9090
"fields",
9191
List.of(
9292
Map.of("name", "text", "type", "text"),
93+
Map.of("name", "type", "type", "tag"), // TAG field for filtering by chunk type
9394
Map.of("name", "metadata", "type", "text"),
9495
Map.of(
9596
"name",
@@ -128,12 +129,15 @@ public RAGService createRAGService(LLMConfig config) {
128129
}
129130

130131
// Create content retriever
132+
// Use higher maxResults to ensure TEXT chunks are retrieved (IMAGE chunks
133+
// have generic descriptions that may match better semantically but contain
134+
// no useful content). RAGService separates TEXT vs IMAGE for processing.
131135
RedisVLContentRetriever retriever =
132136
RedisVLContentRetriever.builder()
133137
.embeddingStore(embeddingStore)
134138
.embeddingModel(embeddingModel)
135-
.maxResults(5)
136-
.minScore(0.7)
139+
.maxResults(15)
140+
.minScore(0.2) // Low threshold since we'll filter in RAGService
137141
.build();
138142

139143
// Create chat model based on provider

0 commit comments

Comments
 (0)