微信扫码
添加专属顾问
我要投稿
最近在默沙东制药的内部研讨会分享了一下我们医学图书馆如何利用知识图谱和大模型技术构建文档级别知识图谱和打标签能力并应用于智能知识库建设以及推荐和检索、问答等应用场景。
from gliner import GLiNER
#Model Initialization
model = GLiNER.from_pretrained("numind/NuNerZero")
#Merging and Displaying Entities
# NuZero requires labels to be lower-cased!
labels=[
"people",
"organizations",
"concepts/terms",
"principles",
"documents",
"dates"
]
labels = [l.lower() for l in labels]
text = content_process
entities = model.predict_entities(text, labels)
entities = merge_entities(entities)
for entity in entities:
print(entity["text"], "=>", entity["label"])
import openai
import json
# Function to generate entities and relationships from the given text using OpenAI's API
def generate_entities_and_relationships(text, api_key):
# Set the OpenAI API key
openai.api_key = api_key
# Create the prompt that will be sent to the OpenAI API.
# The prompt asks the model to identify entities and relationships within the provided text
# and format the response in JSON format.
prompt = f"""
Given the following text, identify the main entities and their relationships:
Text: {text}
Please provide the output in the following JSON format:
{{
"entities": [
{{"name": "Entity1", "type": "PersonType"}},
{{"name": "Entity2", "type": "OrganizationType"}},
...],
"relationships": [
{{"subject": "Entity1", "predicate": "works_for", "object": "Entity2"}},
{{"subject": "Entity2", "predicate": "located_in", "object": "Entity3"}},
...]}}"""
# Send the request to the OpenAI API using the 'gpt-3.5-turbo' model.
# The API call is structured as a chat completion with system and user messages.
response = openai.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "system", "content": "You are a helpful assistant that identifies entities and relationships in text."},
{"role": "user", "content": prompt}
]
)# Extract and clean up the response by removing extra characters or code format markers
result = response.choices[0].message.content.strip().strip('```json').strip().strip('```')
return json.loads(result)
iText2KG:使用大型语言模型构建增量知识图谱
知识图谱增强大模型GraphRAG全面综述解读 - 蚂蚁集团、北大、浙大、人大等
“大模型+知识图谱”双轮驱动的医药数智化转型新范式-OpenKG TOC专家谈
LLMs用于知识图谱系列之一:将文本以超高速转换为高质量知识图谱
LLMs大模型生成知识图谱系列之二:GPT提示工程创建知识图谱实践
GraphRAG + GPT-4o mini 低成本构建 AI 图谱知识库
53AI,企业落地大模型首选服务商
产品:场景落地咨询+大模型应用平台+行业解决方案
承诺:免费场景POC验证,效果验证后签署服务协议。零风险落地应用大模型,已交付160+中大型企业
2025-04-09
LLM知识图谱构建器:前端架构如何革新数据可视化?
2025-04-07
解决Dify与Milvus集成难题:从零到一的实战避坑指南
2025-04-07
别只看LLM!为什么知识图谱才是通往AGI的关键一步
2025-04-07
腾讯ima支持Markdown格式了,开心了一会又不开心了
2025-04-07
公安专业知识库的构建:DeepSeek大模型技术赋能智慧警务新未来
2025-04-06
Stardog-基于知识图谱的企业级人机协同Agent智能体
2025-04-06
大型知识库文档高效分块实践:从基础到进阶
2025-04-05
向量数据库 Milvus :为什么都在用它实现搜索效率提升
2025-01-02
2024-07-17
2024-08-13
2025-01-03
2024-07-11
2024-08-27
2024-06-24
2024-07-13
2024-07-12
2024-06-10
2025-04-09
2025-03-29
2025-02-13
2025-01-14
2025-01-10
2025-01-06
2025-01-02
2024-12-16