stanfordnlp / dspy

DSPy: The framework for programming—not prompting—foundation models
https://dspy-docs.vercel.app/
MIT License
13.82k stars 1.06k forks source link

How do I specify metadata query parameters in Retrievers? #1212

Open rodrigomeireles opened 5 days ago

rodrigomeireles commented 5 days ago

I was wondering how do I specify metadata to the retrievers' queries. For instance, a user might ask about something specifically for 2022 and semantically, all year numbers are very similar. Therefore I might want to query all documents with a "year" label attached to them being equal to 2022.

This is trivially done if I have control of the query and almost all vector DBs support metadata filters. How should I go about implementing this in my Retriever? Is there any way to use the built-in retrievers?

Any suggestion is appreciated.

rodrigomeireles commented 3 days ago

I figured maybe no one answered because my question is too generic. I am looking at the PGVector retriever.

rodrigomeireles commented 3 days ago

@arnavsinghvi11 you seem to have comitted recently to the PgVector retriever. Do you have any idea on how to add filtering?