Skip to content

Commit 66559c3

Browse files
committed
docs: update blog post with terraphim-graph hybrid scoring and comparison data
1 parent 0816beb commit 66559c3

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

content/posts/frontend-developer-agent-walkthrough.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ The front-end developer agent combines three capabilities:
3030

3131
3. **Global Code Search (GrepApp)**: Searches millions of public GitHub repositories for TypeScript code patterns via the grep.app API, filtered to TypeScript for modern front-end relevance.
3232

33-
Results from both haystacks are merged and ranked using BM25Plus, giving you a single sorted list that blends your local context with community examples.
33+
Results from both haystacks are merged and ranked using TerraphimGraph, a hybrid scoring algorithm that combines knowledge graph concept matching with TF-IDF rescoring. In testing, a query for "svelte component" returned 13 results with TerraphimGraph versus 1 result with the simpler BM25Plus scorer. The 18 concept files with 358 synonyms actively influence ranking, not just display.
3434

3535
## The Knowledge Graph
3636

@@ -50,6 +50,19 @@ When you search for `$derived` or `+page.svelte`, the Aho-Corasick automaton mat
5050

5151
If no exact match exists, a TF-IDF fallback kicks in using `trigger::` directives for semantic similarity.
5252

53+
## Hybrid Scoring: Why TerraphimGraph
54+
55+
Terraphim offers multiple relevance functions. For a knowledge-graph-backed agent, `terraphim-graph` is strictly superior to the simpler `bm25plus`:
56+
57+
| Aspect | BM25Plus | TerraphimGraph |
58+
|--------|----------|----------------|
59+
| KG concepts affect ranking | No (display only) | Yes (graph + TF-IDF hybrid) |
60+
| Term co-occurrence | Not used | Boosts related documents |
61+
| KG link insertion | Disabled | Enabled in results |
62+
| TF-IDF rescoring | Not applied | 30% weight boost |
63+
64+
TerraphimGraph uses a two-pass scoring system. Pass 1 builds a co-occurrence graph from Aho-Corasick matches and ranks documents by `total_rank = node_rank + edge_rank + document_rank`. Pass 2 applies TF-IDF rescoring at 30% weight. Documents containing co-occurring concepts (e.g., "svelte" + "component" + "state management") score higher than those matching only one term.
65+
5366
## Svelte and SvelteKit Focus
5467

5568
The knowledge graph is tuned for Svelte/SvelteKit development with TypeScript:
@@ -94,10 +107,13 @@ Query: "flexbox responsive layout"
94107
v
95108
[Ripgrep] [GrepApp (TypeScript)]
96109
| |
97-
+--- merged + ranked (BM25Plus) ---+
98-
|
99-
v
100-
Ranked results
110+
v v
111+
[TerraphimGraph hybrid scoring:
112+
Pass 1: KG graph ranking (node + edge co-occurrence)
113+
Pass 2: TF-IDF rescoring (30% weight boost)]
114+
|
115+
v
116+
Ranked results
101117
```
102118

103119
## Read the Full Walkthrough

0 commit comments

Comments
 (0)