Model Overview
Model Features
Model Capabilities
Use Cases
🚀 StyleLLM: A Large Model for Text Style Transfer
StyleLLM is a text style transfer project based on large language models (LLMs). It leverages LLMs to learn the writing styles (common vocabulary, sentence structures, rhetorical devices, character dialogues, etc.) of specified literary works, creating a series of models with specific styles. These models can transplant the learned styles onto other general texts. That is, given an original text, the model can rewrite it to output a text with the learned style, achieving the effects of text decoration, polishing, or style imitation.
🚀 Quick Start
Model Introduction
StyleLLM is a text style transfer project based on large language models (LLMs). The project uses LLMs to learn the writing styles (common vocabulary, sentence structures, rhetorical devices, character dialogues, etc.) of specified literary works, creating a series of models with specific styles.
With the StyleLLM models, the learned styles can be transplanted onto other general texts. That is, given an original text, the model can rewrite it to output a text with the learned style, achieving the effects of text decoration, polishing, or style imitation.
Model List
StyleLLM - Chinese Four Great Classical Novels Series includes four models fine - tuned on Yi - 6b, trained on the four Chinese classical novels: Romance of the Three Kingdoms, Journey to the West, Water Margin, and Dream of the Red Chamber.
Style | Model | Usage |
---|---|---|
Romance of the Three Kingdoms Style | 🤗 stylellm/SanGuoYanYi-6b | inference.py |
Journey to the West Style | 🤗 stylellm/XiYouJi-6b | inference.py |
Water Margin Style | 🤗 stylellm/ShuiHuZhuan-6b | inference.py |
Dream of the Red Chamber Style | 🤗 stylellm/HongLouMeng-6b | inference.py |
Effect Demonstration
Using the original text of Snow White as input, here are the rewritten results of different style models.
Original Text - Snow White | Rewritten - Romance of the Three Kingdoms Style | Rewritten - Journey to the West Style | Rewritten - Water Margin Style | Rewritten - Dream of the Red Chamber Style |
---|---|---|---|---|
In the cold winter, large snowflakes like goose feathers were flying everywhere in the sky. A queen was sitting by a window in the palace, sewing for her daughter. The cold wind blew the snowflakes into the window, and a lot of snow fell on the ebony windowsill. | It was the depth of winter, and the heavy snow was pressing down. The queen was sitting by the window of the palace, sewing with her daughter. The cold wind blew into the room, blowing the snow off the ebony windowsill. | Just then: The north wind was howling, and the auspicious snow was swirling. The queen was sitting by the window, teaching her daughter to sew. Behold: The cold wind blew the snow into the window, and the snow piled up on the ebony windowsill. | It was the middle of winter, and the goose - feather - like snow was flying wildly. There was a queen sitting in front of a window in the palace, sewing clothes for her daughter. The cold wind blew the snow into the window, and it even crushed the ebony windowsill. | It was the severe winter. The goose - feather snow was falling thick and fast. Behold, the queen was sitting by the window of the palace, teaching her daughter to do needlework. Suddenly, the cold wind blew the snow into the window, and there was half a day's worth of snow on the ebony windowsill. |
She looked out of the window. Carelessly, the needle pricked her finger, and bright red blood flowed out from the needle hole. Three drops of blood fell on the snowflakes that had blown into the window. | Her daughter looked up at the window. Unexpectedly, the needle pricked her finger, and blood dripped onto the snow, leaving three dots. | Behold, when the girl looked out of the window, unexpectedly, she pricked her finger with the needle. Then, she saw the blood, which was like two or three drops of blood beads falling into the snow. | When the lady looked up, she thought it was a snowflake falling. Without warning, she pinched the needle in her hand. For a moment, she lost her grip, and it hit the tip of her finger. Then, she saw the blood. Two or three drops dripped into the window. | Behold, when the girl looked out of the window, for a moment, the needle pricked her hand, and blood came out. Two or three drops of blood fell into the snow. |
She stared thoughtfully at the bright red blood drops on the white snow, then looked at the ebony windowsill, and said, "I hope my little daughter's skin will be fair with a rosy glow, just like this white snow and bright red blood, so gorgeous and delicate. And her hair will be as black and shiny as the ebony of this window!" | Her daughter stared intently at the bright red blood drops on the white snow. Then, she looked at the ebony window frame and said, "I wish my little daughter's skin were as white as snow, and her appearance were like this white snow and bright red blood. Her delicate hair should be just like the ebony of this window frame." | Behold, the bloodstains were so red; and the snow was so pure. She looked at the ebony window frame again and said, "I hope my daughter's skin is as white as snow, her complexion is like vermilion, and her hair is as black as lacquer. That would be perfect!" | The woman looked at the little drops of blood on the white snow and then at the ebony window. She said, "I just hope my little daughter's skin is as fair as this, just like this snow; and her hair is as black and shiny as this ebony!" | While looking at the little bloodstains in the white snow and then at the ebony window frame, she sighed and said, "I just hope my little daughter's skin is plump and fair, like this white snow and red blood, and her hair is like this ebony." |
Her little daughter grew up gradually. The little girl was so delicate and charming that everyone loved her. Her skin was really as fair and delicate as snow, with a rosy glow like blood, and her hair was as black and shiny as ebony. So the queen gave her a name, Snow White. | Her daughter grew up gradually. She was named "Snow White". Her complexion was like snow, extremely beautiful. Her skin was like ice and snow, and her hair was like ebony. So the queen named her Snow White. | Time flew like an arrow. Unconsciously, several years passed. The little daughter grew up. She was so charming and delicate. Truly: Her skin was like congealed fat, her appearance was like a peach blossom, and her hair was as black as ink. Therefore, the queen named her Snow White. | The little daughter grew up gradually. She was extremely beautiful, truly having the charm to topple kingdoms. Her skin was like jade, her face was like a peach blossom, and her hair was as black as ink. Therefore, the queen named her "Snow White". | The girl grew up gradually. She was slender and delicate, clever and cute. Her skin was plump and fair, and her appearance was charming. Moreover, she had a fair complexion and red lips, a willowy waist. Therefore, the queen named her "Snow White". |
But before Snow White grew up, her queen mother died. Soon after, her king father married another wife. This queen was very beautiful, but she was very proud and conceited, with extremely strong jealousy. As long as she heard that someone was more beautiful than her, she couldn't stand it. | It is said that Snow White was still young when her mother, the queen, died. A few days later, the king remarried. This woman was beautiful but proud and jealous. When she heard that someone was better than herself, she couldn't tolerate it. | Snow White was still a child when her mother, the queen, died. Not long after, the king married another wife. This woman was beautiful but proud and arrogant, with a very strong sense of jealousy. When she heard that someone was better than herself, she couldn't tolerate it. | At this time, Snow White was still young when her mother, the queen, died. Within a few days, the king remarried. This woman was extremely beautiful, with a proud and high - spirited nature and a very strong sense of jealousy. When she heard that someone was better than herself, she couldn't tolerate it. | It is said that Snow White was not yet fully grown when her mother, the queen, died. A few days later, the king married another wife. This concubine was very beautiful, but she was arrogant and had a very strong sense of jealousy. Whenever she saw someone better than herself, she couldn't tolerate it. |
She had a magic mirror. She often went in front of the mirror to admire herself and asked, "Tell me, mirror, tell me the truth! Who is the most beautiful woman here? Tell me who she is!" The mirror replied, "It's you, Queen! You are the most beautiful woman here." Hearing this, she would smile contentedly. | The queen had a magic mirror. She often looked at herself in the mirror and said, "Tell me, mirror, the truth! Which of the women here is the most beautiful? Tell me who she is." The mirror replied, "It's you, Queen! You are the most beautiful here." Hearing this, she was pleased. | She also had a magic mirror. She often came to look at it and asked, "Mirror, tell me clearly! Which of these women is the most beautiful? Quickly let me recognize her!" The mirror immediately replied, "Your Highness is the most beautiful woman in the world." Hearing this, she laughed happily. | The woman had a magic mirror. She often looked at her reflection and asked, "Tell me, who is the most beautiful in the mirror? Which woman is it?" The mirror replied, "My lady is the most beautiful here." Hearing this, she was happy. | She also had a precious mirror. Every day, she looked at herself in the mirror and sometimes asked the mirror, "Who am I?" The mirror would reply, "You are the most beautiful woman in the world!" Every time this happened, she was overjoyed. |
But Snow White grew up slowly and became more and more beautiful. When she was seven years old, she was more gorgeous than the bright spring scenery and more beautiful than the queen. One day, as usual, the queen went to ask the magic mirror. The mirror replied, "Queen, you are beautiful, but Snow White is more beautiful than you!" Hearing this, she was filled with anger and jealousy, and her face turned pale. | However, Snow White grew up gradually, and her beauty surpassed that of the past. When she was seven years old, her appearance was even more beautiful than the queen's. One day, the queen asked the mirror as usual, "I am the most beautiful in the world, but now Snow White has surpassed me!" Hearing this, she was furious, and her face turned green. | Time flew like an arrow. Unconsciously, another seven years passed. Snow White grew up gradually. She was as beautiful as a flower. Compared with the charming spring, she was more like a delicate girl. When the queen came to look at the magic mirror, behold, the mirror replied, "Your Highness, although you are beautiful, how can you compare with Snow White?" Hearing this, she was furious. Suddenly, her face looked sad and haggard. | It is said that Snow White grew up gradually. She was extremely beautiful. When she was seven years old, she was more beautiful than the spring scenery and more beautiful than the queen. One day, the queen went to ask the magic mirror as usual. The mirror replied, "Your Highness, although you are extremely wonderful, how can you compare with Snow White?" Hearing this, she was angry, and her face was as white as paper. | It is said that Snow White grew up gradually. She was quite extraordinary. When she was seven years old, she was more beautiful than the spring scenery and more beautiful than the queen. One day, the queen came to look at the magic mirror. The mirror replied, "Your Highness! Although you are beautiful, how can you compare with Snow White?" Hearing this, she was extremely angry, and her appearance changed. |
She called a servant and said to him, "Catch Snow White and take her to the big forest. I never want to see her again." The servant took Snow White away. In the forest, when he was about to kill her, she cried and pleaded with him not to kill her. | Her daughter called a maid and said, "Quickly capture Snow White and take her to the big forest. I don't want to see her again." The maid led Snow White away. When they reached the forest, she was about to kill her. The princess cried and begged not to be killed. | Then, she called a maid and ordered, "Quickly take Snow White to the big forest. Don't let me see her again!" The maid immediately led Snow White away. When they reached the forest, she was about to kill her. Behold, she cried and said, "Please don't hurt my life." | The woman called a maid and said, "Take Snow White to the big forest. Don't let me see her." Then, she pulled Snow White out of the forest and was about to kill her. She cried and pleaded not to do it. | Behold, the girl called a maid and said, "You take Snow White away. How can I bear to see her?" The maid took the order and left. When she reached the big forest and was about to kill her, Snow White cried and pleaded not to be spared. |
Facing the pitiful little princess's pleading, the servant's sympathy welled up. He said, "You are a lovely child. I won't kill you." So, he left her alone in the forest. | The servant pitied the delicate little girl and said, "You are a lovely person. I won't kill you." Then, he left her alone in the forest. | The little princess was crying so miserably that the servant felt very sorry for her. Then, he said, "You are a good girl. How could I kill you?" Then, he left her alone in the forest. | The poor little princess was so charming that the servant's heart softened. He said, "You are a natural beauty. How could I bear to kill you? I'll just leave you alone in the forest." | The little girl was crying so pitifully. Seeing that the servant pitied her, she said, "You are a good person. How could I harm you?" Then, she left her alone in the forest. |
When the servant decided not to kill Snow White and left her there, although he knew that in that desolate and uninhabited big forest, she would most likely be torn to pieces by wild animals, he felt as if a heavy stone had fallen from his heart when he thought that he didn't have to kill her with his own hands. | The servant saw that he didn't kill Snow White and left her there. Although he knew that in the big forest, she would surely be eaten by tigers and wolves, yet thinking that he didn't have to kill her with his own hands, his heart felt lighter as if a heavy stone had been removed. | Behold, the servant refused to kill Snow White and left her in this desolate forest. Although he knew that she would surely be devoured by wild animals, yet since he didn't have to do it himself, he felt relieved. | The servant thought to himself: If I want to kill Snow White, I'll do it here. But I'm afraid that in this big forest, she'll be eaten by wild animals. It's better to leave her there. I don't have to do it myself. Then, he let her go. | After the servant had made up his mind not to harm Snow White, he left her there. Although he knew that deep in the big forest, she would surely be devoured by wild animals, yet thinking that he didn't have to do it himself, he felt as if a thousand - jun burden had been lifted. |
🔍View Full Text | 🔍View Full Text | 🔍View Full Text | 🔍View Full Text |
💻 Usage Examples
Basic Usage
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: 时值隆冬,大雪压境,王后坐于王宫之窗下,正与女作绣,寒风入室,吹落乌木窗台之雪。
📄 License
This project uses the yi-license.
👏 Acknowledgments
This project benefited from the following open - source projects during model training. We sincerely thank the relevant project teams:
- 01-ai/Yi: The base model of this project.
- hiyouga/LLaMA-Factory: The training framework of this project.

