Find answers from the community

Home
Members
pikachu8887867
p
pikachu8887867
Offline, last seen 3 months ago
Joined September 25, 2024
Is it possible to add system prompt in CitationQueryEngine?

Plain Text
    query_engine = CitationQueryEngine.from_args(
        index=temp_index,
        similarity_top_k=3,
        citation_chunk_size=512,
        system_prompt="Doesn't matter what user asks, always reply with: `I love bananas`"
    )


doesn't matter what I ask, it is not outputting I love bananas
1 comment
p
Hi! I'm using LlamaParse through Python library. I've sent a pdf with 9 pages. I can see in LlamaCloud that it indeed processed 9 pages.

But in my code debugger, I can see that it returns only 1 document, not 9. Where is the rest of the pages?
3 comments
L
p
Hi! Let's say I want to retrieve relevant chunks about "X" and I don't want augmented generation by LLM. Just want to retrieve chunks and that's it. What other methods but retriever.retrieve(X) does LlamaIndex propose?

If I must use query engine (with LLM), then I would ask something like: retrieve all information about X , but not sure If it is sufficient.
2 comments
L
P
What is the best set of instruments I can use for the task of comparing everything vs everything in one PDF vs another PDF? And list down all the contradicting information (e.g.:
Plain Text
1) in PDF-A it is written that Microsoft made profit in 2021, but in PDF-B it is written that Microsoft made loss in 2021

2) Based on PDF-A, Apple spends more money on design than on technology, however in PDF-B it is stated that Apple spends more money on techonlogy etc.

)??

You see? I don't have any "initial query". I just want to compare the whole PDF-A vs the whole PDF-B and list down all the contradicting information.

I'm reading the LlamaIndex docs and frankly I have a headache now. Can't figure out which exact instruments to use and how.

use agents? ok, which?

use multi-hop query engine like in the example with Tesla and another company (forgot the name)? But I don't have initial query. Do I need to ask "compare everything and list down contradictions?"

Stuff as much as the model can handle, ask it to summarize then compare summary vs summary? Maybe? But summarization might omit important info...

etc.

Help, please
2 comments
p
W
Hi! I'm trying to use LlamaParse the following way:

1) Writing my code on front-end library CodeMirror. This code contains LlamaParse stuff (reading files using SimpleDirectoryReader etc.
2) Then I send that text to FastAPI backend and call exec() function to perform pdf parsing

I was getting a warning from LlamaParse telling that I need to use nest_asyncio.apply(). I did it, and now I am getting this:

Plain Text
  File "/home/ali/AI/nexus/llm-topic-modelling/venv/lib/python3.10/site-packages/nest_asyncio.py", line 193, in _patch_loop
    raise ValueError('Can\'t patch loop of type %s' % type(loop))
ValueError: Can't patch loop of type <class 'uvloop.Loop'>


Any ideas on how to fix this?
2 comments
L
Hi! How to serialize/deserialize Document objects?

I used LlamaParse to parse my documents:

Plain Text
file_extractor = {".pdf": parser}
documents = SimpleDirectoryReader(
    "./docs/pdfs/all", file_extractor=file_extractor
).load_data()


I want to store them and then re-use later on. Is it possible?
1 comment
L
Hi! Is there a way to process Ollama calls in batch? Like batch functionality in langchain
10 comments
N
L
p
it modifies the prompt I'm using for search, isn't it? I need to add a system prompt, e.g.:

Plain Text
You are a professional Business Analyst bla bla bla


It has nothing to do with the prompt I will use for retrieval?
3 comments
L
p
Where to write a system prompt, when using Groq + Query engine?

Plain Text
@app.post("/query/")
def process_text(request_body: dict, db: Session = Depends(get_db)):
    query = request_body.get('query')
    vector_store = QdrantVectorStore(client=client, collection_name="data")
    index = VectorStoreIndex.from_vector_store(vector_store=vector_store)
    query_engine = index.as_query_engine()
    response = query_engine.query(query)
    return response.response


Where exactly do I need to plug my system prompt in the code above?
1 comment
L
Why is LLMTextCompletionProgram + GroqCloud is hella slow?? I’ve tested GroqCloud native api from terminal and it is indeed super fast, but when I use with pydantic program it is slow as hell. Does it have some kind of loop internally?
3 comments
L
p
Does Llamaindex support JSONmode and system prompt, when using Groq?

In the example given, I see this:

Plain Text
llm.complete(prompt)


is there a way to send a system prompt and turn json mode on?
4 comments
L
p
Hi! Is there a way to use PydanticProgram with Groq?
I'm using OpenAIPydanticProgram with OpenAI, but is there a way to use it with Groq?
3 comments
L
p
Hi!

I have a list of topics, e.g: [expenses, profit, risks] etc.

I have a big pdf (around 500 pages).

I want to classify each page in that pdf; e.g.:

page-1: [expenses, risks]
page-2: [profit]
page-3: []

etc.

Is it possible to acheve with Llamaindex?
7 comments
A
p
L
Hi! While using pydantic program, I'm getting this error:

