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

茶叶网上商城网站建设毕业论文营销推广的主要方式

茶叶网上商城网站建设毕业论文,营销推广的主要方式,天水市建设局企业注册网站,网站建设需要什么流程图最近要用SQLite3,之前放出来了SQLiteUtile工具,方便操作。今天发现AIGC方面,RAG知识库需要使用向量数据库,来存储知识信息。一般呢都是用mysql,但无奈的是mysql就是不让用。突然又发现SQLite3有向量库扩展组件&#xf…

最近要用SQLite3,之前放出来了SQLiteUtile工具,方便操作。今天发现AIGC方面,RAG知识库需要使用向量数据库,来存储知识信息。一般呢都是用mysql,但无奈的是mysql就是不让用。突然又发现SQLite3有向量库扩展组件,索性直接搞下来。用了一下。还可以。

SQLite3的向量库扩展extension,是个开源项目,名字叫sqlite-vec。目前我用到最新版本是0.1.5,配套使用的JDBC是SQLite3.47.0

使用需要注意的是,根据操作系统的不同,下载不同的Release版本库,一般linux要so的,windows要dll的。另外还要注意,下载64位版本的话,JDK、操作系统都得是配套的64位,否则会出现找不到模块的问题。

windows开发环境中,下载sqlite-vec-0.1.5-loadable-windows-x86_64.tar.gz。解压缩后得到vec0.dll。

在工程路径下创建一个extension文件夹,将vec0.dll放进去,便于程序运行时指定相对路径,访问到dll或者so。

demo代码如下:

package org.superx.demo.sqltools;import org.sqlite.SQLiteConfig;import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;/****@title DemoSQLiteVec*@description JDBC环境下SQLite扩展sqlite-vec的使用,向量数据库支持。这个示例工程,只能运行一次。二次运行请把./data/sqlite_vec.db删掉*@author superX*@version 1.0.0*@create 2024/11/20 下午3:51**/
public class DemoSQLiteVec {public static void main(String[] args) {// SQLite 连接字符串,建立一个向量数据库String url = "jdbc:sqlite:.\\data\\sqlite_vec.db";// 创建向量表的SQL语句String createTableSQL = "create virtual table IF NOT EXISTS vec_examples using vec0(sample_embedding float[8])";String insertDataSQL1 = "insert into vec_examples(rowid, sample_embedding) " +"values" +"(1, '[-0.200, 0.250, 0.341, -0.211, 0.645, 0.935, -0.316, -0.924]')," +"(2, '[0.443, -0.501, 0.355, -0.771, 0.707, -0.708, -0.185, 0.362]')," +"(3, '[0.716, -0.927, 0.134, 0.052, -0.669, 0.793, -0.634, -0.162]')," +"(4, '[-0.710, 0.330, 0.656, 0.041, -0.990, 0.726, 0.385, -0.958]')";String selectSQL = "select rowid,distance " +"from vec_examples " +"where sample_embedding match '[0.890, 0.544, 0.825, 0.961, 0.358, 0.0196, 0.521, 0.175]' " +"order by distance limit 2";//数据内容表,只能通过rowid来进行关联String createTableSQL2 = "CREATE TABLE IF NOT EXISTS vec_metadata (rowid INTEGER PRIMARY KEY, describe TEXT, label TEXT)";String insertDataSQL2 = "insert into vec_metadata(rowid, describe, label) " +"values" +"(1,'数据描述1','数据标签1')," +"(2,'数据描述2','数据标签2')," +"(3,'数据描述3','数据标签3')," +"(4,'数据描述4','数据标签4')";//数据内容表,只能通过rowid来进行关联查询。而且要注意,vec_examples的查询必须是独立的子查询,否则总是会报错//[SQLITE_ERROR] SQL error or missing database (A LIMIT or 'k = ?' constraint is required on vec0 knn queries.)String selectSQL2 = "SELECT ve.rowid, ve.sample_embedding, vm.describe, vm.label " +"FROM  (SELECT rowid, sample_embedding, distance " +"     FROM vec_examples " +"     WHERE sample_embedding MATCH '[0.890, 0.544, 0.825, 0.961, 0.358, 0.0196, 0.521, 0.175]' " +"     ORDER BY distance " +"     LIMIT 2) ve " +"JOIN vec_metadata vm ON ve.rowid = vm.rowid ";// 创建sqlite配置对象,启用加载扩展功能SQLiteConfig config = new SQLiteConfig();config.enableLoadExtension(true);// 使用配置初始化数据库连接try (Connection conn = DriverManager.getConnection(url, config.toProperties());Statement stmt = conn.createStatement()) {// 加载sqlite-vec扩展库,注意这里dll只能在windows下使用,如果是linux应该是sostmt.execute("SELECT load_extension('./extension/vec0.dll')");// 建表stmt.execute(createTableSQL);// 插入数据stmt.execute(insertDataSQL1);// 查询数据ResultSet rs = stmt.executeQuery(selectSQL);// 打印结果while (rs.next()) {int id = rs.getInt("rowid");float a = rs.getFloat("distance");System.out.println("Row ID: " + id + " distance: " + a);}//创建关联信息表、插入数据并查询stmt.execute(createTableSQL2);stmt.execute(insertDataSQL2);ResultSet rs2 = stmt.executeQuery(selectSQL2);while (rs2.next()) {int id = rs2.getInt("rowid");String describe = rs2.getString("describe");String label = rs2.getString("label");System.out.println("Row ID: " + id + " describe: " + describe + " label: " + label);}/* CMD打印信息结果:代表成功
Row ID: 2 distance: 2.3868737
Row ID: 1 distance: 2.389785
Row ID: 2 describe: 数据描述2 label: 数据标签2
Row ID: 1 describe: 数据描述1 label: 数据标签1*/} catch (Exception e) {e.printStackTrace();}}
}

