AI Hero Club

Context Engineering · Lesson 5

Marked Complete by You0 / 8

Saved in this browser only. Marking a lesson complete does not mean the project has passed verification.

Lesson Outline 7 subsections
Course Contents 8 lessons
Full course plan.
Context Engineering / Learning Plan ↗

LESSON 05 / 8Suggested study 140 minutes

Retrieval and Fusion: Rank Evidence from Source Documents

When retrievers use different score scales, how can we merge rankings without treating rank values as answer confidence?

3 Questions for This Lesson
  • Calculating Characters and Snippet Words by Item
  • To deduce RRF and its tectonic and confidence boundary
  • Recapitulate the real list of fixed version and filter order
Course Project ZIP ↓

Retrieval Starts by Defining What May Be Read

The pre-chapter gives a definitive version and date view, and this chapter looks for evidence relevant to the problem in this view. Readers simply need to gather, sort and score; the goal is to calculate the results of the two word types by hand, and to distinguish between failure in recall, failure in ranking and failure in selection. We introduced RRF as an external algorithm, but the two word fractions, test information and downstream tube lines are clearly defined in this project. The baseline accomplishment of the original paper does not prove the effect of the mission.

Retrieving input is a list of query strings and candidate records, each with stable id, quite and source fields. Chapter IV allows viewing first, followed by range selection; no rating will be applied to cancel, expired and other scope information. Rank does not read the list of correct answers, and selects a target on the basis of an artificial score. Fields are used only for follow-up controlled generation and evaluation; therefore, searching for the correct content may still fail. Availability does not imply relevance, nor does it mean authenticity, and the source supports a separate examination in chapter VI.

The word search is only literal. The Chinese task of this project does not rely on the external vocabulary, but uses a combination of characters and adjoining two character segments. Character pools ignore numbers and sequences, tolerate minor expressions of deformations, and may also allow completely different words to score high for sharing common words; binary segments retain a partial adjacent order without understanding synonyms, negation and semantics. This is not an embedding search, let alone hiding the capabilities of a large model in an auxiliary program.

First Ranking Method: Set Overlap

Decrees QQ is the non-space character set of the problem, DD The intersection is a cross-section of characters that are common to both sides and that appear at least at one side. The overlap fraction is the intersection size divided by the combination size; the denominator takes at least one to prevent the partition from being zero. The fractions are zero and one: the intersection cannot be larger than the confluence; if the two sets are identical and non-empty, one. The problem is not directly distributed as probabilities with the length of the text, the Chinese repetitions are not validated as “Probability of answers”.

J(Q,D)=∣Q∩D∣max⁡(1,∣Q∪D∣),0≤J≤1J(Q,D)=\frac{|Q\cap D|}{\max(1,|Q\cup D|)},\qquad 0\leq J\leq1
Q, D are a limited set of characters; represents the number of elements, and J is an inspirational similar score.

Worked Example 1: The Benefits and Costs of Losing Order

Problem “活动时间” "The time of the event is Thursday 16:30." 30."Shared with it four words, the text added the denominator; another candidate “时间活动” Although the language is different, it's exactly the same. J For one. The assembly sorting may lead the latter line, even if it does not provide any time value. This reverse reveals the missing mechanism: the high overlap does not prove that an answer can be extracted. The format of a true field statement and the source support check will reject a mismatching of an unvalued value at a later stage and cannot be solved by adding a character score alone.

Another problem is that the key words in “Borrowing premises” may be synonymized in “Camera registration conditions”, with few characters shared and the word-calling missing. The course does not provide the pass rate for such synonyms, nor does it provide a semantic search capability for literal titles. If replaced into vector models, the model should be fixed, the vector is firstised, indexed and tested again; the contract to recall vectors with scope/dismantration of filters still needs to be retained.

Standalone ProgramIndependent standard library reverses: a collection of similarities does not encode word sequence or answer integrity.
def overlap(q,d):
    a={c for c in q if not c.isspace()};b=set(d)
    return len(a&b)/max(1,len(a|b))
assert overlap('活动时间','时间活动')==1
assert overlap('活动时间','活动时间:周四16:30。')<1
print('order is not represented by character sets')

Second Ranking Method: Phrase Fragments and Exact Containment

Set question length to nn, take all adjacent two-character snippets and form a collection GG;codes take segments by the original problem character, and the blank treatment is slightly different from the first one, which is part of the freeze realization. Check each different segment if it appears in the text and the hits are divided by max⁡(1,∣G∣)\max(1,|G|). If the whole question is a text string, add two. This is the inspirational weight of this lesson, not the parameter of learning, nor is there a theoretical best value. Only positive candidates are involved in the second sorting, and there are no binary segments for the word, but precise inclusion still stands to gain points.

Question “活动时间” gets three segments of activity, movement, and time. The text reads: "Activation Time: Thursday 16: 30." Three hits and full; “Place and time of events” hits and time, and is incomplete when it does not move, two thirds. This score retains a small local order, but does not distinguish between “Activity time not yet determined” and the exact time; support and whether it is sufficient to complete the task must be determined by clear rules of follow-up.

L(q,d)=2 1[q is a substring of d]+∑g∈G(q)1[g occurs in d]max⁡(1,∣G(q)∣)L(q,d)=2\,\mathbf{1}[q\text{ is a substring of }d]+\frac{\sum_{g\in G(q)}\mathbf{1}[g\text{ occurs in }d]}{\max(1,|G(q)|)}
1 [Condition] is 1 if not 0 if the condition is established; L is a manual scoring, not specious.

Worked Example 2: Fusion Uses Ranks Rather Than Raw Scores

Two fractions are different in scale, and directly add up to a range. RRF is the ranking on each list. rr Add 1/(k+r)1/(k+r); this item has been fixed from the beginning k=60k=60. A candidate who does not appear on a list contributes zero, instead of adding an unlimited number of points. If A is in the first, third, B is in the second and first. 1/61+1/631/61+1/63 Bed. 1/62+1/611/62+1/61, the B is slightly higher. This comparison is a workable one. The values are not probabilities, and the sum of the values does not have to be one.

To integrate the signals of “I'm going to get ahead of you in a variety of rankings.”, while discarding the original score. The first ranking is 100 times ahead, and integration is not expected to vote at first place. This feature avoids inconsistencies in the quantum schematics and may lose meaningful confidence. Both orders are based on words, errors are not independent, so it cannot be claimed that integration automatically acquires multiple independent knowledges. Parameter 60 follows the known RRF as a fixed option, and the current project does not use the same task report to enhance it without bias after it has been transferred.

s(u)=∑j:u∈Rj160+rj(u)s(u)=\sum_{j:u\in R_j}\frac{1}{60+r_j(u)}
R_j is the first list of positive candidates, r_j(u) starting from 1.
Standalone ProgramIndependently reasoned routes review the order of integration to avoid a rounding of floating points to mask differences.
from fractions import Fraction
a=Fraction(1,61)+Fraction(1,63)
b=Fraction(1,62)+Fraction(1,61)
assert b>a
print(float(a),float(b),float(b-a))

How Real Documents Flow Through Retrieval

Time-current uses the first twelve events. The first four configurations are schedule@2: 3, Schedule@2: 4, location@2: 3, access@1: full; the first contains the right time for the activity and the latter may still be listed because of “Activities” or the overlap of characters. Pack will continue to select the actual incremental word meta-costs and enter the final 958 words in their entirety. This is an example of recall that has found a target but does not prove that the remaining candidates are all useful; the next step could be to study less irrelevant content and the more successful the number of candidates can be considered.

Version filters must be pre-screened before the candidate. The old version is ranked first in length, new in print, and the previous version is left open only; the new version is filtered and sorted first to enter the list. No complex semantic model is required for this counter-case. The actual item untits only generates entries from active data, while historical queries are replayed and filtered, so that the old version can be the correct evidence in a clear historical task, but cannot be revived with high scores in the current one.

Sorts a stable id and the same version and query runs back to the same list. The Quality does not mean that a defined bad searcher can still miss the same answer at a time. So, on the one hand, the test fixes the output order and, on the other hand, arranges an unknown, camera-revoked question, confirming that empty candidates and missing information are not considered to be supported. There is a target fact in the library that is not in the visible package, and the coverage will decline; When a target does not exist at all in the database, coverage is defined as None, which does not give full points to zero denominators.

