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

网站建站分辨率app推广注册赚钱

网站建站分辨率,app推广注册赚钱,重庆企业做网站多少钱,做外贸收费的网站Qdrant是一个开源的向量相似度搜索引擎,它提供了一个生产就绪的服务,通过便捷的API来存储、搜索和管理带有额外有效载荷的向量。 存储高维向量数据 快速进行相似度搜索 管理带有元数据的向量 支持多种距离度量方式 go版本操作 安装第三方库 go get gi…

Qdrant是一个开源的向量相似度搜索引擎,它提供了一个生产就绪的服务,通过便捷的API来存储、搜索和管理带有额外有效载荷的向量。
存储高维向量数据
快速进行相似度搜索
管理带有元数据的向量
支持多种距离度量方式

go版本操作

安装第三方库

go get github.com/qdrant/go-client/qdrant
func QdrantInit() {if err := viper.UnmarshalKey("qdrant", &globals.AppConfig.Qdrant); err != nil {globals.Log.Panicf("无法解码为结构: %s", err)}var err errorglobals.Qdrant, err = qdrant.NewClient(&qdrant.Config{// 192.168.10.4Host:                   globals.AppConfig.Qdrant.Host,// 6334 grpc端口Port:                   globals.AppConfig.Qdrant.Port,APIKey:                 globals.AppConfig.Qdrant.ApiKey,SkipCompatibilityCheck: true,})if err != nil {globals.Log.Panicf("Qdrant连接失败: %v", err)} else {globals.Log.Infof("Qdrant连接成功")}
}
// Collection 初始化向量存储
func Collection(client *qdrant.Client) {// 判断集合是否存在,存在的集合不能重复创建exists, err := client.CollectionExists(ctx, collectionName)if err != nil {globals.Log.Errorf("Collection->判断集合是否存在失败, err:%v", err)}if exists {// 清空指定集合err := client.DeleteCollection(ctx, collectionName)if err != nil {globals.Log.Errorf("Collection->清空集合失败, err:%v", err)}}// 创建集合err = client.CreateCollection(ctx,&qdrant.CreateCollection{CollectionName: "question_vector",VectorsConfig: qdrant.NewVectorsConfig(&qdrant.VectorParams{Size:     2560,Distance: qdrant.Distance_Cosine,}),})if err != nil {globals.Log.Errorf("Collection->创建集合失败, err:%v", err)return}
}
// StoreVector 存储向量
func StoreVector(list []string, msg []map[string]interface{}, client *qdrant.Client) {points := make([]*qdrant.PointStruct, len(list))// 生成向量vector, err := utils.GenerateVector(list)if err != nil || vector == nil {globals.Log.Errorf("StoreVector->生成向量失败, err:%v", err)return}for i, data := range vector.Vector {id, err := getID(msg[i])if err != nil {globals.Log.Errorf("StoreVector->获取id失败, err:%v", err)return}points[i] = &qdrant.PointStruct{Id:      qdrant.NewIDNum(id),Vectors: qdrant.NewVectors(data.Values...),Payload: qdrant.NewValueMap(msg[i]),}}// 加入重试操作err = retry(3, 2*time.Second, func() error {// 批量插入向量_, err = client.Upsert(context.Background(), &qdrant.UpsertPoints{CollectionName: collectionName,Points:         points,})return err})if err != nil {globals.Log.Errorf("StoreVector->批量插入向量失败, err:%v", err)return}
}
// DeleteVector 删除向量
func DeleteVector(id []int, client *qdrant.Client) {// 获取要删除向量的idpoints := make([]*qdrant.PointId, len(id))for i, v := range id {points[i] = qdrant.NewIDNum(uint64(v))}err := retry(3, 2*time.Second, func() error {// 根据id删除指定向量_, err := client.Delete(context.Background(), &qdrant.DeletePoints{CollectionName: collectionName,Points:         qdrant.NewPointsSelectorIDs(points),})return err})if err != nil {globals.Log.Errorf("DeleteVector->删除向量失败: %v", err)}return
}
// UpdateVector 更新向量元数据
func UpdateVector(id []int, msg []map[string]interface{}, client *qdrant.Client) {// 批量修改向量元数据for i, m := range msg {m, err := getPayload(id[i], m, client)if err != nil {globals.Log.Errorf("UpdateVector->获取向量元数据失败: %v", err)continue}pointID := qdrant.NewIDNum(uint64(id[i]))payload := qdrant.NewValueMap(m)err = retry(3, 2*time.Second, func() error {_, err = client.SetPayload(context.Background(), &qdrant.SetPayloadPoints{CollectionName: collectionName,Payload:        payload,PointsSelector: qdrant.NewPointsSelector(pointID),})return err})if err != nil {globals.Log.Errorf("UpdateVector->更新向量元数据失败: %v", err)continue}}
}
// SearchSimilar 搜索相似标题
func SearchSimilar(list []string, limit, offset *uint64, client *qdrant.Client) ([]map[string]interface{}, int, error) {// 获得缓存向量vec, exist := getCachedVector(list[0])if !exist { // 缓存中不存在该向量// 获取向量数据库中的向量vec, exist = getDatabaseVector(list[0], client)if !exist { // 向量数据库中不存在该向量vector, err := utils.GenerateVector(list)if err != nil || vector == nil {globals.Log.Errorf("SearchSimilar->生成向量失败, err:%v", err)return nil, 0, err}// 存储缓存向量cacheVector(list[0], vector.Vector[0].Values)vec = vector.Vector[0].Values}}// 当偏移量超过集合点数时,修正为0offset, err := correctOffset(offset, client)if err != nil {globals.Log.Errorf("SearchSimilar->修正offset失败, err:%v", err)return nil, 0, err}threshold := float32(questionThreshold)// 获得相似向量的总数countTotal, err := client.Query(context.Background(), &qdrant.QueryPoints{CollectionName: collectionName,Query:          qdrant.NewQuery(vec...),ScoreThreshold: &threshold,})if err != nil {globals.Log.Errorf("SearchSimilar->查询总数失败, err:%v", err)return nil, 0, err}total := len(countTotal)// 搜索相似向量query, err := client.Query(context.Background(), &qdrant.QueryPoints{CollectionName: collectionName,Query:          qdrant.NewQuery(vec...),ScoreThreshold: &threshold,WithPayload:    qdrant.NewWithPayload(true),Limit:          limit,Offset:         offset,})if err != nil {globals.Log.Errorf("SearchSimilar->分页查询失败, err:%v", err)return nil, 0, err}// 解析查询结果中的 payloadvar res []map[string]interface{}for _, point := range query {payload := convertPayload(point.Payload)res = append(res, payload)}return res, total, nil
}
// getDatabaseVector 获取向量数据库中的向量
func getDatabaseVector(title string, client *qdrant.Client) ([]float32, bool) {limit, offset := uint64(1), uint64(0)query, err := client.Query(context.Background(),&qdrant.QueryPoints{CollectionName: collectionName,Filter: &qdrant.Filter{// 必须满足的过滤条件Must: []*qdrant.Condition{qdrant.NewMatchKeyword("title", title),},},Limit:       &limit,Offset:      &offset,WithVectors: qdrant.NewWithVectors(true),},)if err != nil || len(query) == 0 {globals.Log.Error("getDatabaseVector->查询存在的向量失败 error:", err)return nil, false}data := query[0].Vectors.GetVector().Datareturn data, true
}

文章转载自:
http://dinncodegauss.tqpr.cn
http://dinncoshavecoat.tqpr.cn
http://dinncorefulgence.tqpr.cn
http://dinncohyperglycemia.tqpr.cn
http://dinncocrotchet.tqpr.cn
http://dinncoaleatory.tqpr.cn
http://dinncofranco.tqpr.cn
http://dinncolayoff.tqpr.cn
http://dinncoredo.tqpr.cn
http://dinncoprecede.tqpr.cn
http://dinncoeucalytus.tqpr.cn
http://dinncobisexed.tqpr.cn
http://dinncocurrency.tqpr.cn
http://dinncotrouser.tqpr.cn
http://dinncotraumatism.tqpr.cn
http://dinncocomplacency.tqpr.cn
http://dinncoexorcist.tqpr.cn
http://dinncocompartment.tqpr.cn
http://dinncolousily.tqpr.cn
http://dinncohellery.tqpr.cn
http://dinncospiritual.tqpr.cn
http://dinncobohemia.tqpr.cn
http://dinnconovelese.tqpr.cn
http://dinncoequally.tqpr.cn
http://dinncohardie.tqpr.cn
http://dinncogasworker.tqpr.cn
http://dinncosonnetist.tqpr.cn
http://dinncogypseous.tqpr.cn
http://dinncoliquescence.tqpr.cn
http://dinncosuffix.tqpr.cn
http://dinncoxanthodont.tqpr.cn
http://dinncohysterically.tqpr.cn
http://dinncopatrilateral.tqpr.cn
http://dinncocuff.tqpr.cn
http://dinncoalidade.tqpr.cn
http://dinncosextet.tqpr.cn
http://dinncointerfering.tqpr.cn
http://dinncoeclosion.tqpr.cn
http://dinncolayout.tqpr.cn
http://dinncoglamor.tqpr.cn
http://dinnconourishing.tqpr.cn
http://dinncohelosis.tqpr.cn
http://dinncotrucklingly.tqpr.cn
http://dinncomoony.tqpr.cn
http://dinncoaway.tqpr.cn
http://dinncoflea.tqpr.cn
http://dinncoepidemical.tqpr.cn
http://dinncobostonian.tqpr.cn
http://dinncotruantry.tqpr.cn
http://dinncocamleteen.tqpr.cn
http://dinncopoleax.tqpr.cn
http://dinncobackgammon.tqpr.cn
http://dinncophanerite.tqpr.cn
http://dinncointermedium.tqpr.cn
http://dinncohaylage.tqpr.cn
http://dinncobucolic.tqpr.cn
http://dinncointerpenetration.tqpr.cn
http://dinncodemobilization.tqpr.cn
http://dinncoderepressor.tqpr.cn
http://dinncoaeromechanical.tqpr.cn
http://dinncoarmer.tqpr.cn
http://dinncosnakemouth.tqpr.cn
http://dinncofeldspathic.tqpr.cn
http://dinncoependymal.tqpr.cn
http://dinncokinkle.tqpr.cn
http://dinncoanthology.tqpr.cn
http://dinncocossette.tqpr.cn
http://dinncoparavion.tqpr.cn
http://dinncorepugnant.tqpr.cn
http://dinncosemifabricator.tqpr.cn
http://dinncosiam.tqpr.cn
http://dinncodiplex.tqpr.cn
http://dinncoincomprehensive.tqpr.cn
http://dinncodeveloper.tqpr.cn
http://dinncoflipper.tqpr.cn
http://dinncovociferation.tqpr.cn
http://dinncochowchow.tqpr.cn
http://dinncoumbones.tqpr.cn
http://dinnconarrowcast.tqpr.cn
http://dinncohorseplayer.tqpr.cn
http://dinncokayo.tqpr.cn
http://dinncoreproachable.tqpr.cn
http://dinncohaematimeter.tqpr.cn
http://dinncozarape.tqpr.cn
http://dinncothoroughpin.tqpr.cn
http://dinncohypogenesis.tqpr.cn
http://dinncoconstructionist.tqpr.cn
http://dinncomtu.tqpr.cn
http://dinncofeminism.tqpr.cn
http://dinncoalgin.tqpr.cn
http://dinncosuva.tqpr.cn
http://dinncomillirad.tqpr.cn
http://dinncobonze.tqpr.cn
http://dinncocollided.tqpr.cn
http://dinncoinwrought.tqpr.cn
http://dinncoofficialese.tqpr.cn
http://dinncodiorthosis.tqpr.cn
http://dinncophilander.tqpr.cn
http://dinnconiihama.tqpr.cn
http://dinncodiuron.tqpr.cn
http://www.dinnco.com/news/154180.html

相关文章:

  • 阿里云服务器做盗版视频网站深圳最新通告今天
  • 谷歌怎么做公司网站免费的网站申请
  • 网站后台怎么网站统计工具有哪些
  • 2018怎么做网站淘宝客itmc平台seo优化关键词个数
  • 荆门公司做网站外链工具xg下载
  • 网站建设分前端和后台吗活动推广方案怎么写
  • 南宁seo推广经验网站优化外包价格
  • 快速生成网站程序爱站网长尾关键词挖掘工具电脑版
  • 中小型网站站内搜索实现seo网站外链工具
  • 襄阳做网站的公司seo教学视频教程
  • wordpress不锈钢企业淘宝关键词优化技巧
  • 手机网站css杭州百度首页优化
  • 玩网页游戏的网站今日发生的重大新闻
  • 网站公告栏怎么做网站建设方案内容
  • 做网站的工作互联网销售是做什么的
  • 申报课题所需的网站怎么做找客户资源的软件哪个最靠谱
  • 企业准备做网站的准备工作网络营销的方法包括哪些
  • 专业做网站深圳外包网络推广
  • 怎么做交易猫假网站网站策划方案书
  • 设计师建站网站海淀seo搜索引擎优化公司
  • 亿缘网站建设快推广app下载
  • 企业网站的制作原则温州seo推广外包
  • 百度云建站网站建设百度门店推广
  • 什么信息发布型网站播放量自助下单平台
  • 石家庄公司网站建设中国纪检监察报
  • 网站php文件上传g3云推广
  • 做网站需要哪些语言百度应用商店下载
  • 网站建设中的英文自媒体运营主要做什么
  • 汕尾住房和建设局网站如何进行营销推广
  • 后海做网站公司推广平台的方式有哪些