80 lines
2.1 KiB
Markdown
80 lines
2.1 KiB
Markdown
# Catalog Search Agent
|
|
|
|
智能数据检索专家系统,基于多层数据架构的专业数据检索,具备自主决策能力和复杂查询优化技能。
|
|
|
|
## 功能特点
|
|
|
|
- **多层数据架构支持**
|
|
- 原始文档层 (document.txt) - 完整上下文信息
|
|
- 分页数据层 (pagination.txt) - 高效关键词/正则检索
|
|
- 语义检索层 (embedding.pkl) - 向量化语义搜索
|
|
|
|
- **智能检索策略**
|
|
- 关键词扩展与优化
|
|
- 数字格式标准化扩展
|
|
- 范围性正则表达式生成
|
|
- 多关键词权重混合检索
|
|
|
|
- **多种搜索模式**
|
|
- 正则表达式搜索
|
|
- 关键词匹配
|
|
- 语义相似度搜索
|
|
- 上下文行检索
|
|
|
|
## 安装
|
|
|
|
```bash
|
|
# 安装依赖
|
|
pip install -r skills/catalog-search-agent/scripts/requirements.txt
|
|
```
|
|
|
|
## 使用方法
|
|
|
|
### 多关键词搜索
|
|
|
|
```bash
|
|
python skills/catalog-search-agent/scripts/multi_keyword_search.py search \
|
|
--patterns '[{"pattern": "laptop", "weight": 2.0}, {"pattern": "/[0-9]+\\.?[0-9]*kg/", "weight": 1.5}]' \
|
|
--file-paths data/pagination.txt \
|
|
--limit 20
|
|
```
|
|
|
|
### 语义搜索
|
|
|
|
```bash
|
|
python skills/catalog-search-agent/scripts/semantic_search.py \
|
|
--queries "lightweight laptop for travel" \
|
|
--embeddings-file data/embedding.pkl \
|
|
--top-k 10
|
|
```
|
|
|
|
### 正则表达式搜索
|
|
|
|
```bash
|
|
python skills/catalog-search-agent/scripts/multi_keyword_search.py regex_grep \
|
|
--patterns "/price:\\s*\\$[0-9]+/" \
|
|
--file-paths data/pagination.txt \
|
|
--context-lines 3
|
|
```
|
|
|
|
## 环境变量
|
|
|
|
| 变量 | 说明 | 默认值 |
|
|
|------|------|--------|
|
|
| `FASTAPI_URL` | Embedding API 服务地址 | `http://localhost:8000` |
|
|
|
|
## 数据架构
|
|
|
|
### document.txt
|
|
原始 markdown 文本内容,提供完整上下文信息。获取某一行数据时需要包含前后 10 行的上下文。
|
|
|
|
### pagination.txt
|
|
基于 document.txt 整理的分页数据,每一行代表完整的一页数据,支持正则高效匹配和关键词检索。
|
|
|
|
### embedding.pkl
|
|
语义检索文件,将 document.txt 按段落/页面分块并生成向量化表达,用于语义相似度搜索。
|
|
|
|
## 作者
|
|
|
|
Sparticle <support@gbase.ai>
|