文本嵌入



1. 测试数据与代码

1.1 测试代码

import json
import random
from datetime import datetime, timedelta

# 基础数据配置
base_id = 200001
user_id = "coderpwh"
start_time = datetime(2025, 2, 1, 15, 10, 0)

# 可选项配置
activities = [
    ("打篮球", "打篮球非常好,运动增加免疫力"),
    ("跑步", "跑步有助于提高心肺功能,保持健康"),
    ("游泳", "游泳对关节友好,适合全身锻炼"),
    ("踢足球", "踢足球增强团队协作能力"),
    ("打羽毛球", "打羽毛球提高反应速度和灵活性"),
    ("骑自行车", "骑自行车有助于提升腿部肌肉力量"),
    ("做瑜伽", "做瑜伽帮助放松身心,改善柔韧性"),
    ("爬山", "爬山能锻炼耐力,享受自然风光"),
    ("跳绳", "跳绳是高效的有氧运动,燃烧卡路里"),
    ("打网球", "打网球锻炼全身协调性和爆发力")
]

places = ["深圳湾", "公园", "体育馆", "社区运动场", "学校操场",
          "河边", "健身房", "运动中心", "小区花园", "海滨长廊"]

time_phrases = ["昨天下午", "今天早上", "上周六晚上", "前天中午",
                "今天傍晚", "上周日清晨", "昨晚", "今天中午",
                "今天下午", "上周五傍晚"]

# 生成测试数据
test_data = []
for i in range(100):
    # 随机选择要素
    time_phrase = random.choice(time_phrases)
    place = random.choice(places)
    activity, prompt = random.choice(activities)

    # 构建内容
    user_content = f"我{time_phrase}去{place}{activity}了"
    current_time = start_time + timedelta(minutes=10 * i)

    # 构建完整记录
    record = {
        "id": str(base_id + i),
        "content": user_content,
        "map": {
            "id": str(base_id + i),
            "user_id": user_id,
            "user_content": user_content,
            "prompt_content": prompt,
            "create_time": current_time.strftime("%Y-%m-%d %H:%M:%S")
        }
    }
    test_data.append(record)

# 转换为JSON格式
json_data = json.dumps(test_data, ensure_ascii=False, indent=2)

# 打印结果(实际使用时可以写入文件)
print(json_data)

1.2 测试数据(100条)

