CNN News RAG Assistant is a simple retrieval-augmented generation (RAG) desktop app built with Tkinter. It indexes cleaned CNN news articles, retrieves the most relevant chunks with FAISS, and asks an Ollama-served LLM to answer user questions with citations to the retrieved context.
- One-click GUI for submitting prompts and displaying answers.
- Automatic FAISS index and chunk metadata creation when missing.
- Shows the top retrieved article chunks used to craft each answer.
- Configurable Ollama model name (defaults to
llama3.2:3b).
gui_app.py: Tkinter interface, initialization, and query handling.rag_data_preparation.py: CSV ingestion, text chunking, embedding, and FAISS index creation.query_engine.py: Vector search, prompt construction, and LLM call via Ollama.requirements.txt: Python dependencies.CNN_Articles_clean.csv: Cleaned CNN articles dataset (required for indexing).articles_index.faiss/chunk_metadata.csv: Generated artifacts storing the vector index and chunk text.
- Python 3.10+
- An Ollama installation with network access to
http://localhost:11434. - The cleaned articles CSV named
CNN_Articles_clean.csvin the project root. If you download it asCNN_Articels_clean.csvfrom Kaggle, rename it accordingly.
-
(Recommended) Create and activate a virtual environment.
-
Install dependencies:
pip install -r requirements.txt
-
Ensure Ollama is running and pull the default model:
ollama pull llama3.2:3b
-
Place
CNN_Articles_clean.csvin the repository root. -
Launch the GUI:
python gui_app.py
-
If
articles_index.faissorchunk_metadata.csvare missing, the app automatically:- Splits articles into ~500-character chunks with 100-character overlap.
- Embeds chunks using the
all-MiniLM-L6-v2SentenceTransformer model (CPU or CUDA when available). - Builds a FAISS L2 index and saves chunk metadata.
-
Enter a prompt in the text box and press Submit (or hit Enter). The app will show the model response followed by the retrieved chunks.
- To change the number of retrieved chunks, adjust the
kargument inanswer_queryinsidequery_engine.py. - To use a different model, pass a
model_nametoanswer_queryor modify the default value. - The Ollama client endpoint can be customized in
query_engine.pyviaClient(host=...).
- If initialization stalls, confirm
CNN_Articles_clean.csvexists and is readable. - Ensure Ollama is running locally and that the requested model is available.
- Large embeddings generation may take several minutes on CPU; a GPU (CUDA) will accelerate the process.