Skip to main content

Introduction

The Hacker News dataset contains 28.74 million postings and their vector embeddings. The embeddings were generated using SentenceTransformers model all-MiniLM-L6-v2. The dimension of each embedding vector is 384. This dataset can be used to walk through the design, sizing and performance aspects for a large scale, real world vector search application built on top of user generated, textual data.

Dataset details

The complete dataset with vector embeddings is made available by ClickHouse as a single Parquet file in a S3 bucket We recommend users first run a sizing exercise to estimate the storage and memory requirements for this dataset by referring to the documentation.

Steps

1

Create table

Create the hackernews table to store the postings & their embeddings and associated attributes:
The id is just an incrementing integer. The additional attributes can be used in predicates to understand vector similarity search combined with post-filtering/pre-filtering as explained in the documentation
2

Load data

To load the dataset from the Parquet file, run the following SQL statement:
Inserting 28.74 million rows into the table will take a few minutes.
3

Build a vector similarity index

Run the following SQL to define and build a vector similarity index on the vector column of the hackernews table:
The parameters and performance considerations for index creation and search are described in the documentation. The statement above uses values of 64 and 512 respectively for the HNSW hyperparameters M and ef_construction. You need to carefully select optimal values for these parameters by evaluating index build time and search results quality corresponding to selected values.Building and saving the index could even take a few minutes/hour for the full 28.74 million dataset, depending on the number of CPU cores available and the storage bandwidth.
4
Once the vector similarity index has been built, vector search queries will automatically use the index:
Query
The first time load of the vector index into memory could take a few seconds/minutes.
5

Generate embeddings for search query

Sentence Transformers provide local, easy to use embedding models for capturing the semantic meaning of sentences and paragraphs.The dataset in this HackerNews dataset contains vector emebeddings generated from the all-MiniLM-L6-v2 model.An example Python script is provided below to demonstrate how to programmatically generate embedding vectors using sentence_transformers1 Python package. The search embedding vector is then passed as an argument to the [cosineDistance()](/reference/functions/regular-functions/distance-functions#cosineDistance) function in the SELECT` query.
An example of running the above Python script and similarity search results are shown below (only 100 characters from each of the top 20 posts are printed):

Summarization demo application

The example above demonstrated semantic search and document retrieval using ClickHouse.A very simple but high potential generative AI example application is presented next.The application performs the following steps:
  1. Accepts a topic as input from the user
  2. Generates an embedding vector for the topic by using the SentenceTransformers with model all-MiniLM-L6-v2
  3. Retrieves highly relevant posts/comments using vector similarity search on the hackernews table
  4. Uses LangChain and OpenAI gpt-3.5-turbo Chat API to summarize the content retrieved in step #3. The posts/comments retrieved in step #3 are passed as context to the Chat API and are the key link in Generative AI.
An example from running the summarization application is first listed below, followed by the code for the summarization application. Running the application requires an OpenAI API key to be set in the environment variable OPENAI_API_KEY. The OpenAI API key can be obtained after registering at https://platform.openai.com.This application demonstrates a Generative AI use-case that is applicable to multiple enterprise domains like : customer sentiment analysis, technical support automation, mining user conversations, legal documents, medical records, meeting transcripts, financial statements, etc
Code for the above application :
Last modified on July 1, 2026