当前位置: 首页 > news >正文

如何网站做镜像b站官方推广

如何网站做镜像,b站官方推广,介绍自己的做的网站吗,做网站需要交印花税一、PGVector 介绍 PGVector 是一个基于 PostgreSQL 的扩展插件,为用户提供了一套强大的向量存储和查询的功能: 精确和近似最近邻搜索单精度(Single-precision)、半精度(Half-precision)、二进制&#xff…

一、PGVector 介绍

        PGVector 是一个基于 PostgreSQL 的扩展插件,为用户提供了一套强大的向量存储和查询的功能:

  • 精确和近似最近邻搜索
  • 单精度(Single-precision)、半精度(Half-precision)、二进制(Binary)和稀疏向量(Sparse Vectors)
  • L2 距离(L2 Distance)、内积(Inner Product)、余弦距离(Cosine Distance)、L1 距离(L1 Distance)、汉明距离(Hamming Distance)和 Jaccard 距离(Jaccard Distance)
  • 支持 ACID 事务、点时间恢复、JOIN 操作,以及 Postgres 所有的其他优秀特性

二、安装 PGVector

2.1 安装 PostgreSQL

        PGVector是基于PostgreSQL的扩展插件,要使用PGVector需要先安装PostgreSQL(支持Postgres 12以上),PostgreSQL具体安装操作可参考:PostgreSQL基本操作。

2.2 安装 PGVector

# 1.下载

git clone --branch v0.7.0 https://github.com/pgvector/pgvector.git

# 2.进入下载目录
cd pgvector

# 3.编译安装
make && make install

2.3 启用 PGVector

        登录PostgreSQL数据库,执行以下命令启用PGVector:

CREATE EXTENSION IF NOT EXISTS vector;

三、PGVector 日常使用

3.1 存储数据

        创建向量字段:

#建表时,创建向量字段

CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3));

#已有表,新增向量字段

ALTER TABLE items ADD COLUMN embedding vector(3);

        插入向量数据:

INSERT INTO items (embedding) VALUES ('[1,2,3]'), ('[4,5,6]');

        更新向量数据:

UPDATE items SET embedding = '[1,2,3]' WHERE id = 1;

        删除向量数据:

DELETE FROM items WHERE id = 1;

3.2 查询数据

距离函数
操作符函数距离类型
<-> l2_distance两个向量相减得到的新向量的长度
<#>vector_negative_inner_product两个向量内积的负值
<=>cosine_distance两个向量夹角的cos值
<+>

Get the nearest neighbors to a vector

SELECT * FROM items ORDER BY embedding <-> '[3,1,2]' LIMIT 5;

Get the nearest neighbors to a row

SELECT * FROM items WHERE id != 1 ORDER BY embedding <-> (SELECT embedding FROM items WHERE id = 1) LIMIT 5;

Get rows within a certain distance

SELECT * FROM items WHERE embedding <-> '[3,1,2]' < 5;

Get the distance

SELECT embedding <-> '[3,1,2]' AS distance FROM items;

For inner product, multiply by -1 (since <#> returns the negative inner product)

SELECT (embedding <#> '[3,1,2]') * -1 AS inner_product FROM items;

For cosine similarity, use 1 - cosine distance

SELECT 1 - (embedding <=> '[3,1,2]') AS cosine_similarity FROM items;

Average vectors

SELECT AVG(embedding) FROM items;

Average groups of vectors

SELECT category_id, AVG(embedding) FROM items GROUP BY category_id;

3.3 HNSW 索引

        HNSW索引创建了一个多层图。在速度-召回权衡方面,它的查询性能优于IVFFlat,但构建时间较慢且占用更多内存。另外,由于没有像IVFFlat那样的训练步骤,可以在表中没有数据的情况下创建索引。

        Supported types are:

  • vector - up to 2,000 dimensions
  • halfvec - up to 4,000 dimensions (added in 0.7.0)
  • bit - up to 64,000 dimensions (added in 0.7.0)
  • sparsevec - up to 1,000 non-zero elements (added in 0.7.0)

        L2 distance

CREATE INDEX ON items USING hnsw (embedding vector_l2_ops);

        Inner product

CREATE INDEX ON items USING hnsw (embedding vector_ip_ops);

        Cosine distance

CREATE INDEX ON items USING hnsw (embedding vector_cosine_ops);

        L1 distance - added in 0.7.0

CREATE INDEX ON items USING hnsw (embedding vector_l1_ops);

        Hamming distance - added in 0.7.0

CREATE INDEX ON items USING hnsw (embedding bit_hamming_ops);

        Jaccard distance - added in 0.7.0

CREATE INDEX ON items USING hnsw (embedding bit_jaccard_ops);

3.4 IVFFlat 索引

        IVFFlat索引将向量划分为列表,然后搜索最接近查询向量的那些列表的子集。它的构建时间比HNSW快,且占用更少内存,但查询性能(就速度-召回权衡而言)较低。

        Supported types are:

  • vector - up to 2,000 dimensions
  • halfvec - up to 4,000 dimensions (added in 0.7.0)
  • bit - up to 64,000 dimensions (added in 0.7.0)

        L2 distance

CREATE INDEX ON items USING ivfflat (embedding vector_l2_ops) WITH (lists = 100);

Inner product

CREATE INDEX ON items USING ivfflat (embedding vector_ip_ops) WITH (lists = 100);

        Cosine distance

CREATE INDEX ON items USING ivfflat (embedding vector_cosine_ops) WITH (lists = 100);

        Hamming distance - added in 0.7.0

CREATE INDEX ON items USING ivfflat (embedding bit_hamming_ops) WITH (lists = 100);

http://www.zhongyajixie.com/news/43926.html

相关文章:

  • 太原网站建设需求多嘛传统营销
  • 企业推广系统海城seo网站排名优化推广
  • 做网站如何与美工配合seo岗位工作内容
  • 党建网站建设实施方案哪个搜索引擎最好
  • 网站建设主机类型怎么选软文推广系统
  • 网站搜索引擎优化方案郑州专业seo首选
  • 哪个网站做新中式热点营销案例
  • 烟台建网站公司价格百度seo搜搜
  • 上海 高端网站建设百度最贵关键词排名
  • 有限责任公司公司章程范本seo接单平台有哪些
  • 网上销售 网站建设培训学校
  • 做网站上传的程序在哪里下载如何自己创造一个网站平台
  • 网站如何做关键字收录建站abc网站
  • 2016年做网站能赚钱吗百度 人工客服
  • 香港公司能在大陆做网站吗中国优化网
  • 网站维护需要用到哪些知识哪里可以买链接网站
  • html 网站开发如何在百度发布文章
  • 中山市网站建设公司直播:韩国vs加纳直播
  • 网站建设开场白经典软文范例大全
  • wordpress日期控件优化百度涨
  • 凡科网站设计微信投放广告多少钱
  • 手把手教你做网站7软文街
  • 国外网站设计模板百度网盘下载速度慢破解方法
  • 如何使用qq空间做推广网站应用市场
  • 文化传播公司做网站宣传好吗网络营销是什么意思?
  • 策划人网深圳网站关键词优化公司
  • 温州网约车哪个平台最好360网站seo手机优化软件
  • 怎么查看网站谁做的seochinaz查询
  • 数据库网站建设新媒体营销策略有哪些
  • 中央广播电视总台山东总站站长之家whois查询