Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Self Query Retriever malfunctioning #29711

Open
5 tasks done
imvaibhav28 opened this issue Feb 10, 2025 · 0 comments
Open
5 tasks done

Self Query Retriever malfunctioning #29711

imvaibhav28 opened this issue Feb 10, 2025 · 0 comments
Labels
Ɑ: vector store Related to vector store module

Comments

@imvaibhav28
Copy link

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

While using Self Query in my code, I am facing following issue.

  • The Query translator produces a structured query output with metadata fields populated similar as shown
query_constructor.invoke( 
   {
       "query": "What are some sci-fi movies from the 90's directed by Luc Besson about taxi drivers"
   }
)

Output: StructuredQuery(query='taxi driver', filter=Operation(operator=<Operator.AND: 'and'>, arguments=[Comparison(comparator=<Comparator.EQ: 'eq'>, attribute='genre', value='science fiction'), Operation(operator=<Operator.AND: 'and'>, arguments=[Comparison(comparator=<Comparator.GTE: 'gte'>, attribute='year', value=1990), Comparison(comparator=<Comparator.LT: 'lt'>, attribute='year', value=2000)]), Comparison(comparator=<Comparator.EQ: 'eq'>, attribute='director', value='Luc Besson')]), limit=None)

`

But I need to use original query and not the translated query while retrieval .

  • I believe the the official code base for retriever (here) provides this functionality using a boolean parameter use_original_query

  • This was working until 3-4 months ago. But now I can not see it using the original query.

  • Using PGVectorTranslator and PGVector store for this implementation. I found three different implementations of PGVectorTranslator() as below which is confusing.

 from langchain_postgres.translator import PGVectorTranslator
from langchain_community.query_constructors.pgvector import PGVectorTranslator
from langchain_postgres import PGVectorTranslator
vectorstore = PGVector(
    embeddings=embeddings,
    collection_name=collection_name,
    connection=connection,
    use_jsonb=True,
)
retriever = SelfQueryRetriever.from_llm(
    llm=llm,
    vectorstore=vectorstore,
    document_contents=document_content_description,
    metadata_field_info=metadata_field_info,
    structured_query_translator=PGVectorTranslator(),
    use_original_query=True,    
)

Error Message and Stack Trace (if applicable)

No response

Description

  • Trying to use Self Query Retriever
  • Expect to use original query paramter as true
  • But I need to use original query and not the translated query while retrieval .This was working until 3-4 months ago. But now I can not see it using the original query.

-Using PGVectorTranslator and PGVector store for this implementation.

System Info

System Information

OS: Linux
OS Version: #84~20.04.1-Ubuntu SMP Mon Nov 4 18:58:41 UTC 2024
Python Version: 3.12.3 (main, Nov 6 2024, 18:32:19) [GCC 13.2.0]

Package Information

langchain_core: 0.3.34
langchain: 0.3.16
langchain_community: 0.3.16
langsmith: 0.1.133
langchain_experimental: 0.3.4
langchain_openai: 0.3.2
langchain_postgres: 0.0.12
langchain_text_splitters: 0.3.6
langgraph_sdk: 0.1.51

Optional packages not installed

langserve

Other Dependencies

aiohttp: 3.9.5
async-timeout: Installed. No version info available.
dataclasses-json: 0.6.7
httpx: 0.27.2
httpx-sse: 0.4.0
jsonpatch<2.0,>=1.33: Installed. No version info available.
langchain-core<1.0.0,>=0.3.34: Installed. No version info available.
langsmith<0.4,>=0.1.125: Installed. No version info available.
numpy: 1.26.4
openai: 1.61.1
orjson: 3.10.11
packaging<25,>=23.2: Installed. No version info available.
pgvector: 0.2.5
psycopg: 3.2.4
psycopg-pool: 3.2.4
pydantic: 2.8.2
pydantic-settings: 2.7.1
pydantic<3.0.0,>=2.5.2;: Installed. No version info available.
pydantic<3.0.0,>=2.7.4;: Installed. No version info available.
PyYAML: 6.0.1
PyYAML>=5.3: Installed. No version info available.
requests: 2.32.2
requests-toolbelt: 1.0.0
SQLAlchemy: 2.0.30
sqlalchemy: 2.0.30
tenacity: 8.2.2
tenacity!=8.4.0,<10.0.0,>=8.1.0: Installed. No version info available.
tiktoken: 0.7.0
typing-extensions>=4.7: Installed. No version info available.

@dosubot dosubot bot added the Ɑ: vector store Related to vector store module label Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ɑ: vector store Related to vector store module
Projects
None yet
Development

No branches or pull requests

1 participant