Back to the room

Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works

Code Observatory / Source

Reciprocal rank fusion

Each list contributes 1/(60 + rank). Dense and keyword modes keep their own scores.

PINNED SOURCE Copied from the repository at this commit. Source, not an execution.

PHAROS at 975a38dMIT license

Retriever._fusebackend/app/codeintel/retrieval.py, lines 409–444Open source
    def _fuse(self, mode: str, keyword, dense, terms: list[str], query: str,              hints: list[str] | None = None) -> dict[str, Hit]:        hits: dict[str, Hit] = {}        def hit(cid: str) -> Hit:            if cid not in hits:                hits[cid] = Hit(chunk_id=cid, score=0.0, evidence=Evidence())            return hits[cid]        if mode == "keyword":            for rank, (cid, score) in enumerate(keyword, start=1):                h = hit(cid)                h.score = score                h.evidence.keyword_rank, h.evidence.keyword_score = rank, score            return hits        if mode == "dense":            for rank, (cid, sim) in enumerate(dense, start=1):                h = hit(cid)                h.score = sim                h.evidence.dense_rank, h.evidence.dense_similarity = rank, sim            return hits        for rank, (cid, score) in enumerate(keyword, start=1):            h = hit(cid)            h.score += 1.0 / (RRF_K + rank)            h.evidence.keyword_rank, h.evidence.keyword_score = rank, score        for rank, (cid, sim) in enumerate(dense, start=1):            h = hit(cid)            h.score += 1.0 / (RRF_K + rank)            h.evidence.dense_rank, h.evidence.dense_similarity = rank, sim        # Exact symbol-name match: the query names the symbol directly        # (e.g. "verify_password" or "TokenSigner.verify").        if hits:            self._symbol_boost(hits, terms, query, hints)        return hits

Where this comes from

Commit
975a38d5d17839c26ee219295a5be6ac66b6d910
File
backend/app/codeintel/retrieval.py
Lines
409–444
Git blob
884729a39ae0b3d340ad83f75946677dcddf3791
License
MIT, © 2024–2026 Pharos Contributors. Notice

Read it on GitHub at this commit

Check it yourself

From a clone of the repository, the first command prints the blob above and the second prints these lines.

git rev-parse 975a38d:backend/app/codeintel/retrieval.py
git show 975a38d:backend/app/codeintel/retrieval.py | sed -n '409,444p'