Plain Text
pydantic_core._pydantic_core.ValidationError: 3 validation errors for Data102Model
scope_1_emissions
  Field required [type=missing, input_value={}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.6/v/missing
scope_2_emissions_location_based
  Field required [type=missing, input_value={}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.6/v/missing
scope_3_emissions
  Field required [type=missing, input_value={}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.6/v/missing


Does it mean that my declared fields are wrong?


Not sure what's wrong with my pydantic model:


Plain Text
class Data102Model(BaseModel):
    """Data model of scope 1,2 and 3 emissions"""
    scope_1_emissions: str = Field(
        description='scope 1 emissions value. If not found, return "not mentioned"')
    scope_2_emissions_location_based: str = Field(
        description='location based scope 2 emissions value. If not found, return "not mentioned"')
    scope_3_emissions: str = Field(
        description='scope 3 emissions value. If not found, return "not mentioned"')


please, help
4 comments
p
L
Hi! I remember while creating pydantic models for pydantic program, there was a way to explain what each field in a class represent, e.g:

Plain Text
class ClimateChangeTarget(BaseModel):
    """Data model for climate change target"""
    target_reduction_of_emission: str # I want to write what I mean by this field
    base_year: int # I want to write what I mean by this field
    timeline: str # I want to write what I mean by this field
    target_description: str # I want to write what I mean by this field


class Data101Model(BaseModel):
    """Data model for climate change targets"""
    overall_target: ClimateChangeTarget  # I want to write what I mean by this field
    scope_1: ClimateChangeTarget # I want to write what I mean by this field
    scope_2: ClimateChangeTarget # I want to write what I mean by this field
    scope_3: ClimateChangeTarget # I want to write what I mean by this field


How to declare my fields with explanations of each field?
4 comments
L
p
Hi! In your experience, what are the best approaches to improve retrieval?

Now all I do is: chunking using chunk size 500 tokens, embedding to qdrant, then search “my question vs embeddings”.

The questions are predefined btw
2 comments
L
How to turn off stdouts when I call run function in IngestionPipeline?

Plain Text
    pipeline = IngestionPipeline(
        transformations=[
            TokenTextSplitter(chunk_size=1024, chunk_overlap=300),
            OpenAIEmbedding()
        ],
        vector_store=vector_store
    )

    pipeline.run(documents=documents)
4 comments
L
p
Where do I declare top_k argument?

Plain Text
    vector_store = QdrantVectorStore(client=qdrant_vectorstore_client,
                                     collection_name=str(uuid.uuid4()))
    
    index = VectorStoreIndex.from_vector_store(vector_store=vector_store)
    retriever = index.as_retriever()
    nodes = retriever.retrieve(question)
9 comments
L
p
N
#1 Weeb 😄

Might be because of the LLM you are using? Bet you are using an open source one?
17 comments
p
s
Sorry, I'm abit confused about usage of IngestionPipeline along with self-created Documents:

Plain Text
        embed_model = HuggingFaceEmbedding(model_name="WhereIsAI/UAE-Large-V1")
        documents = [Document(text="...", metadata={...}), Document(text=",,,", metadata={...})]

        pipeline=[
            TokenTextSplitter(
                chunk_size=512,
                chunk_overlap=20,
                separator=" "
            ),
            embed_model
        ]

      pipeline.run(documents=documents)


As of my understanding, the pipeline.run must use the embed_model to create embeddings for the documents and autopopulate them?

With the code above, I can see that my embeddings are empty in my qdrant local.

This is from qdrantUI:

Plain Text
{"id_": "04fd0f75-0641-4ff9-96df-da768e99922c", "embedding": null,
9 comments
L
p
How to get an existing index? (without creating it)


Plain Text
service_context = ServiceContext.from_defaults()
vector_store = QdrantVectorStore(client=client, collection_name="paul_graham")
storage_context = StorageContext.from_defaults(vector_store=vector_store)
index = VectorStoreIndex.from_documents(
    documents, storage_context=storage_context, service_context=service_context
)
query_engine = index.as_query_engine()
response = query_engine.query("What did the author do growing up?")


Here, we are using from_documents, which inserts new data. But how do I get an existing index, If I reboot the app for example? I don't want to re-create the index again
6 comments
N
p
How to load a model, that I've already loaded?

Plain Text
service_context = ServiceContext.from_defaults(llm=llm, embed_model="local:WhereIsAI/UAE-Large-V1")


In the above example, I must declare local flag, right?

But If I need just an embedding model, what should I write?

Plain Text
embed_model = HuggingFaceEmbedding(model_name="local:WhereIsAI/UAE-Large-V1")


the above does not work and If I remove local , it will download the model again
8 comments
p
L
Hi! Can you help me to choose a proper class/loader, to ingest pdf file(s) sent from frontend?

Plain Text
from fastapi import File, UploadFile
from typing import List

async def upload_files(pdf_files: List[UploadFile] = File(...)):
  for pdf_file in pdf_files:
      # what loader do I need to use? Do I need to first read the text contents myself and create a list of Documents?
2 comments
p
L
Hi! I could not figure out where do I declare top_k argument in RAG?

Plain Text
query_engine = index.as_query_engine(similarity_top_k=1)
response = query_engine.query("query")


Is this correct?
1 comment
W
How to increase waiting time?

I'm using a local LLM model from ollama + qdrant:

Plain Text
llm = Ollama(model="model")
...
query_engine = index.as_query_engine()
response = query_engine.query("query")


but keep getting:

Plain Text
TimeoutError: timed out
...
httpcore.ReadTimeout: timed out
...
httpx.ReadTimeout: timed out


I confirm that ollama server is running and I can access: http://localhost:11434

I also confirm that I can chat with the model using terminal with ollama run command.

I played around with the raw llm (without qdrant) and it worked, even though sometimes it used to throw the same error.
3 comments
p
L