pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
[pgvector/pgvector] issue #848: What's the current status of random_vector()? + Proposal for enhancement
3+ messages / 2 participants
[nested] [flat]

* [pgvector/pgvector] issue #848: What's the current status of random_vector()? + Proposal for enhancement
@ 2025-05-27 00:42  "JoongHyuk-Shin (@JoongHyuk-Shin)" <noreply+JoongHyuk-Shin@github.com>
  0 siblings, 0 replies; 3+ messages in thread

From: JoongHyuk-Shin (@JoongHyuk-Shin) @ 2025-05-27 00:42 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Hi 👋

I noticed that a `random_vector(dim int)` function was added in the `random_vector` branch [here](https://github.com/pgvector/pgvector/commit/f7a0abe6ad7caae4156c88b01c969e9a14f77415) 
The function seems quite useful for generating vectors in benchmarking or development setups.

I’m curious- is there a specific reason it hasn’t been merged into `master` yet?

Is it waiting for:
- Additional design decisions?
- Broader use cases?
- Testing/stability guarantees across versions?

I’d be happy to suggest a few extensions (e.g. `dist = 'normal'`, `normalize = true`) that could make this function even more broadly applicable for simulating real-world embedding behavior inside the database:
```
random_vector(dim int,
              dist text default 'uniform',
              normalize bool default false)
```           
If possible, I’d also love to contribute to the implementation. Please let me know if there are any planned features or design directions for the random_vector function that I should align with.

Thanks for all the great work on pgvector!

^ permalink  raw  [nested|flat] 3+ messages in thread

* Re: [pgvector/pgvector] issue #848: What's the current status of random_vector()? + Proposal for enhancement
@ 2025-05-27 18:23  "ankane (@ankane)" <noreply+ankane@github.com>
  1 sibling, 0 replies; 3+ messages in thread

From: ankane (@ankane) @ 2025-05-27 18:23 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Hi @Joshua-Shin, there aren't any current plans to merge this (as I don't think it's useful for most users, and users who need it can create it with SQL).

```sql
CREATE FUNCTION random_vector(dim integer) RETURNS vector
    AS $$ SELECT array_agg(random())::vector FROM generate_series(1, dim) i $$
    LANGUAGE SQL;

-- Postgres 16+
CREATE FUNCTION random_normal_vector(dim integer) RETURNS vector
    AS $$ SELECT array_agg(random_normal())::vector FROM generate_series(1, dim) i $$
    LANGUAGE SQL;
```

```sql
SELECT random_vector(3);
SELECT random_normal_vector(3);
SELECT l2_normalize(random_vector(3));
```

^ permalink  raw  [nested|flat] 3+ messages in thread

* Re: [pgvector/pgvector] issue #848: What's the current status of random_vector()? + Proposal for enhancement
@ 2025-05-27 18:23  "ankane (@ankane)" <noreply+ankane@github.com>
  1 sibling, 0 replies; 3+ messages in thread

From: ankane (@ankane) @ 2025-05-27 18:23 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@ankane closed this.

^ permalink  raw  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2025-05-27 18:23 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-05-27 00:42 [pgvector/pgvector] issue #848: What's the current status of random_vector()? + Proposal for enhancement "JoongHyuk-Shin (@JoongHyuk-Shin)" <noreply+JoongHyuk-Shin@github.com>
2025-05-27 18:23 ` "ankane (@ankane)" <noreply+ankane@github.com>
2025-05-27 18:23 ` "ankane (@ankane)" <noreply+ankane@github.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox