生活资讯
OpenChatKit:强大的聊天机器人项目(很好的chatGPT开源平替)
2025-01-02 08:20  浏览:107

原文链接:GitHub - togethercomputer/OpenChatKit

OpenChatKit是一个由前OpenAI研究员共同打造的开源聊天机器人平台。它包含了训练好的大型语言模型、定制配方和可扩展的检索系统,可以帮助用户快速构建高精度、多功能的聊天机器人应用。

其中,最核心的组件是一个经过微调的、具有200亿参数的语言模型——GPT-NeoXT-Chat-base-20B。这个模型基于EleutherAI的GPT-NeoX模型,重点调整了多轮对话、问答、分类、提取和摘要等多项任务,并使用了4300万条高质量指令进行训练。这使得OpenChatKit在处理聊天对话时可以提供高精度、流畅的回答。

除此之外,OpenChatKit还提供了定制配方的功能,可以帮助用户根据自己的数据集微调模型,以提高模型在特定任务上的表现。另外,该平台还提供了可扩展的检索系统,可以从文档存储库、API或实时更新信息源等多个来源中检索信息,以提供更全面的回答。

 

OpenChatKit provides a powerful, open-source base to create both specialized and general purpose chatbots for various applications. The kit includes an instruction-tuned language models, a moderation model, and an extensible retrieval system for including up-to-date responses from custom repositories. OpenChatKit models were trained on the OIG-43M training dataset, which was a collaboration between Together, LAION, and Ontocord.ai.

In this repo, you'll find code for:

  • Training GPT-NeoXT-Chat-base-20B, a 20B parameter chat model (see docs/GPT-NeoXT-Chat-base-20B.md)
  • Training Pythia-Chat-base-7B, a 7B parameter chat model
  • Testing inference using either of the chat models
  • Augmenting the model with additional context from a retrieval index
  • Getting Started
    • Requirements
    • Chatting with Pythia-Chat-base-7B
  • Reproducing Pythia-Chat-base-7B
    • Downloading training data and the base model
    • (Optional) 8bit Adam
    • Training the model
    • Converting weights to Huggingface format
    • Testing the new model
  • Monitoring
    • Loguru
    • Weights & Biases
  • Experimental: Retrieval-Augmented Models
  • See Also
  • License
  • Citing OpenChatKit
  • Acknowledgements

In this tutorial, you will download Pythia-Chat-base-7B, an instruction-tuned language model, and run some some inference requests against it using a command-line tool.

Pythia-Chat-base-7B is a 7B-parameter fine-tuned variant of Pythia-6.9B-deduped from Eleuther AI. Pre-trained weights for this model are available on Huggingface as togethercomputer/Pythia-Chat-base-7B under an Apache 2.0 license.

More details can be found on the model card for Pythia-Chat-base-7B on Huggingface.

Before you begin, you need to install PyTorch and other dependencies.

  1. Install Miniconda from their website.

  2. Install Git LFS from their website.

  3. Install the  hooks.

git lfs install
  1. Install mamba in the  environment so it's available in all environments.
conda install mamba -n base -c conda-forge
  1. Create an environment called OpenChatKit using the  file at the root of this repo.

Note Use  to create the environment. It's much faster than using .

mamba env create -f environment.yml 
  1. Activate the new conda environment.
conda activate OpenChatKit

To help you try the model, inference/bot.py is a simple command-line test harness that provides a shell inferface enabling you to chat with the model. Simply enter text at the prompt and the model replies. The test harness also maintains conversation history to provide the model with context.

Start the bot by calling  from the root for the repo.

python inference/bot.py --model togethercomputer/Pythia-Chat-base-7B

Loading the model can take some time, but once it's loaded, you are greeted with a prompt. Say hello.

$ python inference/bot.py 
Loading /home/csris/src/github.com/togethercomputer/OpenChatKit/inference/https://blog.csdn.net/qq_41771998/article/huggingface_models/GPT-NeoXT-Chat-base-20B to cuda:1...
Welcome to OpenChatKit shell.   Type /help or /? to list commands.

>>> Hello.
Hello human.

