Skip to content

case study

Ask the portfolio: a retrieval-augmented answering app

My role: I built this in 2026 as a demonstration. It is not client work; the source is public.

Scope and constraints

Ownership
A solo demonstration. Not client work.
Scale
Passages drawn from the case studies.
Constraints
No API key required, a small function bundle for the included free-tier Azure template, and no guessing when the site has no answer.

What was delivered and checked

  • Right page first for 10 of 12 test questions with keyword search and 11 of 12 with vector search, right page in the top three for 12 of 12 with both, and 3 of 3 off-topic questions refused with both. A smoke test, not a benchmark.
  • 14 unit tests, including a model failure and a timeout.
  • Azure template build: a 180 KB static site and an 824 KB function bundle, with the native embedding runtime left out. Not deployed or validated against Azure.

What it is

This is a demonstration of retrieval with refusal: a question box that answers only from the case studies on this site, citing the passages it used. It exists to show retrieval-augmented generation (finding the relevant text first, then answering only from it) on a corpus that can be checked by hand.

Illustration only, with invented sample data: an answer cites the passages it used, and a question the site cannot answer is refused with no sources.

How it works

  1. Case-study pagesSplit by heading into short passages.
  2. Embed locallyAn open model, no API key.
  3. Question arrivesChecked, rate limited, embedded the same way.
  4. Retrieve and checkClosest passages; below the threshold, refuse.
  5. Answer with citationsThe passages themselves, or a model that may use only them.
Retrieval decides whether there is an answer; the model, if any, only phrases it.
Illustration only, with invented scores: a passage is used only if its similarity clears the threshold, and keyword ranking takes over when the embedding model is unavailable.
  • Embeddings run locally

    The passages and the question are embedded (turned into numbers that capture meaning) with an open model in Node, so retrieval works without an API key, costs nothing per question and sends no site content to a third party.

  • It still works when the model cannot load

    If the embedding model is unavailable, search falls back to BM25 keyword ranking with its own threshold. The included Azure template sets this keyword path, because its function bundle leaves out the embedding runtime.

  • It says when it does not know

    If no passage clears the similarity threshold, the answer is a plain "I could not find that on this site" and no sources are shown, instead of a guess.

  • The language model is optional and constrained

    With a key set, the numbered passages go to any OpenAI-compatible chat endpoint, constrained to those passages. A provider error or timeout falls back to search-only.

  • A guarded API route

    The route validates the question and is rate limited.

  • Azure deployment templates included

    The repository includes a Bicep template and a GitHub Actions workflow for Azure Static Web Apps. The workflow runs the tests before deploying, and the build leaves the native embedding runtime out, which keeps the function bundle to 824 KB next to a 180 KB static site, with keyword search. The template and workflow have been written and the build checked, but not deployed or validated against Azure.

What I measured

12 on-topic and 3 off-topic questions against passages from the case studies:

Retrieval results by search type: right page first, right page in the top three, and off-topic questions refused
SearchRight page firstRight page in top 3Off-topic refused
Vector11 of 1212 of 123 of 3
Keyword (BM25)10 of 1212 of 123 of 3

The question set is small. The BM25 stop words and thresholds were tuned against an earlier version of it, and the questions were then rewritten for the current pages without further tuning, so treat these figures as a smoke test, not a benchmark. The two keyword misses and the one vector miss at rank 1 still have the right page in the top three.

Not measured: answer quality from a real language model (no key was used) and latency under load.

Source

The app runs locally; there is no hosted demo. The source and tests are public in the ask-the-portfolio repository on GitHub under the MIT licence. The corpus is built from the pages of this site, and the evaluation is run with npm run eval.

Stack

  • Nuxt 4
  • Vue 3
  • TypeScript
  • Transformers.js
  • Vitest
  • Azure Static Web Apps (template)

More case studies

    Engineering notes: the decisions behind the work