Spaces:
Sleeping
Sleeping
|
Download README.md from cynstl/groundwork: direct link, hf CLI and curl.
- Browser
- Download file 7.19 kB
-
https://huggingface.co/spaces/cynstl/groundwork/resolve/main/README.md
- Command line
-
hf download hf://spaces/cynstl/groundwork/README.md
-
curl -L -o README.md https://huggingface.co/spaces/cynstl/groundwork/resolve/main/README.md
7.19 kB
| title: Groundwork | |
| emoji: π | |
| colorFrom: blue | |
| colorTo: indigo | |
| sdk: gradio | |
| sdk_version: 6.26.0 | |
| app_file: app.py | |
| pinned: false | |
| # Groundwork | |
| **Multi-Document RAG with Citations** β GenAI Course, Topic 183 (Model Making) | |
| Jury 1 Submission | |
| --- | |
| ## What this is | |
| Groundwork answers questions by retrieving relevant passages from a set of | |
| source documents and generating an answer that cites **exactly which passage** | |
| supports each claim β instead of relying on the model's memory. Every claim | |
| in the answer is traceable back to a specific paper and page. | |
| **Live demo:** `https://huggingface.co/spaces/cynstl/groundwork` | |
| --- | |
| ## The problem this solves | |
| Large language models answer confidently even when they don't actually know | |
| something β a well-documented failure mode called hallucination. This is a | |
| real, practical problem anywhere an answer needs to be trustworthy and | |
| checkable: research assistants, legal/policy tools, internal documentation | |
| search. Retrieval-Augmented Generation (RAG) addresses this by forcing the | |
| model to ground its answer in retrieved source text and to show its work via | |
| citations, rather than answering from parametric memory alone. | |
| --- | |
| ## Document corpus | |
| Five real, publicly available research papers on generative AI itself β | |
| chosen so the system can be tested on genuine cross-document synthesis, | |
| including a real scholarly disagreement: | |
| | Paper | Role in the corpus | | |
| |---|---| | |
| | Kaplan et al. 2020 β *Scaling Laws for Neural Language Models* | Position A on compute-optimal scaling | | |
| | Hoffmann et al. 2022 β *Training Compute-Optimal LLMs* (Chinchilla) | Position B β directly conflicts with Kaplan | | |
| | Pearce & Song 2024 β *Reconciling Kaplan and Chinchilla Scaling Laws* | Resolves the Kaplan/Chinchilla disagreement | | |
| | Lewis et al. 2020 β *Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks* | The original RAG paper β this system's own architecture | | |
| | Kalai et al. 2025 β *Why Language Models Hallucinate* | Independent theme: why grounding matters | | |
| The Kaplan/Chinchilla pair gives the system a genuine conflicting-source case | |
| to handle, not a synthetic one. | |
| --- | |
| ## How it works (architecture) | |
| 1. **Ingest** β each PDF is loaded page-by-page and split into ~500-character | |
| chunks, each tagged with its source paper and page number. | |
| 2. **Embed & index** β chunks are embedded with `all-MiniLM-L6-v2` | |
| (sentence-transformers) and stored in a FAISS vector index. | |
| 3. **Retrieve** β for a given question, the top-k most similar chunks are | |
| retrieved via similarity search. | |
| 4. **Generate with citations** β the retrieved chunks are numbered and passed | |
| to the LLM (Groq, Llama 3.3 70B) with an explicit instruction: answer using | |
| *only* these excerpts, and tag every claim with a `[n]` citation. | |
| 5. **Display** β the UI shows the answer plus a citation key underneath, | |
| mapping each `[n]` back to the exact paper, page, and excerpt text. | |
| ``` | |
| PDFs β chunk (w/ source metadata) β embed β FAISS index | |
| β | |
| question βββββββββββββββββββΊ similarity search βββ | |
| β | |
| top-k chunks | |
| β | |
| LLM (answer ONLY from chunks, cite [n]) | |
| β | |
| answer + citation key | |
| ``` | |
| --- | |
| ## Mapping to the rubric | |
| | Criterion | Marks | How this submission addresses it | | |
| |---|---|---| | |
| | **Technical depth & correctness** | 12 | Implements embeddings, similarity-based retrieval, and prompt-constrained generation β concepts spanning both the prompt-engineering and transformer/LLM units of the syllabus | | |
| | **Problem understanding & real-world grounding** | 8 | Addresses a documented, real problem (LLM hallucination / lack of source traceability) using a real, verifiable source corpus | | |
| | **Implementation / demo quality** | 10 | Working, live, interactive demo (Gradio) β not a static notebook. Jury can ask its own questions in real time | | |
| | **Results, evaluation & analysis** | 6 | *Jury 1 scope: qualitative testing on multi-document questions (see below).* Quantitative faithfulness/citation-accuracy metrics are planned for Jury 2 | | |
| | **Presentation & communication** | 6 | This README + live demo walkthrough; architecture explicitly mapped to syllabus concepts above | | |
| | **Individual viva / Q&A** | 5 | Each team member can speak to their part β ingestion/chunking, retrieval, citation-prompting, or UI/deployment | | |
| | **Teamwork & contribution** | 3 | Balanced ownership across ingestion, retrieval logic, prompt design, and deployment | | |
| --- | |
| ## What's tested (Jury 1) | |
| The system was tested on questions that genuinely require combining | |
| information from more than one document, for example: | |
| - *What do Kaplan et al. and the Chinchilla paper disagree about?* | |
| - *How was the Kaplan/Chinchilla disagreement resolved?* | |
| - *Why do language models hallucinate, and how does retrieval help?* | |
| For each, we checked manually: (a) did the retrieved chunks actually contain | |
| the relevant information, and (b) did every citation in the answer correctly | |
| point to a chunk that supports the claim it's attached to. | |
| --- | |
| ## Anticipated jury questions | |
| **"How do you ensure a citation actually supports the answer?"** | |
| Currently: the prompt constrains the model to answer *only* from numbered, | |
| retrieved excerpts, and every claim must carry a `[n]` tag pointing to one of | |
| them β this is enforced structurally, not just requested. For Jury 2, this | |
| will be extended with an automated faithfulness check (e.g. an entailment | |
| check between each cited claim and its source chunk, using the `ragas` | |
| evaluation library) to measure this quantitatively rather than by manual | |
| inspection. | |
| **"How do you handle conflicting sources?"** | |
| The corpus was deliberately built to include a real conflict (Kaplan vs. | |
| Chinchilla scaling laws) plus its resolution paper. Currently the prompt | |
| instructs the model to surface disagreement explicitly rather than silently | |
| picking a side. Explicit, structured conflict-surfacing (e.g. detecting when | |
| retrieved chunks contradict each other and presenting both positions with | |
| separate citations) is planned for Jury 2. | |
| --- | |
| ## What's next (Jury 2 / ESE β not yet built) | |
| This is a Model Making submission, so the same system deepens across all | |
| three juries: | |
| - **Jury 2:** reranking of retrieved chunks, a formal citation-accuracy / | |
| faithfulness evaluation (grounded vs. hallucinated answer rate), explicit | |
| conflicting-source detection and side-by-side presentation | |
| - **ESE:** hallucination guardrails, full evaluation harness (retrieval | |
| precision/recall + citation faithfulness rate), and a limitations analysis | |
| --- | |
| ## Tech stack | |
| Python Β· LangChain Β· FAISS Β· sentence-transformers (`all-MiniLM-L6-v2`) Β· | |
| Groq (Llama 3.3 70B) Β· Gradio Β· Hugging Face Spaces | |
| ## Running locally | |
| See `SETUP.md` for local installation and Hugging Face deployment steps. | |
| ## Team | |
| Add team member names + individual contribution areas here before submission | |
| (maps to the Teamwork & Individual Viva criteria). | |