Wulewule is an open-source AI assistant project for Black Myth: Wukong based on InternLM, aiming to help players deeply explore the game's cultural connotations and enrich their gaming experience. By analyzing the game's storyline, character origins, clever connections to the original work, hidden details in the game, and interesting easter eggs, the project lets players better understand the traditional Chinese culture behind the game; in addition, the assistant also provides detailed game guides to help players complete the game easily.
Main capabilities
- A knowledge Q&A assistant for game characters, background stories, connections to the original work, and more.
- Uses RAG to support updates with fresh knowledge such as game guides, menus, and internet memes.
- An agent based on LlamaIndex, integrating TTS (text-to-speech) and text-to-image tools.
- Supports history memory, and plans to add a standard test set to evaluate model performance using opencompass.
Technical implementation The model is fine-tuned on InternLM2.5 using xtuner: first, incremental pretraining is performed on some web data (such as the Chinese and English versions of Journey to the West, Wukong Zhuan, etc.), and then QLoRA instruction fine-tuning is performed based on an accurate question-answer pair dataset generated by RAG. During deployment, RAG and LMDeploy are integrated to accelerate inference, specifically including:
- Creating an accurate and real-time new knowledge dataset based on RAG.
- KV cache + Turbomind inference acceleration.
- An agent based on LlamaIndex (TTS, text-to-image).
How to use
- Hugging Face demo address:https://huggingface.co/spaces/xzyun2011/wulewule
- The models in the Agent all call SiliconFlow's API (not fine-tuned models), and are only for experiencing the overall effect.
- Dataset creation: split the text data collected from the web, and run the script to obtain the incremental_pretraining.jsonl incremental pretraining data; replace the api_key in data_utils.py with your own, and run the script to obtain the self_cognition.jsonl self-cognition data; after starting the Huixiangdou server service, run the script to obtain the accurate question-answer pair data huixiangdou_conversations.jsonl.
- Training configuration: note that accumulative_counts = 1, and be sure to change it to 1 for single-GPU training. QLoRA+deepspeed training is supported.
- Model quantization: use the command to apply w4a16 quantization to the model. For more operations, refer to the official lmdeploy documentation.
- RAG deployment: modify the configs/model_cfg.yaml file to enable the w4a16-4bit model based on lmdeploy (enabled by default); deploy/lmdeploy_model.py is a simple demo, and it can be run directly after modifying the configuration. The default data directory is the txt data source directory. After RAG is enabled, bce-embedding-base_v1 will be used to automatically convert the txt data under the data directory into chroma vector database data, stored in the rag/chroma directory (if database files already exist in that directory, database creation is skipped), and then bce-reranker-base_v1 will be used to rerank the retrieved information, after which the question and context are given to the model together to obtain the final output. rag/simple_rag.py is a simple demo, and the parameter configuration can be found in configs/rag_cfg.yaml.
- Agent configuration: modify the configs/agent_cfg.yaml configuration file. By default, the remote LLM and Embeddings models of the SiliconFlow API are used. The RAG tool in the Agent loads the txt data under the data directory to build the knowledge base. In addition, there are text-to-speech and text-to-image tools, both of which call SiliconFlow API for implementation.
Applicable scenarios Suitable for Black Myth: Wukong players to query game characters, background stories, connections to the original work, and guides, and also suitable as a practical project for learning large model fine-tuning, RAG, and agent deployment.
Limitations
- The project-related resources are for academic research only, and commercial use is strictly prohibited. When using parts involving third-party code, please strictly follow the corresponding open-source licenses.
- The content generated by the model is affected by factors such as model computation, randomness, and quantization precision loss. This project does not guarantee its accuracy, nor does it assume any responsibility for any losses that may arise from the use of related resources and output results.
- The project is initiated and maintained by individuals and collaborators in their spare time, and there is no guarantee of timely replies to resolve corresponding issues.
- The models in the Agent all call SiliconFlow's API (not fine-tuned models), and are only for experiencing the overall effect.