AI320 — Original on-site preparation
Independent written study. All essential explanations and optional model reasoning for this chapter are on this page. References are optional further study. No degree, professional approval or observed competence is conferred.
Calculate the retriever before interpreting its result
The retained project implements a small term-frequency/inverse-document-frequency cosine baseline. Its tokenizer lowercases text and extracts sequences matching [a-z0-9]+. This particular choice splits punctuation and does not supply stemming, multilingual tokenization or learned semantic representations. A query containing only tokens absent from the eligible vocabulary becomes a zero vector. The implementation then assigns zero similarity and returns no positively scored result, rather than dividing by zero. A useful semantic model might recognize a synonym this tokenizer misses, but that possibility requires a measured comparison.
First select eligible documents using the caller and policy snapshot. For N eligible documents, let df(t) be the number containing term t at least once. The project uses natural-log smoothed weight idf(t)=ln((1+N)/(1+df(t)))+1. A document's coordinate is its raw token count times this weight; the query uses the same fitted weights and vocabulary. Repeating a term changes its count, but not the document-frequency count by more than one. Cosine similarity divides the dot product by the two Euclidean lengths. It compares direction under this representation, not truth, authority or a probability of answer correctness.
Consider three fictional eligible chunks with stable IDs: A has text refund receipt, B has refund refund custom, and C has custom excluded. Use coordinate order [refund,custom,receipt,excluded]. Both refund and custom occur in two documents, so their weight is a=ln(4/3)+1≈1.287682. Receipt and excluded each occur in one document, giving b=ln(2)+1≈1.693147. The vectors are A=[a,0,b,0], B=[2a,a,0,0] and C=[0,a,0,b]. For query refund custom, q=[a,a,0,0] and its length is √2·a.
The three dot products are a², 3a² and a². A and C each have length √(a²+b²); B has length √5·a. Consequently B's score is 3/√10≈.948683, while A and C each score a/(√2·√(a²+b²))≈.428046. The implementation sorts decreasing scores and then ascending string IDs, so it returns B,A,C. The tie-break makes this fixture reproducible; it gives A no greater substantive authority than C. B ranks highly because its terms align with the query. Its three words do not establish any refund policy.
Now suppose A is the general rule's required receipt passage and C is an applicable custom-order exception. Answering a custom-order eligibility question requires both, even though B ranks first. Top-one keyword or cosine relevance does not establish complete evidence. A chunker that separates rule and exception must retain document/section relationships or use an explicitly tested neighbor-expansion strategy. Expanding neighbors must still recheck authorization and version: proximity is not permission. Large chunks can preserve qualifications while admitting irrelevant text and consuming context; small chunks can lose conditions. Compare these settings on questions with known complete support sets rather than selecting chunk size from aesthetics.
For a question whose gold support set is {A,C}, returning {A} has passage recall 1/2 and precision 1/1 under that declared labeling, but complete-support success is zero. Returning {A,B,C} has recall 1, precision 2/3 and complete-support success one. These are retrieval labels, not an assessment of whether generation used the passages faithfully. Record unsupported citations, wrong versions and unauthorized context separately. A fluent answer produced after incomplete retrieval can be a lucky unsupported answer and should not receive grounded-success credit.
Optional changed eligible corpus: complete reasoning
Remove B because the caller lacks permission. Refit on A and C only: N=2 and every remaining term occurs in one document, so every weight is c=ln(3/2)+1. The query is [c,c,0,0], while each document has two nonzero coordinates of weight c. Each score is c²/(√2c·√2c)=1/2, so A precedes C only by stable ID. Filtering B after ranking under the three-document IDF state would not reproduce this declared algorithm. More seriously, a shared vocabulary or ranking cache fitted using a restricted corpus can expose information about that corpus; specify the scope and ownership of fitted retrieval state. If the query becomes unicorn, no coordinate remains and both scores are zero: return the explicit no-evidence state, not an arbitrary first document. If top-two A,C are supplied, assess their conditions before composing an answer; two references alone are not entailment.
Optional criteria, one point each: calculate counts and smoothed weights; reconcile dot products, norms and ranking; recompute after eligibility changes and handle zero vectors; distinguish passage recall, complete evidence and supported answering. Explain all four for four points.
Optional source references
These sources support the explanations; reading them is optional. Original Academy examples are fictional. Historical attributed readings remain preserved.