Closed nithinreddyyyyyy closed 9 months ago
π€
Hey @nithinreddyyyyyy! Great to see you around here again. How's everything going with your projects? π
The reason you're not seeing the query field in your output is due to the use_original_query
attribute in the SelfQueryRetriever
class. If use_original_query
is set to False
, the original query will not be used. Instead, a new query will be generated by the structured_query_translator
from the StructuredQuery
object.
Here's the relevant code from the SelfQueryRetriever
class:
def _prepare_query(
self, query: str, structured_query: StructuredQuery
) -> Tuple[str, Dict[str, Any]]:
new_query, new_kwargs = self.structured_query_translator.visit_structured_query(
structured_query
)
if structured_query.limit is not None:
new_kwargs["k"] = structured_query.limit
if self.use_original_query:
new_query = query
search_kwargs = {**self.search_kwargs, **new_kwargs}
return new_query, search_kwargs
In this method, new_query
and new_kwargs
are generated by the structured_query_translator
visiting the structured_query
. If self.use_original_query
is True
, new_query
is replaced by the original query
. If self.use_original_query
is False
, the original query is not used, and new_query
remains as the query generated by the structured_query_translator
.
To use the original query, you should set use_original_query
to True
when creating an instance of SelfQueryRetriever
. You can find this in the LangChain repository.
Also, the default value of the use_original_query
attribute in the SelfQueryRetriever
class in LangChain is False
. This is defined in the SelfQueryRetriever
class definition:
class SelfQueryRetriever(BaseRetriever):
...
use_original_query: bool = False
"""Use original query instead of the revised new query from LLM"""
...
You can also find this in the LangChain repository.
I hope this helps! If you have any other questions, feel free to ask.
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a π if this is helpful and π if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
Issue with current documentation:
below's the code
below's the output
[Document(page_content='Training and evaluation corpora inlow-resource\nlanguages may notbeaseffective due tothepaucity of\ndata.\n3.Create acentral dialect tomediate between the\nvarious Gondi dialects, which can beused asa\nstandard language forallGondi speakers.\n4.Low BLEU scores formachine translation model :\nThere isaneed forbetter methods oftraining and\nevaluating machine translation models.\nPOS Tagging\nData Collection', metadata={'page': 0, 'source': '/content/documents/Pre-proposal PhD students.pdf'}))]
where as in the langchain selfQueryRetriver documentation, below's the output which has been shown
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)
where i can see the query above which is classified as taxi driver
Idea or request for content:
No response