[
  {
    "id": "200001",
    "content": "我今天早上去学校操场打羽毛球了",
    "map": {
      "id": "200001",
      "user_id": "coderpwh",
      "user_content": "我今天早上去学校操场打羽毛球了",
      "prompt_content": "打羽毛球提高反应速度和灵活性",
      "create_time": "2025-02-01 15:10:00"
    }
  },
  {
    "id": "200002",
    "content": "我今天下午去公园跑步了",
    "map": {
      "id": "200002",
      "user_id": "coderpwh",
      "user_content": "我今天下午去公园跑步了",
      "prompt_content": "跑步有助于提高心肺功能,保持健康",
      "create_time": "2025-02-01 15:20:00"
    }
  },
  {
    "id": "200003",
    "content": "我今天傍晚去深圳湾打羽毛球了",
    "map": {
      "id": "200003",
      "user_id": "coderpwh",
      "user_content": "我今天傍晚去深圳湾打羽毛球了",
      "prompt_content": "打羽毛球提高反应速度和灵活性",
      "create_time": "2025-02-01 15:30:00"
    }
  },
  {
    "id": "200004",
    "content": "我上周六晚上去体育馆打网球了",
    "map": {
      "id": "200004",
      "user_id": "coderpwh",
      "user_content": "我上周六晚上去体育馆打网球了",
      "prompt_content": "打网球锻炼全身协调性和爆发力",
      "create_time": "2025-02-01 15:40:00"
    }
  },
  {
    "id": "200005",
    "content": "我前天中午去公园踢足球了",
    "map": {
      "id": "200005",
      "user_id": "coderpwh",
      "user_content": "我前天中午去公园踢足球了",
      "prompt_content": "踢足球增强团队协作能力",
      "create_time": "2025-02-01 15:50:00"
    }
  },
  {
    "id": "200006",
    "content": "我上周六晚上去河边骑自行车了",
    "map": {
      "id": "200006",
      "user_id": "coderpwh",
      "user_content": "我上周六晚上去河边骑自行车了",
      "prompt_content": "骑自行车有助于提升腿部肌肉力量",
      "create_time": "2025-02-01 16:00:00"
    }
  },
  {
    "id": "200007",
    "content": "我今天早上去学校操场游泳了",
    "map": {
      "id": "200007",
      "user_id": "coderpwh",
      "user_content": "我今天早上去学校操场游泳了",
      "prompt_content": "游泳对关节友好,适合全身锻炼",
      "create_time": "2025-02-01 16:10:00"
    }
  },
  {
    "id": "200008",
    "content": "我上周日清晨去河边打羽毛球了",
    "map": {
      "id": "200008",
      "user_id": "coderpwh",
      "user_content": "我上周日清晨去河边打羽毛球了",
      "prompt_content": "打羽毛球提高反应速度和灵活性",
      "create_time": "2025-02-01 16:20:00"
    }
  },
  {
    "id": "200009",
    "content": "我今天早上去健身房游泳了",
    "map": {
      "id": "200009",
      "user_id": "coderpwh",
      "user_content": "我今天早上去健身房游泳了",
      "prompt_content": "游泳对关节友好,适合全身锻炼",
      "create_time": "2025-02-01 16:30:00"
    }
  },
  {
    "id": "200010",
    "content": "我昨晚去公园跑步了",
    "map": {
      "id": "200010",
      "user_id": "coderpwh",
      "user_content": "我昨晚去公园跑步了",
      "prompt_content": "跑步有助于提高心肺功能,保持健康",
      "create_time": "2025-02-01 16:40:00"
    }
  },
  {
    "id": "200011",
    "content": "我今天早上去公园打篮球了",
    "map": {
      "id": "200011",
      "user_id": "coderpwh",
      "user_content": "我今天早上去公园打篮球了",
      "prompt_content": "打篮球非常好,运动增加免疫力",
      "create_time": "2025-02-01 16:50:00"
    }
  },
  {
    "id": "200012",
    "content": "我上周日清晨去河边打羽毛球了",
    "map": {
      "id": "200012",
      "user_id": "coderpwh",
      "user_content": "我上周日清晨去河边打羽毛球了",
      "prompt_content": "打羽毛球提高反应速度和灵活性",
      "create_time": "2025-02-01 17:00:00"
    }
  },
  {
    "id": "200013",
    "content": "我今天下午去小区花园骑自行车了",
    "map": {
      "id": "200013",
      "user_id": "coderpwh",
      "user_content": "我今天下午去小区花园骑自行车了",
      "prompt_content": "骑自行车有助于提升腿部肌肉力量",
      "create_time": "2025-02-01 17:10:00"
    }
  },
  {
    "id": "200014",
    "content": "我今天中午去健身房踢足球了",
    "map": {
      "id": "200014",
      "user_id": "coderpwh",
      "user_content": "我今天中午去健身房踢足球了",
      "prompt_content": "踢足球增强团队协作能力",
      "create_time": "2025-02-01 17:20:00"
    }
  },
  {
    "id": "200015",
    "content": "我前天中午去社区运动场跑步了",
    "map": {
      "id": "200015",
      "user_id": "coderpwh",
      "user_content": "我前天中午去社区运动场跑步了",
      "prompt_content": "跑步有助于提高心肺功能,保持健康",
      "create_time": "2025-02-01 17:30:00"
    }
  },
  {
    "id": "200016",
    "content": "我昨天下午去小区花园骑自行车了",
    "map": {
      "id": "200016",
      "user_id": "coderpwh",
      "user_content": "我昨天下午去小区花园骑自行车了",
      "prompt_content": "骑自行车有助于提升腿部肌肉力量",
      "create_time": "2025-02-01 17:40:00"
    }
  },
  {
    "id": "200017",
    "content": "我前天中午去学校操场打篮球了",
    "map": {
      "id": "200017",
      "user_id": "coderpwh",
      "user_content": "我前天中午去学校操场打篮球了",
      "prompt_content": "打篮球非常好,运动增加免疫力",
      "create_time": "2025-02-01 17:50:00"
    }
  },
  {
    "id": "200018",
    "content": "我今天中午去运动中心踢足球了",
    "map": {
      "id": "200018",
      "user_id": "coderpwh",
      "user_content": "我今天中午去运动中心踢足球了",
      "prompt_content": "踢足球增强团队协作能力",
      "create_time": "2025-02-01 18:00:00"
    }
  },
  {
    "id": "200019",
    "content": "我上周五傍晚去健身房做瑜伽了",
    "map": {
      "id": "200019",
      "user_id": "coderpwh",
      "user_content": "我上周五傍晚去健身房做瑜伽了",
      "prompt_content": "做瑜伽帮助放松身心,改善柔韧性",
      "create_time": "2025-02-01 18:10:00"
    }
  },
  {
    "id": "200020",
    "content": "我昨晚去社区运动场打网球了",
    "map": {
      "id": "200020",
      "user_id": "coderpwh",
      "user_content": "我昨晚去社区运动场打网球了",
      "prompt_content": "打网球锻炼全身协调性和爆发力",
      "create_time": "2025-02-01 18:20:00"
    }
  },
  {
    "id": "200021",
    "content": "我今天早上去运动中心踢足球了",
    "map": {
      "id": "200021",
      "user_id": "coderpwh",
      "user_content": "我今天早上去运动中心踢足球了",
      "prompt_content": "踢足球增强团队协作能力",
      "create_time": "2025-02-01 18:30:00"
    }
  },
  {
    "id": "200022",
    "content": "我今天下午去社区运动场游泳了",
    "map": {
      "id": "200022",
      "user_id": "coderpwh",
      "user_content": "我今天下午去社区运动场游泳了",
      "prompt_content": "游泳对关节友好,适合全身锻炼",
      "create_time": "2025-02-01 18:40:00"
    }
  },
  {
    "id": "200023",
    "content": "我今天早上去公园打羽毛球了",
    "map": {
      "id": "200023",
      "user_id": "coderpwh",
      "user_content": "我今天早上去公园打羽毛球了",
      "prompt_content": "打羽毛球提高反应速度和灵活性",
      "create_time": "2025-02-01 18:50:00"
    }
  },
  {
    "id": "200024",
    "content": "我上周日清晨去社区运动场打羽毛球了",
    "map": {
      "id": "200024",
      "user_id": "coderpwh",
      "user_content": "我上周日清晨去社区运动场打羽毛球了",
      "prompt_content": "打羽毛球提高反应速度和灵活性",
      "create_time": "2025-02-01 19:00:00"
    }
  },
  {
    "id": "200025",
    "content": "我前天中午去海滨长廊跳绳了",
    "map": {
      "id": "200025",
      "user_id": "coderpwh",
      "user_content": "我前天中午去海滨长廊跳绳了",
      "prompt_content": "跳绳是高效的有氧运动,燃烧卡路里",
      "create_time": "2025-02-01 19:10:00"
    }
  },
  {
    "id": "200026",
    "content": "我上周六晚上去健身房打篮球了",
    "map": {
      "id": "200026",
      "user_id": "coderpwh",
      "user_content": "我上周六晚上去健身房打篮球了",
      "prompt_content": "打篮球非常好,运动增加免疫力",
      "create_time": "2025-02-01 19:20:00"
    }
  },
  {
    "id": "200027",
    "content": "我上周日清晨去公园踢足球了",
    "map": {
      "id": "200027",
      "user_id": "coderpwh",
      "user_content": "我上周日清晨去公园踢足球了",
      "prompt_content": "踢足球增强团队协作能力",
      "create_time": "2025-02-01 19:30:00"
    }
  },
  {
    "id": "200028",
    "content": "我前天中午去深圳湾跳绳了",
    "map": {
      "id": "200028",
      "user_id": "coderpwh",
      "user_content": "我前天中午去深圳湾跳绳了",
      "prompt_content": "跳绳是高效的有氧运动,燃烧卡路里",
      "create_time": "2025-02-01 19:40:00"
    }
  },
  {
    "id": "200029",
    "content": "我昨天下午去社区运动场跳绳了",
    "map": {
      "id": "200029",
      "user_id": "coderpwh",
      "user_content": "我昨天下午去社区运动场跳绳了",
      "prompt_content": "跳绳是高效的有氧运动,燃烧卡路里",
      "create_time": "2025-02-01 19:50:00"
    }
  },
  {
    "id": "200030",
    "content": "我今天傍晚去公园打网球了",
    "map": {
      "id": "200030",
      "user_id": "coderpwh",
      "user_content": "我今天傍晚去公园打网球了",
      "prompt_content": "打网球锻炼全身协调性和爆发力",
      "create_time": "2025-02-01 20:00:00"
    }
  },
  {
    "id": "200031",
    "content": "我昨天下午去深圳湾打羽毛球了",
    "map": {
      "id": "200031",
      "user_id": "coderpwh",
      "user_content": "我昨天下午去深圳湾打羽毛球了",
      "prompt_content": "打羽毛球提高反应速度和灵活性",
      "create_time": "2025-02-01 20:10:00"
    }
  },
  {
    "id": "200032",
    "content": "我上周五傍晚去公园打网球了",
    "map": {
      "id": "200032",
      "user_id": "coderpwh",
      "user_content": "我上周五傍晚去公园打网球了",
      "prompt_content": "打网球锻炼全身协调性和爆发力",
      "create_time": "2025-02-01 20:20:00"
    }
  },
  {
    "id": "200033",
    "content": "我今天早上去学校操场做瑜伽了",
    "map": {
      "id": "200033",
      "user_id": "coderpwh",
      "user_content": "我今天早上去学校操场做瑜伽了",
      "prompt_content": "做瑜伽帮助放松身心,改善柔韧性",
      "create_time": "2025-02-01 20:30:00"
    }
  },
  {
    "id": "200034",
    "content": "我今天早上去河边打篮球了",
    "map": {
      "id": "200034",
      "user_id": "coderpwh",
      "user_content": "我今天早上去河边打篮球了",
      "prompt_content": "打篮球非常好,运动增加免疫力",
      "create_time": "2025-02-01 20:40:00"
    }
  },
  {
    "id": "200035",
    "content": "我今天中午去海滨长廊爬山了",
    "map": {
      "id": "200035",
      "user_id": "coderpwh",
      "user_content": "我今天中午去海滨长廊爬山了",
      "prompt_content": "爬山能锻炼耐力,享受自然风光",
      "create_time": "2025-02-01 20:50:00"
    }
  },
  {
    "id": "200036",
    "content": "我前天中午去深圳湾跑步了",
    "map": {
      "id": "200036",
      "user_id": "coderpwh",
      "user_content": "我前天中午去深圳湾跑步了",
      "prompt_content": "跑步有助于提高心肺功能,保持健康",
      "create_time": "2025-02-01 21:00:00"
    }
  },
  {
    "id": "200037",
    "content": "我昨晚去运动中心跳绳了",
    "map": {
      "id": "200037",
      "user_id": "coderpwh",
      "user_content": "我昨晚去运动中心跳绳了",
      "prompt_content": "跳绳是高效的有氧运动,燃烧卡路里",
      "create_time": "2025-02-01 21:10:00"
    }
  },
  {
    "id": "200038",
    "content": "我昨晚去体育馆打篮球了",
    "map": {
      "id": "200038",
      "user_id": "coderpwh",
      "user_content": "我昨晚去体育馆打篮球了",
      "prompt_content": "打篮球非常好,运动增加免疫力",
      "create_time": "2025-02-01 21:20:00"
    }
  },
  {
    "id": "200039",
    "content": "我今天傍晚去健身房做瑜伽了",
    "map": {
      "id": "200039",
      "user_id": "coderpwh",
      "user_content": "我今天傍晚去健身房做瑜伽了",
      "prompt_content": "做瑜伽帮助放松身心,改善柔韧性",
      "create_time": "2025-02-01 21:30:00"
    }
  },
  {
    "id": "200040",
    "content": "我昨天下午去运动中心游泳了",
    "map": {
      "id": "200040",
      "user_id": "coderpwh",
      "user_content": "我昨天下午去运动中心游泳了",
      "prompt_content": "游泳对关节友好,适合全身锻炼",
      "create_time": "2025-02-01 21:40:00"
    }
  },
  {
    "id": "200041",
    "content": "我上周日清晨去海滨长廊踢足球了",
    "map": {
      "id": "200041",
      "user_id": "coderpwh",
      "user_content": "我上周日清晨去海滨长廊踢足球了",
      "prompt_content": "踢足球增强团队协作能力",
      "create_time": "2025-02-01 21:50:00"
    }
  },
  {
    "id": "200042",
    "content": "我前天中午去健身房打羽毛球了",
    "map": {
      "id": "200042",
      "user_id": "coderpwh",
      "user_content": "我前天中午去健身房打羽毛球了",
      "prompt_content": "打羽毛球提高反应速度和灵活性",
      "create_time": "2025-02-01 22:00:00"
    }
  },
  {
    "id": "200043",
    "content": "我前天中午去健身房踢足球了",
    "map": {
      "id": "200043",
      "user_id": "coderpwh",
      "user_content": "我前天中午去健身房踢足球了",
      "prompt_content": "踢足球增强团队协作能力",
      "create_time": "2025-02-01 22:10:00"
    }
  },
  {
    "id": "200044",
    "content": "我上周五傍晚去运动中心打网球了",
    "map": {
      "id": "200044",
      "user_id": "coderpwh",
      "user_content": "我上周五傍晚去运动中心打网球了",
      "prompt_content": "打网球锻炼全身协调性和爆发力",
      "create_time": "2025-02-01 22:20:00"
    }
  },
  {
    "id": "200045",
    "content": "我今天中午去社区运动场踢足球了",
    "map": {
      "id": "200045",
      "user_id": "coderpwh",
      "user_content": "我今天中午去社区运动场踢足球了",
      "prompt_content": "踢足球增强团队协作能力",
      "create_time": "2025-02-01 22:30:00"
    }
  },
  {
    "id": "200046",
    "content": "我今天下午去小区花园做瑜伽了",
    "map": {
      "id": "200046",
      "user_id": "coderpwh",
      "user_content": "我今天下午去小区花园做瑜伽了",
      "prompt_content": "做瑜伽帮助放松身心,改善柔韧性",
      "create_time": "2025-02-01 22:40:00"
    }
  },
  {
    "id": "200047",
    "content": "我上周五傍晚去社区运动场爬山了",
    "map": {
      "id": "200047",
      "user_id": "coderpwh",
      "user_content": "我上周五傍晚去社区运动场爬山了",
      "prompt_content": "爬山能锻炼耐力,享受自然风光",
      "create_time": "2025-02-01 22:50:00"
    }
  },
  {
    "id": "200048",
    "content": "我今天傍晚去体育馆骑自行车了",
    "map": {
      "id": "200048",
      "user_id": "coderpwh",
      "user_content": "我今天傍晚去体育馆骑自行车了",
      "prompt_content": "骑自行车有助于提升腿部肌肉力量",
      "create_time": "2025-02-01 23:00:00"
    }
  },
  {
    "id": "200049",
    "content": "我昨天下午去海滨长廊爬山了",
    "map": {
      "id": "200049",
      "user_id": "coderpwh",
      "user_content": "我昨天下午去海滨长廊爬山了",
      "prompt_content": "爬山能锻炼耐力,享受自然风光",
      "create_time": "2025-02-01 23:10:00"
    }
  },
  {
    "id": "200050",
    "content": "我昨天下午去海滨长廊打羽毛球了",
    "map": {
      "id": "200050",
      "user_id": "coderpwh",
      "user_content": "我昨天下午去海滨长廊打羽毛球了",
      "prompt_content": "打羽毛球提高反应速度和灵活性",
      "create_time": "2025-02-01 23:20:00"
    }
  },
  {
    "id": "200051",
    "content": "我上周日清晨去河边骑自行车了",
    "map": {
      "id": "200051",
      "user_id": "coderpwh",
      "user_content": "我上周日清晨去河边骑自行车了",
      "prompt_content": "骑自行车有助于提升腿部肌肉力量",
      "create_time": "2025-02-01 23:30:00"
    }
  },
  {
    "id": "200052",
    "content": "我今天中午去河边跑步了",
    "map": {
      "id": "200052",
      "user_id": "coderpwh",
      "user_content": "我今天中午去河边跑步了",
      "prompt_content": "跑步有助于提高心肺功能,保持健康",
      "create_time": "2025-02-01 23:40:00"
    }
  },
  {
    "id": "200053",
    "content": "我今天傍晚去小区花园爬山了",
    "map": {
      "id": "200053",
      "user_id": "coderpwh",
      "user_content": "我今天傍晚去小区花园爬山了",
      "prompt_content": "爬山能锻炼耐力,享受自然风光",
      "create_time": "2025-02-01 23:50:00"
    }
  },
  {
    "id": "200054",
    "content": "我上周六晚上去社区运动场打篮球了",
    "map": {
      "id": "200054",
      "user_id": "coderpwh",
      "user_content": "我上周六晚上去社区运动场打篮球了",
      "prompt_content": "打篮球非常好,运动增加免疫力",
      "create_time": "2025-02-02 00:00:00"
    }
  },
  {
    "id": "200055",
    "content": "我上周五傍晚去学校操场骑自行车了",
    "map": {
      "id": "200055",
      "user_id": "coderpwh",
      "user_content": "我上周五傍晚去学校操场骑自行车了",
      "prompt_content": "骑自行车有助于提升腿部肌肉力量",
      "create_time": "2025-02-02 00:10:00"
    }
  },
  {
    "id": "200056",
    "content": "我前天中午去公园爬山了",
    "map": {
      "id": "200056",
      "user_id": "coderpwh",
      "user_content": "我前天中午去公园爬山了",
      "prompt_content": "爬山能锻炼耐力,享受自然风光",
      "create_time": "2025-02-02 00:20:00"
    }
  },
  {
    "id": "200057",
    "content": "我今天早上去小区花园骑自行车了",
    "map": {
      "id": "200057",
      "user_id": "coderpwh",
      "user_content": "我今天早上去小区花园骑自行车了",
      "prompt_content": "骑自行车有助于提升腿部肌肉力量",
      "create_time": "2025-02-02 00:30:00"
    }
  },
  {
    "id": "200058",
    "content": "我今天下午去小区花园爬山了",
    "map": {
      "id": "200058",
      "user_id": "coderpwh",
      "user_content": "我今天下午去小区花园爬山了",
      "prompt_content": "爬山能锻炼耐力,享受自然风光",
      "create_time": "2025-02-02 00:40:00"
    }
  },
  {
    "id": "200059",
    "content": "我今天下午去小区花园爬山了",
    "map": {
      "id": "200059",
      "user_id": "coderpwh",
      "user_content": "我今天下午去小区花园爬山了",
      "prompt_content": "爬山能锻炼耐力,享受自然风光",
      "create_time": "2025-02-02 00:50:00"
    }
  },
  {
    "id": "200060",
    "content": "我上周日清晨去学校操场爬山了",
    "map": {
      "id": "200060",
      "user_id": "coderpwh",
      "user_content": "我上周日清晨去学校操场爬山了",
      "prompt_content": "爬山能锻炼耐力,享受自然风光",
      "create_time": "2025-02-02 01:00:00"
    }
  },
  {
    "id": "200061",
    "content": "我上周日清晨去深圳湾跳绳了",
    "map": {
      "id": "200061",
      "user_id": "coderpwh",
      "user_content": "我上周日清晨去深圳湾跳绳了",
      "prompt_content": "跳绳是高效的有氧运动,燃烧卡路里",
      "create_time": "2025-02-02 01:10:00"
    }
  },
  {
    "id": "200062",
    "content": "我今天早上去体育馆跳绳了",
    "map": {
      "id": "200062",
      "user_id": "coderpwh",
      "user_content": "我今天早上去体育馆跳绳了",
      "prompt_content": "跳绳是高效的有氧运动,燃烧卡路里",
      "create_time": "2025-02-02 01:20:00"
    }
  },
  {
    "id": "200063",
    "content": "我上周日清晨去公园骑自行车了",
    "map": {
      "id": "200063",
      "user_id": "coderpwh",
      "user_content": "我上周日清晨去公园骑自行车了",
      "prompt_content": "骑自行车有助于提升腿部肌肉力量",
      "create_time": "2025-02-02 01:30:00"
    }
  },
  {
    "id": "200064",
    "content": "我上周六晚上去社区运动场做瑜伽了",
    "map": {
      "id": "200064",
      "user_id": "coderpwh",
      "user_content": "我上周六晚上去社区运动场做瑜伽了",
      "prompt_content": "做瑜伽帮助放松身心,改善柔韧性",
      "create_time": "2025-02-02 01:40:00"
    }
  },
  {
    "id": "200065",
    "content": "我今天早上去河边跳绳了",
    "map": {
      "id": "200065",
      "user_id": "coderpwh",
      "user_content": "我今天早上去河边跳绳了",
      "prompt_content": "跳绳是高效的有氧运动,燃烧卡路里",
      "create_time": "2025-02-02 01:50:00"
    }
  },
  {
    "id": "200066",
    "content": "我今天下午去学校操场骑自行车了",
    "map": {
      "id": "200066",
      "user_id": "coderpwh",
      "user_content": "我今天下午去学校操场骑自行车了",
      "prompt_content": "骑自行车有助于提升腿部肌肉力量",
      "create_time": "2025-02-02 02:00:00"
    }
  },
  {
    "id": "200067",
    "content": "我今天早上去海滨长廊跳绳了",
    "map": {
      "id": "200067",
      "user_id": "coderpwh",
      "user_content": "我今天早上去海滨长廊跳绳了",
      "prompt_content": "跳绳是高效的有氧运动,燃烧卡路里",
      "create_time": "2025-02-02 02:10:00"
    }
  },
  {
    "id": "200068",
    "content": "我前天中午去社区运动场骑自行车了",
    "map": {
      "id": "200068",
      "user_id": "coderpwh",
      "user_content": "我前天中午去社区运动场骑自行车了",
      "prompt_content": "骑自行车有助于提升腿部肌肉力量",
      "create_time": "2025-02-02 02:20:00"
    }
  },
  {
    "id": "200069",
    "content": "我前天中午去健身房游泳了",
    "map": {
      "id": "200069",
      "user_id": "coderpwh",
      "user_content": "我前天中午去健身房游泳了",
      "prompt_content": "游泳对关节友好,适合全身锻炼",
      "create_time": "2025-02-02 02:30:00"
    }
  },
  {
    "id": "200070",
    "content": "我今天中午去海滨长廊骑自行车了",
    "map": {
      "id": "200070",
      "user_id": "coderpwh",
      "user_content": "我今天中午去海滨长廊骑自行车了",
      "prompt_content": "骑自行车有助于提升腿部肌肉力量",
      "create_time": "2025-02-02 02:40:00"
    }
  },
  {
    "id": "200071",
    "content": "我昨天下午去公园骑自行车了",
    "map": {
      "id": "200071",
      "user_id": "coderpwh",
      "user_content": "我昨天下午去公园骑自行车了",
      "prompt_content": "骑自行车有助于提升腿部肌肉力量",
      "create_time": "2025-02-02 02:50:00"
    }
  },
  {
    "id": "200072",
    "content": "我今天下午去海滨长廊骑自行车了",
    "map": {
      "id": "200072",
      "user_id": "coderpwh",
      "user_content": "我今天下午去海滨长廊骑自行车了",
      "prompt_content": "骑自行车有助于提升腿部肌肉力量",
      "create_time": "2025-02-02 03:00:00"
    }
  },
  {
    "id": "200073",
    "content": "我上周日清晨去公园打篮球了",
    "map": {
      "id": "200073",
      "user_id": "coderpwh",
      "user_content": "我上周日清晨去公园打篮球了",
      "prompt_content": "打篮球非常好,运动增加免疫力",
      "create_time": "2025-02-02 03:10:00"
    }
  },
  {
    "id": "200074",
    "content": "我上周五傍晚去深圳湾跳绳了",
    "map": {
      "id": "200074",
      "user_id": "coderpwh",
      "user_content": "我上周五傍晚去深圳湾跳绳了",
      "prompt_content": "跳绳是高效的有氧运动,燃烧卡路里",
      "create_time": "2025-02-02 03:20:00"
    }
  },
  {
    "id": "200075",
    "content": "我前天中午去学校操场跳绳了",
    "map": {
      "id": "200075",
      "user_id": "coderpwh",
      "user_content": "我前天中午去学校操场跳绳了",
      "prompt_content": "跳绳是高效的有氧运动,燃烧卡路里",
      "create_time": "2025-02-02 03:30:00"
    }
  },
  {
    "id": "200076",
    "content": "我前天中午去小区花园打篮球了",
    "map": {
      "id": "200076",
      "user_id": "coderpwh",
      "user_content": "我前天中午去小区花园打篮球了",
      "prompt_content": "打篮球非常好,运动增加免疫力",
      "create_time": "2025-02-02 03:40:00"
    }
  },
  {
    "id": "200077",
    "content": "我今天早上去河边踢足球了",
    "map": {
      "id": "200077",
      "user_id": "coderpwh",
      "user_content": "我今天早上去河边踢足球了",
      "prompt_content": "踢足球增强团队协作能力",
      "create_time": "2025-02-02 03:50:00"
    }
  },
  {
    "id": "200078",
    "content": "我上周五傍晚去公园打羽毛球了",
    "map": {
      "id": "200078",
      "user_id": "coderpwh",
      "user_content": "我上周五傍晚去公园打羽毛球了",
      "prompt_content": "打羽毛球提高反应速度和灵活性",
      "create_time": "2025-02-02 04:00:00"
    }
  },
  {
    "id": "200079",
    "content": "我今天中午去学校操场打篮球了",
    "map": {
      "id": "200079",
      "user_id": "coderpwh",
      "user_content": "我今天中午去学校操场打篮球了",
      "prompt_content": "打篮球非常好,运动增加免疫力",
      "create_time": "2025-02-02 04:10:00"
    }
  },
  {
    "id": "200080",
    "content": "我昨晚去河边游泳了",
    "map": {
      "id": "200080",
      "user_id": "coderpwh",
      "user_content": "我昨晚去河边游泳了",
      "prompt_content": "游泳对关节友好,适合全身锻炼",
      "create_time": "2025-02-02 04:20:00"
    }
  },
  {
    "id": "200081",
    "content": "我今天中午去社区运动场跳绳了",
    "map": {
      "id": "200081",
      "user_id": "coderpwh",
      "user_content": "我今天中午去社区运动场跳绳了",
      "prompt_content": "跳绳是高效的有氧运动,燃烧卡路里",
      "create_time": "2025-02-02 04:30:00"
    }
  },
  {
    "id": "200082",
    "content": "我今天下午去河边骑自行车了",
    "map": {
      "id": "200082",
      "user_id": "coderpwh",
      "user_content": "我今天下午去河边骑自行车了",
      "prompt_content": "骑自行车有助于提升腿部肌肉力量",
      "create_time": "2025-02-02 04:40:00"
    }
  },
  {
    "id": "200083",
    "content": "我上周日清晨去运动中心做瑜伽了",
    "map": {
      "id": "200083",
      "user_id": "coderpwh",
      "user_content": "我上周日清晨去运动中心做瑜伽了",
      "prompt_content": "做瑜伽帮助放松身心,改善柔韧性",
      "create_time": "2025-02-02 04:50:00"
    }
  },
  {
    "id": "200084",
    "content": "我上周五傍晚去小区花园骑自行车了",
    "map": {
      "id": "200084",
      "user_id": "coderpwh",
      "user_content": "我上周五傍晚去小区花园骑自行车了",
      "prompt_content": "骑自行车有助于提升腿部肌肉力量",
      "create_time": "2025-02-02 05:00:00"
    }
  },
  {
    "id": "200085",
    "content": "我今天傍晚去河边跳绳了",
    "map": {
      "id": "200085",
      "user_id": "coderpwh",
      "user_content": "我今天傍晚去河边跳绳了",
      "prompt_content": "跳绳是高效的有氧运动,燃烧卡路里",
      "create_time": "2025-02-02 05:10:00"
    }
  },
  {
    "id": "200086",
    "content": "我昨晚去健身房做瑜伽了",
    "map": {
      "id": "200086",
      "user_id": "coderpwh",
      "user_content": "我昨晚去健身房做瑜伽了",
      "prompt_content": "做瑜伽帮助放松身心,改善柔韧性",
      "create_time": "2025-02-02 05:20:00"
    }
  },
  {
    "id": "200087",
    "content": "我昨晚去社区运动场骑自行车了",
    "map": {
      "id": "200087",
      "user_id": "coderpwh",
      "user_content": "我昨晚去社区运动场骑自行车了",
      "prompt_content": "骑自行车有助于提升腿部肌肉力量",
      "create_time": "2025-02-02 05:30:00"
    }
  },
  {
    "id": "200088",
    "content": "我上周日清晨去社区运动场爬山了",
    "map": {
      "id": "200088",
      "user_id": "coderpwh",
      "user_content": "我上周日清晨去社区运动场爬山了",
      "prompt_content": "爬山能锻炼耐力,享受自然风光",
      "create_time": "2025-02-02 05:40:00"
    }
  },
  {
    "id": "200089",
    "content": "我今天中午去社区运动场跳绳了",
    "map": {
      "id": "200089",
      "user_id": "coderpwh",
      "user_content": "我今天中午去社区运动场跳绳了",
      "prompt_content": "跳绳是高效的有氧运动,燃烧卡路里",
      "create_time": "2025-02-02 05:50:00"
    }
  },
  {
    "id": "200090",
    "content": "我上周日清晨去海滨长廊骑自行车了",
    "map": {
      "id": "200090",
      "user_id": "coderpwh",
      "user_content": "我上周日清晨去海滨长廊骑自行车了",
      "prompt_content": "骑自行车有助于提升腿部肌肉力量",
      "create_time": "2025-02-02 06:00:00"
    }
  },
  {
    "id": "200091",
    "content": "我上周日清晨去体育馆打篮球了",
    "map": {
      "id": "200091",
      "user_id": "coderpwh",
      "user_content": "我上周日清晨去体育馆打篮球了",
      "prompt_content": "打篮球非常好,运动增加免疫力",
      "create_time": "2025-02-02 06:10:00"
    }
  },
  {
    "id": "200092",
    "content": "我今天傍晚去深圳湾踢足球了",
    "map": {
      "id": "200092",
      "user_id": "coderpwh",
      "user_content": "我今天傍晚去深圳湾踢足球了",
      "prompt_content": "踢足球增强团队协作能力",
      "create_time": "2025-02-02 06:20:00"
    }
  },
  {
    "id": "200093",
    "content": "我今天中午去海滨长廊打网球了",
    "map": {
      "id": "200093",
      "user_id": "coderpwh",
      "user_content": "我今天中午去海滨长廊打网球了",
      "prompt_content": "打网球锻炼全身协调性和爆发力",
      "create_time": "2025-02-02 06:30:00"
    }
  },
  {
    "id": "200094",
    "content": "我上周五傍晚去深圳湾跑步了",
    "map": {
      "id": "200094",
      "user_id": "coderpwh",
      "user_content": "我上周五傍晚去深圳湾跑步了",
      "prompt_content": "跑步有助于提高心肺功能,保持健康",
      "create_time": "2025-02-02 06:40:00"
    }
  },
  {
    "id": "200095",
    "content": "我昨天下午去学校操场爬山了",
    "map": {
      "id": "200095",
      "user_id": "coderpwh",
      "user_content": "我昨天下午去学校操场爬山了",
      "prompt_content": "爬山能锻炼耐力,享受自然风光",
      "create_time": "2025-02-02 06:50:00"
    }
  },
  {
    "id": "200096",
    "content": "我上周日清晨去学校操场踢足球了",
    "map": {
      "id": "200096",
      "user_id": "coderpwh",
      "user_content": "我上周日清晨去学校操场踢足球了",
      "prompt_content": "踢足球增强团队协作能力",
      "create_time": "2025-02-02 07:00:00"
    }
  },
  {
    "id": "200097",
    "content": "我今天中午去体育馆骑自行车了",
    "map": {
      "id": "200097",
      "user_id": "coderpwh",
      "user_content": "我今天中午去体育馆骑自行车了",
      "prompt_content": "骑自行车有助于提升腿部肌肉力量",
      "create_time": "2025-02-02 07:10:00"
    }
  },
  {
    "id": "200098",
    "content": "我上周六晚上去体育馆跳绳了",
    "map": {
      "id": "200098",
      "user_id": "coderpwh",
      "user_content": "我上周六晚上去体育馆跳绳了",
      "prompt_content": "跳绳是高效的有氧运动,燃烧卡路里",
      "create_time": "2025-02-02 07:20:00"
    }
  },
  {
    "id": "200099",
    "content": "我昨天下午去小区花园跳绳了",
    "map": {
      "id": "200099",
      "user_id": "coderpwh",
      "user_content": "我昨天下午去小区花园跳绳了",
      "prompt_content": "跳绳是高效的有氧运动,燃烧卡路里",
      "create_time": "2025-02-02 07:30:00"
    }
  },
  {
    "id": "200100",
    "content": "我昨晚去学校操场跑步了",
    "map": {
      "id": "200100",
      "user_id": "coderpwh",
      "user_content": "我昨晚去学校操场跑步了",
      "prompt_content": "跑步有助于提高心肺功能,保持健康",
      "create_time": "2025-02-02 07:40:00"
    }
  }
]

