stylellm_models
StyleLLM文风大模型:基于大语言模型的文本风格迁移项目。Text style transfer base on Large Language Model. #文字修饰 # 润色 #风格模仿
Stars: 121
**stylellm** is a text style transfer project based on large language models (llms). The project utilizes large language models to learn the writing style of specific literary works (commonly used vocabulary, sentence structure, rhetoric, character dialogue, etc.), forming a series of specific style models. Using the **stylellm** model, the learned style can be transferred to other general texts, that is: input a piece of original text, the model can rewrite it, output text with the characteristics of that style, achieving the effect of text modification,润色or style imitation.
README:
stylellm 是一个基于大语言模型(llm)的文本风格迁移(text style transfer)项目。项目利用大语言模型来学习指定文学作品的写作风格(惯用词汇、句式结构、修辞手法、人物对话等),形成了一系列特定风格的模型。
利用stylellm模型可将学习到的风格移植至其他通用文本上,即:输入一段原始文本,模型可对其改写,输出带有该风格特色的文本,达到文字修饰、润色或风格模仿的效果。
stylellm-中国四大名著系列 包括基于Yi-6b微调的四个模型,分别采用《三国演义》、《西游记》、《水浒传》、《红楼梦》四本中国古典长篇小说训练而成:
风格 | 模型 | 使用方法 |
---|---|---|
三国演义风格 | 🤗 stylellm/SanGuoYanYi-6b | inference.py |
西游记风格 | 🤗 stylellm/XiYouJi-6b | inference.py |
水浒传风格 | 🤗 stylellm/ShuiHuZhuan-6b | inference.py |
红楼梦风格 | 🤗 stylellm/HongLouMeng-6b | inference.py |
风格 | 模型 |
---|---|
三国演义风格 | 🤗 stylellm/SanGuoYanYi-6b-AWQ |
西游记风格 | 🤗 stylellm/XiYouJi-6b-AWQ |
水浒传风格 | 🤗 stylellm/ShuiHuZhuan-6b-AWQ |
红楼梦风格 | 🤗 stylellm/HongLouMeng-6b-AWQ |
注意:
使用AWQ量化模型前需安装AutoAWQ:pip install autoawq
量化后的模型占用显存4.2GB,适用于较小的显卡使用,但风格表达能力有所下降,追求完整效果的场景请使用量化前版本
以《白雪公主》原文作为输入,以下是不同风格模型的改写结果。
原文 - 《白雪公主》 | 改写-三国演义风格 | 改写-西游记风格 | 改写-水浒传风格 | 改写-红楼梦风格 |
---|---|---|---|---|
严冬时节,鹅毛一样的大雪片在天空中到处飞舞着,有一个王后坐在王宫里的一扇窗子边,正在为她的女儿做针线活儿,寒风卷着雪片飘进了窗子,乌木窗台上飘落了不少雪花。 | 时值隆冬,大雪压境,王后坐于王宫之窗下,正与女作绣,寒风入室,吹落乌木窗台之雪。 | 正是那:朔风吹凛凛,瑞雪霭纷纷;王后坐窗前,正教女作绣,只见那:寒风送雪入窗棂,乌木台头堆积雪。 | 此时正是隆冬之际,鹅毛般大雪乱飘,有一王后坐于王宫内一扇窗户前,正缝其女衣,寒风卷雪入得窗来,把那乌木窗台都压坏了。 | 且说那严冬天气,鹅毛大雪,纷纷扬扬,只见那王后坐于王宫之窗下,正教他女儿作针黹,忽见寒风卷雪,吹入窗内,乌木窗台之上,积了半日之雪。 |
她抬头向窗外望去,一不留神,针刺进了她的手指,红红的鲜血从针口流了出来,有三点血滴落在飘进窗子的雪花上。 | 其女仰视窗外,不料针落指中,遂出血于雪,有三点之痕。 | 只见那女子举目望外观看时,不期把个指头儿扎了一针,又见出血,却似三两点血珠儿落于雪内。 | 那娘子仰面看时,只道是雪片落将下来,不提防把针儿捻在手里,一时失手,正中指尖,便见出血来,有三两点,都滴入窗里去。 | 只见那丫头往外瞧时,一时针扎手了,便出血了,有三四个血点儿,落在了雪里。 |
她若有所思地凝视着点缀在白雪上的鲜红血滴,又看了看乌木窗台,说道:"但愿我小女儿的皮肤长得白里透红,看起来就像这洁白的雪和鲜红的血一样,那么艳丽,那么骄嫩,头发长得就像这窗子的乌木一般又黑又亮!" | 其女乃凝眸望那点缀于白雪之下的鲜红血滴,复观乌木窗棂曰:“吾愿吾小女肌肤如雪,容貌似此洁白之雪与鲜红之血,娇嫩之发,正如此窗棂之乌木也。” | 只见那般血迹,却也殷红;又见那般白雪,却也莹洁。她又望了望那乌木窗棂道:“但愿吾女肌肤如雪,颜色似朱,发髻如漆,方才好哩!” | 只见那女子把眼来望那白雪上点点鲜血,又看那乌木窗子道:"只愿俺的小女儿皮肉也似这般白净,便如这雪相似;须发也似这般漆黑光鲜,便似这乌木般好!" | 一面看那白雪中点点血痕,一面又瞧那乌木窗棂,因叹道:“只望我小女肌肤丰泽,如这雪白,血红,发也似的乌木一般。” |
她的小女儿渐渐长大了,小姑娘长得水灵灵的,真是人见人爱,美丽动人。她的皮肤真的就像雪一样的白嫩,又透着血一样的红润,头发像乌木一样的黑亮。所以王后给她取了个名字,叫白雪公主。 | 其女渐长,乃名曰:“白雪”,其色如雪,真美之极。肤若冰雪,发似乌木,故王后以白雪为号。 | 光阴似箭,不觉数载,那小女儿渐长成人,生得娉婷娇艳,真个是:肤如凝脂,貌若桃李,发似漆黑,故此王后名曰白雪公主。 | 那小女儿渐长成,生得十分美貌,真个有倾国之色,娇艳无伦。肌肤如玉,面似桃花,发若漆黑。因此王后便取名唤做"白雪公主"。 | 那丫头渐长,生得袅娜纤巧,乖觉伶俐,肌肤丰泽,容貌娇美,且是雪肌花颜,唇若施脂,腰如束柳。故此,王后便命名曰:“白雪”。 |
但白雪公主还没有长大,她的王后妈妈就死去了。不久,国王爸爸又娶了一个妻子。这个王后长得非常漂亮,但她很骄傲自负,嫉妒心极强,只要听说有人比她漂亮,她都不能忍受。 | 却说白雪公主年方幼小,其母王后乃亡矣。不数日,父王复纳新妇,此妇美而骄妒,闻人言有胜己者,不能容也。 | 那白雪公主尚幼年,其母王后已亡矣。不多时,国王复纳一妻,此女貌美而骄矜,妒忌之心甚重,闻得人言有胜于己者,即不能容也。 | 此时白雪公主尚幼小,其母王后便亡故了;不数日间,父王复纳新妇为妻。此女美貌绝伦,性傲气高,妒忌之心甚重,闻有胜己者,便不能容。 | 且说那白雪公主尚未长成,其母王后已亡故了。不几日,国王复纳一妻,此妃生得甚美,惟性傲慢,妒忌之心颇重,凡见人胜过己者,便不能容。 |
她有一块魔镜,她经常走到镜子面前自我欣赏,并问道:"告诉我,镜子,告诉我实话!这儿所有的女人谁最漂亮?告诉我她是谁?"镜子回答道:"是你,王后!你就是这儿最漂亮的女人。"听到这样的话,她就会满意地笑起来。 | 王后乃有魔镜,常自照其面曰:“汝言我,镜中实也!此间诸女何者最美?吾告汝其人。”镜答曰:“汝也,王后也!汝乃此处之绝色。”闻之,遂喜。 | 她又有个魔镜,常来照见,便问:“镜子呀,你且说个明白!这众女子中那一个最美?快教我认得他哩!”那镜子即答曰:“娘娘乃天下第一美人也。”闻言,她就欢喜而笑。 | 那娘子有面魔镜,常自照影,便问:"你且说与我,镜中甚人最美貌?是何女子?"镜答曰:"娘子乃此间第一美人也。"听得这话,便欢喜。 | 她又有一个宝镜,每日临镜自照,或问于镜曰:“我何人哉?”那镜便答道:“你乃天下第一美人儿!”如此一回,她就喜之不尽了。 |
但白雪公主慢慢地长大,并出落得越来越标致漂亮了。到了七岁时,她长得比明媚的春光还要艳丽夺目,比王后更美丽动人。直到有一天,王后像往常一样地去问那面魔镜时,镜子作出了这样的回答:"王后,你是美丽漂亮的,但是白雪公主要比你更加漂亮!"她听到了这话,心里充满了愤怒和妒忌,脸也变得苍白起来。 | 然则白雪公主渐渐长成,其美乃胜于昔日,至七岁之时,其容貌又胜王后。一日,王后如常问镜曰:“吾乃绝世之色,今白雪公主乃胜我矣!”闻言大怒,面亦变青。 | 光阴似箭,不觉又过了七年,白雪公主渐渐长成,却生得如花似玉,比那妩媚之春,胜似娇娘;及至王后来照那面魔镜,只见那镜中答道:“王后啊,你虽美貌,怎比得上白雪公主?”她闻言大怒,顿觉愁容惨淡,颜色憔悴。 | 且说白雪公主渐渐长成,生得十分美貌,至七岁之时,胜似春光,赛过王后。一日,王后照旧去问那面魔镜,镜中答道:"王后,你虽是极妙绝伦,却怎比得上白雪公主?"听得此言,心中忿怒,面如纸色。 | 且说白雪公主渐渐长成,生得不俗,至七岁上,便胜似春光,又胜过王后。一日,王后来照魔镜,镜中答道:“王后啊!你虽美貌,岂及白雪公主?”闻此言,心内大怒,容颜亦变。 |
她叫来了一名仆人对他说:"给我把白雪公主抓到大森林里去,我再也不希望看到她了。"仆人把白雪公主带走了。在森林里他正要动手杀死她时,她哭泣着哀求他不要杀害她。 | 其女唤一婢曰:“速将白雪公主擒至大林中,吾不复见之。”婢遂引白雪公主而去。行至林内,欲杀之,公主泣告勿杀。 | 遂唤一婢,教:“快与我拿白雪公主于大林中,再不许见也!”那婢即引白雪公主而去。及至林中,欲杀之,只见她哭告曰:“乞勿伤我性命。” | 那娘子唤得一个使女,分付道:"且将白雪公主捉到大林子里去,休教见我。"便将白雪公主掣出林外,欲杀之,哭告勿行。 | 只见那丫头便唤了一个使女来说道:“你且将白雪公主捉来,我那里还见得?”那使女领命去了,至大林中欲杀之,哭诉不饶。 |
面对楚楚动人的可怜小公主的哀求,仆人的同情之心油然而生,他说道:"你是一个人见人爱的孩子,我不会杀害你。"这样,他把她单独留在了森林里。 | 其仆怜楚楚之幼女,曰:“汝乃可爱之人,吾不杀汝。”遂将孤置于林中。 | 那小公主又哭得凄惨,那仆人心下甚怜,遂言曰:“汝乃好身儿,我岂杀汝?”遂将她独自留在林中。 | 那可怜的小公主楚楚动人,哭得仆人心软,便道:"汝乃天姿国色,吾岂忍杀?且将汝独自林中寄放。" | 那小丫头儿哭得可怜,又见仆人怜惜,便说道:“你是好人儿,我岂肯害你?”遂将她一人留在林中。 |
当仆人决定不再杀害白雪公主,而把她留在那儿时,尽管他知道在那荒无人际的大森林里,她十有八九会被野兽撕成碎片,但想到他不必亲手杀害她,他就觉得压在心上的一块沉重的大石头落了下来。 | 其仆见不杀白雪公主,留于彼处,虽知大林之中,必被虎狼食尽,然念吾不用亲刃之,心下遂宽了一块重石。 | 只见那厮家奴不肯杀白雪公主,却将她留此荒林之中,虽知必遭禽兽之嚼,然不须亲下手也,遂宽心矣。 | 仆人自思:若要杀白雪公主,便在此处;又恐此间大林子里,被禽兽啖食了,不如且留她在那里,我亦无须亲自下手。遂放了她去。 | 及至仆人主意已定,不欲加害于白雪公主,遂留之不去,虽知大林深处,必遭禽兽吞噬,然想自己无须亲自动手,便如卸了千钧重担一般。 |
🔍查看全文 | 🔍查看全文 | 🔍查看全文 | 🔍查看全文 |
利用StyleLLM模型对ChatGPT等通用大模型的输出进行风格改写,可改变对话风格单一、AI味过重的状况。(详细介绍见 StyleLLM-Chat)
from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("stylellm/SanGuoYanYi-6b")
model = AutoModelForCausalLM.from_pretrained("stylellm/SanGuoYanYi-6b").eval()
messages = [{"role": "user", "content": "严冬时节,鹅毛一样的大雪片在天空中到处飞舞着,有一个王后坐在王宫里的一扇窗子边,正在为她的女儿做针线活儿,寒风卷着雪片飘进了窗子,乌木窗台上飘落了不少雪花。"}]
input_ids = tokenizer.apply_chat_template(conversation=messages, tokenize=True, add_generation_prompt=True, return_tensors='pt')
output_ids = model.generate(input_ids, do_sample=False, repetition_penalty=1.2)
response = tokenizer.decode(output_ids[0][input_ids.shape[1]:], skip_special_tokens=True)
print("Output:", response)
# Output: 时值隆冬,大雪压境,王后坐于王宫之窗下,正与女作绣,寒风入室,吹落乌木窗台之雪。
本项目在模型训练中借助了下列开源项目,在此对相关项目人员表示诚挚感谢:
- 01-ai/Yi: 本项目模型底座
- hiyouga/LLaMA-Factory: 本项目训练框架
For Tasks:
Click tags to check more tools for each tasksFor Jobs:
Alternative AI tools for stylellm_models
Similar Open Source Tools
stylellm_models
**stylellm** is a text style transfer project based on large language models (llms). The project utilizes large language models to learn the writing style of specific literary works (commonly used vocabulary, sentence structure, rhetoric, character dialogue, etc.), forming a series of specific style models. Using the **stylellm** model, the learned style can be transferred to other general texts, that is: input a piece of original text, the model can rewrite it, output text with the characteristics of that style, achieving the effect of text modification,润色or style imitation.
llms-from-scratch-cn
This repository provides a detailed tutorial on how to build your own large language model (LLM) from scratch. It includes all the code necessary to create a GPT-like LLM, covering the encoding, pre-training, and fine-tuning processes. The tutorial is written in a clear and concise style, with plenty of examples and illustrations to help you understand the concepts involved. It is suitable for developers and researchers with some programming experience who are interested in learning more about LLMs and how to build them.
MindChat
MindChat is a psychological large language model designed to help individuals relieve psychological stress and solve mental confusion, ultimately improving mental health. It aims to provide a relaxed and open conversation environment for users to build trust and understanding. MindChat offers privacy, warmth, safety, timely, and convenient conversation settings to help users overcome difficulties and challenges, achieve self-growth, and development. The tool is suitable for both work and personal life scenarios, providing comprehensive psychological support and therapeutic assistance to users while strictly protecting user privacy. It combines psychological knowledge with artificial intelligence technology to contribute to a healthier, more inclusive, and equal society.
gpupixel
GPUPixel is a real-time, high-performance image and video filter library written in C++11 and based on OpenGL/ES. It incorporates a built-in beauty face filter that achieves commercial-grade beauty effects. The library is extremely easy to compile and integrate with a small size, supporting platforms including iOS, Android, Mac, Windows, and Linux. GPUPixel provides various filters like skin smoothing, whitening, face slimming, big eyes, lipstick, and blush. It supports input formats like YUV420P, RGBA, JPEG, PNG, and output formats like RGBA and YUV420P. The library's performance on devices like iPhone and Android is optimized, with low CPU usage and fast processing times. GPUPixel's lib size is compact, making it suitable for mobile and desktop applications.
aidea-server
AIdea Server is an open-source Golang-based server that integrates mainstream large language models and drawing models. It supports various functionalities including OpenAI's GPT-3.5 and GPT-4, Anthropic's Claude instant and Claude 2.1, Google's Gemini Pro, as well as Chinese models like Tongyi Qianwen, Wenxin Yiyuan, and more. It also supports open-source large models like Yi 34B, Llama2, and AquilaChat 7B. Additionally, it provides features for text-to-image, super-resolution, coloring black and white images, generating art fonts and QR codes, among others.
Awesome-LLMs-for-Video-Understanding
Awesome-LLMs-for-Video-Understanding is a repository dedicated to exploring Video Understanding with Large Language Models. It provides a comprehensive survey of the field, covering models, pretraining, instruction tuning, and hybrid methods. The repository also includes information on tasks, datasets, and benchmarks related to video understanding. Contributors are encouraged to add new papers, projects, and materials to enhance the repository.
go-cyber
Cyber is a superintelligence protocol that aims to create a decentralized and censorship-resistant internet. It uses a novel consensus mechanism called CometBFT and a knowledge graph to store and process information. Cyber is designed to be scalable, secure, and efficient, and it has the potential to revolutionize the way we interact with the internet.
MedicalGPT
MedicalGPT is a training medical GPT model with ChatGPT training pipeline, implement of Pretraining, Supervised Finetuning, RLHF(Reward Modeling and Reinforcement Learning) and DPO(Direct Preference Optimization).
pmhub
PmHub is a smart project management system based on SpringCloud, SpringCloud Alibaba, and LLM. It aims to help students quickly grasp the architecture design and development process of microservices/distributed projects. PmHub provides a platform for students to experience the transformation from monolithic to microservices architecture, understand the pros and cons of both architectures, and prepare for job interviews. It offers popular technologies like SpringCloud-Gateway, Nacos, Sentinel, and provides high-quality code, continuous integration, product design documents, and an enterprise workflow system. PmHub is suitable for beginners and advanced learners who want to master core knowledge of microservices/distributed projects.
Awesome-Jailbreak-on-LLMs
Awesome-Jailbreak-on-LLMs is a collection of state-of-the-art, novel, and exciting jailbreak methods on Large Language Models (LLMs). The repository contains papers, codes, datasets, evaluations, and analyses related to jailbreak attacks on LLMs. It serves as a comprehensive resource for researchers and practitioners interested in exploring various jailbreak techniques and defenses in the context of LLMs. Contributions such as additional jailbreak-related content, pull requests, and issue reports are welcome, and contributors are acknowledged. For any inquiries or issues, contact [email protected]. If you find this repository useful for your research or work, consider starring it to show appreciation.
DISC-LawLLM
DISC-LawLLM is a legal domain large model that aims to provide professional, intelligent, and comprehensive **legal services** to users. It is developed and open-sourced by the Data Intelligence and Social Computing Lab (Fudan-DISC) at Fudan University.
AlignBench
AlignBench is the first comprehensive evaluation benchmark for assessing the alignment level of Chinese large models across multiple dimensions. It includes introduction information, data, and code related to AlignBench. The benchmark aims to evaluate the alignment performance of Chinese large language models through a multi-dimensional and rule-calibrated evaluation method, enhancing reliability and interpretability.
Chinese-LLaMA-Alpaca
This project open sources the **Chinese LLaMA model and the Alpaca large model fine-tuned with instructions**, to further promote the open research of large models in the Chinese NLP community. These models **extend the Chinese vocabulary based on the original LLaMA** and use Chinese data for secondary pre-training, further enhancing the basic Chinese semantic understanding ability. At the same time, the Chinese Alpaca model further uses Chinese instruction data for fine-tuning, significantly improving the model's understanding and execution of instructions.
fastapi
智元 Fast API is a one-stop API management system that unifies various LLM APIs in terms of format, standards, and management, achieving the ultimate in functionality, performance, and user experience. It supports various models from companies like OpenAI, Azure, Baidu, Keda Xunfei, Alibaba Cloud, Zhifu AI, Google, DeepSeek, 360 Brain, and Midjourney. The project provides user and admin portals for preview, supports cluster deployment, multi-site deployment, and cross-zone deployment. It also offers Docker deployment, a public API site for registration, and screenshots of the admin and user portals. The API interface is similar to OpenAI's interface, and the project is open source with repositories for API, web, admin, and SDK on GitHub and Gitee.
step_into_llm
The 'step_into_llm' repository is dedicated to the 昇思MindSpore technology open class, which focuses on exploring cutting-edge technologies, combining theory with practical applications, expert interpretations, open sharing, and empowering competitions. The repository contains course materials, including slides and code, for the ongoing second phase of the course. It covers various topics related to large language models (LLMs) such as Transformer, BERT, GPT, GPT2, and more. The course aims to guide developers interested in LLMs from theory to practical implementation, with a special emphasis on the development and application of large models.
For similar tasks
stylellm_models
**stylellm** is a text style transfer project based on large language models (llms). The project utilizes large language models to learn the writing style of specific literary works (commonly used vocabulary, sentence structure, rhetoric, character dialogue, etc.), forming a series of specific style models. Using the **stylellm** model, the learned style can be transferred to other general texts, that is: input a piece of original text, the model can rewrite it, output text with the characteristics of that style, achieving the effect of text modification,润色or style imitation.
WriteNow
Write Now is an all-in-one writing assistant that helps users elevate their text with features like proofreading, rewriting, friendly and professional tones, concise mode, and custom AI server configuration. It prioritizes user privacy and offers a Lite Edition for trial purposes. Users can install Write Now through the Havoc Store and configure AI server endpoints for enhanced functionality.
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.
ai-guide
This guide is dedicated to Large Language Models (LLMs) that you can run on your home computer. It assumes your PC is a lower-end, non-gaming setup.
classifai
Supercharge WordPress Content Workflows and Engagement with Artificial Intelligence. Tap into leading cloud-based services like OpenAI, Microsoft Azure AI, Google Gemini and IBM Watson to augment your WordPress-powered websites. Publish content faster while improving SEO performance and increasing audience engagement. ClassifAI integrates Artificial Intelligence and Machine Learning technologies to lighten your workload and eliminate tedious tasks, giving you more time to create original content that matters.
mikupad
mikupad is a lightweight and efficient language model front-end powered by ReactJS, all packed into a single HTML file. Inspired by the likes of NovelAI, it provides a simple yet powerful interface for generating text with the help of various backends.
glide
Glide is a cloud-native LLM gateway that provides a unified REST API for accessing various large language models (LLMs) from different providers. It handles LLMOps tasks such as model failover, caching, key management, and more, making it easy to integrate LLMs into applications. Glide supports popular LLM providers like OpenAI, Anthropic, Azure OpenAI, AWS Bedrock (Titan), Cohere, Google Gemini, OctoML, and Ollama. It offers high availability, performance, and observability, and provides SDKs for Python and NodeJS to simplify integration.
onnxruntime-genai
ONNX Runtime Generative AI is a library that provides the generative AI loop for ONNX models, including inference with ONNX Runtime, logits processing, search and sampling, and KV cache management. Users can call a high level `generate()` method, or run each iteration of the model in a loop. It supports greedy/beam search and TopP, TopK sampling to generate token sequences, has built in logits processing like repetition penalties, and allows for easy custom scoring.
firecrawl
Firecrawl is an API service that takes a URL, crawls it, and converts it into clean markdown. It crawls all accessible subpages and provides clean markdown for each, without requiring a sitemap. The API is easy to use and can be self-hosted. It also integrates with Langchain and Llama Index. The Python SDK makes it easy to crawl and scrape websites in Python code.