A system that processes user-provided question files and supplementary documents. It extracts questions, answers them using information from the supplementary files when available, and falls back to an LLM for answers when necessary.
-
Create a virtual environment (optional but recommended)
python -m venv llmrag
-
Install all the dependencies
pip install -r requirements.txt
If you want to use Ollama with local models then follow this steps:
-
Download
Ollamafrom here [https://ollama.com/download] -
Run
ollamaafter installing -
In terminal you need to pull the
llamaandnomic-embed-text. Although you can use any of the model available in the ollama repository.ollama run llama3 ollama pull nomic-embed-text
-
Verify your installation
ollama list
-
Now run the python file. For instance, you can use the following command to run the
langchain_ollama_llama3_rag_for_docx.pyscript.python3 langchain_ollama_llama3_rag_for_docx.py
If you want to run the webapp, you can use the following command. Make sure you have the OPENAI_API_KEY set to your .env file
streamlit run QEAG_webapp.pyNote:
-
Before running the script, you must specify the filepath in the
mainfunction. -
If your docx file is large enough, then try to tweak the
chunk_sizeandchunk_overlapparameters accordingly.def split_documents(documents): text_splitter = RecursiveCharacterTextSplitter(chunk_size=2000, chunk_overlap=1000) chunks = text_splitter.split_documents(documents) document = chunks[0] print(document.page_content) print(document.metadata) print(f"Split into {len(chunks)} chunks") return chunks