新闻详情

新闻详情

首页 / 资讯中心 / 详情

简单使用Laya模型

发布时间:2026/11/14 19:35:06来源:尧图网络
简单使用Laya模型
简单使用Laya模型1 简单说明Laya模型主要用于文本分类、判读的多语言、非自回归的系统1System 1快思考-自动、无意识、并行运行决策模型。给它一个状态文本、邮件、工单或 JSON和带类型的提问它会在一次前向传播中约33毫秒返回带数学校准概率的类型化答案支持100多种语言。参考地址# 官网文档可支持集成到langchain https://nandhakishorm.github.io/laya/ # Github https://github.com/NandhaKishorM/laya # ModelScope网站 https://modelscope.cn/models/convaiinnovations/laya模型分类模型编码参数上下文用途layaModernBERT-large421M512仅支持英语文本、安全护栏、邮件分类laya-multilingualmmBERT-base322M1024 最高支持 8,192支持100多种语言速度约快2.2倍laya-typed-decisionsModernBERT-large421M1024代理轨迹可观测性、客户服务、发票处理和安全事件四种类型化决策工作流三种决策原语说明choice分类选择返回每个选项的概率和置信度类问题的选项数量控制在约 20 个以内。score打分返回有序量表的分布noul是非判断返回 0-1 的成立概率2 简单使用2.1 安装软件包pip install laya -i https://pypi.tuna.tsinghua.edu.cn/simple2.2 Laya代码importosfromlayaimportRouter# 设置离线环境os.environ[HF_HUB_OFFLINE]1# 设置国内的hf-mirror.comos.environ[HF_ENDPOINT]https://hf-mirror.com# 禁用xetXet是Hugging Face的新传输协议国内用不了os.environ[HF_HUB_DISABLE_XET]1# 设置缓存目录os.environ[HF_HOME]E:/laya# 设置单个模型# agent laya.load(E:/laya, subfoldermultilingual)# 预加载模型自动选择laya、laya-multilingual、laya-typed-decisions模型routerRouter(preloadTrue)router.preload([english,multilingual,typed-decisions])# 设置问题state{from:useracme.com,subject:Duplicate charge on invoice #4411,body:Hi, we were billed twice for March. Please refund the duplicate today or we will cancel our plan.}# 设置规则questions{department:{# 设置选择类型返回概率和置信度type:choice,instructions:Which department should handle this request?,# 设置分类标准必须是列表可以字典和文本列表criteria:{billing:invoices, payments, refunds,technical:bugs, outages, system errors,sales:pricing, new contracts,other:everything else}},urgency:{# 设置分数类型返回概率分布type:score,instructions:How urgent is this request?,# 必须是列表不能是字典列表criteria:[not urgent,soon,critical deadline or blocking issue]},churn_risk:{# 设置是非判断返回0-1的成立概率type:noul,instructions:Does the user threaten to cancel or leave?},refund_requested:{type:noul,instructions:Does the user explicitly request a refund?}}# 预测的返回值为字典# 1. 英文 - 选择laya英文模型res_enrouter.predict(state,questions)print(res_en)print(laya-english)print(Answer:,res_en[answers])print(Routing:,res_en[routing])print()# 2. 中文 - 选择laya-multilingual多语言模型res_zhrouter.predict({body:我被收取了两次费用请退还钱款。},questions)print(res_zh)print(laya-multilingual)print(Answer:,res_zh[answers])print(Routing:,res_zh[routing])print()# 3. 设置决策流模型res_tdrouter.predict(state,questions,modeltyped-decisions)print(res_td)print(laya-choice)print(Answer:,res_td[answers])print(Routing:,res_td[routing])2.3 返回值说明{model:laya-rl-agent,answers:{department:{# 选择类型type:choice,# 目标值choice:billing,# 概率分布probabilities:{billing:0.9653,technical:0.014,sales:0.0101,other:0.0107},# 概率分布的置信度confidence:0.864,# 目标值的置信度answer_confidence:0.9653,action:{act_probability:1.0}},urgency:{type:score,# 期望得分表示在1~2之间的序列score:1.44,# 标签列表legend:{0:not urgent,1:soon,2:critical deadline or blocking issue},# 概率分布probabilities:{0:0.1164,1:0.3271,2:0.5565},confidence:0.1425,answer_confidence:0.5565,action:{act_probability:1.0}},churn_risk:{# 表示是非判断返回0-1的成立概率type:noul,# 概率值noul:0.8248,confidence:0.8248,answer_confidence:0.8248,action:{act_probability:1.0}},refund_requested:{type:noul,noul:0.843,confidence:0.843,answer_confidence:0.843,action:{act_probability:1.0}}},usage:{input_tokens:348,output_tokens:0},# 表示路由选择的模型routing:{model:english,repo:convaiinnovations/laya,reason:English Latin text,detection:{script:latin,script_profile:{latin:1.0},language:en,is_english:True,language_undecided:False,diacritic_rate:0.0,non_latin_fraction:0.0},workflow:None}}
网站建设高端定制企业官网
RELATED

