Tianji
制作懂人情世故的大语言模型 | 涵盖提示词工程、RAG、Agent、LLM微调教程
Stars: 1005
Tianji is a free, non-commercial artificial intelligence system developed by SocialAI for tasks involving worldly wisdom, such as etiquette, hospitality, gifting, wishes, communication, awkwardness resolution, and conflict handling. It includes four main technical routes: pure prompt, Agent architecture, knowledge base, and model training. Users can find corresponding source code for these routes in the tianji directory to replicate their own vertical domain AI applications. The project aims to accelerate the penetration of AI into various fields and enhance AI's core competencies.
README:
天机(Tianji)是专注于传统人情场景的大语言模型应用。
涵盖 Prompt工程、RAG知识库、Agent 、模型微调等多种实现、提供 LLM 开发入门教程
🤗 获取天机的 所有数据
了解更多 SocialAI
-
模型支持:ChatGPT、ZhipuAI、ERNIE、DeepSeek、InternLM、Qwen 等 Online / Local 调用
-
模型微调:Transformers、Xtuner 等框架的 Lora 与全量微调
-
数据制造:包含常见社交领域的人情世故语料库,提供数据制造与清洗工具
学完全部内容,获得大语言模型入门级全栈应用开发能力。
[2024/12/21] 🔥 更新送祝福模型v0.2,支持更多风格切换,包含 3B / 7B / 14B(推荐) 模型、数据、制作流程、测试与训练代码
祝朋友新年快乐,文艺风格
当晨曦的第一缕阳光轻轻拂过窗棂,新年的钟声在耳边回荡,我仿佛听见了岁月的低语。那些曾经在时光里绽放的瞬间,如同冬日里温暖的炉火,照亮了每一个寒冷的夜晚。记得去年冬天,我们一起围坐在火炉旁,分享着彼此的故事,那一刻,时间仿佛静止了。如今,新的一年已经到来,愿你依然能够保持那份纯真与热情,让生活中的每一个细节都充满诗意。愿你在未来的日子里,无论风雨变换,都能找到属于自己的那片晴空。
祝朋友中秋快乐,白话风格
中秋快乐!记得去年咱们一起在阳台上赏月,你非要给我讲那些古老的传说,结果我差点以为自己穿越了。今年虽然不能一起过节,但希望你能感受到家的温暖,和家人团团圆圆。对了,上次你借我的书我还没看完,等你有空了再还给你。中秋佳节,愿你和家人幸福安康,月饼甜甜的,生活美美的!
祝爷爷春节快乐,诗词赋风格
皇天赐庆,月满华晖。星临福寿之辰,日照吉祥之地。绮阁流丹,照子孙情深之谊;兰房飘香,显祖孙情长之真。今朝佳节,难得欢聚;千里同庆,举座生辉。玉盘珍馐罗列,金杯美酒盈樽。亲朋满座,尽展欢颜;贺寿齐声,共襄盛事。
时维新春,序属佳节。春光明媚而庭院新,晓色融融而红霞艳。俨然华筵开锦席,共享天伦庆华诞。临寿宴之盛筵,得欢聚之良辰。层楼生辉,上接春晖;高堂焕彩,下临华宇。觥筹交错,尽显亲朋之情谊;歌舞升平,正逢良辰吉日。
开华宴,陈美馔,亲友欢聚其满座,笑语盈盈而悦耳。觥筹交错,温情脉脉之际;花烛生辉,欢声笑语之间。云开月朗,光彻庭户。寿桃与寿糕同献,美酒共佳肴齐陈。笑语盈盈,响彻华堂之内;欢声阵阵,声传四座之中。
抚今追昔,情思飞扬。温情涌动而心潮起,佳话缤纷而笑语生。儿时嬉戏,情深祖孙之间;长大成人,意笃亲情之谊。四季轮回,二难兼备。尽声色于今朝,极欢愉于此日。岁月悠悠,感天伦之可贵;时光荏苒,知亲情之难得。
嗟乎!光阴似箭,岁月如梭。今朝良辰,愿爷爷常怀欢乐;此日华筵,祝君永沐春晖。愿君福如东海,寿比南山。事业蒸蒸日上,家庭幸福美满。所盼亲情永续,祖孙情深。岁岁常来,永享天伦之乐;年年如此,长沐春晖之恩。
孙以微命,聊表衷肠。无以为赠,唯有真诚祝愿;有怀致意,愿献诚挚情深。舍千里而来贺,奉寿礼以表心。他日相聚,共话桑麻;今朝同庆,同享欢乐。
祝哥哥圣诞快乐,祝福长文风格
亲爱的哥哥:
圣诞的钟声即将敲响,窗外飘着雪花,屋内暖意融融。想起小时候我们一起堆雪人、打雪仗的日子,心里暖洋洋的。那时候你总是抢着当我的“助手”,帮我堆出最完美的雪人,还偷偷给我塞了一颗糖,说是为了让雪人更甜。
记得有一次,我因为期末考试压力大,心情特别不好。你不仅陪我聊天解闷,还带我去吃了最爱的烤肉,那顿饭吃得我心花怒放。从那以后,每当我遇到困难,都会想起你的鼓励和支持,让我有了继续前行的勇气。
还有那次,你帮我修理自行车,虽然最后还是没修好,但那份耐心和细心让我感动不已。你总是在我需要的时候出现,就像圣诞老人一样,给我带来惊喜和温暖。
现在,虽然我们各自忙碌,但这份兄弟情谊从未改变。希望这个圣诞节,你能和家人一起度过一个温馨美好的时光。愿你的生活像圣诞树上的彩灯一样,五彩斑斓;愿你的笑容像圣诞老人的礼物一样,带给身边的人无尽的快乐。
最后,别忘了给自己准备一份特别的礼物,毕竟,你也是那个最棒的“圣诞老人”呢!
[2024/10/08] 完成第一阶段全知识库对话更新,数据下载 huggingface
[2024/10/05] 重构 Agent 模块,修复 代码规范
[2024/09/02] 更新第一款专注敬酒场景的知识库对话模型
[2024/08/31] 重构仓库结构,更新工具代码及langchain 知识库问答、对应 demo
[2024/07/16] 发布敬酒场景的天机模型, 开源 语料
[2024/07/14] 更新送祝福模块 支持更多风格切换,数据开源至 huggingface
[2024/05/04] 《化解"尴尬"场合》为例微调数据获取、制造教程,对应数据开源至 huggingface
[2024/05/02] 送祝福任务的数据收集到微调过程的全流程复现文档及其对应数据、配置、辅助脚本
[2024/02/01] 发布初版体验地址
天机虽不可泄漏,但总有一款适合你
运行prompt版本天机,感受放飞自我的答复
运行知识库版本天机,获得详细的人情世故指导
化解尴尬场合 |
如何说对话 |
敬酒礼仪文化 |
矛盾冲突应对 |
请客礼仪文化 |
送礼礼仪文化 |
运行微调后送祝福天机,一片真诚送出祝福
在本项目中,执行下列指令即可完成项目的安装
pip install -e .
为确保项目正常运行,请在项目内新建.env
文件,并在其中设置你的API密钥,你可以根据下列例子写入对应的 key,即可成功运行调用,目前默认使用 siliconflow 与 ZhipuAI,你可以获取对应token即可使用。
当前 Pormpt demo 使用 ZhipuAI api,rag 与 agent demo 使用 Siliconflow api,你可以填写这两者调用密钥,即可使用 tianji 的全部功能。
OPENAI_API_KEY=
ZHIPUAI_API_KEY=
如果在从Hugging Face下载模型时遇到速度极慢或无法下载的问题,请在.env文件中设置HF_ENDPOINT
的值为https://hf-mirror.com
。请注意,某些Hugging Face仓库可能需要访问权限(例如Jina Ai)。为此,请注册一个Hugging Face账号,并在.env文件中添加HF_TOKEN
。你可以在这里找到并获取你的token。
HF_HOME='temp/huggingface_cache/'
HF_ENDPOINT='https://hf-mirror.com'
OPENAI_API_KEY=
OPENAI_API_BASE=
ZHIPUAI_API_KEY=
OPENAI_API_MODEL=
HF_TOKEN=
TAVILY_API_KEY=
如果你想要结合 Agent 中的网络搜索工具给出更好的回答,你需要填写上述环境变量的 TAVILY_API_KEY 进行搜索请求,你可以在 TAVILY 官网获取密钥(个人免费额度)
以下给出 prompt 以及 agent 的相关应用方式,在运行前请确保你已经新建.env
文件:
# 运行prompt webui前端
python3 run/tianji_prompt_webui.py
# 运行agent前端
streamlit run run/metagpt_webui.py
# 运行langchain前端
python run/demo_rag_langchain_onlinellm.py
- [ ] 加入意图识别模块,替代主动选择场景
- [ ] 增加 Dify、Agently 调用方式
- [ ] 补充文档(如何参考本项目构建自己的应用prompt、agent、知识库、微调应用)
- [ ] 等待造模型能力迭代,更新sft数据模板
已完成项目
- [x] 释放最简初版(涉及prompt、aigame、agent、知识库、模型微调)
- [x] 完成人情世故大模型-送祝福的模型微调数据收集到微调过程的可复现文档
- [x] 开源人情世故语料-送祝福至 Huggingface
- [x] 迭代更好的数据制造工具与清洗方案,开源数据清洗脚本
- [x] 完成 Agent 部分重构
- [x] 完成知识库部分迭代,开源至huggingface
- [x] 整理多维度数据,开源较完整人情世故语料
- [x] 完成 Agent 部分文档
基于整理后的人情世故数据,人情世故大模型系统-天机包括了常见人际交往中的七大领域(具体可以参考 场景分类 中的场景细化细节),其中大体可分为:
1.敬酒礼仪文化 Etiquette
不惧碰杯,酒席桌上一条龙
2.请客礼仪文化 Hospitality
友好地展示你的友好
3.送礼礼仪文化 Gifting
此礼非礼,直击人心
4.送祝福 Wishes
承包你的所有祝福语
5.如何说对话 Communication
据说是低情商救星
6.化解"尴尬"场合 Awkwardness
没心没肺,找回自我
7.矛盾&冲突应对 Conflict
《能屈能伸》
结合这些领域,Tianji涉及到的技术路线共有四种:
- 纯prompt(包括AI游戏):内置 system prompt 基于大模型自身能力对话。
- Agent(MetaGPT等):利用 Agent 架构的得到更丰富、更定制化详细的回答。
- 知识库:直接检索人情世故法则(比如餐桌上一般怎么喝酒)。
- 模型训练:基于不同优秀的模型基座,在积累大量数据的情况下进行Lora微调或全量微调。
您可以在 tianji 目录下找到四种路线的对应源码,如果您想参考 Tianji
的项目架构、数据管理、技术路线复刻出属于自己的垂直领域 AI 应用,欢迎 fork 或者直接参考,我们将会开源所有包括从项目的起步、数据的方向探索、数据构建与管理、AI应用从0制作、领域(比如人情世故)与技术路线的深入结合
的全过程;我们希望看到 AI 原生应用在生活中进一步的加速推进。
assets/:静态图片文件
docs/:所有文档目录
run/: 包括了各类演示用前端
temp/:运行时临时文件目录,包含各类模型文件
test/:这里存放了各类功能的测试文件,包括核心模块以及大语言模型单独运行的单元测试
tianji/:源代码目录,包含主要逻辑与算法实现(prompt、agent、knowledges、finetune)
tools/:涵盖帮助收集数据、整理数据清洗语料的工具
得益于良好的ci设施,你只需要参考示例PR,就可以很快提出自己的第一个 Prompt Pull request!
提交PR后,新的prompt将自动合并于 tianji/prompt
下的json文件中,方便一键调用。如果你不知道写什么,可以参考 场景分类 中的各类场景细化细节,写出不同人情世故领域的prompt。
在进行项目开发与贡献之前,在保证key的正确设定后,你还需要在提交 pull request 前进行格式检查。你可以参考下列方式进行 pre-commit 的安装,在 commit 环节将会看到变更文件格式会被自动修改。
pip install pre-commit
pre-commit install
git add .
git commit -m "提交信息"
git push
这一步,你需要反复执行下列两步,直到 commit 成功 (该过程会帮助你自动修复绝大部分格式错误,但对于某些复杂格式需要自己手动根据提示修改。)
git add .
git commit -m "提交信息"
若全部成功,你将会看到类似如下信息显示:
[main 2333] rebuild code standard
5 files changed, 4 insertions(+), 3 deletions(-)
该项目的初衷,第一是为了让AI学会核心技术
,第二是让更多人(领域/行业)可以构建属于自己的AI系统,加速AI对每一个领域的渗透。你可以通过以下方式来学习该项目:
你可以 fork 本项目修改,创造出新的垂直领域应用:
- 租房助手(agent)
- 带娃助手(数据收集与知识库)
- 生活指南(数据收集与知识库) ......
有些贡献者没有Github账户,我们发自内心感谢每一位贡献者,谢谢有你们!,也欢迎你一起加入!
感谢下列所有人对本项目的帮助(不分前后),以及你的关注:
- 项目最开始时刻 智谱AI 的token支持
- 上海人工智能实验室 InternLM(书生·浦语) 模型,以及提供的A100显卡资源、与 书生浦语API 支持
- InternLM(书生·浦语) 系列开源教程(目前最好的LLM实战全栈教程之一)
- 飞桨 aistudio 星河社区 的 token 与显卡支持
- Datawhale 开源学习社区
- 奇想星球
- zRzRzR的帮助
For Tasks:
Click tags to check more tools for each tasksFor Jobs:
Alternative AI tools for Tianji
Similar Open Source Tools
Tianji
Tianji is a free, non-commercial artificial intelligence system developed by SocialAI for tasks involving worldly wisdom, such as etiquette, hospitality, gifting, wishes, communication, awkwardness resolution, and conflict handling. It includes four main technical routes: pure prompt, Agent architecture, knowledge base, and model training. Users can find corresponding source code for these routes in the tianji directory to replicate their own vertical domain AI applications. The project aims to accelerate the penetration of AI into various fields and enhance AI's core competencies.
ChatGPT-On-CS
This project is an intelligent dialogue customer service tool based on a large model, which supports access to platforms such as WeChat, Qianniu, Bilibili, Douyin Enterprise, Douyin, Doudian, Weibo chat, Xiaohongshu professional account operation, Xiaohongshu, Zhihu, etc. You can choose GPT3.5/GPT4.0/ Lazy Treasure Box (more platforms will be supported in the future), which can process text, voice and pictures, and access external resources such as operating systems and the Internet through plug-ins, and support enterprise AI applications customized based on their own knowledge base.
SwanLab
SwanLab is an open-source, lightweight AI experiment tracking tool that provides a platform for tracking, comparing, and collaborating on experiments, aiming to accelerate the research and development efficiency of AI teams by 100 times. It offers a friendly API and a beautiful interface, combining hyperparameter tracking, metric recording, online collaboration, experiment link sharing, real-time message notifications, and more. With SwanLab, researchers can document their training experiences, seamlessly communicate and collaborate with collaborators, and machine learning engineers can develop models for production faster.
ap-plugin
AP-PLUGIN is an AI drawing plugin for the Yunzai series robot framework, allowing you to have a convenient AI drawing experience in the input box. It uses the open source Stable Diffusion web UI as the backend, deploys it for free, and generates a variety of images with richer functions.
MoneyPrinterPlus
MoneyPrinterPlus is a project designed to help users easily make money in the era of short videos. It leverages AI big model technology to batch generate various short videos, perform video editing, and automatically publish videos to popular platforms like Douyin, Kuaishou, Xiaohongshu, and Video Number. The tool covers a wide range of functionalities including integrating with major AI big model tools, supporting various voice types, offering video transition effects, enabling customization of subtitles, and more. It aims to simplify the process of creating and sharing videos to monetize traffic.
VoAPI
VoAPI is a new high-value/high-performance AI model interface management and distribution system. It is a closed-source tool for personal learning use only, not for commercial purposes. Users must comply with upstream AI model service providers and legal regulations. The system offers a visually appealing interface with features such as independent development documentation page support, service monitoring page configuration support, and third-party login support. Users can manage user registration time, optimize interface elements, and support features like online recharge, model pricing display, and sensitive word filtering. VoAPI also provides support for various AI models and platforms, with the ability to configure homepage templates, model information, and manufacturer information.
gzm-design
Gzm Design is a free and open-source poster designer developed using the latest mainstream technologies such as Vue3, Vite4, TypeScript, etc. It provides features like PSD import, JSON import, multiple pages support, shortcut key support, template import, layer management, ruler tool, pen tool, element editing, preview, file download, canvas zooming and dragging, border stroke, filling, blending modes, text formatting, group handling, canvas size modification, rich text support, masking, shadow effects, undo/redo functionality, QR code tool, barcode tool, and ruler line npm package encapsulation.
easyAi
EasyAi is a lightweight, beginner-friendly Java artificial intelligence algorithm framework. It can be seamlessly integrated into Java projects with Maven, requiring no additional environment configuration or dependencies. The framework provides pre-packaged modules for image object detection and AI customer service, as well as various low-level algorithm tools for deep learning, machine learning, reinforcement learning, heuristic learning, and matrix operations. Developers can easily develop custom micro-models tailored to their business needs.
FisherAI
FisherAI is a Chrome extension designed to improve learning efficiency. It supports automatic summarization, web and video translation, multi-turn dialogue, and various large language models such as gpt/azure/gemini/deepseek/mistral/groq/yi/moonshot. Users can enjoy flexible and powerful AI tools with FisherAI.
midjourney-proxy
Midjourney-proxy is a proxy for the Discord channel of MidJourney, enabling API-based calls for AI drawing. It supports Imagine instructions, adding image base64 as a placeholder, Blend and Describe commands, real-time progress tracking, Chinese prompt translation, prompt sensitive word pre-detection, user-token connection to WSS, multi-account configuration, and more. For more advanced features, consider using midjourney-proxy-plus, which includes Shorten, focus shifting, image zooming, local redrawing, nearly all associated button actions, Remix mode, seed value retrieval, account pool persistence, dynamic maintenance, /info and /settings retrieval, account settings configuration, Niji bot robot, InsightFace face replacement robot, and an embedded management dashboard.
ai-tag
AI tag generator that combines 40,000 tags from Bilibili UP main Twelve Today is also very cute with Chinese translations from Novelai, providing Chinese search and tag generation services. It offers a tag community for magicians to directly copy and generate spells. Always free, no ads, no commercial use. The project includes a pure tag parsing library, independent spell parsing library, tag data repository, and a new gallery page with waterfall flow for viewing community images.
anylabeling
AnyLabeling is a tool for effortless data labeling with AI support from YOLO and Segment Anything. It combines features from LabelImg and Labelme with an improved UI and auto-labeling capabilities. Users can annotate images with polygons, rectangles, circles, lines, and points, as well as perform auto-labeling using YOLOv5 and Segment Anything. The tool also supports text detection, recognition, and Key Information Extraction (KIE) labeling, with multiple language options available such as English, Vietnamese, and Chinese.
VoAPI
VoAPI is a new high-value/high-performance AI model interface management and distribution system. It is a closed-source tool for personal learning use only, not for commercial purposes. Users must comply with upstream AI model service providers and legal regulations. The system offers a visually appealing interface, independent development documentation page support, service monitoring page configuration support, and third-party login support. It also optimizes interface elements, user registration time support, data operation button positioning, and more.
MoneyPrinterTurbo
MoneyPrinterTurbo is a tool that can automatically generate video content based on a provided theme or keyword. It can create video scripts, materials, subtitles, and background music, and then compile them into a high-definition short video. The tool features a web interface and an API interface, supporting AI-generated video scripts, customizable scripts, multiple HD video sizes, batch video generation, customizable video segment duration, multilingual video scripts, multiple voice synthesis options, subtitle generation with font customization, background music selection, access to high-definition and copyright-free video materials, and integration with various AI models like OpenAI, moonshot, Azure, and more. The tool aims to simplify the video creation process and offers future plans to enhance voice synthesis, add video transition effects, provide more video material sources, offer video length options, include free network proxies, enable real-time voice and music previews, support additional voice synthesis services, and facilitate automatic uploads to YouTube platform.
AIMedia
AIMedia is a fully automated AI media software that automatically fetches hot news, generates news, and publishes on various platforms. It supports hot news fetching from platforms like Douyin, NetEase News, Weibo, The Paper, China Daily, and Sohu News. Additionally, it enables AI-generated images for text-only news to enhance originality and reading experience. The tool is currently commercialized with plans to support video auto-generation for platform publishing in the future. It requires a minimum CPU of 4 cores or above, 8GB RAM, and supports Windows 10 or above. Users can deploy the tool by cloning the repository, modifying the configuration file, creating a virtual environment using Conda, and starting the web interface. Feedback and suggestions can be submitted through issues or pull requests.
simpletransformers
Simple Transformers is a library based on the Transformers library by HuggingFace, allowing users to quickly train and evaluate Transformer models with only 3 lines of code. It supports various tasks such as Information Retrieval, Language Models, Encoder Model Training, Sequence Classification, Token Classification, Question Answering, Language Generation, T5 Model, Seq2Seq Tasks, Multi-Modal Classification, and Conversational AI.
For similar tasks
Tianji
Tianji is a free, non-commercial artificial intelligence system developed by SocialAI for tasks involving worldly wisdom, such as etiquette, hospitality, gifting, wishes, communication, awkwardness resolution, and conflict handling. It includes four main technical routes: pure prompt, Agent architecture, knowledge base, and model training. Users can find corresponding source code for these routes in the tianji directory to replicate their own vertical domain AI applications. The project aims to accelerate the penetration of AI into various fields and enhance AI's core competencies.
For similar jobs
ChatFAQ
ChatFAQ is an open-source comprehensive platform for creating a wide variety of chatbots: generic ones, business-trained, or even capable of redirecting requests to human operators. It includes a specialized NLP/NLG engine based on a RAG architecture and customized chat widgets, ensuring a tailored experience for users and avoiding vendor lock-in.
anything-llm
AnythingLLM is a full-stack application that enables you to turn any document, resource, or piece of content into context that any LLM can use as references during chatting. This application allows you to pick and choose which LLM or Vector Database you want to use as well as supporting multi-user management and permissions.
chatbot-ui
Chatbot UI is an open-source AI chat app that allows users to create and deploy their own AI chatbots. It is easy to use and can be customized to fit any need. Chatbot UI is perfect for businesses, developers, and anyone who wants to create a chatbot.
deep-chat
Deep Chat is a fully customizable AI chat component that can be injected into your website with minimal to no effort. Whether you want to create a chatbot that leverages popular APIs such as ChatGPT or connect to your own custom service, this component can do it all! Explore deepchat.dev to view all of the available features, how to use them, examples and more!
Avalonia-Assistant
Avalonia-Assistant is an open-source desktop intelligent assistant that aims to provide a user-friendly interactive experience based on the Avalonia UI framework and the integration of Semantic Kernel with OpenAI or other large LLM models. By utilizing Avalonia-Assistant, you can perform various desktop operations through text or voice commands, enhancing your productivity and daily office experience.
chatgpt-web
ChatGPT Web is a web application that provides access to the ChatGPT API. It offers two non-official methods to interact with ChatGPT: through the ChatGPTAPI (using the `gpt-3.5-turbo-0301` model) or through the ChatGPTUnofficialProxyAPI (using a web access token). The ChatGPTAPI method is more reliable but requires an OpenAI API key, while the ChatGPTUnofficialProxyAPI method is free but less reliable. The application includes features such as user registration and login, synchronization of conversation history, customization of API keys and sensitive words, and management of users and keys. It also provides a user interface for interacting with ChatGPT and supports multiple languages and themes.
tiledesk-dashboard
Tiledesk is an open-source live chat platform with integrated chatbots written in Node.js and Express. It is designed to be a multi-channel platform for web, Android, and iOS, and it can be used to increase sales or provide post-sales customer service. Tiledesk's chatbot technology allows for automation of conversations, and it also provides APIs and webhooks for connecting external applications. Additionally, it offers a marketplace for apps and features such as CRM, ticketing, and data export.
UFO
UFO is a UI-focused dual-agent framework to fulfill user requests on Windows OS by seamlessly navigating and operating within individual or spanning multiple applications.