Complexity scan by limited string: M is a candidate number with an average length of B per quite, with a problem of n characters with a maximum of n−1 segments. Character setup O(MB)O(MB);by substring matching to conservative par excellence O(MnB)O(MnB);sort twice O(Mlog⁡M)O(M \log M). The Python internal string search may be faster, but the course does not depend on its specific optimization certificate. Small information can be scanned directly, and millions of documents require back or vector indexes; replacements should re-audit deactivation and sorting stability.

This chapter delivers the actual list that is automatically calculated from the permitted source text, not the manual target vector. The following chapter will verify the response after the list has entered the window: It is not enough to have a true reference; it must prove that the generator actually sees the whole line.

Boundary Cases: Empty Input, Single Characters, and Repeated Fragments

query must not be empty, but it can be a word. The word question is not binary, the phrase hits and zero, and the denominator is one; if the text contains the word, the full inclusion of the reward can still be positive. Both sorted to the empty list, RRF has no contribution, and pack only builds basic wirre. This is not a network error or a data import failure, but the current terminology rule does not find any evidence of a positive score; the caller must distinguish between them by different bug states.

The snippets are grouped to mean that there will be no more points for repetition. “Ha ha ha!” There are two adjacent positions, both of which correspond to the same. “Ha ha!” Snippets, a collection size. If you use a frequency by location, it is another ratingr. You cannot mix test scores without freezing the declaration. The character set is the same. “Activities”, does not multiply the overlap fractions directly by 100. It may still change the score by adding additional noise to the set, so code behaviour should be reviewed by the actual condensed structure.

Integration results in only candidate priority in this project, and real budget access still depends on chapter II pack recoding. The long text before the title may not be loaded, while the short line after the full line is selected; this does not mean that the search score is taken by “It's wrong.”, but rather a second phase option under capacity constraints. The evaluation should keep a list of ranked and selected, asking if the target has been recalled and whether it has entered the context. Calling both the top-k kill ratio will throw away the most important location information and can easily add parameters to the error during optimization.

TRY IT YOURSELF

Base: range of points

The two non-air pools are the same. What's the J? J=1 Can you prove that the sentence means the same thing?

Hint 1
Jacccard compares the members of the assembly and does not keep any text messages?
Hint 2
Compatibility first, and then construction of the same combination of words and entries with different sentences in order or repetition, to see if semantics can change accordingly.
Compare with the Solution
J=1, because it is identical. But the collection is uninsured and duplicated, and the hours of activity are equal to those of the time, and does not prove semantic or the answer.

TRY IT YOURSELF

Step: RRF Manual

A is on two charts of 1, 3; B2, 1; k=60, who's tall?

Hint 1
First contributing to 1/(k+rank), which is written by AB on two separate paths.
Hint 2
Only the remaining denominators are compared after finding common items; the original score difference does not enter the RRF formula.
Compare with the Solution
Public 1/61 offset, compared to 1/63 and 1/62, the latter being bigger, so B is higher. Integration looks good, not original scores.

TRY IT YOURSELF

Challenge: Filter order

Old version 1 and new version 2 and filtered after Top1. What's the correct change?

Hint 1
Will the old material take up the slot that was given to the new version when the Top1 is cut off and filtered?
Hint 2
Move a valid version/cancellation/date/scope before sorting and run again on the same input, without allowing the answer to be refilled.
Compare with the Solution
The changes need to be repeated on the same candidate and task, without additional answers.

CHECK YOUR UNDERSTANDING

Check Your Understanding

Answer first, then open the explanation to check your reasoning. These questions help reveal gaps in understanding; independent implementation and transfer require separate evaluation.

1. Rank read the list of artificial correct answers?

Show ExplanationFields are used for controlled generation and evaluation and are not used for word rating.
What kind of merger does the 2. RRF use?

Show ExplanationAvoids the difference between the two fractions but loses the original difference.
3. Character collection J=1 proof?

Show ExplanationThe sequence and number of words can still vary.
4. Undo filters where?

Show ExplanationFilter first to avoid invalid entries occupying recall amounts.

Manual completion records your progress; it does not certify your project.