2026年7月9日 周四晚上19:30,报名腾讯会议了解“如何构建自进化的动态知识库(Brain)”(限30人)
免费POC, 零成本试错
FDE知识库

FDE知识库

学习大模型的前沿技术与行业落地应用


收藏

专业法律知识问答智能体|Crew.ai 项目分享

发布日期:2025-01-22 07:35:07 浏览次数: 2830
作者:木乐乐的异想世界

微信搜一搜,关注“木乐乐的异想世界”

推荐语

这是一个有趣的法律 AI 助手项目分享。

核心内容:
1. 项目的技术架构
2. “专家团队”的设计
3. 分工协作的工作流程

杨芳贤
53AI创始人/腾讯云(TVP)最具价值专家

”随着人工智能技术的发展,如何让 AI 落地服务于特定的专业领域成为一个重要课题。“



今天,我们来看一个有趣的开源项目 LawGlance。这是一个印度团队开发的法律 AI 助手。 


为什么想要分享呢?


首先,这是一个基于 Crew.AI 的多智能体工作流案例,而且结合智能体框架LangChain 和 向量数据库Chroma ,又有多文档知识库配置,使用聊天的模式,实现法律问题的精准检索和回答。 


接下来,我们逐一拆解。


一、项目核心技术架构

这个项目主要使用了四个核心技术: 

  • Crew.AI:负责管理多个 AI "专家"的协作
  • LangChain:处理 AI 应用的整体流程
  • ChromaDB:存储和检索法律文档
  • OpenAI API:提供语言理解能力


如下,是整个项目类的设计: 

二、Crew.AI "专家团队"的设计

LawGlance 的特别之处在于采用了多个 AI "专家"协同工作的方式,就像一个虚拟的法律顾问团队。项目中,设计了四位 AI "专家",每位都有自己的专长: 

而且这些"专家"的工作流程非常清晰: 


首先由检索专家找到相关法律文档,然后法律顾问根据这些文档回答问题,评估专家验证答案的准确性,最后由编辑专家优化表达。这种分工协作的方式大大提高了回答的质量。 


 

检索专家(Retriever Agent):负责快速找到相关的法律文档。使用到了向量数据库工具。chroma_tool。 

retriever_agent = Agent(
    role='Retriever Agent',
    goal='Retrieve relevant content about "{query}" from the vector store.',
    backstory=("You are skilled at searching the vector store for user queries and fetching relevant documents."
               "Your ability to find and retrieve relevant content ensures accurate reports."),
    verbose=True,
    memory = True,
    tools=[chroma_tool],
    llm=llm
)

 

法律顾问(Legal Assistant Agent):负责解答法律问题。特别要注意的是,如果在知识库里没有对应的法律条款,法律顾问会启动联网检索。使用到了工具 Tools 为 web_search_tool。  

legal_assistant_agent = Agent(
    role="Legal Assistant Agent",
    goal="Generate responses for the {query} based on retrieved documents only",
    backstory=
    "You are a lawyer assistant LawGlance and you answer for legal related queries"
    "You create informative responses using the data provided by the retriever task only"
    "If an informative response can't be provided from the documents you should use websearch tool and respond based on it.",
    verbose=True,
    memory = True,
    allow_delegation=False,
    tools = [web_search_tool],
    llm=llm
)

 

评估专家(Evaluation Agent):确保答案的准确性。  

evaluation_agent = Agent( 

role="Evaluation Expert Agent", 

goal="Verify and evaluate the accuracy and authenticity of responses created by retriever and generator agents.", 

backstory= 

"You are an evaluation expert in the LawGlance ecosystem. " 

"Your primary task is to validate the responses generated by the retriever and generator agents. " 

"You check for accuracy, relevance, and authenticity of the content before it reaches the customer.", 

verbose=True, 

memory=False, 

allow_delegation=False, 

tools = [web_search_tool], 

llm=llm 

) 

 

编辑专家(Editor Agent):让回答更容易理解。 

editor_agent = Agent(
    role="Editor Agent",
    goal="Create a concise and edited output for '{query}' based on the generated response.",
    backstory=(
        "You are an Editor tasked with refining the generated responses."
        "You ensure that the final output is concise,to the point, relevant, and properly formatted without any hallucinations."
        "For responses generated using web search, you must include the source of the information."
    ),
    verbose=True,
    memory=False,
    llm=llm
)

 

三、技术亮点分析

项目有几个特别值得关注的技术亮点: 

 

精准检索技术

