Use with personal context #56

Open
opened 2026-02-15 16:27:46 -05:00 by yindo · 1 comment
Owner

Originally created by @Victordeleusse on GitHub (Mar 20, 2024).

Hello,
Trying to implement a way to question PDFs locally and get answers only based on data from the docs. I have already find a way to embed the data into a vector db (using Chroma) and then retrieve with a "similarity_search" the most relevant data from our query into the doc. I would like now to find a way to give to my model this context to generate answer on it, maybe by using a prompt into the generate call ?

query = "What is the date of the start of the battle ?"
    docs = db.similarity_search(query)
    print(docs[0].page_content)
    
    llm = Ollama(
        model=llm_model_name,
        callbacks=[StreamingStdOutCallbackHandler()],
    )
    my_retriever = db.as_retriever(search_kwargs={"k": 8})
    
    response = ollama.generate(
        "model": llm_model_name,
        
    )``` 
Thank you for your help !
Originally created by @Victordeleusse on GitHub (Mar 20, 2024). Hello, Trying to implement a way to question PDFs locally and get answers only based on data from the docs. I have already find a way to embed the data into a vector db (using Chroma) and then retrieve with a "similarity_search" the most relevant data from our query into the doc. I would like now to find a way to give to my model this context to generate answer on it, maybe by using a prompt into the generate call ? ``` query = "What is the date of the start of the battle ?" docs = db.similarity_search(query) print(docs[0].page_content) llm = Ollama( model=llm_model_name, callbacks=[StreamingStdOutCallbackHandler()], ) my_retriever = db.as_retriever(search_kwargs={"k": 8}) response = ollama.generate( "model": llm_model_name, )``` Thank you for your help !
Author
Owner

@chandansp27 commented on GitHub (Apr 26, 2024):

Refer to this blog, it has a basic code example that can help your issue, feel free to reach out if you need further help.

https://ollama.com/blog/embedding-models

@chandansp27 commented on GitHub (Apr 26, 2024): Refer to this blog, it has a basic code example that can help your issue, feel free to reach out if you need further help. https://ollama.com/blog/embedding-models
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ollama/ollama-python#56