Create

Sign in to ReadmeX

or

How we handle your data: Privacy Policy

ReadmeX

Your AI reading companion

What would you like to catch up on?

Pick a briefing, or ask your own question.

Your community and people briefings stay personal to you.

Story

Tutorial: Move LangChain4j RAG Vectors From JVM Memory to Qdrant

AI summary

A tutorial for an AI homework assistant updates its LangChain4j RAG implementation to store vectors in Qdrant instead of the JVM’s in-memory EmbeddingStore. Version 0.2.1 persists vectors with a Docker volume and checks the collection during startup, skipping embedding when the stored point count already covers the corpus. The author notes that this count-based check does not detect content edits, so changed records require deleting the collection to force re-embedding.

In-depth insight

The tutorial demonstrates a practical way to preserve LangChain4j RAG embeddings across application restarts without changing the surrounding retrieval and chat code.

开场:每次重启,都有一笔冤枉钱

v0.2 中已提到过,每次重启就会重新做一次embedding。虽然 8 首诗总共几百 token,费用忽略不计;但随着生产数据越来越大,这笔钱越来越大,且花得毫无必要。诗没变、embedding 模型没变,算出来的向量就不会变——变的只是"放向量的地方"没了。内存向量库跟着 JVM 生死,进程一重启就清零,于是只好全部重算一遍。

这一篇就干一件事:把向量库从 JVM 内存搬进 Qdrant。

本文源码:github.com/tongli99/zi… ,对应 tag v0.2.1——clone 后 git checkout v0.2.1,或直接浏览 v0.2.1 快照。


一、先复盘 v0.2:重启那一下发生了什么

每次启动都跑一遍:
data/poems.json(8 首)
   → embedding 接口:8 首诗打包成 1 个请求,全部重新向量化(花钱、花时间)
   → 全部塞进 InMemoryEmbeddingStore(JVM 内存)
   → Ctrl+C,全没了
   → 下次启动,再来一遍 ↑

#LangChain4j#Qdrant#Redis#text-embedding-v3#ziwen

Original · 7 min readRead the original
Group chat

No comments yet. Start the conversation.