← Coursework

Personal Learning Platform with RAG Evaluation

A tutor that answers only from a curated library, shows the sources behind every answer and turns each one into a quiz, built at the end of a semester that first studied how to judge model output and how to tune retrieval.

Course
Applications of NL(X) and LLMs
School
Carnegie Mellon University
Term
Fall 2025
Role
AI Engineer
Stack
  • Python
  • LangChain
  • OpenAI
  • Chroma
  • Hugging Face
  • spaCy
  • Streamlit
  • Milvus
  • Ragas
  • pandas
Code
Investment Learning Portal · localhostlocalgpt-4o-mini26 sources
NavigationFive pages; Home and System Status are not drawnView
Ask & Learn

Ask questions about investing and get detailed answers with sources!

how do ETFs work?

Exchange Traded Funds (ETFs) are a type of investment vehicle that allows investors to pool their money to invest in a diversified portfolio of assets, such as stocks, bonds, or other securities. Here's a breakdown of how ETFs work based on the provided context:

  1. Trading Mechanism: Unlike mutual funds, which sell and redeem shares directly to investors, ETFs are traded on national stock exchanges throughout the day. This means that investors can buy and sell ETF shares at market prices, which may differ from the fund's Net Asset Value (NAV).
  2. Authorized Participants: ETFs work with financial institutions known as Authorized Participants (APs). These APs are typically large broker dealers that can create or redeem shares of the ETF in large blocks called creation units.
  3. Market Pricing: The market price of an ETF can fluctuate throughout the trading day based on supply and demand.
▾ Sources & Citations
Source 1: Mutual Funds and ETFs: A Guide for InvestorsGovernment Resource · U.S. SEC
Source 2: Investor Fees Cheat SheetWeb Guide · Investopedia
Source 3: Active and Passive Investing: Understanding Samuelson's DictumJournal Article · Gârleanu & Pedersen
Source 4: How to Start InvestingWeb Guide · Fidelity Investments
Source 5: Best Online Brokers for BeginnersWeb Guide · Investopedia
A quiz question has been generated and saved to the 'Test Your Knowledge' section!
Try asking:What is Modern Portfolio Theory?How do ETFs work?What is diversification and why is it important?
Ask me anything about investing...
The learning portal, as it runs. Three of its five pages: a question answered with its sources, the quiz page, and what the portal teaches. Pick one in the sidebar.

Problem

Any organisation that wants an assistant to answer from its own documents (a support desk, a policy library, a training programme) meets the same gap: a general language model answers fluently, but not from that material, and it cannot show where an answer came from. Retrieval augmented generation closes the gap by fetching the relevant passages before the model writes, but it adds choices that decide quality: how to split the documents, which encoder, how many passages, which model writes, and how to tell a correct answer from a plausible one. In learning there is one more requirement, because an answer read is not an answer learned, so the learner needs a way to check what stuck. This project builds that system over one semester, in three steps, for someone learning to invest from scratch.

Solution

The first step fixes how output is judged: the same prompts run through three hosted models and every answer is scored on one rubric. The second is a benchmark harness for retrieval: one configuration file drives interchangeable pipelines behind a single interface, a plain one and one that rewrites the question and fetches more when its confidence is low, swept across encoder sizes and retrieval depth and scored by exact match, F1 and a language model acting as judge. The third is the portal: a curated library is cleaned, split on sentence boundaries and encoded once into a local vector index; each question fetches the five closest passages, a hosted model answers from them with the sources shown beside the answer, and a second call writes a multiple choice quiz that is filed for the learner to take later. A fixed set of questions with written answers runs through the same chain to score it.

IngestSetup pipelinebuilds the index oncesmoke tests three questionsthen starts the portalfinance_learning_portal.py · --mode fullCurated corpus26 sources, six kindsPDFs converted to plain texttitle, type, author, relevancedata/documents · corpus-tracker.jsonload, chunk, index26 texts + metadataLoader and chunkercleans text, joins metadatasplits on sentence boundsdrops low quality chunksspaCy splitter · 2000 / 500 charsIndexfiltered chunksSentence encoderruns locally, no per call cost768 dimensions, normalisedsame for chunks and questionssentence-transformers all-mpnet-base-v2768d vectorsVector storechunk vectors, source metadatakept on disk, rebuilt on demandsimilarity search, top 5Chroma · data/vector_storelaunchAnswertop 5 chunksLearning portalfive pages, one processanswers with source cardsquizzes on their own pageStreamlit · streamlit_app.py · 882 linesRetrieval and answer chaintop 5 chunks by similaritypersona prompt asks for sourcesreturns answer, sources, quizLangChain RetrievalQA · stuff · k = 5questionanswer · sources · quizprompt: persona + chunksanswer, then quiz JSONHosted language modelwrites the grounded answerthen a three option quizJSON checked, fallback quizgpt-4o-mini · temp 0.1 · max 1000 tokensQuiz and evaluatesave quiz · attempts40 questions, quiz offQuiz and attempt storeevery quiz, three optionsevery attempt, correct or notaccuracy for the progress tilesquiz_data.json · 5 quizzes, 9 attemptsAnswer evaluator40 questions, written answerslexical scores, no LLM judgerelevance, correctness, lengthevaluation/ragas_evaluator.py
The library is indexed once; each question fetches five passages, a hosted model writes from them, and the answer comes back with its sources and a quiz for later.

Learnings

  • Learning

    A fixed evaluation set before any tuning

    A retrieval system has many settings, and without questions whose answers are known every change is a matter of taste. The benchmark made that concrete: fetching ten passages instead of one lifted F1 from 0.49 to 0.63, while the rewrite gated by confidence changed only about one answer in ten. A frozen question set, scored the same way on every run, is what lets a team change the encoder, the chunking or the model in production and know whether it got better.

  • Learning

    Sources as data, not as prose

    The portal shows its sources from what retrieval returned, each passage carrying the title, type and author recorded for its document, rather than trusting the model to cite. That keeps the library the authority and makes every wrong answer traceable to one of two places: the passages fetched or the text written from them. An answer that cannot be traced to a document cannot be audited or corrected, which is what makes grounded answers usable where accuracy matters.

  • Learning

    Index once, answer per question

    Cleaning, splitting and encoding the library happen once, offline, into an index kept on disk; a question only encodes itself, searches and asks the model to write. The encoder is an open model that runs locally, so rebuilding the index costs nothing, and only the writing step is paid per call. Separating the two paths is what lets the library grow and the writing model change without the other side noticing, with cost that follows questions rather than documents.

← Back to coursework