Anthrop\c Claude : LlamaIndex: The model requires further context to answer to the query

222 Views Asked by At

The use case

I am using LLamaIndex to query a pdf stored under the "data" directory

I am using Anthrop\c Claude as Large-Language Model (LLM)

Question

What is the expected piece of code that I need to add in order to comply with the output message :

  1. "Unfortunately I do not have enough context to fully summarize what the document is about without directly referencing the given context"

  2. "Unfortunately, I do not have enough context to directly answer the query about the authors."

The source code

# query the file stored under data/
from llama_index.llms import Anthropic

from dotenv import load_dotenv
import os
load_dotenv()
llm = Anthropic(api_key=os.getenv('LLM_ANTHROPIC_API_KEY'))


from llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext
service_context = ServiceContext.from_defaults(chunk_size=1024, llm=llm, embed_model="local")
documents = SimpleDirectoryReader("data").load_data()

index = VectorStoreIndex.from_documents(documents, service_context=service_context) 

query_engine = index.as_query_engine()
response = query_engine.query("What is the document about?")

print(response)

response = query_engine.query("Who are the authors?")
print(response)


Answer 1 "What is the document about?" from Anthrop\c Claude

Unfortunately I do not have enough context to fully summarize what the document is about without directly referencing the given context.

Based on the page numbers and section titles provided, it seems to cover topics related to ....

However, without further context I cannot conclusively state what the overall focus of the document is.

I apologize that I cannot provide a more specific summary without additional information.

Answer 2 "Who are the authors?" from Anthrop\c Claude

Unfortunately, I do not have enough context to directly answer the query about the authors.

The provided information discusses ... classification, ... and guidelines, but does not mention any authors.

To provide a relevant response, more context related to the specific query would be needed.

0

There are 0 best solutions below