Skip to content

Add: bm25 (Go) — FastEmbed Qdrant/bm25 sparse encoder#2

Merged
Goodnight77 merged 3 commits into
Goodnight77:mainfrom
harsh04:add-bm25-go
Jun 28, 2026
Merged

Add: bm25 (Go) — FastEmbed Qdrant/bm25 sparse encoder#2
Goodnight77 merged 3 commits into
Goodnight77:mainfrom
harsh04:add-bm25-go

Conversation

@harsh04

@harsh04 harsh04 commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Adds bm25 (Go) to the Integrations table.

A byte-for-byte Go port of FastEmbed's Qdrant/bm25 sparse encoder, so Go services can build BM25 sparse vectors that match a FastEmbed-indexed Qdrant corpus — the sparse half of hybrid search. Term-frequencies only (Qdrant applies IDF server-side via the sparse modifier). 16 languages verified against FastEmbed, MIT licensed.

Placed next to the existing FastEmbed row as the Go/sparse counterpart.

@Goodnight77

Copy link
Copy Markdown
Owner

Hey @harsh04 thnx for your contribution, the Go bm25 port is clearly useful work and a clean writeup
one thing though: this repo is meant to host projects and demos themselves not act as a link directory to external repos. the integration table point to tutos/demos inside this repo so your added line doesn't fit the pattern
would you be up for contributing it as an actual demo here instead ? just want the value to live here rather than the table being a pointer elsewhere

… link

Per review: add a runnable Go hybrid-search demo under bm25-go-hybrid/ and point
the Integrations row at it, matching the repo's in-repo-demo pattern.
@harsh04

harsh04 commented Jun 27, 2026

Copy link
Copy Markdown
Contributor Author

Totally fair — thanks for the quick, clear review.

Reworked it into an actual in-repo demo: bm25-go-hybrid/ is a runnable Go program doing dense + sparse (BM25) hybrid search against Qdrant — BM25 sparse vectors from a FastEmbed-compatible Go encoder, dense + sparse arms fused with RRF — plus a README and sample data. The Integrations row now points at the demo instead of the external repo, so it follows the in-repo pattern.

It's the first Go demo in the list, so happy to adjust the folder placement, naming, or format to match whatever convention you'd prefer.

@Goodnight77
Goodnight77 self-requested a review June 27, 2026 22:08
@Goodnight77

Copy link
Copy Markdown
Owner

@harsh04 Thnx, this is the in-repo demo i wanted, left a few inline comments related to dense model, expected output and match folder name. Sort those and will merge it
thnx again for your contribution

Comment thread bm25-go-hybrid/main.go Outdated

// denseEmbed is a stand-in. Replace with a real embedding model and keep the
// dimension/distance consistent with the collection below.
func denseEmbed(text string) []float32 {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes the dense vectors somehow random, hashing bytes into buckets isn't semantic. so the dense arm doesn't actually contribute and the ranking is BM25 only , maybe Gemini-embeddings/ example would give a u a real dense model or choose whatever you want for this

Comment thread bm25-go-hybrid/README.md
The dense embedder here is a tiny stand-in — swap `denseEmbed` for a real model
(Gemini, OpenAI, etc.) and bump `denseDim`.

## Run

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add the expected output here? (printed hits) so readers see what success looks like

Comment thread bm25-go-hybrid/main.go Outdated
log.Fatal(err)
}

for _, query := range []string{"when can I check in", "is there wifi"} {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these queries share words with the docs, so bm25 alone finds them. maybe add one with different words but same meaning so the dense side actually matters (after fixing the dense model)

Comment thread README.md Outdated
| --- | --- | --- | --- |
| ✅ | **Chonkie** | Advanced text chunking with Qdrant handshake | [Tutorial](chonkie/Chonkie_Qdrant_Handshake.ipynb) |
| 🚧 | **FastEmbed** | Fast, lightweight embedding library | Coming Soon |
| ✅ | **bm25 (Go)** | Dense + sparse (BM25) hybrid search in Go, using a FastEmbed-compatible sparse encoder | [Demo](bm25-go-hybrid/) |

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

folder name is bm25-go-hybrid but here is bm25 (Go), can you match them

…utput, folder-name match

- Replace the FNV stand-in with real Gemini embeddings (gemini-embedding-001,
  1536-dim, L2-normalized), so the dense arm actually contributes
- Add queries that share no words with their target docs, so the dense arm is
  demonstrably doing the work (not BM25 alone)
- Document GEMINI_API_KEY setup and add real expected output to the demo README
- Rename the integration table row to match the folder (bm25-go-hybrid)
@harsh04

harsh04 commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the detailed review — all four sorted:

  1. Dense model — replaced the FNV stand-in with real Gemini embeddings (gemini-embedding-001, 1536-dim, L2-normalized). The dense arm now actually contributes.
  2. Queries — added two that share no words with the doc they should match (what time should I arrive → check-in, somewhere to eat early → breakfast), so the dense side is demonstrably doing the work, not BM25 alone.
  3. Expected output — added to the demo README, with a note on why the semantic queries land on the right doc.
  4. Folder name — table row renamed to bm25-go-hybrid to match the folder.

Verified end-to-end against a live Qdrant. Ready for another look whenever you have a sec 🙏

@Goodnight77

Copy link
Copy Markdown
Owner

all four confirmed. run it myself, the outputs matches the readme. Great work!
LGTM! merging

@Goodnight77
Goodnight77 merged commit 44a22e0 into Goodnight77:main Jun 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants