微信扫码
与创始人交个朋友
我要投稿
最近在默沙东制药的内部研讨会分享了一下我们医学图书馆如何利用知识图谱和大模型技术构建文档级别知识图谱和打标签能力并应用于智能知识库建设以及推荐和检索、问答等应用场景。
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+中大型企业
2024-12-21
SAC-KG:利用大型语言模型一键构建领域知识图谱 - 中科大&阿里
2024-12-19
北大Chatlaw - 基于知识图谱增强混合专家模型的多智能体法律助手
2024-12-18
Elasticsearch vs 向量数据库:寻找最佳混合检索方案
2024-12-16
轻量高效的知识图谱RAG系统:LightRAG
2024-12-16
5种方法,让文本信息瞬间变成结构化图谱!
2024-12-16
向量数据库到底算不算一种NoSQL数据库?
2024-12-14
大模型能自动创建高质量知识图谱吗?可行性及人机协同机制 - WhyHow.AI
2024-12-12
大模型+知识图谱在工业领域落地的4大场景
2024-07-17
2024-07-11
2024-08-13
2024-07-13
2024-07-12
2024-06-24
2024-07-08
2024-06-10
2024-07-26
2024-07-04
2024-12-16
2024-12-10
2024-12-04
2024-12-01
2024-11-30
2024-11-22
2024-11-04
2024-10-10