2. 嵌入模型

2.1 嵌入流程

2.2 存入向量库结果(ES)

2.3 查询流程

2.4 Embedding 与LLM关关系

2.4.1 关系图

2.4.2 对比

2.4.2.1 Text Embedding
  • 对嵌入的词或文本进行嵌入化,过程是静态的
  • 词义的表现形式是向量化
  • 词义本身无法理解上下文
2.4.2.2 LLM
  • 对词义的预测有概率性,过程是动态的
  • 能理解与生成上下文,词义会根据上下文变化而变化

2.5 Embedding 使用价值场景

2.5.1 弥补GPT的缺陷

  • 知识或信息的不足
  • 无法访问私有的文档
  • 于历史会话中获取信息
  • 对输入的内容长度有限制

3. 集成Embedding

3.1 技术栈

  • JDK 17+
  • SpringBoot 3.4.0+
  • SpringAi 为 1.0.0-M6
  • elasticsearch 8.15.3
  • Azure open AI (chat-gpt 4o)
  • Embedding model 为:text-embedding-3-large

3.2 代码 略

4. 效果对比

4.1 ES检索

4.1.1 ES检索

  • 依据分词效果,会检索与”喜欢”相关数据如图(kibana界面)
  • 业务逻辑层会筛选出其中10条数据提交给大模型

  • 最终请求效果

4.1.2 基于Embedding 与ES

  • 根据message(词义)做相似化查询
  • 过滤掉上面的喜欢小米汽车等,部分代码与结果截图
  • 最终效果

参考文章:

  1. https://learn.microsoft.com/zh-cn/azure/ai-services/openai/concepts/models?tabs=global-standard%2Cstandard-chat-completions#embeddings-models

  2. https://learn.microsoft.com/zh-cn/azure/ai-services/openai/concepts/understand-embeddings


文章作者: coderpwh
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 coderpwh !
  目录