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`" )
I love bananas
retriever.retrieve(X)
does LlamaIndex propose?retrieve all information about X
, but not sure If it is sufficient.everything
vs everything
in one PDF vs another PDF? And list down all the contradicting information (e.g.: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.
SimpleDirectoryReader
etc.exec()
function to perform pdf parsingnest_asyncio.apply()
. I did it, and now I am getting this: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'>
Document
objects?file_extractor = {".pdf": parser} documents = SimpleDirectoryReader( "./docs/pdfs/all", file_extractor=file_extractor ).load_data()
You are a professional Business Analyst bla bla bla
@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
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?llm.complete(prompt)
OpenAIPydanticProgram
with OpenAI, but is there a way to use it with Groq? 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
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"')
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
run
function in IngestionPipeline
?pipeline = IngestionPipeline( transformations=[ TokenTextSplitter(chunk_size=1024, chunk_overlap=300), OpenAIEmbedding() ], vector_store=vector_store ) pipeline.run(documents=documents)
top_k
argument?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)
IngestionPipeline
along with self-created Documents: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)
pipeline.run
must use the embed_model
to create embeddings for the documents and autopopulate them? {"id_": "04fd0f75-0641-4ff9-96df-da768e99922c", "embedding": null,
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?")
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 againservice_context = ServiceContext.from_defaults(llm=llm, embed_model="local:WhereIsAI/UAE-Large-V1")
local
flag, right?embed_model = HuggingFaceEmbedding(model_name="local:WhereIsAI/UAE-Large-V1")
local
, it will download the model againfrom 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?
top_k
argument in RAG?query_engine = index.as_query_engine(similarity_top_k=1) response = query_engine.query("query")
llm = Ollama(model="model") ... query_engine = index.as_query_engine() response = query_engine.query("query")
TimeoutError: timed out ... httpcore.ReadTimeout: timed out ... httpx.ReadTimeout: timed out
http://localhost:11434
ollama run
command.