微信扫码
与创始人交个朋友
我要投稿
这是一个有趣的法律 AI 助手项目分享。 核心内容: 1. 项目的技术架构 2. “专家团队”的设计 3. 分工协作的工作流程
”随着人工智能技术的发展,如何让 AI 落地服务于特定的专业领域成为一个重要课题。“
今天,我们来看一个有趣的开源项目 LawGlance。这是一个印度团队开发的法律 AI 助手。
为什么想要分享呢?
首先,这是一个基于 Crew.AI 的多智能体工作流案例,而且结合智能体框架LangChain 和 向量数据库Chroma ,又有多文档知识库配置,使用聊天的模式,实现法律问题的精准检索和回答。
接下来,我们逐一拆解。
这个项目主要使用了四个核心技术:
如下,是整个项目类的设计:
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**...。
从向量数据库中检索出 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.
根据检索专家提供的原文资料,识别出与印度的言论自由相关性最高的文章是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.
评估和肯定法律顾问提出的,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%
负责将最终的答案编辑完善,形成用户阅读有好的结论。
# 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+中大型企业
2025-01-22
DeepSeek v3为何爆火?如何用其集成Milvus搭建RAG?
2025-01-22
DeepSeek-R1-Distill-Qwen-1.5B 在某些基准测试中超越了 GPT-4o
2025-01-22
一个智能的AI操作系统OS,开源!
2025-01-22
百聆:集成Deepseek API及语音技术的开源AI语音对话助手,实时交互延迟低至800ms
2025-01-22
腾讯混元3D上新!轻松制作一个3D模型
2025-01-22
「夜袭」 OpenAI!DeepSeek 开源最强推理模型 R1,再震欧美同行
2025-01-21
万字详解DeepSeek-R1,引爆AI圈的又一力作,大模型爆发势不可挡!
2025-01-21
11K+ Star!2025年最火AI+RPA网页操作神器
2024-07-25
2024-05-06
2024-08-13
2024-06-12
2024-07-11
2024-07-20
2024-09-20
2024-06-16
2025-01-01
2024-06-10
2025-01-22
2025-01-16
2024-12-24
2024-12-20
2024-12-19
2024-11-22
2024-11-19
2024-11-13