>>> 

Enter additional queries at the prompt, and the model replies. Under the covers, the shell is forming a prompt with all previous queries and passes that to the model to generate more text.

The shell also supports additional commands to inspect hyperparamters, the full prompt, and more. Commands are prefixed with a .

Note The  command exits the shell.

Please see the inference README for more details about arguments, running on multiple/specific GPUs, and running on consumer hardware.

This tutorial walks through reproducing the Pythia-Chat-base-7B model by fine-tuning Eleuther AI's Pythia-6.9B-deduped model using the OIG dataset.

The chat model was trained on the OIG dataset built by LAION, Together, and Ontocord.ai. To download the dataset from Huggingface run the command below from the root of the repo.

python data/OIG/prepare.py

Note You can help make this chat model better by contributing data! See the OpenDataHub repo for more details.

once the command completes, the data will be in the  directory.

Pythia-Chat-base-7B is a fine-tuned variant of Pythia-6.9B-deduped from Eleuther AI. To download the model and prepare it for fine tuning, run this command from the root of the repo.

python pretrained/Pythia-6.9B-deduped/prepare.py

The weights for this model will be in the  directory.

To use 8bit-adam during training, install the  package.

pip install bitsandbytes # optional, to use 8bit-adam

The  script configures and runs the training loop. After downloading the dataset and the base model, run:

bash training/finetune_Pythia-Chat-base-7B.sh

As the training loop runs, checkpoints are saved to the  directory at the root of the repo.

Please see the training README for more details about customizing the training run.

Before you can use this model to perform inference, it must be converted to the Huggingface format. Run this command from the root of the repo to do so.

mkdir huggingface_models 
  && python tools/convert_to_hf_gptneox.py 
       --config-name EleutherAI/pythia-6.9b-deduped 
       --ckpt-path model_ckpts/Pythia-Chat-base-7B/checkpoint_100 
       --save-path huggingface_models/Pythia-Chat-base-7B 
       --n-stages 4 
       --n-layer-per-stage 8 
       --fp16

where the  flag will load and store models in fp16.

Make sure to replace  with the latest checkpoint in the  directory.

You can use the OpenChatKit Shell test harness to chat with the new model. From the root of the repo, run

python inference/bot.py

By default the script will load the model named Pythia-Chat-base-7B under the  directory, but you can override that behavior by specifying .

python inference/bot.py --model https://blog.csdn.net/qq_41771998/article/details/huggingface_models/GPT-NeoXT-Chat-base-20B

once the model has loaded, enter text at the prompt and the model will reply.

$ python inference/bot.py 
Loading /home/csris/src/github.com/togethercomputer/OpenChatKit/inference/https://blog.csdn.net/qq_41771998/article/huggingface_models/GPT-NeoXT-Chat-base-20B to cuda:1...
Welcome to OpenChatKit shell.   Type /help or /? to list commands.

>>> Hello.
Hello human.

>>> 

The shell also supports additional commands to inspect hyperparamters, the full prompt, and more. Commands are prefixed with a .

Note The  command exits the shell.

Please see the inference README for more details about arguments, running on multiple/specific GPUs, and running on consumer hardware.

By default, the training script simply prints the loss as training proceeds, but it can also output metrics to a file using loguru or report them to Weights & Biases.

Add the flag  to your training script to log to 

To use Weights & Biases, first login with your Weights & Biases token.

wandb login

And set  in the training script to enable logging to Weights & Biases.

Warning Retrieval support is experimental.

The code in  implements a python package for querying a Faiss index of Wikipedia. The following steps explain how to use this index to augment queries in the test harness with context from the retriever.

  1. Download the Wikipedia index.
python data/wikipedia-3sentence-level-retrieval-index/prepare.py
  1. Run the bot with the  flag.
python inference/bot.py --retrieval

After starting, the bot will load both the chat model and the retrieval index, which takes a long time. once the model and the index are loaded, all queries will be augmented with extra context.

$ python inference/bot.py --retrieval
Loading /OpenChatKit/inference/https://blog.csdn.net/qq_41771998/article/huggingface_models/GPT-NeoXT-Chat-base-20B to cuda:0...
Loading retrieval index...
Welcome to OpenChatKit shell.   Type /help or /? to list commands.

