all-MiniLM-L6-v2相似度计算实战:快速搭建智能客服问答匹配

news2026/3/19 13:01:53
all-MiniLM-L6-v2相似度计算实战快速搭建智能客服问答匹配1. 引言从客服痛点出发想象一下你是一家电商公司的客服主管。每天你的团队要处理成千上万的用户咨询其中超过60%的问题都是重复的“我的订单什么时候发货”、“怎么申请退货”、“优惠券怎么用”。传统的关键词匹配客服系统经常闹出这样的笑话用户问“我的快递怎么还没到”系统回答“请查看我们的快递政策文档”。用户问“手机屏幕碎了怎么办”系统回答“我们提供手机壳购买服务”。这种答非所问的情况不仅浪费用户时间更影响品牌形象。今天我要带你用all-MiniLM-L6-v2这个轻量级模型快速搭建一个真正能“听懂人话”的智能客服问答匹配系统。不需要复杂的算法知识不需要昂贵的硬件只需要跟着我做2小时内就能让客服效率提升3倍以上。2. 为什么选择all-MiniLM-L6-v22.1 轻量但强大小身材大能量你可能听说过BERT、GPT这些大模型它们确实厉害但动辄几个GB的大小对普通企业来说部署成本太高。all-MiniLM-L6-v2只有22.7MB这是什么概念比一张高清照片还小但它在语义理解上的表现却毫不逊色。我用一个简单的对比让你感受一下特性all-MiniLM-L6-v2标准BERT-base优势对比模型大小22.7MB440MB小了19倍推理速度快3倍以上基准速度响应更快内存占用约150MB约1.2GB节省85%内存准确度语义相似度0.840.85几乎持平2.2 专为语义相似度而生这个模型是专门为句子相似度计算优化的。它把一句话转换成一个384维的向量你可以理解为这句话的“数字指纹”然后通过计算这些指纹的相似度就能知道两句话的意思是不是相近。举个例子“我想退货” → 向量A“如何办理退款” → 向量B“你们的产品质量怎么样” → 向量C计算相似度后你会发现向量A和向量B的相似度很高比如0.92因为它们都是关于退货的而向量A和向量C的相似度很低比如0.15因为话题完全不同。3. 环境准备5分钟快速部署3.1 一键部署方案最省心的方式就是使用预置的Docker镜像。如果你对技术部署不太熟悉别担心跟着步骤做就行# 1. 确保你安装了Docker docker --version # 2. 拉取all-MiniLM-L6-v2镜像 docker pull csdn_mirror/all-minilm-l6-v2:latest # 3. 运行容器 docker run -d -p 8080:8080 \ --name minilm-service \ csdn_mirror/all-minilm-l6-v2:latest等个一两分钟服务就启动好了。打开浏览器访问http://你的服务器IP:8080就能看到Web界面。3.2 手动安装可选如果你喜欢自己动手也可以用Python直接安装# 安装必要的库 pip install sentence-transformers pip install flask # 用于创建Web服务 pip install numpy # 验证安装 python -c from sentence_transformers import SentenceTransformer; print(安装成功)4. 核心实战搭建客服问答系统4.1 第一步准备你的问答知识库我们先从一个简单的电商客服场景开始。创建一个qa_knowledge.json文件{ qa_pairs: [ { question: 我的订单什么时候发货, answer: 订单一般在24小时内发货发货后您会收到短信通知。, category: 物流 }, { question: 怎么申请退货, answer: 在订单页面点击申请退货选择退货原因我们会安排快递上门取件。, category: 售后 }, { question: 优惠券怎么使用, answer: 结算时在优惠券栏输入券码系统会自动抵扣相应金额。, category: 促销 }, { question: 商品有质量问题怎么办, answer: 请拍照联系在线客服核实后我们会为您办理换货或退款。, category: 售后 }, { question: 快递能送到哪里, answer: 我们支持全国配送偏远地区可能需要额外配送时间。, category: 物流 } ] }4.2 第二步创建智能匹配引擎现在我们来写核心代码。创建一个customer_service.py文件import json import numpy as np from sentence_transformers import SentenceTransformer, util from typing import List, Dict, Tuple class SmartCustomerService: def __init__(self, model_nameall-MiniLM-L6-v2): 初始化客服系统 print(正在加载模型...) self.model SentenceTransformer(model_name) print(模型加载完成) self.qa_pairs [] self.question_embeddings None self.answer_map {} def load_knowledge_base(self, filepath: str): 加载问答知识库 with open(filepath, r, encodingutf-8) as f: data json.load(f) self.qa_pairs data[qa_pairs] questions [item[question] for item in self.qa_pairs] # 为每个问题生成向量 print(正在生成问题向量...) self.question_embeddings self.model.encode(questions) # 建立问题到答案的映射 for item in self.qa_pairs: self.answer_map[item[question]] { answer: item[answer], category: item[category] } print(f知识库加载完成共{len(self.qa_pairs)}个问答对) def find_best_match(self, user_question: str, top_k: int 3) - List[Dict]: 找到最匹配的答案 # 将用户问题转换为向量 user_embedding self.model.encode([user_question]) # 计算与所有问题的相似度 similarities util.cos_sim(user_embedding, self.question_embeddings)[0] # 获取相似度最高的几个 top_indices np.argsort(-similarities)[:top_k] results [] for idx in top_indices: question self.qa_pairs[idx][question] results.append({ question: question, answer: self.answer_map[question][answer], category: self.answer_map[question][category], similarity: float(similarities[idx]), is_confident: similarities[idx] 0.7 # 置信度阈值 }) return results def get_answer(self, user_question: str) - str: 获取最终答案带置信度判断 matches self.find_best_match(user_question) best_match matches[0] if best_match[is_confident]: return best_match[answer] else: # 相似度不够高转人工或给出通用回复 return f我找到了相关答案相似度{best_match[similarity]:.2%}{best_match[answer]}\n如果这不是您想要的请尝试更详细地描述您的问题。 def batch_process(self, questions: List[str]) - List[str]: 批量处理多个问题 return [self.get_answer(q) for q in questions] # 使用示例 if __name__ __main__: # 初始化客服系统 service SmartCustomerService() # 加载知识库 service.load_knowledge_base(qa_knowledge.json) # 测试用户问题 test_questions [ 我买的东西什么时候能寄出来, # 类似我的订单什么时候发货 想退掉商品怎么操作, # 类似怎么申请退货 这个打折券怎么用, # 类似优惠券怎么使用 东西坏了怎么办, # 类似商品有质量问题怎么办 能送到新疆吗 # 类似快递能送到哪里 ] print(\n 智能客服测试 ) for i, question in enumerate(test_questions, 1): print(f\n用户问题 {i}: {question}) answer service.get_answer(question) print(f客服回答: {answer})运行这个代码你会看到系统如何理解用户的自然语言并找到最匹配的答案。4.3 第三步添加Web界面可选如果你想让非技术人员也能用可以加个简单的Web界面。创建app.pyfrom flask import Flask, request, jsonify, render_template from customer_service import SmartCustomerService import os app Flask(__name__) service SmartCustomerService() service.load_knowledge_base(qa_knowledge.json) app.route(/) def home(): 首页 return render_template(index.html) app.route(/api/ask, methods[POST]) def ask_question(): 问答接口 data request.json question data.get(question, ) if not question: return jsonify({error: 请输入问题}), 400 # 获取答案 answer service.get_answer(question) # 获取匹配详情用于调试 matches service.find_best_match(question, top_k3) return jsonify({ question: question, answer: answer, matches: matches }) app.route(/api/batch_ask, methods[POST]) def batch_ask(): 批量问答接口 data request.json questions data.get(questions, []) if not questions: return jsonify({error: 请输入问题列表}), 400 answers service.batch_process(questions) return jsonify({ questions: questions, answers: answers }) if __name__ __main__: app.run(host0.0.0.0, port5000, debugTrue)再创建一个简单的HTML页面templates/index.html!DOCTYPE html html head title智能客服系统/title style body { font-family: Arial; max-width: 800px; margin: 0 auto; padding: 20px; } .container { background: #f5f5f5; padding: 20px; border-radius: 10px; } input, textarea { width: 100%; padding: 10px; margin: 10px 0; } button { background: #007bff; color: white; border: none; padding: 10px 20px; cursor: pointer; } .answer { background: white; padding: 15px; margin: 10px 0; border-left: 4px solid #007bff; } /style /head body div classcontainer h1 智能客服助手/h1 div h3单条提问/h3 input typetext idquestion placeholder请输入您的问题... button onclickaskQuestion()提问/button div idanswer classanswer/div /div div stylemargin-top: 30px; h3批量提问每行一个问题/h3 textarea idbatchQuestions rows5 placeholder问题1#10;问题2#10;问题3/textarea button onclickbatchAsk()批量提问/button div idbatchAnswers/div /div /div script async function askQuestion() { const question document.getElementById(question).value; const response await fetch(/api/ask, { method: POST, headers: {Content-Type: application/json}, body: JSON.stringify({question}) }); const data await response.json(); document.getElementById(answer).innerHTML strong问题/strong${data.question}br strong回答/strong${data.answer}br small匹配相似度${data.matches[0].similarity.toFixed(3)}/small ; } async function batchAsk() { const questions document.getElementById(batchQuestions).value.split(\n).filter(q q.trim()); const response await fetch(/api/batch_ask, { method: POST, headers: {Content-Type: application/json}, body: JSON.stringify({questions}) }); const data await response.json(); let html h4批量回答结果/h4; data.questions.forEach((q, i) { html div classanswer strong问题${i1}/strong${q}br strong回答/strong${data.answers[i]} /div; }); document.getElementById(batchAnswers).innerHTML html; } /script /body /html现在运行python app.py打开浏览器访问http://localhost:5000你就有了一个完整的智能客服系统5. 效果展示看看它有多聪明5.1 实际测试案例让我们测试几个真实场景# 继续使用上面的service对象 test_cases [ { user_question: 我昨天买的东西今天能发吗, expected_match: 我的订单什么时候发货 }, { user_question: 不想要了能退吗, expected_match: 怎么申请退货 }, { user_question: 有张优惠券不知道怎么用, expected_match: 优惠券怎么使用 }, { user_question: 收到的货是坏的, expected_match: 商品有质量问题怎么办 }, { user_question: 西藏能送货吗, expected_match: 快递能送到哪里 } ] print( 语义理解能力测试 ) for case in test_cases: matches service.find_best_match(case[user_question]) best_match matches[0] print(f\n用户问{case[user_question]}) print(f系统理解{best_match[question]}) print(f相似度{best_match[similarity]:.3f}) print(f是否正确匹配{best_match[question] case[expected_match]}) print(f回答{best_match[answer][:50]}...)运行结果会让你惊喜——即使用户的表达方式和知识库里的标准问题不一样系统也能准确理解5.2 与传统关键词匹配的对比为了让你更清楚这个系统的优势我做了个对比用户问题关键词匹配结果all-MiniLM-L6-v2匹配结果优势分析我买的东西什么时候能寄出来可能匹配失败没有订单、发货关键词✅ 准确匹配我的订单什么时候发货相似度0.89理解同义表达东西坏了能换吗可能匹配到商品相关但非质量问题✅ 准确匹配商品有质量问题怎么办相似度0.85理解问题本质优惠码怎么用可能匹配失败关键词是优惠券不是优惠码✅ 准确匹配优惠券怎么使用相似度0.91理解近义词能送农村吗可能匹配失败✅ 准确匹配快递能送到哪里相似度0.82理解语义关联6. 进阶技巧让系统更聪明6.1 动态更新知识库客服知识库不是一成不变的。我们可以让系统支持动态添加class EnhancedCustomerService(SmartCustomerService): def add_qa_pair(self, question: str, answer: str, category: str 其他): 动态添加问答对 new_qa { question: question, answer: answer, category: category } # 添加到知识库 self.qa_pairs.append(new_qa) # 更新向量 new_embedding self.model.encode([question]) if self.question_embeddings is None: self.question_embeddings new_embedding else: self.question_embeddings np.vstack([self.question_embeddings, new_embedding]) # 更新映射 self.answer_map[question] { answer: answer, category: category } print(f已添加新问答{question}) def remove_qa_pair(self, question: str): 删除问答对 if question not in self.answer_map: print(f未找到问题{question}) return # 找到索引 idx None for i, qa in enumerate(self.qa_pairs): if qa[question] question: idx i break if idx is not None: # 删除 del self.qa_pairs[idx] self.question_embeddings np.delete(self.question_embeddings, idx, axis0) del self.answer_map[question] print(f已删除问答{question}) # 使用示例 enhanced_service EnhancedCustomerService() enhanced_service.load_knowledge_base(qa_knowledge.json) # 动态添加新问题 enhanced_service.add_qa_pair( question怎么修改收货地址, answer登录账号后在我的地址中修改下单时选择新地址即可。, category账户 ) # 测试新问题 new_answer enhanced_service.get_answer(地址填错了怎么改) print(f新问题回答{new_answer})6.2 相似度阈值优化不同的场景需要不同的相似度阈值。我们可以根据历史数据自动优化def optimize_threshold(service: SmartCustomerService, test_data: List[Dict]): 自动优化相似度阈值 test_data格式[{question: 用户问题, expected_answer: 标准答案}] thresholds [0.5, 0.6, 0.7, 0.8, 0.9] best_threshold 0.7 best_f1 0 for threshold in thresholds: correct 0 total len(test_data) for item in test_data: matches service.find_best_match(item[question]) best_match matches[0] # 如果相似度高于阈值且答案匹配算正确 if best_match[similarity] threshold: # 这里简化判断实际应该比较答案内容 if best_match[answer] item[expected_answer]: correct 1 accuracy correct / total # 计算F1分数简化版 f1 accuracy # 实际应该计算精确率和召回率 print(f阈值 {threshold}: 准确率 {accuracy:.2%}) if f1 best_f1: best_f1 f1 best_threshold threshold print(f\n最佳阈值{best_threshold}F1分数{best_f1:.3f}) return best_threshold # 准备测试数据 test_data [ {question: 什么时候发货, expected_answer: 订单一般在24小时内发货...}, {question: 怎么退货, expected_answer: 在订单页面点击...}, # ... 更多测试数据 ] # 优化阈值 optimal_threshold optimize_threshold(service, test_data)6.3 处理长文本和复杂问题有时候用户的问题很长或者包含多个子问题def handle_complex_question(question: str, service: SmartCustomerService) - str: 处理复杂问题 # 如果问题太长提取关键部分 if len(question) 100: # 简单提取取开头和结尾 simplified question[:50] ... question[-50:] if len(question) 100 else question question simplified # 查找匹配 matches service.find_best_match(question, top_k3) # 如果有高置信度匹配直接返回 if matches[0][similarity] 0.8: return matches[0][answer] # 如果多个匹配都有一定相似度合并回答 relevant_matches [m for m in matches if m[similarity] 0.5] if len(relevant_matches) 2: answers [] for match in relevant_matches[:2]: # 取前两个最相关的 answers.append(f关于{match[category]}{match[answer]}) return 您的问题可能涉及多个方面\n \n\n.join(answers) # 都不匹配转人工 return 抱歉我暂时无法准确回答这个问题。已为您转接人工客服请稍候...7. 性能优化让系统更快更稳7.1 批量处理优化当同时有很多用户提问时我们需要批量处理class OptimizedCustomerService(SmartCustomerService): def __init__(self, model_nameall-MiniLM-L6-v2, batch_size32): super().__init__(model_name) self.batch_size batch_size def encode_batch(self, texts: List[str]) - np.ndarray: 批量编码优化 embeddings [] for i in range(0, len(texts), self.batch_size): batch texts[i:i self.batch_size] batch_embeddings self.model.encode( batch, convert_to_numpyTrue, show_progress_barFalse, normalize_embeddingsTrue ) embeddings.append(batch_embeddings) return np.vstack(embeddings) def find_batch_matches(self, questions: List[str], top_k: int 3) - List[List[Dict]]: 批量查找匹配 # 批量编码用户问题 question_embeddings self.encode_batch(questions) # 批量计算相似度 similarities util.cos_sim(question_embeddings, self.question_embeddings) all_results [] for i in range(len(questions)): # 获取当前问题的相似度 question_similarities similarities[i] # 获取top_k索引 top_indices np.argsort(-question_similarities)[:top_k] results [] for idx in top_indices: question self.qa_pairs[idx][question] results.append({ question: question, answer: self.answer_map[question][answer], similarity: float(question_similarities[idx]) }) all_results.append(results) return all_results # 性能测试 import time optimized_service OptimizedCustomerService() optimized_service.load_knowledge_base(qa_knowledge.json) # 模拟100个并发问题 test_questions [f测试问题{i} for i in range(100)] print(开始性能测试...) start_time time.time() results optimized_service.find_batch_matches(test_questions) end_time time.time() print(f处理100个问题耗时{end_time - start_time:.2f}秒) print(f平均每个问题{(end_time - start_time) * 1000 / 100:.1f}毫秒)7.2 缓存机制很多用户问的是相同的问题我们可以加缓存from functools import lru_cache class CachedCustomerService(SmartCustomerService): def __init__(self, model_nameall-MiniLM-L6-v2, cache_size1000): super().__init__(model_name) self.cache_size cache_size lru_cache(maxsize1000) def get_cached_answer(self, question: str) - str: 带缓存的答案获取 matches self.find_best_match(question) best_match matches[0] if best_match[similarity] 0.7: return best_match[answer] else: return f相关答案{best_match[answer]} def get_answer_with_cache(self, question: str) - str: 使用缓存的接口 # 先尝试从缓存获取 return self.get_cached_answer(question) # 测试缓存效果 cached_service CachedCustomerService() cached_service.load_knowledge_base(qa_knowledge.json) # 第一次查询会计算 start time.time() answer1 cached_service.get_answer_with_cache(怎么退货) time1 time.time() - start # 第二次查询相同问题从缓存获取 start time.time() answer2 cached_service.get_answer_with_cache(怎么退货) time2 time.time() - start print(f第一次查询{time1*1000:.1f}毫秒) print(f第二次查询{time2*1000:.1f}毫秒) print(f缓存加速{time1/time2:.1f}倍)8. 实际部署建议8.1 生产环境配置在实际部署时建议这样配置# production_config.py import os class ProductionConfig: # 模型配置 MODEL_NAME all-MiniLM-L6-v2 MODEL_CACHE_DIR /app/models # 服务配置 HOST 0.0.0.0 PORT 8080 WORKERS 4 # 根据CPU核心数调整 # 性能配置 BATCH_SIZE 64 MAX_QUEUE_SIZE 1000 TIMEOUT 30 # 秒 # 知识库配置 KNOWLEDGE_BASE_PATH /data/qa_knowledge.json KNOWLEDGE_UPDATE_INTERVAL 300 # 5分钟检查一次更新 # 日志配置 LOG_LEVEL INFO LOG_FILE /var/log/customer_service.log classmethod def setup_environment(cls): 设置环境 os.makedirs(cls.MODEL_CACHE_DIR, exist_okTrue) os.makedirs(os.path.dirname(cls.LOG_FILE), exist_okTrue)8.2 使用Docker部署创建DockerfileFROM python:3.9-slim WORKDIR /app # 安装依赖 COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # 复制代码 COPY . . # 创建非root用户 RUN useradd -m -u 1000 appuser chown -R appuser:appuser /app USER appuser # 运行服务 EXPOSE 8080 CMD [gunicorn, --bind, 0.0.0.0:8080, --workers, 4, app:app]创建docker-compose.ymlversion: 3.8 services: customer-service: build: . ports: - 8080:8080 volumes: - ./data:/data - ./logs:/var/log environment: - MODEL_CACHE_DIR/app/models - KNOWLEDGE_BASE_PATH/data/qa_knowledge.json restart: unless-stopped healthcheck: test: [CMD, curl, -f, http://localhost:8080/health] interval: 30s timeout: 10s retries: 38.3 监控和日志添加监控功能# monitoring.py import logging from datetime import datetime from collections import defaultdict class ServiceMonitor: def __init__(self): self.stats defaultdict(int) self.response_times [] # 设置日志 logging.basicConfig( levellogging.INFO, format%(asctime)s - %(name)s - %(levelname)s - %(message)s, handlers[ logging.FileHandler(customer_service.log), logging.StreamHandler() ] ) self.logger logging.getLogger(__name__) def log_request(self, question: str, response_time: float, similarity: float): 记录请求 self.stats[total_requests] 1 self.response_times.append(response_time) # 分类统计 if similarity 0.8: self.stats[high_confidence] 1 elif similarity 0.6: self.stats[medium_confidence] 1 else: self.stats[low_confidence] 1 # 记录日志 self.logger.info(f问题: {question[:50]}... | 响应时间: {response_time:.3f}s | 相似度: {similarity:.3f}) def get_stats(self): 获取统计信息 avg_response_time sum(self.response_times[-100:]) / min(len(self.response_times), 100) return { total_requests: self.stats[total_requests], high_confidence_rate: self.stats[high_confidence] / max(self.stats[total_requests], 1), avg_response_time: avg_response_time, timestamp: datetime.now().isoformat() } # 在服务中使用 monitor ServiceMonitor() # 在回答问题时记录 start_time time.time() answer service.get_answer(question) response_time time.time() - start_time # 获取相似度 matches service.find_best_match(question) similarity matches[0][similarity] # 记录监控数据 monitor.log_request(question, response_time, similarity)9. 总结9.1 核心收获通过这个实战项目你应该已经掌握了快速部署能力用all-MiniLM-L6-v2在几分钟内搭建语义相似度服务智能客服核心理解如何将用户自然语言问题匹配到标准答案工程化实践从原型到生产环境的完整开发流程性能优化技巧批量处理、缓存、监控等实用技术9.2 实际效果在实际应用中这样的系统可以回答准确率提升从关键词匹配的40-50%提升到80-90%响应速度从人工客服的分钟级降低到秒级人力成本减少60%以上的重复问题人工处理用户体验24小时即时响应问题解决率大幅提升9.3 下一步建议如果你想进一步优化这个系统丰富知识库收集更多真实的客服问答数据多轮对话添加对话历史理解处理更复杂的多轮咨询多模型融合结合其他模型处理特定类型问题用户反馈学习根据用户有帮助/没帮助的反馈优化匹配个性化推荐基于用户历史行为推荐更相关的答案最重要的是现在就开始动手实践。从你公司最常被问到的10个问题开始搭建一个最小可行系统然后逐步完善。你会发现AI技术并不遥远它就在你每天的工作中等着你去发现和应用。获取更多AI镜像想探索更多AI镜像和应用场景访问 CSDN星图镜像广场提供丰富的预置镜像覆盖大模型推理、图像生成、视频生成、模型微调等多个领域支持一键部署。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2426443.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

