利用知识图谱与Llama-Index技术构建大模型驱动的RAG系统(下)

描述

7、构建知识图谱索引

大模型

 

 

#setup the service context

service_context = ServiceContext.from_defaults(
    chunk_size=256,
    llm=llm,
    embed_model=embed_model
)

#setup the storage context

graph_store = SimpleGraphStore()
storage_context = StorageContext.from_defaults(graph_store=graph_store)

#Construct the Knowlege Graph Undex
index = KnowledgeGraphIndex.from_documents( documents=documents,
                                           max_triplets_per_chunk=3,
                                           service_context=service_context,
                                           storage_context=storage_context,
                                          include_embeddings=True)

8、从文档中创建知识图谱

Text: page_label: 2
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

What is an ESOP?
Triplets:
(page_label, is, 2)
(ESOP, is, What is an ESOP?)
---------------------
Text: page_label: 3
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

Why Offer an ESOP?
Triplets:
(page_label, is, 3)
(ESOP, is, Why Offer an ESOP?)
---------------------
Text: page_label: 4
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-P
(page_label, is, part of)
(page_label, is, Table of Contents)
(file_path, is, path of)
(file_path, is, /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf)
(ESOP, is, part of)
(ESOP, is, Intro to Options Plans)
(Option, is, part of)
(Option, is, Intro to Options Plans)
(Lifecycle of a Startup ESOP, is, part of)
(Lifecycle of a Startup ESOP, is, Intro to Options Plans)
(Common Terms in an Options Package, is, part of)
(Common Terms in an Options Package, is, Intro to Options Plans)
(Why Issue Options to Employees, is, part of)
(Why Issue Options to Employees, is, Intro to Options Plans)
(A Defining Characteristic of Startup Culture, is, part of)
(A Defining Characteristic of Startup Culture, is, Why Issue Options to Em
(ESOP, is, equity compensation plan)
(ESOP, is, employee stock option plan)
(ESOP, is, part of startup culture)
(ESOP, is, necessary part of capital structure)
(ESOP, is, defined characteristic of startup culture)
(ESOP, is, defined characteristic of startup culture)
(ESOP, is, defined characteristic of startup culture)
(ESOP, is, defined characteristic of startup culture)
(ESOP, is, defined characteristic of startup culture)
(ESOP, is, defined characteristic of startup culture)
(ESOP, is, defined characteristic of startup culture)
(ESOP, is, defined characteristic of startup culture)
(ESOP, is, defined characteristic of startup culture)
(ESOP, is, defined characteristic of startup culture)
(ESOP, is, defined characteristic of startup culture)
(ESOP, is, defined characteristic of startup culture)
(ESOP, is, defined characteristic of startup culture)
(ESOP, is, defined characteristic of startup culture)
(ESOP, is, defined characteristic of startup culture)
(ESOP, is, defined characteristic of startup culture)

(page_label, is, 3)
(INTRO TO OPTIONS PLANS, is, Part I)
---------------------
Text: The 2018 Annual Report of the Board of Trustees of the University of Arkansas System is presented here as a PDF file.
Triplets:
(The, is, PDF file)
(The, is presented, here)
(The, is, The 2018 Annual Report of the Board of Trustees of the University of Arkansas System)
---------------------
Text: The 2018 Annual Report of the Board of Trustees of the University of Arkansas System is presented here as a PDF file.
Triplets:
(The, is, PDF file)
(The, is presented, here)
(The, is, The 2018 Annual Report of the Board of Trustees of the University of Arkansas System)
---------------------
Text: The 2018 Annual Report of the Board of Trustees of the University of Arkansas System is presented here as a PDF file.
Triplets:
(The, is, PDF file)
(The, is presented, here)
(The,
(ESOP, is, Employee Stock Options Plan)
(ESOP, is, allocation)
(ESOP, is, plan)
---------------------
Text: page_label: 5
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

What is an ESOP?  
•An Employee Stock Options Plan (ESOP)  

•An allocation  of shares that will be granted to employees in the future
in the form of stock options  
–How much equity should we set aside for employees?  

•A plan for how these options will be distributed:  
–How many shares will individual employees receive?  
–What terms will govern these grants?  

•The plan is as important as the allocation!
Triplets:
(ESOP, is, allocation)
(ESOP, is, plan)
(ESOP, is, important)
---------------------
Text: page_label: 6
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-
(Option, is, effective form of equity ownership)
(Option, has, intrinsic value)
(Option, is, locked-in price for shares)
---------------------
Text: page_label: 1
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

What is an ESOP?  
•What is an ESOP?  
–A qualified retirement plan  
–A tax-qualified defined contribution plan  
–A plan that is primarily designed to
provide retirement benefits to employees  
–A plan that is primarily designed to
provide benefits in the form of stock  
–A plan that is primarily designed to
provide benefits in the form of stock  
–A plan that is primarily designed to
provide benefits in the form of stock  
–A plan that is primarily designed to
provide benefits in the form of stock  
–A plan that is primarily designed to
provide benefits in the form of stock  
–A plan that is primarily designed to
provide benefits in the form of stock  
–
(Option, is, right to purchase)
(Option, is, set price)
(Option, is, certain period of time)
---------------------
Text: page_label: 1
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

What is an ESOP?  
•What is an ESOP?  
–A qualified retirement plan  
–A tax-qualified plan that meets
ERISA requirements  
–A plan that is primarily designed
to provide retirement benefits to
employees  
–A plan that is primarily designed
to provide benefits in the form
of employer securities  
–A plan that is primarily designed
to provide benefits in the form
of employer securities that are
acquired through purchase,
receipt from a corporate parent,
or through the accumulation of
distributions on employer securities  
–A plan that is primarily designed
to provide benefits in the form
of employer securities that are
acquired through the accumulation
of
(Lifecycle of a Startup ESOP, involves, founders and early investors)
(Lifecycle of a Startup ESOP, involves, management and the Board of Directors)
(Lifecycle of a Startup ESOP, involves, employees)
(Employees, receive, options packages)
(Options, are, exercised)
(Options, are, granted)
(Options, are, issued)
(Options, are, marketable)
(Options, are, forfeitable)
(Options, are, vested)
(Shares, are, acquired)
(Shares, are, granted)
(Shares, are, marketable)
(Shares, are, owned)
(Shares, are, vested)
(Strike price, is, paid)
(Strike price, is, set)
(Strike price, is, specified)
---------------------
Text: page_label: 11
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

Lifecycle of a Startup ESOP  
•Found
(Common Terms in an Options Package, is, Number of Shares)
(Common Terms in an Options Package, is, Strike Price)
(Common Terms in an Options Package, is, Vesting Schedule)
(Common Terms in an Options Package, is, Cliff Period)
(Common Terms in an Options Package, is, Expiration Date)
---------------------
Text: page_label: 1
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

Executive Summary  
This document outlines the best practices for designing and implementing an employee stock option plan (ESOP) for a private company. The document is intended to provide a framework for designing an ESOP that is tailored to the specific needs of the company and its employees. The document is not intended to be a comprehensive guide to ESOP design, but rather a high-level overview of the key considerations that should be taken into account when designing an ESOP.
Triplets:
(Executive Summary, is, High-level overview)
(Executive Summary, is, Key considerations)
(Executive Summary
(Why Issue Options to Employees?, attracts, top recruits)
(Why Issue Options to Employees?, retains, employees)
(Why Issue Options to Employees?, aligns, incentives)
(Why Issue Options to Employees?, rewards, value creation)
(Why Issue Options to Employees?, encourages, long -term thinking)
---------------------
Text: page_label: 10
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

How Should Options Be Granted?  
•At the Right Time:  options should be granted at the right time in the
company’s life cycle, when the company has achieved a certain level
of success and the value of the company is clear  
•At the Right Price:  options should be granted at a fair price, based on
the company’s valuation at the time of grant  
•At the Right Size:  options should be granted in the right size, based
on the employee’s role and contribution to the company  
Triplets:
(
(Startups, are, unique case)
(Startups, use, options)
(Startups, seeking to achieve, big exit)
---------------------
Text: page_label: 10
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

The defining difference between Silicon Valley companies and almost
every other industry in the U.S. Is the virtually universal practice among
tech companies of distributing meaningful equity (usually in the form of
stock options) to ordinary employees .  A Defining Characteristic of Startup Culture  
Steven Johnson, Technology Writer  
•Startups are a unique case . Unlike at larger corporations, employee
ownership is an essential element of startup communities and culture  
–As high -risk/high -reward enterprises, startups use options to align
employee compensation with the risk -prone mentality of the
business  
–Startups seeking to achieve a “big exit” use options to align all
employees to drive toward this desired outcome
Triplets:
(Startups
(ESOP, is, necessary part of, capital structure)
(VCs, require, ESOPs)
(Startups, are compelled, to offer, options packages)
---------------------
Text: page_label: 11
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

The ESOP as a Recruitment and Retention Tool  
•ESOPs are a critical tool for recruiting and retaining employees
–In a competitive job market, ESOPs can be used to attract top talent
–In a tight labor market, ESOPs can be used to retain key employees
–In a volatile market, ESOPs can be used to retain employees during
a downturn  
–In a high-growth company, ESOPs can be used to retain employees during
a period of rapid expansion  
–In a company with a high employee turnover rate, ESOPs can be used to
reduce turnover and associated costs  
–In a company with a high executive turnover rate, ESOPs can be used to
(page_label: 11, is, stage)
(stage, is, pre-seed)
(stage, is, seed)
(stage, is, early -vc)
---------------------
Text: page_label: 11
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

page_label: 12
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

page_label: 13
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

page_label: 14
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

page_label: 15
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices
(ESOP, is necessary for, Pre-seed)
(ESOP, is not necessary for, Pre-seed)
(ESOP, can be helpful for, Pre-seed)
(ESOP, is not necessary for, Seed)
(ESOP, is required for, Early -VC)
(ESOP, must be created for, Early -VC)
(ESOP, serves as a guideline for, Early -VC)
(ESOP, is important to have standardized for, Late-VC)
(ESOP, is gone for, Growth)
(ESOP, shares remaining are more valuable for, Growth)
(ESOP, is used to allow new hires to share in the upside for, Growth)
(ESOP, should be set up between, Pre-seed and, Early -VC)
---------------------
Text: page_label: 12
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

How Much Equity Should You Grant?  
Stage  Considerations  Takeaway  
Pre-seed  Found
(Communicating options to employees, can be communicated, % versus $)
(Communicating options to employees, can be communicated, %)
(Communicating options to employees, can be communicated, $)
(Communicating options to employees, can be communicated, 0.5%)
(Communicating options to employees, can be communicated, $200,000)
---------------------
Text: page_label: 13
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

Exercise Price: Market Price vs. Discount  
When setting the exercise price for options, there are two
approaches: (1) set the price equal to the market price of
the stock at the time of grant, or (2) set the price at a
discount to the market price.  
Market Price:  
•Fair to employees and the company  
•No tax deduction for company
•Employees can sell immediately
•Employees can exercise immediately
Discount:
(Communication of options packages, recommended, dollar value)
(Communication of options packages, recommended against, percent of the company)
(Communication of options packages, effective when, dollar value)
---------------------
Text: page_label: 13
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

or (2) a dollar value based on the
current valuation; we encourage the latter when possible  
% $
“We are granting you options equivalent to
0.5% of the company’s equity”  
Considerations:  
•At an early stage, the only way
to communicate options grants given no true
valuation of the company  
•Hard for employees to grasp  what they
are really getting (“0.5% seems too little”)  
•Invites a negotiation  about what percent
of the company an employee really
deserves  “We are granting you options equivalent to
$200,000 of company stock”  
Considerations
(page_label, is, 12)
(file_path, is, /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf)
(5%, is, equivalent to)
(5%, is, $200,000 of company stock)
(Considerations, is, highly effective way to communicate the true value of an options grant)
---------------------
Text: The 2018 FIFA World Cup was the 21st FIFA World Cup, an international men's football tournament contested by the national teams of FIFA member associations. It took place in Russia from 14 June to 15 July 2018. It was the first World Cup to be held in Eastern Europe, and the 11th time that it had been held in Europe. At an estimated cost of over $14.2 billion, it is the most expensive World Cup.
Triplets:
(2018 FIFA World Cup, is, 21st FIFA World Cup)
(2018 FIFA World Cup, took place in, Russia)
(201
(HOW MUCH TO GRANT, Part II, )
---------------------
Text: page_label: 13
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

HOW MUCH TO GRANT  Part II
Triplets:
(HOW MUCH TO GRANT, Part II, )
---------------------
Text: page_label: 13
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

HOW MUCH TO GRANT  Part II
Triplets:
(HOW MUCH TO GRANT, Part II, )
---------------------
Text: page_label: 13
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

HOW MUCH TO GRANT  Part II
Triplets:
(HOW MUCH TO GRANT, Part II, )
----------------
(Two Approaches, is, reality)
(Creating an ESOP, requires, a combination of top-down and bottom -up planning)
(Decide the total amount of equity to be granted, is, part of creating an ESOP)
(Allocate these shares to employees over time, is, part of creating an ESOP)
(Decide the appropriate size of individual equity grants by position, is, part of creating an ESOP)
(Issue these shares as employees are hired, is, part of creating an ESOP)
---------------------
Text: page_label: 15
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

Two Approaches  
In reality, creating an ESOP will require a combination of
top-down and bottom -up planning  Top Down  Bottom Up  
Decide the total amount of
equity to be granted; allocate
these shares to employees
over time  Decide the appropriate size of
individual equity grants by
position; issue these shares as
employees are
(Top -Down Process, consists of, determining)
(Top -Down Process, consists of, creating)
(Top -Down Process, consists of, scheduling)

Text: page_label: 16
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

The Bottom -Up Process  
1.Determine the number of shares to be granted to each employee  
2.Determine the grant date  
3.Determine the vesting schedule  
Triplets:
(Bottom -Up Process, consists of, determining)
(Bottom -Up Process, consists of, determining)
(Bottom -Up Process, consists of, determining)

Text: page_label: 17
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

The Bottom -Up Process (continued)  
1.Determine the exercise price  
2.Determine the expiration date  
Triplets:
(Bottom -Up Process, consists
(page_label, is, 16)
(page_label, represents, how much equity to set aside in the esop)
(page_label, has, values of 15-20% for generally non-founder employees)
---------------------
Text: The 2018-19 budget for the Department of Energy (DOE) includes $3.7 billion for the Office of Science (SC), an increase of $645 million (21.1%) over the 2018 enacted level.
Triplets:
(The, 2018-19 budget for the Department of Energy, includes, $3.7 billion for the Office of Science)
(The, 2018-19 budget for the Department of Energy, is, an increase of $645 million over the 2018 enacted level)
(The, 2018-19 budget for the Department of Energy, represents, a 21.1% increase over the 2018 enacted level for the Office of Science)
---------------------
Text: The 2018
(page_label, is, 16)
(file_path, is, /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf)
(no, is, 0)
(technology emphasis, is, 0)
(geographic focus, is, region that is not considered a startup hub)
(hiring needs, are primarily, administrative or back -office team members)
(percentage of company issued to non founder employees, is between, 15% and 20%)
(founders, are, top managers, but hire others to fill key technical or functional roles)
(dna of the company, is, applying technology to a non -technical industry)
(geographic focus, is, either wholly or partially in a startup hub)
(hiring needs, are primarily, sales and marketing team members)
(founders, are not top managers in the business, or plan to step aside)
(dna of the company, is, technology, engineering, or data science)
(geographic focus, is, in a leading startup hub such as sf,
(page_label, is, 16)
(file_path, is, /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf)
(companies, issue, up to 25%)
(founders, are, top managers)
(founders, are not, top managers in the business, or)
(DNA, is, in applying technology to a non -technical industry)
(DNA, is, in technology, engineering, or data science)
(geographic focus, is, wholly or partially in a startup hub)
(geographic focus, is, in a leading startup hub such as SF, NYC or Boston)
(hiring needs, are, primarily sales and marketing team members)
(hiring needs, are, primarily engineering, development, or technical team members)
---------------------
Text: The 2018-19 season of the National Basketball Association (NBA) is the 72nd season of the National Basketball Association.
Triplets:
(2018-19 season, is, the 7
(Typical Distribution Schedule, consists of, Seniority)
(Typical Distribution Schedule, consists of, Equity Allocation)
(First, consists of, 10%)
(Next, consists of, 5%)
(Next, consists of, 5%)
(CTO, consists of, 1-5%)
(Key Developer or Engineer, consists of, 1-2%)
(Other Functional Team Member, consists of, 0.5-1.5%)
(No non -founding member of the senior team, should not exceed, 10%)
---------------------
Text: page_label: 18
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

3. Vesting Schedule  
•Four year vesting schedule is most common.  
•Cliff vesting is less common, but can be used to retain key employees.  
•Monthly vesting is less common, but can be used to align employee interests with company performance.  
Triplets:
(Vesting Schedule, is most common
(Bottom -Up Process, consists of, Segment your human resources)
(Bottom -Up Process, consists of, Create pay multipliers for each job function)
(Bottom -Up Process, consists of, Determine the dollar value of an options grant)
(Bottom -Up Process, consists of, Determine the current share price)
(Bottom -Up Process, consists of, Calculate options grants)
---------------------
Text: page_label: 19
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

The Top-Down Process  
1.Determine the total dollar amount to be spent on options  
2.Determine the number of shares to be reserved for options  
3.Determine the number of options to be granted  
4.Determine the exercise price  
5.Determine the vesting schedule  
Triplets:
(Top-Down Process, consists of, Determine the total dollar amount to be spent on options)
(Top-Down Process, consists of, Determine the number of shares to be reserved for options)
(Top-
(Segment Your Human Resources, is, segmentation)
(Segment Your Human Resources, has, Segment  Roles)
(Segment Your Human Resources, has, Award)
---------------------
Text: page_label: 20
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

2. Communicate Early and Often  
•Communicate the plan to all employees as soon as possible  
•Communicate the plan to all new hires as part of their orientation  
•Communicate the plan to all employees at least annually  
•Communicate the plan to all employees when there is a material change  
Triplets:
(Communicate Early and Often, is, communication)
(Communicate Early and Often, has, Communicate the plan to all employees as soon as possible)
(Communicate Early and Often, has, Communicate the plan to all new hires as part of their orientation)
(Communicate Early and Often, has, Communicate the plan to all employees at least annually)
(Communicate Early and Often,
(2, establish, Pay Multipliers for Each Role)
(Segment, Roles, 2)
(Segment, Award, ?)
---------------------
Text: page_label: 21
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

3. Establish Vesting Schedules  
Segment  Vesting Schedule  
in Years or %?
Triplets:
(3, establish, Vesting Schedules)
(Segment, Vesting Schedule, ?)
---------------------
Text: page_label: 22
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

4. Establish Performance Criteria  
Segment  Performance Criteria  
in % or $?
Triplets:
(4, establish, Performance Criteria)
(Segment, Performance Criteria, ?)
---------------------
Text: page_label: 23
file_path: /content/Documents/Employee-Stock-Option-
(page_label, is, 20)
(2, establish, Pay Multipliers for Each Role)
(Segment, is, Roles)
(Segment, is, Award)
(Segment, is, Options Multiplier)
(Segment, is, Founders)
(Segment, is, Co-Founders)
(Segment, is, %)
(Segment, is, Founding Team)
(Segment, is, Technical & Product)
(Segment, is, Early -Stage Hires)
(Segment, is, Senior Team)
(Segment, is, C-Level)
(Segment, is, Directors / VPs)
(Segment, is, Functional / Technical Team)
(Segment, is, Support Team)
(Segment, is, $)
(Segment, is, 0.5x)
(Segment, is, 1.0x)
(Segment, is, 0.25x)
(Segment, is, 0.5x)
(Segment, is, 0.1x)
(Segment, is, 0.0x)
(page_label, is, 2)

(Employee, Base Salary, x)
(Employee, Options, x)
(Employee, Options Multiplier, based on the employee’s role in HR segmentation schedule)
---------------------
Text: page_label: 21
file_path: /content/Documents/Employee-Stock-Option-Plans-ESOP-Best-Practices-2.pdf

3. Determine the Dollar Value of the Options Grant  
Employee  
Base Salary  = x Options  
Multiplier  Dollar Value  
of Options Grant  Base Salary as negotiated with
the employee at the time of hire
or promotion  
Options Multiplier is decided
based on the employee’s role in
the HR segmentation schedule
Triplets:
(Employee, Base Salary, x)
(Employee, Options, x)
(Employee, Options Multiplier, based on the employee’s role in HR segmentation schedule)
---------------------
Text: page_label: 21
file_path: /content/Documents/Employ

9、构建查询引擎来查询知识图谱

query = 'What is ESOP?'
query_engine = index.as_query_engine(include_text=True,
                                     response_mode ='tree_summarize',
                                     embedding_mode='hybrid',
                                     similarity_top_k=5,)
#
message_template =f'''<|system|>Please check if the following pieces of context has any mention of the  keywords provided in the Question.If not then don't know the answer, just say that you don't know.Stop there.Please donot try to make up an answer.
<|user|>
Question: {query}
Helpful Answer:
'''
#
response = query_engine.query(message_template)
#
print(response.response.split('<|assistant|>')[-1].strip())
#####OUTPUT #####################
ESOP stands for Employee Stock Ownership Plan. It is a retirement plan that allows employees to receive company stock or stock options as part of their compensation. In simpler terms, it is a plan that allows employees to own a portion of the company they work for. This can be a motivating factor for employees as they have a direct stake in the company's success. ESOPs can also be a tax-efficient way for companies to provide retirement benefits to their employees.


query ='Who is Atul?'
message_template =f'''<|system|>Please check if the following pieces of context has any mention of the  keywords provided in the Question.If not then don't know the answer, just say that you don't know.Stop there.Please donot try to make up an answer.
<|user|>
Question: {query}
Helpful Answer:
'''
#
response = query_engine.query(message_template)
#
print(response.response.split('<|assistant|>')[-1].strip())

################OUTPUT#####################
I do not have prior knowledge or context about who atul is. Please provide more information or context so I can assist you better. Without any further context, I do not know the answer to your question.

10、可视化表示

from pyvis.network import Network
from IPython.display import display
g = index.get_networkx_graph()
net = Network(notebook=True,cdn_resources='in_line',directed=True)
net.from_nx(g)
net.show('graph.html')
net.save_graph('Knowledge_graph.html')
#
import IPython
IPython.display.HTML(filename='/content/Knowledge_graph.html')

11、持久化保存

storage_context.persist()

总结

对于语言模型(LLM)幻觉,知识图谱被证明优于向量数据库。知识图谱提供更准确、多样化、有趣、逻辑和一致的信息,减少了LLM中出现幻觉的可能性。这种优越性源于它们能够提供关于实体之间关系的精确细节,而不仅仅是表示相似性,支持更复杂的查询和逻辑推理。

向量数据库以其数字数组在相似性搜索和最佳匹配场景中表现出色。最终,两者之间的选择取决于项目的需求,包括数据的性质、关系探索的需要以及预期的查询类型。

审核编辑:黄飞

打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分