A retrieval-augmented chat application that combines a locally hosted LLaMA 2 7B (Q4_K_M) model with a Pinecone vector index built from four detailed computer-science study guides (OOP, Computer Architecture, Operating Systems, and SDLC). A lightweight HTML interface lets users converse with “Jarvis” while the backend performs retrieval over Pinecone and produces grounded responses.
- Local inference with
llama-cpp-python(CPU by default; GPU optional). - Retrieval-Augmented Generation via Pinecone + sentence-transformer embeddings.
- FastAPI backend with streaming-ready
/chatendpoint. - Minimal HTML/JS frontend for quick experimentation.
backend/app.py– FastAPI server (embeddings, Pinecone retrieval, LLaMA runner).ingest.py– Creates Pinecone index from the curated study guides.config.py– Paths, model parameters, Pinecone settings.requirements.txt– Python dependencies.
data/– Source.txtknowledge files.frontend/index.html– Static chat UI.llm_model/– Expected location forllama-2-7b-chat.Q4_K_M.gguf(not tracked).
- Python 3.10+
- Pip (newest version recommended)
- Pinecone account (Starter/workspace with available quota)
- Internet access (first run) to download embeddings and reach Pinecone
- LLaMA 2 7B GGUF weights (see below)
The 3 GB llama-2-7b-chat.Q4_K_M.gguf file is not included and should not be committed to GitHub. Instead:
- Download the quantized model (e.g. from TheBloke’s Hugging Face repo).
- Place it at
llm_model/llama-2-7b-chat.Q4_K_M.gguf. - Keep
llm_model/in.gitignoreto avoid uploading large binaries.
If you want to share the project, add a note in the README (or separate docs) describing how to obtain the weights.
cd C:\MYData\Llm_project
python -m venv .venv
.venv\Scripts\activate
pip install --upgrade pip
pip install -r backend\requirements.txtCreate a .env (not tracked) in the project root:
PINECONE_API_KEY=your-api-key
PINECONE_ENVIRONMENT=us-east1-gcp # or the environment shown in the Pinecone console
PINECONE_INDEX_NAME=jarvis-knowledge-index
PINECONE_NAMESPACE=defaultThe ingestion script parses PINECONE_ENVIRONMENT to derive the serverless cloud/region (e.g. us-east1-gcp → cloud=gcp, region=us-east1). Override those defaults by setting PINECONE_ENVIRONMENT accordingly.
cd C:\MYData\Llm_project\backend
python ingest.pyUse python ingest.py --force to recreate the index after updating files in data/.
cd C:\MYData\Llm_project\backend
uvicorn app:app --host 0.0.0.0 --port 8000 --reloadStartup logs should include “Application startup complete” once LLaMA loads and Pinecone connects successfully.
Open frontend/index.html in a browser (e.g. file:///C:/MYData/Llm_project/frontend/index.html). It sends requests to http://localhost:8000/chat.
- Commit the codebase (
backend/,frontend/,data/, README, etc.). - Exclude large artifacts: add
llm_model/and.envto.gitignore. - Document model acquisition so collaborators can reproduce the setup without committing the weights.
Example .gitignore entries:
.venv/
__pycache__/
.env
llm_model/
- Adjust
LLM_MAX_NEW_TOKENS,LLM_TEMPERATURE, orn_gpu_layersinsidebackend/config.py/app.pyto tune responses or enable GPU offload. - Rerun
python ingest.pywhenever you change the.txtfiles indata/. - Keep Pinecone costs in mind; delete unused indexes from the console after testing.
With the .env populated and the model weights downloaded locally, you can ingest, run the server, and interact with Jarvis end-to-end. When sharing the project, push the code and instructions—never the proprietary or large binary weights.