pku-yuangroup / chatlaw Goto Github PK
View Code? Open in Web Editor NEWChatLaw:A Powerful LLM Tailored for Chinese Legal. 中文法律大模型
Home Page: https://chatlaw.cloud/
License: GNU Affero General Public License v3.0
ChatLaw:A Powerful LLM Tailored for Chinese Legal. 中文法律大模型
Home Page: https://chatlaw.cloud/
License: GNU Affero General Public License v3.0
this say JessyTsu1/ChatLaw-13B does not appear to have a file named config.json.
感谢你们贡献如此优秀的开源项目。
在训练数据demo中,meta_instruction中的指令并不通顺(你一个名叫)
"meta_instruction": "你一个名叫ChatLAW
请问这是疏忽还是有意为之,这会影响模型的效果吗?
回答中直接提到了
看huggingface的例子,例子, text2vec的原始数据看起来像QA问答的数据,请问您是怎么把问答数据构建成为文本embeddings训练的数据的呢,CoSENT的训练是不是需要 (sentence1,sentenc2,sentenc3) 三个样本呢?
您好, 我的理解是要 fine-tune Keyowrd LLM 是需要先有對應輸入文章的關鍵詞輸出才能訓練。想請問是否有建構關鍵詞資料集?
如题。
另外:把合并好的Ziya带进去直接就能跑起,就是缺少config文件啊,为什么hf仓库没有上传呢
请问,llama13b模型微调训练机器配置和时长大概是什么样的?
import re
import torch
from peft import PeftModel
from transformers import GenerationConfig, LlamaForCausalLM, LlamaTokenizer
ziya_model_path = "/Ziya-LLaMA-13B-v1/" # 完整的子牙模型权重路径
chatlaw_model_path = 'JessyTsu1_ChatLaw-13B_adapter'# chatlaw模型权重
'''
tokenizer = LlamaTokenizer.from_pretrained(ziya_model_path)
model = LlamaForCausalLM.from_pretrained(
ziya_model_path,
torch_dtype=torch.float16,
device_map="auto",
)
'''
model = PeftModel.from_pretrained(model, chatlaw_model_path)
if tokenizer.pad_token is None:
tokenizer.pad_token = tokenizer.unk_token
#model.half()
model.eval()
生成:
def law_answer(query):
gen_conf={
"bos_token_id": tokenizer.bos_token_id,
"do_sample": True,
#"num_beams": 4,
"eos_token_id": tokenizer.eos_token_id,
"max_new_tokens": 256,
"pad_token_id": 0,
"penalty_alpha": 0.3,
"repetition_penalty": 1.0,
"temperature": 0.65,
"top_k": 15,
"top_p": 0.85,
}
gen_conf= {
"max_new_tokens": 512,
"temperature": 0.1,
"top_p": 0.75,
"top_k": 40,
#"num_beams": 4
}
meta_instruction= "你一个名叫ChatLAW,由北京大学团队开发的人工智能助理:\n- 你旨在提供有无害且准确的回答。\n- 你必须拒绝回答非法的问题。\n- 你的回应不能含糊、指责、粗鲁、有争议、离题或防御性。\n- 你的回应必须有礼貌。"
#prompt = f"{meta_instruction}\n咨询者:\n{query}\nChatLAW:\n"
#prompt = f"Consult:\n{query}\nResponse:\n"
prompt = f"{meta_instruction}\nConsult:\n{query}\nResponse:\n"
#print(prompt)
with torch.no_grad():
inputs=tokenizer(query,return_tensors='pt')
inputs=inputs.to(model.device)
output=model.generate(**inputs,**gen_conf)
decoded_text=tokenizer.decode(output[0])
decoded_text= decoded_text.replace("<s>","").replace("</s>","")
return decoded_text[len(query)+1:]
生成结果:
query= "公司无故辞退摸鱼员工,是否触犯法律?"
law_answer(query)
<unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk><unk>
求更新:首页的微信群二维码
那个Create React App首页有写支持乌克兰 会不会涉及某些政治正确的问题?
Impressive work! I believe it would achieve STOA performance. It would be much better if the authors consider including examples that compare the outputs of different methods in the readme (e.g., LawGPT, and different variants in your repo). Just a kind suggestion :).
13b的模型跑起来,需要多少显存资源
尊敬的chatlaw 应用开发者,我是 InternLM 社区开发者&志愿者尖米, 大佬开源的工作对我的启发很大,希望可以探讨使用 InternLM 实现chatlaw 的可能性和实现路径,我的微信是mzm312,希望可以取得联系进行更深度的交流;
"We propose a self-attention method to enhance the ability of large models to overcome errors present in reference data, further optimizing the issue of model hallucinations at the model level and improving the problem-solving capabilities of large models. "
Would you like to provide these parts of codes?
请问训练关键词提取模型的数据是怎么获得的呢?
好东西 希望能长期维护
能大概分享一下keyWord模型的训练思路吗?是按照大模型训练还是小模型训练,需要多大的数据量呢
我们最近也在做法律垂域相关的,请问下评测数据能否开源,方便进行横向对比,谢谢!
Readme中https://chatlaw.cloud/lawchat/ 显示为404
as title
或者你们模型的同步升级。
请问在用指令数据微调的时候,有没有再加上通用数据?
我在尝试微调的时候:
1、指令+垂直领域问题/不加指令+通用问题
==》没法区分用户的问题是否要加上指令,加上指令会回答正确,不加回答不上来。
2、垂直领域问题
==》只能回答垂直领域问题,通用能力完全丧失。
谢谢!
2021年1月1日民法典生效后,《中华人民共和国民法通则》、《中华人民共和国担保法》、《中华人民共和国合同法》、《中华人民共和国物权法》、《中华人民共和国民法总则》等法律文件已经失效
在论文的3.1部分,作者说“Additionally, we introduced the self-suggestion role to further alleviate model hallucination issues”这句话不太理解。请问,这个self-suggestion role是如何在训练中体现出来的?是通过设计特殊的loss function吗?还是说在训练样本中通过prompt的方式,实现模型的self-suggestion?如果是后者能否举个例子说明。
训练语录数据会开源吗?
当我运行demo/web.py程序是,得到如下错误提示:
ImportError: cannot import name 'LlamaForCausalLM' from 'transformers’
是怎么从input中提取keywords的(甚至出现input中不存在的单词)?
fine-tune LLM后将input输入给LLM后得到的输出就是keywords吗?还是又对输出进行了处理得到的keywords?
@JessyTsu1
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument index in method wrapper_CUDA__index_select)a'
请问chatlaw是否只使用了领域相关的训练数据?
若不是的话,领域数据/通用数据的配比及数据量能否透露?
请问内测申请大概多久可以审批完成?
如题~~
如题~
可以请问下前端的 Web UI 是怎么制作的么
您好,关于预训练阶段语料不知道以下几点是否有特殊的考量?
请问法律增量预训练阶段的语料大约是多少B的量级?全都是法律的吗,没有和通用的做混合?以及同属于法律数据,不同数据来源的比例?
想问问self-suggestion部分在训练集中是如何构建的?是跟moss数据集引入inner thought类似吗?模型是如何知道引用的知识库是否有效?我看论文里关于这部分没有细说,希望可以帮忙解答。
刑法第二百六十七条不是故意伤害罪,而是第二百三十四条。二百六十七条为: 抢劫罪。
详见维基百科: https://zh.wikisource.org/wiki/%E4%B8%AD%E5%8D%8E%E4%BA%BA%E6%B0%91%E5%85%B1%E5%92%8C%E5%9B%BD%E5%88%91%E6%B3%95
另附上ChatGPT答案:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.