通用轻量级命名实体识别模型
GLiNER是一个通用轻量级的命名实体识别模型,采用双向转换器编码器架构。它能识别任意类型的实体,填补了传统NER模型和大型语言模型之间的空白。GLiNER具有灵活性高、体积小、效率高的特点,适用于资源受限的场景。该模型支持自定义实体类型,可应用于信息提取、文本分类等多种自然语言处理任务。
GLiNER是一个能够使用双向transformer编码器(类似BERT)识别任何实体类型的命名实体识别(NER)模型。它为传统NER模型提供了一种实用的替代方案,传统模型仅限于预定义的实体,而大型语言模型(LLMs)虽然灵活,但在资源受限的场景下成本高昂且体积庞大。
<p align="center"> <a href="https://pypi.org/project/gliner/" target="_blank"> <img alt="Python" src="https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54" /> <img alt="Version" src="https://img.shields.io/pypi/v/gliner?style=for-the-badge&color=3670A0"> </a> </p> <p align="center"> <a href="https://arxiv.org/abs/2311.08526">📄 论文</a> <span> • </span> <a href="https://discord.gg/Y2yVxpSQnG">📢 Discord</a> <span> • </span> <a href="https://huggingface.co/spaces/urchade/gliner_mediumv2.1">🤗 演示</a> <span> • </span> <a href="https://huggingface.co/models?library=gliner&sort=trending">🤗 可用模型</a> <span> • </span> <a href="https://colab.research.google.com/drive/1mhalKWzmfSTqMnR0wQBZvt9-ktTsATHB?usp=sharing"> <img align="center" src="https://yellow-cdn.veclightyear.com/2b54e442/2e133510-e2ee-4a99-9532-1dfcde72bf2e.svg" /> </a> </p>探索各种示例,包括微调、ONNX转换和合成数据生成。
!pip install gliner
安装GLiNER库后,导入GLiNER
类。然后,您可以使用GLiNER.from_pretrained
加载所选模型,并使用predict_entities
识别文本中的实体。
from gliner import GLiNER # 使用基础模型初始化GLiNER model = GLiNER.from_pretrained("urchade/gliner_mediumv2.1") # 用于实体预测的示例文本 text = """ Cristiano Ronaldo dos Santos Aveiro (Portuguese pronunciation: [kɾiʃˈtjɐnu ʁɔˈnaldu]; born 5 February 1985) is a Portuguese professional footballer who plays as a forward for and captains both Saudi Pro League club Al Nassr and the Portugal national team. Widely regarded as one of the greatest players of all time, Ronaldo has won five Ballon d'Or awards,[note 3] a record three UEFA Men's Player of the Year Awards, and four European Golden Shoes, the most by a European player. He has won 33 trophies in his career, including seven league titles, five UEFA Champions Leagues, the UEFA European Championship and the UEFA Nations League. Ronaldo holds the records for most appearances (183), goals (140) and assists (42) in the Champions League, goals in the European Championship (14), international goals (128) and international appearances (205). He is one of the few players to have made over 1,200 professional career appearances, the most by an outfield player, and has scored over 850 official senior career goals for club and country, making him the top goalscorer of all time. """ # 实体预测的标签 # 大多数GLiNER模型在实体类型为小写或标题格式时效果最佳 labels = ["Person", "Award", "Date", "Competitions", "Teams"] # 执行实体预测 entities = model.predict_entities(text, labels, threshold=0.5) # 显示预测的实体及其标签 for entity in entities: print(entity["text"], "=>", entity["label"])
Cristiano Ronaldo dos Santos Aveiro => person
5 February 1985 => date
Al Nassr => teams
Portugal national team => teams
Ballon d'Or => award
UEFA Men's Player of the Year Awards => award
European Golden Shoes => award
UEFA Champions Leagues => competitions
UEFA European Championship => competitions
UEFA Nations League => competitions
European Championship => competitions
模型作者是:
如果您在研究中 发现GLiNER有用,请考虑引用我们的论文:
@misc{zaratiana2023gliner, title={GLiNER: Generalist Model for Named Entity Recognition using Bidirectional Transformer}, author={Urchade Zaratiana and Nadi Tomeh and Pierre Holat and Thierry Charnois}, year={2023}, eprint={2311.08526}, archivePrefix={arXiv}, primaryClass={cs.CL} }
本项目得到了FI Group和巴黎北部信息学实验室的支持和资助。
在过去20年里,FI Group已成为R&D&I²(研究、开发、创新和投资)公共资金策略的专家。FI Group的顾问都是工程师或博士,他们为客户提供从研发到创新生产的全程支持。
<p align="center"> <img src="https://yellow-cdn.veclightyear.com/2b54e442/a61399d0-7eef-4036-ad61-f031cfcaad17.png" alt="FI Group" width="200"/> </p>我们也衷心感谢开源社区的宝贵贡献,这对本项目的成功至关重要。
AI数字人视频创作平台
Keevx 一款开箱即用的AI数字人视频创作平台,广泛适用于电商广告、企业培训与社媒宣传,让全球企业与个人创作者无需拍摄剪辑,就能快速生成多语言、高质量的专业视频。
一站式AI创作平台
提供 AI 驱动的图片、视频生成及数字人等功能,助力创意创作
AI办公助手,复杂任务高效处理
AI办公助手,复杂任务高效处理。办公效率低?扣子空间AI助手支持播客生成、PPT制作、网页开发及报告写作,覆盖科研、商业、舆情等领域的专家Agent 7x24小时响应,生活工作无缝切换,提升50%效率!
AI辅助编程,代码自动修复
Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交 付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。
AI小说写作助手,一站式润色、改写、扩写
蛙蛙写作—国内先进的AI写作平台,涵盖小说、学术、社交媒体等多场景。提供续写、改写、润色等功能,助力创作者高效优化写作流程。界面简洁,功能全面,适合各类写作者提升内容品质和工作效率。
全能AI智能 助手,随时解答生活与工作的多样问题
问小白,由元石科技研发的AI智能助手,快速准确地解答各种生活和工作问题,包括但不限于搜索、规划和社交互动,帮助用户在日常生活中提高效率,轻松管理个人事务。
实时语音翻译/同声传译工具
Transly是一个多场景的AI大语言模型驱动的同声传译 、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。
一键生成PPT和Word,让学习生活更轻松
讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。
深度推理能力全新升级,全面对标OpenAI o1