Data agent 项目

本文围绕Data Agent项目,详解语义层核心建模机制:基于YAML的五段式结构(元信息、properties、measures、relationships、defaults+governance),时间字段time_property与sql_on_expr的语义对齐能力,上下文通过namespace.yml/glossary.json/business_context.yml三级注入,评测依托1300+行规范与semantic-lint打分,权限通过维度映射与可达性校验实现。
项目简介:
 业务侧临时取数长期依赖数据团队,需求转译链路长、指标口径分散。部门自研Data-Agent,让 LLM 仅承担自然语言到结构化意图的翻译,SQL 由语义引擎确定性生成,接入 Web、飞书、MCP、API 四条渠道,使运营、分析师、高管以自然语言直接取数,并从根源规避 LLM 直写 SQL 导致的口径漂移与幻觉字段风险,平台语义准确率达92%。

技术栈:Claude Code + Python + LangGraph + LLM + Hologres + Elasticsearch + React + Docker 
职责与成果:
1、独立搭建语义模型:独立搭建售后 + 线索领域语义模型,覆盖 30 张表、500+ 个度量,交付 40+ class 本体论语义模型;完成售后 + 线索域数仓 → Hologres 同步与查询授权,为自然语言问数提供统一语义底座。

2、重构 Business Rules 规则集:针对规则冗余导致 LLM 混淆的问题,优化 YAML 规范,压缩最短可验证指令、将可检索内容下沉至索引层,字符量缩减 85%,降低 LLM 混淆概率,提升意图识别与语义解析稳定性。

3、参与共建评测体系:负责本域评测问题供给与标准答案构建,形成评测数据飞轮闭环,结合 Pipeline 归因分类 + 线上链路回溯两套机制定位问题,修复 6 类核心问题,经过10+轮迭代,销售+线索实体语义准确率从50%提升至94% 。                                                                                                                                                                                      

4、参与平台上下文工程:参与系统提示词、附件源、会话尾注、注入节点四层并行注入架构的设计与实现,并参与同义词 → 描述 → 术语表 → 领域上下文的知识分层规范建设,提升 LLM 对业务语义的理解一致性。

5、审计权限风险与漏洞修复:针对语义层越权风险进行代码审计,验证 9 条攻击路径,发现并推动修复 fail-open、审计日志死代码 2 个高危漏洞;完成汽车 NS 实体级权限声明与命名空间维度映射配置,保障平台权限安全。

6、上线运营与持续维护:基于上线后主动巡查机制,通过管理控制台看板监控语义准确率与异常,定位并修复模型语义问题,保障平台稳定运行与持续迭代。

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

面试相关问题:
现在 假如在面试,面试官有以下问题:你帮我回答一下 : 1 本体论相关介绍 ,2 yaml 构造和结构 3 上下文怎么注入的 3 评测怎么做的 5 权限怎么实现

1 面试回答

1.1本体论相关介绍

在这里插入图片描述

1.2yaml 构造和结构

口述版
一个 Class 一个 YAML 文件,分五块:头部元信息、properties、measures、relationships、defaults,最后还有一个可选的 governance。构建顺序是:先用数仓表 DDL 生成 properties 骨架;再和业务方对齐口径,写 measures;然后按外键声明关系;最后补同义词和描述,用评测题集驱动迭代。

下面是从你域里的 clue_pipeline.yml 精简出来的:

class: CluePipeline              # LLM 选的是实体名,不是表名
permission: [x_org_id]           # 行级权限维度
synonym: {zh: [线索明细, 线索漏斗]}
description:                     # 给 LLM 的选表规则
  zh: 一行一条线索…统计汇总指标禁止用本表,必须用 ClueOrgStaffMinute…
table: adsfssfdseline_rt # 物理映射
primary_key: clue_id
properties:
  level:
    type: string
    dim_source: true             # 维度值同步到检索层,供枚举值匹配
    enum_values: [{value: A, name: {zh: 高意向}}, ...]
measures:
  clue_drive_cnt:
    synonym: {zh: [已试驾线索数, 试驾转化线索数]}
    agg: count_distinct
    expression: clue_id
    condition: "${drive_cnt} > 0"  # 条件度量,口径固化
    time_property: ymd             # 用户说"上个月",自动落到这个时间字段
relationships:
  category:
    to: DimCategory
    type: many_to_one
    foreign_key: first_item_id
    target_key: car_item_id        # 先去重再 JOIN,防止翻倍
    sql_on_expr: ${source}.first_item_id::TEXT = ${target}.car_item_id::TEXT

被追问时

description 写的是「查询规则」,不是普通注释,比如「①本表用于… ②禁止用于…」。这是写给 LLM 的路由提示。

time_property 解决时间口径:比如锁单量对应 lock_tm,小订对应 sm_tm。用户说「上个月」,时间条件会自动落到这个度量对应的时间字段上。

sql_on_expr 处理特殊 JOIN:类型不一致要加 ::TEXT 转换;还有多键 JOIN,比如 staff_id + org_id + 岗位域一起关联。

NS 级还有三个配置文件:
namespace.yml:数据库连接、权限维度映射、business_rules。
glossary.json:术语表。
business_context.yml:领域上下文。
质量保障:后端启动时 loader 会做校验,包括度量引用、关系字段引用、权限声明是否齐全、权限维度是否可达;另外有一份 1300+ 行的建模规范,还有 semantic-lint 打分。

1.3上下文怎么注入的

在这里插入图片描述

1.4评测怎么做的

在这里插入图片描述

1.5权限怎么实现

在这里插入图片描述

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Direction_Wind

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值