Find answers from the community

Updated last year

I have a question about the system's

I have a question about the system's responses. I've observed that when I issue the command 'summarize the document,' the system correctly summarizes the content. However, when I use the command 'what is this document about,' it responds with, "this document is about the different tools available for natural language processing (NLP) tasks. It provides an overview of the tools and their functionalities, including default query engines, etc." How can I address this inconsistency in responses?
L
J
19 comments
Those are effectively two different things you are asking. The response to the second question seems fine

Are you expecting both prompts to summarize? That seems a little unreasonable, but you could just append a static string to your queries like query_str + "\nWrite your response as a summary." maybe?
Yes, I expected that the 'document' mentioned in the two questions point to the same document which I provided. But the second question's 'document' seems not to indicate the document content that I provided, and I don't know where it (the NLP thing) comes from.
as for query_str + "\nWrite your response as a summary."
This solution effectively handles specific questions but lacks flexibility for diverse phrasings. To address a wider range of queries, a more robust approach with NLP or rule-based systems is needed. Therefore, it may not be the best solution.
I'm not sure what triggers these two questions to reference different documents.
My original document pertains to insurance policies, with no connection to NLP. Therefore, responses related to NLP should not be generated.
You can check response.source_nodes to see what info was used to generate the response.
empty, which is why I have no idea where this NLP-related information is coming from.
what kind of index are you querying? Pretty weird to have empty sources
Does this OpenAI log assist you with debugging?

message='Request to OpenAI API' method=post path=https://api.openai.com/v1/chat/completions
api_version=None data='{"messages": [{"role": "user", "content": "what this doc is about"}], "stream": false, "model": "gpt-3.5-turbo-0613", "temperature": 0.1, "max_tokens": null, "functions": [{"name": "default_query_engine_tool", "description": "Use a detailed plain text question as input to the tool.", "parameters": {"title": "DefaultToolFnSchema", "description": "Default tool function Schema.", "type": "object", "properties": {"input": {"title": "Input", "type": "string"}}, "required": ["input"]}}, {"name": "retriever_query_engine_tool", "description": "Use for semantic search.", "parameters": {"title": "DefaultToolFnSchema", "description": "Default tool function Schema.", "type": "object", "properties": {"input": {"title": "Input", "type": "string"}}, "required": ["input"]}}, {"name": "keyword_query_engine_tool", "description": "Useful for summary of context.", "parameters": {"title": "DefaultToolFnSchema", "description": "Default tool function Schema.", "type": "object", "properties": {"input": {"title": "Input", "type": "string"}}, "required": ["input"]}}], "function_call": "auto"}' message='Post details'
continue

message='OpenAI API response' path=https://api.openai.com/v1/chat/completions processing_ms=12278 request_id=8e461889815e11d40cac9ed247a53d73 response_code=200
body='{\n "id": "chatcmpl-8ISdXEuHrt18wpzKIYTtmyFwQlxWg",\n "object": "chat.completion",\n "created": 1699410675,\n "model": "gpt-3.5-turbo-0613",\n "choices": [\n {\n "index": 0,\n "message": {\n "role": "assistant",\n "content": "This document is about the different tools available for natural language processing (NLP) tasks. It provides an overview of the tools and their functionalities, including default query engines, retriever query engines, and keyword query engines. These tools can be used for tasks such as semantic search, summarization, and keyword extraction."\n },\n "finish_reason": "stop"\n }\n ],\n "usage": {\n "prompt_tokens": 106,\n "completion_tokens": 64,\n "total_tokens": 170\n }\n}\n' headers='{'Date': 'Wed, 08 Nov 2023 02:31:27 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'access-control-allow-origin': '*', 'Cache-Control': 'no-cache, must-revalidate', 'openai-model': 'gpt-3.5-turbo-0613', 'openai-organization': 'user-8tnka43iuqgkrybnyt8kunve', 'openai-processing-ms': '12278', 'openai-version': '2020-10-01', 'strict-transport-security': 'max-age=15724800; includeSubDomains', 'x-ratelimit-limit-requests': '3500', 'x-ratelimit-limit-tokens': '90000', 'x-ratelimit-remaining-requests': '3499', 'x-ratelimit-remaining-tokens': '89977', 'x-ratelimit-reset-requests': '17ms', 'x-ratelimit-reset-tokens': '15ms', 'x-request-id': '8e461889815e11d40cac9ed247a53d73', 'CF-Cache-Status': 'DYNAMIC', 'Server': 'cloudflare', 'CF-RAY': '822a66106c4d169c-SJC', 'Content-Encoding': 'gzip', 'alt-svc': 'h3=":443"; ma=86400'}' message='API response body'
oh you are using an agent. You will likely need a more explicit setup with proper descriptions of the query engine(s) it has access to and maybe also a system prompt
agent = OpenAIAgent.from_tools(query_engine_tools, system_prompt="...")
Do you imply that my engine descriptions lack sufficient detail for accessibility? In that case, where did this NLP content originate?
it completely hallucinated it since it probably didn't query your index to answer the user message
πŸ€·β€β™‚οΈ
it's how agents work sometimes -- need to be more explicit in what info it has access to, and when that info is useful

For example

Plain Text
query_engine_tools = [
    QueryEngineTool(
        query_engine=lyft_engine,
        metadata=ToolMetadata(
            name="lyft_10k",
            description=(
                "Provides information about Lyft financials for year 2021. "
                "Use a detailed plain text question as input to the tool."
            ),
        ),
    ),
    QueryEngineTool(
        query_engine=uber_engine,
        metadata=ToolMetadata(
            name="uber_10k",
            description=(
                "Provides information about Uber financials for year 2021. "
                "Use a detailed plain text question as input to the tool."
            ),
        ),
    ),
]

agent = OpenAIAgent.from_tools(query_engine_tools, system_prompt="You are a helpful assistant capable of accessing information related to Uber and Lyft 2021 financials.")
Much less likely to hallucinate
Thank you very much for your assistance; it is greatly appreciated!
Add a reply
Sign up and join the conversation on Discord