项目使用了向量数据库技术Chroma,可以理解问题的含义而不是简单的关键词匹配。比如当你问"我可以在什么情况下解除劳动合同",系统会理解这是一个关于劳动法的问题,并找到相关法律条款。 


智能协作机制

各个 AI "专家"之间的配合就像真实的团队协作。每个专家都会把自己的工作结果传递给下一位,同时共享必要的上下文信息,确保整个过程的连贯性。 

 

对话记忆功能

系统能够记住对话的上下文,这意味着你可以进行连续的对话。比如在问完"什么是知识产权"后,直接问"如何保护它",系统也能理解你指的是知识产权。 

 

四、实际应用案例

让我们看一个具体的使用例子: 


用户: "What is relevant articles dealing with freedom of speech"? 系统:[检索相关法律文档] → [生成初步回答] → [验证准确性] → [优化表达] 最终回答:Articles related to freedom of speech in the Indian Constitution are encapsulated mainly in **Article 19**...。 

 

1-Agent: Retriever Agent 检索专家

从向量数据库中检索出 5 篇与言论自由相关的文章。并且提供了对应的原文 Content。 

1. Document Source: [Indian Constitution](https://cdnbbsr.s3waas.gov.in/s380537a945c7aaa788ccfcdf1b99b5d8f/uploads/2024/07/20240716890312078.pdf)
   - Content: "Prohibited and any contravention of this provision shall be an offence punishable in accordance with law. (2) Nothing in this article shall prevent the State from imposing compulsory service for public purposes, and in imposing such service the State shall not make any discrimination on grounds only of religion, race, caste, or class or any of them. Article 24. Prohibition of employment of children in factories, etc.—No child below the age of fourteen years shall be employed to work in any factory or mine or engaged in any other hazardous employment. Right to Freedom of Religion Article 25. Freedom of conscience and free profession, practice and propagation of religion.—(1) Subject to public order, morality and health and to the other provisions of this Part, all persons are equally entitled to freedom of conscience and the right freely to profess, practice, and propagate religion. (2) Nothing in this article shall affect the operation of any existing law or…"

2. Document Source: [Indian Constitution](https://cdnbbsr.s3waas.gov.in/s380537a945c7aaa788ccfcdf1b99b5d8f/uploads/2024/07/20240716890312078.pdf)
   - Content: "No citizen of India shall accept any title from any foreign State. (3) No person who is not a citizen of India shall, while he holds any office of profit or trust under the State, accept without the consent of the President any title from any foreign State. (4) No person holding any office of profit or trust under the State shall, without the consent of the President, accept any present, emolument, or office of any kind from or under any foreign State. Right to Freedom Article 19. Protection of certain rights regarding freedom of speech, etc.—(1) All citizens shall have the right—(a) to freedom of speech and expression; (b) to assemble peaceably and without arms; (c) to form associations or unions or co-operative societies; (d) to move freely throughout the territory of India; (e) to reside and settle in any part of the territory of India…"

3. Document Source: [Indian Constitution](https://cdnbbsr.s3waas.gov.in/s380537a945c7aaa788ccfcdf1b99b5d8f/uploads/2024/07/20240716890312078.pdf)
   - Content: "No person shall be deprived of his life or personal liberty except according to procedure established by law. Article 21A. Right to education.—The State shall provide free and compulsory education to all children of the age of six to fourteen years in such manner as the State may, by law, determine. Article 22. Protection against arrest and detention in certain cases.—(1) No person who is arrested shall be detained in custody without being informed, as soon as may be, of the grounds for such arrest nor shall he be denied the right to consult, and to be defended by, a legal practitioner of his choice…"

4. Document Source: [Indian Constitution](https://cdnbbsr.s3waas.gov.in/s380537a945c7aaa788ccfcdf1b99b5d8f/uploads/2024/07/20240716890312078.pdf)
   - Content: "No person shall be compelled to pay any taxes, the proceeds of which are specifically appropriated in payment of expenses for the promotion or maintenance of any particular religion or religious denomination. Article 28. Freedom as to attendance at religious instruction or religious worship in certain educational institutions.—(1) No religious instruction shall be provided in any educational institution wholly maintained out of State funds…"

5. Document Source: [Indian Constitution](https://cdnbbsr.s3waas.gov.in/s380537a945c7aaa788ccfcdf1b99b5d8f/uploads/2024/07/20240716890312078.pdf)
   - Content: "The right to move the Supreme Court by appropriate proceedings for the enforcement of the rights conferred by this Part is guaranteed..."

These documents highlight various articles related to freedom of speech and its context within the Indian Constitution.


2-Agent: Legal Assistant Agent 法律顾问

根据检索专家提供的原文资料,识别出与印度的言论自由相关性最高的文章是Article 19,并且提供了对应的理由。 

# Agent: Legal Assistant Agent## Final Answer: 
Articles related to freedom of speech in the Indian Constitution are primarily encapsulated in Article 19. Specifically:

1. **Article 19(1)(a)**: This article guarantees all citizens the right to freedom of speech and expression. It serves as the foundational legal provision that upholds the principle of free speech in India.

2. **Article 19(2)**: While Article 19(1)(a) ensures freedom of speech, Article 19(2) stipulates that this freedom is not absolute and can be subject to "reasonable restrictions." These restrictions can be imposed in the interest of:
   - Sovereignty and integrity of India
   - Security of the State
   - Friendly relations with foreign States
   - Public order
   - Decency or morality
   - Contempt of court
   - Defamation
   - Incitement to an offence

The balance between freedom of speech and the need for regulation is a critical aspect of legal discourse in India, with various court rulings interpreting these articles in different contexts. For instance, the Supreme Court has affirmed the constitutionality of pre-censorship in films, indicating that some limitations on free expression can be legally upheld.

Thus, the right to free speech in India, as enshrined in Article 19, is a complex interplay of rights and restrictions, reflecting the challenges in ensuring both individual liberties and societal interests.

 

3-Agent: Evaluation Expert Agent评估专家

评估和肯定法律顾问提出的,Article 19 是关联性最高的文章。并且给了对应的评估理由。 

# Agent: Evaluation Expert Agent## Final Answer: 
Articles related to freedom of speech in the Indian Constitution are primarily encapsulated in Article 19. Specifically:

1. **Article 19(1)(a)**: This article guarantees all citizens the right to freedom of speech and expression. It serves as the foundational legal provision that upholds the principle of free speech in India.

2. **Article 19(2)**: While Article 19(1)(a) ensures freedom of speech, Article 19(2) stipulates that this freedom is not absolute and can be subject to "reasonable restrictions." These restrictions can be imposed in the interest of:
   - Sovereignty and integrity of India
   - Security of the State
   - Friendly relations with foreign States
   - Public order
   - Decency or morality
   - Contempt of court
   - Defamation
   - Incitement to an offence

The balance between freedom of speech and the need for regulation is a critical aspect of legal discourse in India, with various court rulings interpreting these articles in different contexts. For instance, the Supreme Court has affirmed the constitutionality of pre-censorship in films, indicating that some limitations on free expression can be legally upheld.

Thus, the right to free speech in India, as enshrined in Article 19, is a complex interplay of rights and restrictions, reflecting the challenges in ensuring both individual liberties and societal interests.

Accuracy: 100%

 

4-Agent: Editor Agent 编辑专家

负责将最终的答案编辑完善,形成用户阅读有好的结论。 

# Agent: Editor Agent## Final Answer: 
Articles related to freedom of speech in the Indian Constitution are encapsulated mainly in **Article 19**. **Article 19(1)(a)** guarantees the right to freedom of speech and expression, while **Article 19(2)** outlines reasonable restrictions on this freedom to protect interests such as public order and morality. This dynamic between rights and restrictions is frequently interpreted by the courts, highlighting the balance between individual liberties and societal interests.

 

最后,说一点感悟。大模型应用上的各种幻觉和专业度不足的问题,在行业里,基本都是通过 RAG 技术解决。但是,只用 RAG 也只能解决知识关联和参考的问题。没办法能够保证答案输出的精准度。 


而,LawGlance 项目展示了如何将先进的 AI 技术应用到专业领域。通过多个 AI "专家"的协作,实现了准确、可靠的法律问答服务。这个开源项目不仅为法律服务提供了新的可能,也为其他专业领域的 AI 应用提供了有价值的参考。 

 

github 项目地址:https://github.com/lawglance/lawglance 


53AI,企业落地大模型首选服务商

产品:场景落地咨询+大模型应用平台+行业解决方案

承诺:免费POC验证,效果达标后再合作。零风险落地应用大模型,已交付160+中大型企业

联系我们

售前咨询
186 6662 7370
预约演示
185 8882 0121

微信扫码

添加专属顾问

回到顶部

加载中...

扫码咨询

扫码登录
登录即表示您同意《53AI网站服务协议》
服务协议

欢迎您使用【53AI 官方网站】(以下简称“本网站”或“我们”)。本《会员服务协议》(以下简称“本协议”)是您(以下简称“会员”或“用户”)与【深圳市博思协创网络科技有限公司】之间关于注册、登录及使用本网站会员服务所订立的法律协议。

在您注册或登录前,请务必审慎阅读、充分理解各条款内容,特别是免除或限制责任的条款、知识产权条款、争议解决条款等。此类条款将以加粗形式提示您注意。 当您通过微信公众号授权、手机验证码验证或其他方式成功登录本网站时,即视为您已完全理解并同意接受本协议的全部内容。

一、 定义

本网站:指由【深圳市博思协创网络科技有限公司】运营的,域名为【53ai.com】的网站及相关移动端页面。

会员服务:指本网站向注册会员提供的知识库文章查阅、内容检索及其他相关增值服务。

知识库内容:指本网站发布的包括但不限于文字、图表、数据、研究报告、行业分析等数字化内容资源。

二、 账号注册与登录

登录方式:本网站支持以下登录方式,您可根据实际情况选择:

微信公众号授权登录:您同意将您的微信OpenID信息授权给本网站,用于创建或关联会员账号。

手机验证码登录:您需提供真实有效的手机号码,并通过短信验证码完成身份验证与登录/注册。

账号安全:您的账号仅限您本人使用,禁止赠与、借用、租用、转让或售卖。因您保管不善导致的账号被盗、密码泄露等损失,由您自行承担。

实名认证:根据相关法律法规要求,我们可能要求您在特定功能下完成实名认证。如您拒绝提供,可能无法使用部分或全部服务。

未成年人保护:若您未满18周岁,请在法定监护人的陪同下阅读本协议,并在征得监护人同意后使用本服务。

三、 服务内容与规范

知识库查阅权限:会员登录后,有权按照其会员等级对应的权限范围,在线浏览、检索本网站知识库中的相关文章及内容。

服务变更:我们有权根据业务发展需要,调整、变更或终止部分服务内容,并将以网站公告、公众号消息等方式提前通知。

禁止行为:您在使用服务时不得实施以下行为:

利用技术手段批量爬取、下载、转存知识库内容;

将知识库内容用于商业目的或未经授权地向第三方传播;

干扰本网站正常运行或侵犯其他用户合法权益;

发布违法违规信息或从事违反公序良俗的活动。

四、 知识产权声明

权利归属:本网站知识库中的排版设计、软件代码等内容的知识产权均归【公司全称】或原权利人所有,受《中华人民共和国著作权法》等法律保护。

有限许可:本网站授予会员一项非独占、不可转让、不可转授权的普通许可,仅限于个人学习、研究之目的在线查阅知识库内容。

侵权追责:未经书面许可,任何单位或个人不得以任何形式复制、转载、摘编、镜像、汇编或以其他方式使用上述内容。一经发现,我们保留追究其法律责任的权利。

五、 个人信息保护

我们重视对您个人信息的保护。关于我们如何收集、使用、存储和保护您的个人信息,请单独阅读 《隐私政策》。

您通过微信公众号授权或手机号验证所提供的信息,我们将严格按照《个人信息保护法》的规定处理,仅用于身份识别、服务提供及安全验证等必要用途。

您可以随时通过网站设置或联系客服行使查阅、更正、删除个人信息及撤回授权同意的权利。

六、 免责声明

内容准确性:知识库内容仅供参考,不构成专业建议。我们不对其完整性、准确性、时效性作任何明示或暗示的保证,您应自行判断并承担使用风险。

不可抗力:因自然灾害、政策法规变化、网络故障、第三方平台接口异常(如微信接口维护、运营商短信通道故障)等不可抗力导致的服务中断或延迟,我们不承担违约责任。

第三方链接:本网站可能包含指向第三方网站的链接,该等网站的内容和服务不受我们控制,请您自行甄别风险。

七、 违约责任

如您违反本协议约定,我们有权视情节采取警告、限制功能、暂停服务、注销账号等措施,并保留要求赔偿损失的权利。

如因您的违约行为导致我们遭受行政处罚、第三方索赔或商誉损失,您应承担全部赔偿责任(包括但不限于罚款、赔偿金、律师费、公证费等)。

八、 法律适用与争议解决

本协议的订立、执行和解释均适用中华人民共和国大陆地区法律。

因本协议产生的或与本协议有关的任何争议,双方应友好协商解决;协商不成的,任何一方均可向【公司所在地】有管辖权的人民法院提起诉讼。

九、 其他

本协议构成双方就本服务达成的完整协议,取代此前任何口头或书面约定。

本协议任一条款被认定为无效或不可执行的,不影响其他条款的效力。

我们对本协议享有最终解释权,并在法律允许的范围内保留随时修改的权利。修改后的协议一经公布即生效,继续使用服务即视为同意修订内容。


已查阅