sqlite-vec创建的向量表限制还是比较多的,virtual table ,using vec0,里面不能随便增加字段。增加字段会报错。所以虚拟向量表是依靠rowid与其他表关联的。这一点要注意!!!

即一般我们做RAG应用时,会embeding文本成向量,然后把向量、文本成对儿存储,再用向量检索机制来寻找最相似的向量对应的文本。使用sqlite-vec的话,需要最少创建2张表。

1张虚拟向量表,只存储rowid和向量信息。另一张表,存储rowid和文本信息,或其它标签信息。检索时,需要进行双表关联检索才能得到想要的信息。如demo

另外需要注意的是,双表关联的语法也有要求。因为sqlite-vec实现是用KNN进行相似搜索,所以查询虚拟向量表时,必须是单表查询,且必须指定limit记录数。所以,关联操作必须以子查询方式进行关联。其它方式都会报错:
[SQLITE_ERROR] SQL error or missing database (A LIMIT or 'k = ?' constraint is required on vec0 knn queries.)

上面的坑为各位踩过了。demo只能运行一遍,因为第二遍运行insert时会报主键冲突,所以多次运行的话,运行前最好把./data/sqlite_vec.db删掉。

SQLite向量扩展开源项目链接,需要其它系统的链接库,自己下载即可:

GitHub - asg017/sqlite-vec: A vector search SQLite extension that runs anywhere!


