I'm Jonathan and I built Hacker Search (https://hackersearch.net), a semantic search engine for Hacker News. Type a keyword or a description of what you're interested in, and you'll get top links from HN surfaced to you along with brief summaries.
Unlike HN's otherwise very valuable search feature, Hacker Search doesn't require you to get your keywords exactly right. That's achieved by leveraging OpenAI's latest embedding models alongside more traditional indexes extracted from the scraped and cleaned up contents of the links.
I think there are many more interesting things one could build atop the HN dataset in the age of LLMs (e.g. more explicitly searching for technical opinions, recommending stories to you based on your interests, and making the core search feature more useful). If any of those sound interesting to you, head over to https://hackersearch.net/signup to get notified when I launch them!
Note: at least one person has built something similar before (https://news.ycombinator.com/item?id=36391655). Funnily enough, I only found out about this through my own implementation, and I based on my testing, I think Hacker Search generally performs better when doing keyword/sentence searches (vs. whole document similarity lookup), thanks to the way the data is indexed.
Testing it out, I'd say the results for "graph visualization" are focused if a bit incomplete. So to me it has high precision, but lower recall.
I don't see this searching comments. That could be a nice extension. Thanks for sharing.
If you feel up for it, you should share your email in the righthand "Unhappy with your results?" widget. My plan is to manually look into the disappointing searches and follow-up with better results for folks, in addition to fixing whatever can be fixed.
Agreed re: searching comments (which it indeed currently doesn't do).
In the meantime, one thing that comes to mind is that simply embedding the whole contents of the webpages after scraping them didn't yield very good search results. As an example, an article about Python might only mention Python by name once. I found that trimming extraneous strings (e.g. menus, share links), and then extracting key themes + embedding those directly yielded much, much better results.
https://arxiv.org/abs/2212.10496
https://github.com/texttron/hyde
From the abstract:
Given a query, HyDE first zero-shot instructs an instruction-following language model (e.g. InstructGPT) to generate a hypothetical document. The document captures relevance patterns but is unreal and may contain false details. Then, an unsupervised contrastively learned encoder~(e.g. Contriever) encodes the document into an embedding vector. This vector identifies a neighborhood in the corpus embedding space, where similar real documents are retrieved based on vector similarity. This second step ground the generated document to the actual corpus, with the encoder's dense bottleneck filtering out the incorrect details.
Loving your LLM generated summaries! Very nice user experience to see at a glance what a hit is about. Also your back button actually works, haha.
Well done!
Kudos to you!
I will play with it some more.
Unfortunately, though, it didn't find what I was looking for in the following real-word test case: The other day I tried to remember the name of an SaaS to pin/cache/ back up my apt/apk/pip dependencies, which I think I had read about either here[0] or here[1]. After quite a bit of time and some elaborate Google-fu, I did end up finding those HN threads again. However, they did not show up on hackersearch.net for me, neither when entering the service's name nor when I searched for "deterministic Docker builds" or "cache apt apk pip dependencies".
I'm planning to fix that in short order, feel free to sign up at https://hackersearch.net/signup if you care to receive an update when that goes live!
I built mine on top of an RSS feed I generate from Hacker News which filters out any posts linking to the top 1 million domains [1] and creates a readable version of the content. I use it to surface articles on smaller blogs/personal websites—it's become my main content source. It's generated via Github Actions every 4 hours and stored in a detached branch on Github (~2 GB of data from the past 4 years). Here's an example for posts with >= 10 upvotes [2].
It only took several hours to build the semantic search on top. And that included time for me to try out and learn several different vector DBs, embedding models, data pipelines, and UI frameworks! The current state of AI tooling is wonderfully simple.
In the end I landed on (selected in haste optimizing for developer ergonomics, so only a partial endorsement):
- BAAI/bge-small-en as an embedding model
- Python with
- HuggingFaceBgeEmbeddings from langchain_community for creating embeddings
- SentenceSplitter from llama_index for chunking documents
- ChromaDB as a vector DB + chroma-ops to prune the DB
- sqlite3 for metadata
- FastAPI, Pydantic, Jinja2, Tailwind for API and server-rendered webpages
- jsdom and mozilla-readability for article extraction
I generated the index locally on my M2 Mac which ripped through the ~70k articles in ~12 hours to generate all the embeddings.I run the search site with Podman on a VM from Hetzner—along with other projects—for ~$8 / month. All requests are handled on CPU w/o calls to external AI providers. Query times are <200 ms, which includes embedding generation → vector DB lookup → metadata retrieval → page rendering. The server source code is here [3].
Nice work @jnnnthnn! What you built is fast, the rankings were solid, and the summaries are convenient.
[1] https://majestic.com/reports/majestic-million
[2] https://github.com/awendland/hacker-news-small-sites/blob/ge...
[3] https://github.com/awendland/hacker-news-small-sites-website...
Clearly many of us see the need here. I have also been working on a similar demo: https://search-hackernews.vercel.app/ 1. Stack: Vectara for RAG, Vercel for hosting 2. Results show the main story and top 3-4 comments from the story 3. Focused mostly on the search aspect - so if you click it redirects you to the HN page itself. No summaries although it'd be easy to add.
Would love to get some feedback and any suggestions for improvement. I'm still working on this as a side project.
Example query to try: "What did Nvidia announce in GTC 2024?" (regular HN search returns empty)
Here's a question for this crowd: Do we see domain/personalized RAG as the future of search? In other words, instead of Google, you go to your own personal LLM, which has indexed all of the content you care about (whether it's everything from HN, or an extra informative blog post, or ...)? I personally think this would be great. I would still use Google for general-purpose search, but a lot of my search needs are trying to remember that really interesting article someone posted to HN a year ago that is germane to what I'm doing now.
Quality aside, I think the primary challenge is in figuring out the right UX for delivering that at scale. One of the really great advantages of Google is that it is right there in your URL bar, and that for many of the searches you might do, it works just fine. Figuring out when it doesn't and how to provide better result then seems like a big unsolved UX component of figuring out personalized search.
One big distinction with the "site:https://news.ycombinator.com" hack is that the search on Hacker Search directly runs against the underlying link's contents, rather than whatever happens to be on HN. We also more directly leverage HN's curation by factoring in scores.
Appreciate your suggestions; will look into building those!
My only piece of advice, though: try to do the reranking using some other rerankers instead of an LLM -- you'll save both on the latency AND the cost.
Other than that, good job.
> recommending stories to you based on your interests
I built this as a service that monitors and classifies HN stories based on your interests (solved my FOMO): https://www.kadoa.com/hacksnack
> e.g. more explicitly searching for technical opinions...
Yes, please! I would love to be able to search for strongly held opinions by folks who _know_ what they are talking about.
> recommending stories to you based on your interests...
I am curious how, in principle, you would you do that? Where do you think the signal that indicates my "interest" lies?
To learn your interests we'd at a minimum need to know what HN stories you tend to click or comment on, e.g. by a different reader view or using a browser extension. Presumably your comments and submissions could provide useful signal as well :)
Apparently the old Algolia search has not been accessible around the world for a few months at least.
I actually generate two summaries: one is part of the ingestion pipeline and used for indexing and embedding, and another is generated on-the-fly based on user queries (the goal there is to "reconcile" the user query with each individual item being suggested).
I use GPT-3.5 Turbo, which works well enough for that purpose. Cost of generating the original summaries from raw page contents came down to about $0.01 per item. That could add up quickly, but I was lucky enough to have some OpenAI credits laying around so I didn't have to think much about this or explore alternative options.
GPT-4 would produce nicer summaries for the user-facing portion, but the latency and costs are too high for production. With GPT-3.5 however those are super cheap since they require very few tokens (they operate off of the original summaries mentioned above).
Worth noting that I've processed stories by score descending, and didn't process anything under 50 points which substantially reduced the number of tokens to process.
https://hn.algolia.com/?q=postgres+clustering
only one is semanthically correct, the other pick up the wrong version of clustering (i.e. k-means instead of multi master writes)
but yeah if one doesn't test the hard cases, how does one know it preserves semantics :D
https://hackersearch.net/search?q=Solutions+for+PostgreSQL+c...
and results are much better:
1. An overview of distributed Postgres architectures 2. A Technical Dive into PostgreSQL's replication mechanisms 3. Ways to capture changes in Postgres
hyde paper is here https://arxiv.org/abs/2212.10496
it's possible that openai embedding are simmetrical, if that the case you need to hallucinate some content and use that as base for the embedding distance calculation. or you can move to asymmetric embedding, or you can try prompting their embedding
edit: prompting embedding seems to work, tried searching for “write an article about: solutions for postgres clustering” and results are much better https://hackersearch.net/search?q=write+an+article+about%3A+...
you can try prepending "write an article about: " to all user searches :D
I definitely want to re-explore that though; I think it should be possible to do so a lot more rigorously now that I have a better sense for what people want to search for.
Agreed it could be faster for uncached queries. The embeddings retrieval itself is actually pretty fast (uses pgvector). However, I found that having a LLM rerank results + generate summaries related to the search query made results more useful, which is what accounts for much of the latency.
Maybe I should make that a user-customizable setting!
If you'd like free hosting, feel free to reach out. I'm one of the founders at postgresml.org.
What about using the embeddings for nearest-neighbor search for similar articles? I.E., for any given article, can you use the embeddings of an article to run a search, rather than encoding my query? That would let me find similar / related articles much more easily.
Yup, totally feasible. I might add that!
Turns out the page was ending up in bfcache (https://web.dev/articles/bfcache), which in turn led to the button's loading state being preserved when clicking back. Listening to the `pageshow` event enables one to handle that somewhat gracefully.
- Next.js
- OpenAI's embeddings and GPT endpoints
- Postgres with pgvector (on neon.tech)
- Tailwind
- tRPC
- Vercel for web hosting
- Google Cloud products for data pipelines (GCS, Cloud Tasks)
Keyword searches on the Algolia engine will generally result in better recall -- at least when identifying the right keyword is easy, e.g. the name of a company. They likely will require more sifting through results & keyword "engineering" however.
In my mind the two approaches are complementary. I suppose there's an argument for working more directly towards blending them :)
Trying the examples now, semantic search usually works better. But if I trim extra phrasing (e.g. how do diffusion models work -> diffusion models) they're about the same (but Algolia is much faster).
What was the biggest thing you learned while implementing this? Was anything surprisingly difficult? Was there anything that worked better than you expected?
> What was the biggest thing you learned while implementing this?
How much the quality of the data and resulting indexes matter. My impression based on this experience is that "RAG" might be a cohesive set of techniques, but their application to various domains likely is very domain-specific.
> Was anything surprisingly difficult?
Evaluating results is very tedious, almost by definition: you need to figure out ground truth by some mechanism and build evaluation datasets from there. To be honest, a lot of this beta was built on "vibes" only.
> Was there anything that worked better than you expected?
In terms of whether something worked better than I expected: modern embeddings are really magical. I'd previously worked with TF/IDF (a decade-or-so ago) and Doc2Vec (6-7 years ago), and while those were surprisingly useful, they really pale compared to what LLM embeddings can encode in very dense representations.
search 'ssh'.. select comments not stories.. omg the thing I am looking for is only a few days ago but I can't get through all the ones from the one story.. page to page.. meh..
anyways I love the privacy terms statement page, I almost used it to check something.