相关资讯

更多精彩内容,欢迎继续阅读

较早相关资讯

最新相关资讯

【外设】之大彩串口显示屏 2026/11/14 3:51:47

【外设】之大彩串口显示屏

大彩串口屏初步使用 1 .官网下载 STM32 屏幕 GUI 设计资料 http://www.gz-dc.com/category/typeid/4112 找到 STM32 Keil 工程,移植相关代码因项目而异进行移植,由于项目简单,本人只对用到的指令接口进行修改。 比如:注意事项&…

阅读更多 →
无法下载Windows系统iso文件 2026/11/12 23:59:09

无法下载Windows系统iso文件

当我遇到这个问题的时候,我打开了一个网站: 登录 然后我打算下载的时候: 突然那个官方的连接就可以下载了:

阅读更多 →
【清华代码熊】DeepSeek V4.1 Flash 后训练详解 2026/11/14 10:11:15

【清华代码熊】DeepSeek V4.1 Flash 后训练详解

📌 上期解析了 DeepSeek V4.1 Flash 模型架构改进,本期解析 DeepSeek V4.1 Flash 预训练/后训练技术: 🌟 预训练:45T 文本 多模态混合语料、直接训练 sparse attention(取消 DeepSeek V4 的 dense 冷启动&…

阅读更多 →
Shuffle-R1: Efficient RL framework for Multimodal Large Language Models via Data-centric Dynamic ... 2026/11/14 17:14:38

Shuffle-R1: Efficient RL framework for Multimodal Large Language Models via Data-centric Dynamic ...

文章主要内容和创新点 主要内容 本文聚焦于多模态大语言模型(MLLM)强化学习(RL)训练中的效率问题,提出了一个名为Shuffle-R1的框架。研究发现,当前RL训练存在两个关键缺陷: 优势值坍缩(Advantage Collapsing):批次中大多数优势值集中在零附近,导致有效梯度信号被淹…

阅读更多 →
PRvL: Quantifying the Capabilities and Risks of Large Language Models for PII Redaction 2026/11/14 16:35:50

PRvL: Quantifying the Capabilities and Risks of Large Language Models for PII Redaction

一、文章主要内容总结 本文聚焦于利用大型语言模型(LLMs)实现个人身份信息(PII)脱敏的研究,旨在解决传统脱敏方法(如基于规则的系统、领域特定命名实体识别(NER)模型)泛化能力差、跨格式/跨语境适应性弱的问题。 研究通过全面评估多种LLM架构(包括密集型LLM(D-LLM…

阅读更多 →
LLaVA-RE: Binary Image-Text Relevancy Evaluation with Multimodal Large Language Model 2026/11/14 3:51:43

LLaVA-RE: Binary Image-Text Relevancy Evaluation with Multimodal Large Language Model

文章主要内容和创新点 主要内容 本文聚焦于二进制图像-文本相关性评估任务(判断图像与文本“相关”或“不相关”),针对该任务中文本格式多样、相关性定义随场景变化等挑战,提出了基于多模态大语言模型(MLLM)的解决方案LLaVA-RE。 模型设计:LLaVA-RE基于LLaVA 1.5架构,…

阅读更多 →

今日资讯

本周资讯

本月资讯

看完文章仍有疑问?

联系尧图顾问,获取一对一建站咨询

立即免费咨询 📞 400-888-8888
📞 ✉