spring-projects / spring-ai

An Application Framework for AI Engineering
https://docs.spring.io/spring-ai/reference/index.html
Apache License 2.0
3.34k stars 862 forks source link

Add tags for embedded data #316

Closed DanilTk closed 9 months ago

DanilTk commented 9 months ago

I've came over the following issue: E.g. when feeding my vector db with multiple pdfs on different topics, e.g. K8S and some medical related topic brochure and asking LLM smth - the one started hallucinating mixing topics from K8S and medical brochure.

In this regard a request would be to add tags so that it is possible to give hints to LLM on which context the question relates to

ThomasVitale commented 9 months ago

The DocumentReaderfunctionality has general support for adding metadata to a document during the loading phase. However, not all implementation allow adding custom metadata.

When retrieving relevant documents, for supported vector stores (like Chroma or Weaviate), you can use filter expressions to include only documents labelled with certain metadata (example).