>>> Where is Zurich?
Where is Zurich?
Zurich is located in Switzerland.

>>>
  • docs/GPT-NeoXT-Chat-base-20B.md. OpenChatKit also provides a larger, 20B parameter chat model that was trained on GPT-NeoXT-Chat-base-20B from Eleuther AI.

All code in this repository was developed by Together Computer except where otherwise noted. Copyright (c) 2023, Together Computer. All rights reserved. The code is licensed under the Apache 2.0 license.

 

This repository also contains code written by a number of other authors. Such contributions are marked and the relevant licensing is included where appropriate.

    以上就是本篇文章【OpenChatKit:强大的聊天机器人项目(很好的chatGPT开源平替)】的全部内容了,欢迎阅览 ! 文章地址:http://sjzytwl.xhstdz.com/xwnews/930.html 
     栏目首页      相关文章      动态      同类文章      热门文章      网站地图      返回首页 物流园资讯移动站 http://mip.xhstdz.com/ , 查看更多   
最新文章
教你彻底关闭手机自动更新,老手机不再卡顿还可以继续用几年手机系统更新怎么关闭「教你彻底关闭手机自动更新,老手机不再卡顿还可以继续用几年」
当我们购买一部新手机时,第一时间关闭系统更新是非常重要的。你们知道为什么我们经常更换手机吗?不正是因为手机变得卡顿和不流
电信固话怎么设置呼叫转移座机转接到手机怎么设置「电信固话怎么设置呼叫转移」
在现代通信中,呼叫转移功能为用户提供了极大的便利,尤其是在无法接听电话或需要临时将电话转接到其他号码时。对于电信固话用户
从“出新必换”到“多年不换”,消费者为啥不爱换手机了?手机几年换一次比较好「从“出新必换”到“多年不换”,消费者为啥不爱换手机了?」
你有多久没换手机了?不少消费者反馈,自己已经一两年或更长时间没有购买新手机或新平板电脑了。从“出新必换”到“多年不换”,
求小明正确的四位手机密码手机密码破解「求小明正确的四位手机密码」
小学生题目:小明五次输入四位数的手机密码均错误,但是每次输入的密码中都有两位数字正确,且输入的数字的位
奥尼尔谈GOAT人选:NBA仅4人够格
关于谁才是NBA的GOAT,每个人心中都会有自己的看法,毕竟大家看比赛的角度不同,对于球星成色的判断也就不同。近日,奥尼尔就谈
新就业形态下,灵活就业人员权益如何保障?
原标题:新就业形态下,灵活就业人员权益如何保障?(主题)专家:多方协同推动劳动者权益保障与企业可持续发展(副题)中国妇女
5G麒麟芯+卫星通信!华为20多款中端机已备案,继续发力高性能手机「5G麒麟芯+卫星通信!华为20多款中端机已备案,继续发力」
近日,有消息称华为将不仅在高端市场回归,还将回归中端市场,将麒麟9000s芯片下放到中端手机中。同时,华为还计划在中端手机中
买台手机好过年 没选新出的S16 Pro 却买了上代15 Pro新出的手机「买台手机好过年 没选新出的S16 Pro 却买了上代15 Pro」
购买小米12 Pro翻车后,眼看离春节就几天,还是要在过年前满足自己买过年的愿望。只考虑了OPPO和VIVO的产品后,放弃了OPPO的Reno
iPhone游戏必备神器、精准识别那个老六。雷蛇手机「iPhone游戏必备神器、精准识别那个老六。」
相信很多用iPhone玩游戏的值友们都遇到过降频的问题,尤其13PM,虽然支持120hz但是只要你敢开,十分钟内必让你的屏幕黑下来,感
割裂的杭州楼市:手握千万资金抢不到房,刚需盘降价40万无人问津
“ 杭州一季度的楼市表现,如同一面多棱镜,映照出土地市场的狂热、开发商的野心、购房者的焦虑,也暴露出城市发展的不均衡。中