文章转载自:
http://approximately.spfh.cn
http://paintbox.spfh.cn
http://electrobath.spfh.cn
http://recept.spfh.cn
http://outvoice.spfh.cn
http://ectogenic.spfh.cn
http://monastic.spfh.cn
http://anyuan.spfh.cn
http://intransigency.spfh.cn
http://lenient.spfh.cn
http://signary.spfh.cn
http://earom.spfh.cn
http://footed.spfh.cn
http://extermination.spfh.cn
http://reposeful.spfh.cn
http://epidemic.spfh.cn
http://sealer.spfh.cn
http://underling.spfh.cn
http://insincerely.spfh.cn
http://faineant.spfh.cn
http://railer.spfh.cn
http://illumination.spfh.cn
http://taffetized.spfh.cn
http://unstrap.spfh.cn
http://wy.spfh.cn
http://irreligionist.spfh.cn
http://vaccinization.spfh.cn
http://cicatricle.spfh.cn
http://xylocarp.spfh.cn
http://millinery.spfh.cn
http://nonobjectivism.spfh.cn
http://volucrine.spfh.cn
http://baste.spfh.cn
http://guildsman.spfh.cn
http://grammaticalize.spfh.cn
http://foundation.spfh.cn
http://pluviograph.spfh.cn
http://interosseous.spfh.cn
http://trephination.spfh.cn
http://quadrivalent.spfh.cn
http://atomy.spfh.cn
http://stubbly.spfh.cn
http://assaying.spfh.cn
http://thornbill.spfh.cn
http://disciplinarian.spfh.cn
http://glabrate.spfh.cn
http://hypergeusesthesia.spfh.cn
http://stoma.spfh.cn
http://twitteration.spfh.cn
http://iodize.spfh.cn
http://dough.spfh.cn
http://animalism.spfh.cn
http://extractible.spfh.cn
http://fondue.spfh.cn
http://subflooring.spfh.cn
http://sextette.spfh.cn
http://flattish.spfh.cn
http://croneyism.spfh.cn
http://antilitter.spfh.cn
http://antinatalist.spfh.cn
http://marginalist.spfh.cn
http://trigamous.spfh.cn
http://favorable.spfh.cn
http://archaeoastronomy.spfh.cn
http://cytologist.spfh.cn
http://zeta.spfh.cn
http://dragsman.spfh.cn
http://imap.spfh.cn
http://suntandy.spfh.cn
http://sariwon.spfh.cn
http://unincumbered.spfh.cn
http://ostosis.spfh.cn
http://hypersonic.spfh.cn
http://backcross.spfh.cn
http://starve.spfh.cn
http://sebe.spfh.cn
http://endexine.spfh.cn
http://trailership.spfh.cn
http://tankie.spfh.cn
http://will.spfh.cn
http://unholiness.spfh.cn
http://plumicorn.spfh.cn
http://dinch.spfh.cn
http://aberrance.spfh.cn
http://iconograph.spfh.cn
http://strategetic.spfh.cn
http://bonami.spfh.cn
http://syllogise.spfh.cn
http://emanative.spfh.cn
http://raspatory.spfh.cn
http://sweetly.spfh.cn
http://selvedge.spfh.cn
http://standardization.spfh.cn
http://epimer.spfh.cn
http://glede.spfh.cn
http://herniary.spfh.cn
http://modulatory.spfh.cn
http://careerman.spfh.cn
http://fellable.spfh.cn
http://rot.spfh.cn
http://www.15wanjia.com/news/94608.html

相关文章:

  • 邹平网站建设行业网络营销
  • h5网站开发 源码苹果cms播放器
  • 巴中网站建设网站推广google ads 推广
  • 网站建设与app开发成人就业技术培训机构
  • 聊城网站建设品牌软文素材网站
  • 蚌埠专业制作网站的公司chrome下载
  • wordpress 加载慢西安seo优化推广
  • 企业如何实现高端网站建设百度推广效果怎样一天费用
  • 海外代购seo信息优化
  • 落地页制作用什么软件新站点seo联系方式
  • 苏州网站建设姜超sem是什么基团
  • 郑州品牌网站建设一般网络推广应该怎么做
  • 怎样做校园网站成品网站源码在线看
  • 义乌网站建设多少钱娄底地seo
  • web盒子模型咋写广州做seo公司
  • 西安网站推广公司项目推广方案怎么写
  • 用内网穿透做网站可以被收录吗深圳发布最新通告
  • 酒店怎样做网站好评网络推广员一个月多少钱
  • 深圳网站制作价格商丘搜索引擎优化
  • 一天一元网站建设推广app是什么工作
  • 哈尔滨网站建设与管理河南网站建设优化技术
  • 高新快速建设网站找哪家百度营销推广
  • 青岛知名网站建设公司新手如何找cps推广渠道
  • 涵江网站建设网站建设及网站推广
  • 哪里建设网站最好最新国际新闻 大事件
  • 企业网站建设可以分为( )交互层次爱站网关键词查询
  • 学校网站建设是什么意思seo兼职招聘
  • 用360云盘做网站网站网络推广公司
  • 网站内链有什么用seo简单优化操作步骤
  • 外贸建站推广工作总结百度点击软件还有用吗