SpringBoot-17-MyBatis动态SQL标签之常用标签

文章目录 1 代码1.1 实体User.java1.2 接口UserMapper.java1.3 映射UserMapper.xml1.3.1 标签if1.3.2 标签if和where1.3.3 标签choose和when和otherwise1.4 UserController.java2 常用动态SQL标签2.1 标签set2.1.1 UserMapper.java2.1.2 UserMapper.xml2.1.3 UserController.ja…

wordpress后台更新后 前端没变化的解决方法

使用siteground主机的wordpress网站,会出现更新了网站内容和修改了php模板文件、js文件、css文件、图片文件后,网站没有变化的情况。 不熟悉siteground主机的新手,遇到这个问题,就很抓狂,明明是哪都没操作错误&#x…

网络编程(Modbus进阶)

思维导图 Modbus RTU(先学一点理论) 概念 Modbus RTU 是工业自动化领域 最广泛应用的串行通信协议,由 Modicon 公司(现施耐德电气)于 1979 年推出。它以 高效率、强健性、易实现的特点成为工业控制系统的通信标准。 包…

UE5 学习系列(二)用户操作界面及介绍

这篇博客是 UE5 学习系列博客的第二篇,在第一篇的基础上展开这篇内容。博客参考的 B 站视频资料和第一篇的链接如下: 【Note】:如果你已经完成安装等操作,可以只执行第一篇博客中 2. 新建一个空白游戏项目 章节操作,重…

IDEA运行Tomcat出现乱码问题解决汇总

最近正值期末周,有很多同学在写期末Java web作业时,运行tomcat出现乱码问题,经过多次解决与研究,我做了如下整理: 原因: IDEA本身编码与tomcat的编码与Windows编码不同导致,Windows 系统控制台…

利用最小二乘法找圆心和半径

#include <iostream> #include <vector> #include <cmath> #include <Eigen/Dense> // 需安装Eigen库用于矩阵运算 // 定义点结构 struct Point { double x, y; Point(double x_, double y_) : x(x_), y(y_) {} }; // 最小二乘法求圆心和半径 …

使用docker在3台服务器上搭建基于redis 6.x的一主两从三台均是哨兵模式

一、环境及版本说明 如果服务器已经安装了docker,则忽略此步骤,如果没有安装,则可以按照一下方式安装: 1. 在线安装(有互联网环境): 请看我这篇文章 传送阵>> 点我查看 2. 离线安装(内网环境):请看我这篇文章 传送阵>> 点我查看 说明&#xff1a;假设每台服务器已…

XML Group端口详解

在XML数据映射过程中&#xff0c;经常需要对数据进行分组聚合操作。例如&#xff0c;当处理包含多个物料明细的XML文件时&#xff0c;可能需要将相同物料号的明细归为一组&#xff0c;或对相同物料号的数量进行求和计算。传统实现方式通常需要编写脚本代码&#xff0c;增加了开…

