Pegasus YaY
commited on
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,141 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
---
|
4 |
+
# CardProjector-24B-v1
|
5 |
+
|
6 |
+
## Overview
|
7 |
+
|
8 |
+
CardProjector-24B-v1 is a specialized language model derived from Mistral Small, fine-tuned to generate character cards for **SillyTavern** in the **chara_card_v2** specification. This model is designed to assist creators and roleplayers by automating the process of crafting detailed and well-structured character cards, ensuring compatibility with SillyTavern's format.
|
9 |
+
|
10 |
+
Whether you're creating NPCs for storytelling, roleplaying games, or interactive fiction, CardProjector-24B-v1 streamlines the workflow while maintaining high-quality outputs tailored to your needs.
|
11 |
+
|
12 |
+
---
|
13 |
+
|
14 |
+
## Key Features
|
15 |
+
|
16 |
+
- **Specialized Output Format**: Generates character cards strictly adhering to the `chara_card_v2` JSON schema used by SillyTavern.
|
17 |
+
- **Rich Character Details**: Produces comprehensive profiles including personality traits, appearance descriptions, example dialogues, and scenario setups.
|
18 |
+
- **Customizable Inputs**: Allows users to provide prompts, themes, or specific attributes to guide the generation process.
|
19 |
+
- **High-Quality Writing**: Leverages Mistral Small’s robust linguistic capabilities to ensure engaging, coherent, and creative writing.
|
20 |
+
- **Roleplay-Friendly**: Optimized for use in collaborative storytelling environments like SillyTavern.
|
21 |
+
|
22 |
+
---
|
23 |
+
|
24 |
+
## Use Cases
|
25 |
+
|
26 |
+
- **Storytelling & Worldbuilding**: Quickly populate your fictional worlds with diverse characters.
|
27 |
+
- **Interactive Fiction**: Create dynamic NPCs for text-based adventures or chat-based roleplaying platforms.
|
28 |
+
- **Game Development**: Generate placeholder or fully fleshed-out characters for game prototypes.
|
29 |
+
- **Creative Writing Assistance**: Overcome writer’s block by generating unique character ideas and backstories.
|
30 |
+
|
31 |
+
---
|
32 |
+
|
33 |
+
## Getting Started
|
34 |
+
|
35 |
+
### Prerequisites
|
36 |
+
|
37 |
+
- Python 3.8+
|
38 |
+
- Libraries: `transformers`, `torch`, `json`
|
39 |
+
- Access to the pre-trained weights of CardProjector-24B-v1 (contact the maintainers for access).
|
40 |
+
|
41 |
+
### Installation
|
42 |
+
|
43 |
+
```bash
|
44 |
+
pip install transformers torch
|
45 |
+
```
|
46 |
+
|
47 |
+
### Usage Example
|
48 |
+
|
49 |
+
Here’s how you can generate a character card using CardProjector-24B-v1:
|
50 |
+
|
51 |
+
```python
|
52 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
53 |
+
import json
|
54 |
+
|
55 |
+
# Load the model and tokenizer
|
56 |
+
model_name = "path_to_CardProjector-24B-v1"
|
57 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
58 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
59 |
+
|
60 |
+
# Define input prompt
|
61 |
+
prompt = """
|
62 |
+
Create a character card for a wise old wizard who lives in a forest.
|
63 |
+
He is kind but mysterious, often speaking in riddles. His name is Eldrin.
|
64 |
+
"""
|
65 |
+
|
66 |
+
# Tokenize and generate
|
67 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
68 |
+
outputs = model.generate(**inputs, max_length=512)
|
69 |
+
|
70 |
+
# Decode and parse output as JSON
|
71 |
+
output_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
72 |
+
character_card = json.loads(output_text)
|
73 |
+
|
74 |
+
# Save to file
|
75 |
+
with open("eldrin_character_card.json", "w") as f:
|
76 |
+
json.dump(character_card, f, indent=4)
|
77 |
+
|
78 |
+
print("Character card saved to eldrin_character_card.json")
|
79 |
+
```
|
80 |
+
|
81 |
+
### Sample Output (`chara_card_v2` Schema)
|
82 |
+
|
83 |
+
```json
|
84 |
+
{
|
85 |
+
"name": "Eldrin",
|
86 |
+
"description": "A wise old wizard residing deep within an ancient forest. Known for his kindness and cryptic wisdom.",
|
87 |
+
"personality": "Kind-hearted yet enigmatic, Eldrin enjoys testing others' wit through riddles and puzzles.",
|
88 |
+
"scenario": "You find yourself lost in the dense woods when suddenly, a faint glow reveals a small cottage ahead...",
|
89 |
+
"example_dialogue": [
|
90 |
+
{"speaker": "You", "message": "Can you help me find my way out of this forest?"},
|
91 |
+
{"speaker": "Eldrin", "message": "Ah, the path is not always where it seems. Tell me first—what walks on four legs at dawn?"}
|
92 |
+
],
|
93 |
+
"metadata": {
|
94 |
+
"version": "chara_card_v2",
|
95 |
+
"tags": ["wizard", "forest", "riddle", "kind"]
|
96 |
+
}
|
97 |
+
}
|
98 |
+
```
|
99 |
+
|
100 |
+
---
|
101 |
+
|
102 |
+
## Fine-Tuning & Customization
|
103 |
+
|
104 |
+
If you'd like to further fine-tune CardProjector-24B-v1 for niche genres or specific styles, follow these steps:
|
105 |
+
|
106 |
+
1. Prepare a dataset of character cards in the `chara_card_v2` format.
|
107 |
+
2. Use Hugging Face’s `Trainer` API to fine-tune the model.
|
108 |
+
3. Evaluate the updated model for consistency and creativity.
|
109 |
+
|
110 |
+
For more details, refer to the [Hugging Face Documentation](https://huggingface.co/docs/transformers/training).
|
111 |
+
|
112 |
+
---
|
113 |
+
|
114 |
+
## Limitations
|
115 |
+
|
116 |
+
- **Input Sensitivity**: The quality of generated cards depends heavily on the clarity and specificity of the input prompt.
|
117 |
+
- **Token Limitations**: Very long prompts may exceed the model’s context window, leading to truncated outputs.
|
118 |
+
- **Ethical Considerations**: Ensure that generated content aligns with ethical guidelines, avoiding harmful stereotypes or inappropriate material.
|
119 |
+
|
120 |
+
---
|
121 |
+
|
122 |
+
## Contributing
|
123 |
+
|
124 |
+
Contributions are welcome! If you have suggestions, bug reports, or feature requests, please open an issue on our GitHub repository.
|
125 |
+
|
126 |
+
---
|
127 |
+
|
128 |
+
## License
|
129 |
+
|
130 |
+
CardProjector-24B-v1 is released under the MIT License. See the [LICENSE](LICENSE) file for more information.
|
131 |
+
|
132 |
+
---
|
133 |
+
|
134 |
+
## Acknowledgments
|
135 |
+
|
136 |
+
- Built upon the foundational work of Mistral AI and their Mistral Small model.
|
137 |
+
- Inspired by the vibrant communities around SillyTavern and interactive storytelling.
|
138 |
+
|
139 |
+
---
|
140 |
+
|
141 |
+
For questions or support, contact us at [[email protected]].
|