AI知识库

53AI知识库

学习大模型的前沿技术与行业应用场景


【AI大模型】【赋能】广告匹配
发布日期:2024-07-25 08:40:28 浏览次数: 1651


近期考虑AI结合business的一些场景!如下是搭建的一个简易的数字广告过程!应用大模型的能力来赋能,一起来Get!


看效果


PS:本次的实验中,就假定了这用户的profile是automation 汽车爱好者


话原理


如下是本次实验的展示广告的基本单元,包含媒体(web站)、SSP(供应方平台)、DSP(需求方平台),简单理解就是广告过程是,不同的DSP会去就一次展示请求填充不同的广告,SSP会做内部的竞价,获胜DSP可以填充广告,最后是在媒体上展示!



左侧的标准逻辑推荐展示儿童衣服的逻辑大致如下,因为用户是汽车爱好者,给他推荐了儿童衣服,用户不会点击...


好的,实现上就是如下的3个DSP分别报价,价高者得;


AI的大模型能优化这个结果吗,如下离线的把要投放的广告主的素材的内容做抓取、信息提取,利用大模型做广告主网站信息和既定分类的Match,形成广告主投放信息的既定Match,当一个用户过来的时候,可即时根据profile的信息对要展示广告进行Match匹配度过滤,再是常规的竞价,,这里的用户大概率就会点击了...发生后续事件


下面是借助一个工作流dify搭建的网站内容提取步骤!实践部分是第一个广告展示逻辑,基于大模型的没有呈现可以自行尝试!


来实践


1、项目结构如下


2、app.py


from flask import Flask, request, jsonifyimport requestsfrom pymongo import MongoClientfrom flask_cors import CORSapp = Flask(__name__)CORS(app)# 连接 MongoDBclient = MongoClient('localhost', 27017)db = client.ad_database# 示例广告数据ads = [{"id": 1, "url": "http://www.1989c.com/youxigonglue/84353.html", "img": "https://p26.toutiaoimg.com/origin/tos-cn-i-qvj2lq49k0/6043ee8e5c6249269b24439bc37311ac?from=pc"},{"id": 2, "url": "http://www.maomaopost.com/", "img": "https://k.sinaimg.cn/n/sinakd20115/448/w624h624/20231115/1451-414b3203772c419fa230560a335ac8c3.jpg/w700d1q75cms.jpg"}]dsp_urls = ['http://localhost:5001/dsp','http://localhost:5002/dsp','http://localhost:5003/dsp']def save_user_profile(user_id, profile_data):db.user_profiles.update_one({'user_id': user_id},{'$set': profile_data},upsert=True)def select_ad_based_on_profile(profile):if 'interests' in profile and 'sports' in profile['interests']:return ads[0]else:return ads[1]@app.route('/ssp', methods=['POST'])def ssp():print('Received a request at /ssp')data = request.jsonprint('Request data:', data)user_id = data.get('user', {}).get('id')if not user_id:print('Missing user id')return jsonify({'error': 'Invalid request: missing user id'}), 400user_profile = db.user_profiles.find_one({'user_id': user_id})if user_profile:selected_ad = select_ad_based_on_profile(user_profile)else:selected_ad = ads[0]bid_responses = []for dsp_url in dsp_urls:try:response = requests.post(dsp_url, json=data)if response.status_code == 200:bid_responses.append(response.json())else:print(f"Error response from DSP at {dsp_url}: {response.status_code}")except requests.RequestException as e:print(f"Error contacting DSP at {dsp_url}: {e}")if not bid_responses:return jsonify({'error': 'No valid bids received'}), 400highest_bid = max(bid_responses, key=lambda x: x['seatbid'][0]['bid'][0]['price'])print('Sending bid response:', highest_bid)# 直接将 adm 字段的内容传递给前端highest_bid['adm_content'] = highest_bid['seatbid'][0]['bid'][0]['adm']highest_bid['adomain'] = selected_ad['url']return jsonify(highest_bid)@app.route('/user/<user_id>', methods=['POST'])def update_user_profile(user_id):profile_data = request.jsonif not profile_data:return jsonify({'error': 'Invalid data'}), 400save_user_profile(user_id, profile_data)return jsonify({'status': 'success'})@app.route('/')def index():return """<div id="ad-space"></div><script>fetch('http://127.0.0.1:5000/ssp', {method: 'POST',headers: {'Content-Type': 'application/json'},body: JSON.stringify({"id": "1","imp": [{"id": "1", "banner": {}}],"user": {"id": "user123"}})}).then(response => response.json()).then(data => {const adSpace = document.getElementById('ad-space');adSpace.innerHTML = ''; // 清空广告位内容// 直接设置 adm_contentconst admContent = data.adm_content;adSpace.innerHTML = admContent;}).catch(error => console.error('Error:', error));</script>"""if __name__ == '__main__':app.run(port=5000)


3、dsp.py


from flask import Flask, request, jsonifyapp = Flask(__name__)@app.route('/dsp', methods=['POST'])def dsp():data = request.jsonuser_id = data['user']['id']# 简单出价逻辑,可以根据实际情况优化bid_price = 0.5# 默认出价response = {"id": data['id'],"seatbid": [{"bid": [{"id": "1","impid": data['imp'][0]['id'],"price": bid_price,"adm": '<a href="https://www.xiaohongshu.com/explore/6323e4fc00000000080087db"><img src="https://n.sinaimg.cn/sinacn22/268/w1600h1068/20180416/3728-fzcyxmv5793322.jpg" /></a>'}]}]}return jsonify(response)if __name__ == '__main__':app.run(port=5001)

写在最后


如上是AI大语言模型在广告投放中的语意理解的一个小应用...试想如果AI大模型在某一天能够即时响应(毫秒)级,大模型完全可以handle填充哪个广告展示,甚至根据用户自动做素材适配(风格迁移),这时,广告匹配效率极大的增加,无效的广告会减少吧?


天有几高,奋起两手可攀到...年岁很大也敢于挑战艰苦让人肃然起敬愿今夜,好入眠!


[words]


vocation 职业


luninosity 明度


time-saving


allow


part-time job


Role play 角色扮演


resemble 与什么相似


wreck 破坏,毁坏


drunk 醉汉


sake 缘由


conceal 隐藏,隐瞒


possess 拥有,掌握


scratch 刮擦


circular 圆形的


fashionable 流行的


devise 设计,捐赠


sideway 斜着向一边


harbour 港口


cliff 悬崖


concede 承让让步


sexism 性别追


rational 神智清楚的,理性的


accustom 使习惯


aquaintance 熟悉的人


legible 清晰的


tickle 使满足,使得发痒


cardiac 心脏病


ageism 年龄歧视


unparalleled 无比的


ramble 漫游


spiral 螺旋,漩涡


provocative 挑衅的,刺激性的


resume 继续,重新开始


no brainer 显而易见的


The deal is a long shot


Empathy


The vision of product


Cambodia 柬埔寨


Qualifying out 胜出


参考




53AI,企业落地应用大模型首选服务商

产品:大模型应用平台+智能体定制开发+落地咨询服务

承诺:先做场景POC验证,看到效果再签署服务协议。零风险落地应用大模型,已交付160+中大型企业

联系我们

售前咨询
186 6662 7370
预约演示
185 8882 0121

微信扫码

与创始人交个朋友

回到顶部

 
扫码咨询