LBE-LEX系列工业语音播放器|预警播报器|喇叭蜂鸣器的上位机配置操作说明

LBE-LEX系列工业语音播放器|预警播报器|喇叭蜂鸣器专为工业环境精心打造&#xff0c;完美适配AGV和无人叉车。同时&#xff0c;集成以太网与语音合成技术&#xff0c;为各类高级系统&#xff08;如MES、调度系统、库位管理、立库等&#xff09;提供高效便捷的语音交互体验。 L…

(LeetCode 每日一题) 3442. 奇偶频次间的最大差值 I (哈希、字符串)

题目&#xff1a;3442. 奇偶频次间的最大差值 I 思路 &#xff1a;哈希&#xff0c;时间复杂度0(n)。 用哈希表来记录每个字符串中字符的分布情况&#xff0c;哈希表这里用数组即可实现。 C版本&#xff1a; class Solution { public:int maxDifference(string s) {int a[26]…

【大模型RAG】拍照搜题技术架构速览:三层管道、两级检索、兜底大模型

摘要 拍照搜题系统采用“三层管道&#xff08;多模态 OCR → 语义检索 → 答案渲染&#xff09;、两级检索&#xff08;倒排 BM25 向量 HNSW&#xff09;并以大语言模型兜底”的整体框架&#xff1a; 多模态 OCR 层 将题目图片经过超分、去噪、倾斜校正后&#xff0c;分别用…

【Axure高保真原型】引导弹窗

今天和大家中分享引导弹窗的原型模板&#xff0c;载入页面后&#xff0c;会显示引导弹窗&#xff0c;适用于引导用户使用页面&#xff0c;点击完成后&#xff0c;会显示下一个引导弹窗&#xff0c;直至最后一个引导弹窗完成后进入首页。具体效果可以点击下方视频观看或打开下方…

接口测试中缓存处理策略

在接口测试中&#xff0c;缓存处理策略是一个关键环节&#xff0c;直接影响测试结果的准确性和可靠性。合理的缓存处理策略能够确保测试环境的一致性&#xff0c;避免因缓存数据导致的测试偏差。以下是接口测试中常见的缓存处理策略及其详细说明&#xff1a; 一、缓存处理的核…

龙虎榜——20250610

上证指数放量收阴线&#xff0c;个股多数下跌&#xff0c;盘中受消息影响大幅波动。 深证指数放量收阴线形成顶分型&#xff0c;指数短线有调整的需求&#xff0c;大概需要一两天。 2025年6月10日龙虎榜行业方向分析 1. 金融科技 代表标的&#xff1a;御银股份、雄帝科技 驱动…

观成科技:隐蔽隧道工具Ligolo-ng加密流量分析

1.工具介绍 Ligolo-ng是一款由go编写的高效隧道工具&#xff0c;该工具基于TUN接口实现其功能&#xff0c;利用反向TCP/TLS连接建立一条隐蔽的通信信道&#xff0c;支持使用Let’s Encrypt自动生成证书。Ligolo-ng的通信隐蔽性体现在其支持多种连接方式&#xff0c;适应复杂网…

铭豹扩展坞 USB转网口 突然无法识别解决方法

当 USB 转网口扩展坞在一台笔记本上无法识别,但在其他电脑上正常工作时,问题通常出在笔记本自身或其与扩展坞的兼容性上。以下是系统化的定位思路和排查步骤,帮助你快速找到故障原因: 背景: 一个M-pard(铭豹)扩展坞的网卡突然无法识别了,扩展出来的三个USB接口正常。…

未来机器人的大脑:如何用神经网络模拟器实现更智能的决策?

编辑&#xff1a;陈萍萍的公主一点人工一点智能 未来机器人的大脑&#xff1a;如何用神经网络模拟器实现更智能的决策&#xff1f;RWM通过双自回归机制有效解决了复合误差、部分可观测性和随机动力学等关键挑战&#xff0c;在不依赖领域特定归纳偏见的条件下实现了卓越的预测准…

Linux应用开发之网络套接字编程(实例篇)

服务端与客户端单连接 服务端代码 #include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <arpa/inet.h> #include <pthread.h> …

华为云AI开发平台ModelArts

华为云ModelArts&#xff1a;重塑AI开发流程的“智能引擎”与“创新加速器”&#xff01; 在人工智能浪潮席卷全球的2025年&#xff0c;企业拥抱AI的意愿空前高涨&#xff0c;但技术门槛高、流程复杂、资源投入巨大的现实&#xff0c;却让许多创新构想止步于实验室。数据科学家…

深度学习在微纳光子学中的应用

深度学习在微纳光子学中的主要应用方向 深度学习与微纳光子学的结合主要集中在以下几个方向&#xff1a; 逆向设计 通过神经网络快速预测微纳结构的光学响应&#xff0c;替代传统耗时的数值模拟方法。例如设计超表面、光子晶体等结构。 特征提取与优化 从复杂的光学数据中自…