初始化项目,由ModelHub XC社区提供模型

Model: adriangg04/TheLastOfUs-QA
Source: Original Platform
This commit is contained in:
ModelHub XC
2026-06-13 09:32:16 +08:00
commit 9519ca1bf6
8 changed files with 377 additions and 0 deletions

36
.gitattributes vendored Normal file
View File

@@ -0,0 +1,36 @@
*.7z filter=lfs diff=lfs merge=lfs -text
*.arrow filter=lfs diff=lfs merge=lfs -text
*.bin filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.ckpt filter=lfs diff=lfs merge=lfs -text
*.ftz filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.h5 filter=lfs diff=lfs merge=lfs -text
*.joblib filter=lfs diff=lfs merge=lfs -text
*.lfs.* filter=lfs diff=lfs merge=lfs -text
*.mlmodel filter=lfs diff=lfs merge=lfs -text
*.model filter=lfs diff=lfs merge=lfs -text
*.msgpack filter=lfs diff=lfs merge=lfs -text
*.npy filter=lfs diff=lfs merge=lfs -text
*.npz filter=lfs diff=lfs merge=lfs -text
*.onnx filter=lfs diff=lfs merge=lfs -text
*.ot filter=lfs diff=lfs merge=lfs -text
*.parquet filter=lfs diff=lfs merge=lfs -text
*.pb filter=lfs diff=lfs merge=lfs -text
*.pickle filter=lfs diff=lfs merge=lfs -text
*.pkl filter=lfs diff=lfs merge=lfs -text
*.pt filter=lfs diff=lfs merge=lfs -text
*.pth filter=lfs diff=lfs merge=lfs -text
*.rar filter=lfs diff=lfs merge=lfs -text
*.safetensors filter=lfs diff=lfs merge=lfs -text
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
*.tar.* filter=lfs diff=lfs merge=lfs -text
*.tar filter=lfs diff=lfs merge=lfs -text
*.tflite filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.wasm filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text
*tfevents* filter=lfs diff=lfs merge=lfs -text
tokenizer.json filter=lfs diff=lfs merge=lfs -text

177
README.md Normal file
View File

@@ -0,0 +1,177 @@
---
license: apache-2.0
datasets:
- adriangg04/the-last-of-us-instruction-dataset
language:
- en
base_model:
- Qwen/Qwen2.5-7B-Instruct
new_version: Qwen/Qwen2.5-7B-Instruct
pipeline_tag: text-generation
library_name: transformers
tags:
- agent
- text-generation
- question-answering
- the-last-of-us
- qwen
- fine-tuned
model-index:
- name: TheLastOfUs-QA
results:
- task:
type: question-answering
dataset:
name: the-last-of-us-instruction-dataset
type: the-last-of-us-instruction-dataset
metrics:
- name: Evaluation Loss
type: loss
value: 1.011
- name: Evaluation Entropy
type: entropy
value: 1.011
---
[![GitHub Source Code](https://img.shields.io/badge/GitHub-Source_Code-black?logo=github)](https://github.com/4drian04/qwen-7b-tlou-qa-finetuning)
# TheLastOfUs-QA: Fine-tuned Model on Qwen2.5-7B-Instructed for The Last of Us
This model is a fine-tuned version of the base model <a href="https://huggingface.co/Qwen/Qwen2.5-7B-Instruct">**Qwen2.5-7B-Instructed**</a>, specifically adapted to answer questions and generate text related to the universe of **The Last of Us**.
## Description
The model was trained to understand and generate content about the story, characters, events, and lore of the video game **The Last of Us**. Thanks to fine-tuning with the specialized dataset **the-last-of-us-instruction-dataset**, this model is capable of providing coherent and detailed answers to any query about this universe.
This model is ideal for:
- Creating conversational assistants that answer questions about The Last of Us.
- Generate narrative or explanatory content based on the game's lore.
- Support creative projects related to the post-apocalyptic world of The Last of Us.
## Training Dataset
The model was trained using the <a href="https://huggingface.co/datasets/adriangg04/the-last-of-us-instruction-dataset">**the-last-of-us-instruction-dataset**</a>, a custom dataset containing instructions and questions about the game's universe, as well as answers based on the official narrative and key story elements.
## Training Details
- **Base model:** Qwen/Qwen2.5-7B-Instruct
- **Method:** QLoRA (4-bit) + PEFT
**LoRA**
- r=16, alpha=32, dropout=0.05
- target: q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
**Training**
- epochs=3, lr=1e-4, scheduler=cosine
- batch=4, grad_accum=4 (effective=16)
- warmup=0.03
**Optimization**
- optimizer: paged_adamw_8bit
- bf16 + gradient checkpointing
**Quantization**
- 4-bit (nf4), double quant, bfloat16 compute
**Eval & Saving**
- eval/save: each epoch
- best model: eval_loss
## LoRA Merge
After fine-tuning, the LoRA adapters were merged into the base model weights.
### Why merge?
Merging the LoRA adapters has several advantages:
- **Simpler usage**: The model can be used directly without loading additional adapters.
- **Better compatibility**: Works seamlessly with standard inference pipelines.
- **Easier deployment**: No need to manage separate LoRA weights.
- **Improved portability**: A single model file is easier to share and integrate.
### Notes
- The performance is equivalent to using the LoRA adapters during inference.
- This repository provides the **fully merged model**, ready for immediate use.
## Hardware
The model was fine-tuned using:
- GPU: NVIDIA T4
- Precision: bfloat16 + 4-bit quantization
- Frameworks:
- Transformers
- PEFT
- TRL (SFTTrainer)
- BitsAndBytes
## Training Efficiency
Thanks to QLoRA and 4-bit quantization:
- Only a small percentage of parameters were trained (LoRA adapters)
- Reduced VRAM usage, enabling training on a single GPU
- Maintained strong performance while being computationally efficient
## Prompt Format
This model follows a chat-based format using roles:
- system
- user
- assistant
Example:
messages = [
{"role": "system", "content": "You are an expert on The Last of Us"},
{"role": "user", "content": "Who is Ellie?"}
]
## Example of Use
You can load the model directly with Transformers:
```python
from transformers import pipeline, AutoTokenizer
MODEL_NAME = "adriangg04/TheLastOfUs-QA"
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
pipe = pipeline(
"text-generation",
model=MODEL_NAME,
tokenizer=tokenizer,
device_map="auto"
)
# Prompt de prueba simple
messages = [
{"role": "system", "content": "You are an expert on The Last of Us"},
{"role": "user", "content": "What is the main reason for Ellie's journey to Seattle in The Last of Us?"}
]
prompt = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
response = pipe(
prompt,
max_new_tokens=200,
temperature=0.5
)
answer = response[0]["generated_text"]
print("Prompt:", messages[1]["content"])
print("Response:", answer)
```
**Disclaimer:** This model is not affiliated with, endorsed by, or approved by Naughty Dog, Sony Interactive Entertainment, or PlayStation. All content related to *The Last of Us* is used solely for professional and research purposes. Copyrights and trademarks belong to their respective owners.

54
chat_template.jinja Normal file
View File

@@ -0,0 +1,54 @@
{%- if tools %}
{{- '<|im_start|>system\n' }}
{%- if messages[0]['role'] == 'system' %}
{{- messages[0]['content'] }}
{%- else %}
{{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }}
{%- endif %}
{{- "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
{%- for tool in tools %}
{{- "\n" }}
{{- tool | tojson }}
{%- endfor %}
{{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
{%- else %}
{%- if messages[0]['role'] == 'system' %}
{{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
{%- else %}
{{- '<|im_start|>system\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\n' }}
{%- endif %}
{%- endif %}
{%- for message in messages %}
{%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
{{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
{%- elif message.role == "assistant" %}
{{- '<|im_start|>' + message.role }}
{%- if message.content %}
{{- '\n' + message.content }}
{%- endif %}
{%- for tool_call in message.tool_calls %}
{%- if tool_call.function is defined %}
{%- set tool_call = tool_call.function %}
{%- endif %}
{{- '\n<tool_call>\n{"name": "' }}
{{- tool_call.name }}
{{- '", "arguments": ' }}
{{- tool_call.arguments | tojson }}
{{- '}\n</tool_call>' }}
{%- endfor %}
{{- '<|im_end|>\n' }}
{%- elif message.role == "tool" %}
{%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
{{- '<|im_start|>user' }}
{%- endif %}
{{- '\n<tool_response>\n' }}
{{- message.content }}
{{- '\n</tool_response>' }}
{%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
{{- '<|im_end|>\n' }}
{%- endif %}
{%- endif %}
{%- endfor %}
{%- if add_generation_prompt %}
{{- '<|im_start|>assistant\n' }}
{%- endif %}

61
config.json Normal file
View File

@@ -0,0 +1,61 @@
{
"architectures": [
"Qwen2ForCausalLM"
],
"attention_dropout": 0.0,
"bos_token_id": 151643,
"dtype": "bfloat16",
"eos_token_id": 151645,
"hidden_act": "silu",
"hidden_size": 3584,
"initializer_range": 0.02,
"intermediate_size": 18944,
"layer_types": [
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention"
],
"max_position_embeddings": 32768,
"max_window_layers": 28,
"model_type": "qwen2",
"num_attention_heads": 28,
"num_hidden_layers": 28,
"num_key_value_heads": 4,
"pad_token_id": null,
"rms_norm_eps": 1e-06,
"rope_parameters": {
"rope_theta": 1000000.0,
"rope_type": "default"
},
"sliding_window": null,
"tie_word_embeddings": false,
"transformers_version": "5.2.0",
"use_cache": true,
"use_sliding_window": false,
"vocab_size": 152064
}

14
generation_config.json Normal file
View File

@@ -0,0 +1,14 @@
{
"bos_token_id": 151643,
"do_sample": true,
"eos_token_id": [
151645,
151643
],
"pad_token_id": 151643,
"repetition_penalty": 1.05,
"temperature": 0.7,
"top_k": 20,
"top_p": 0.8,
"transformers_version": "5.2.0"
}

3
model.safetensors Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0d76de496e2560f1ffca82d8cfb9f2d107337bc67121832ee3f2d8eac48678e5
size 15231272152

3
tokenizer.json Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3fd169731d2cbde95e10bf356d66d5997fd885dd8dbb6fb4684da3f23b2585d8
size 11421892

29
tokenizer_config.json Normal file
View File

@@ -0,0 +1,29 @@
{
"add_prefix_space": false,
"backend": "tokenizers",
"bos_token": null,
"clean_up_tokenization_spaces": false,
"eos_token": "<|im_end|>",
"errors": "replace",
"extra_special_tokens": [
"<|im_start|>",
"<|im_end|>",
"<|object_ref_start|>",
"<|object_ref_end|>",
"<|box_start|>",
"<|box_end|>",
"<|quad_start|>",
"<|quad_end|>",
"<|vision_start|>",
"<|vision_end|>",
"<|vision_pad|>",
"<|image_pad|>",
"<|video_pad|>"
],
"is_local": false,
"model_max_length": 131072,
"pad_token": "<|endoftext|>",
"split_special_tokens": false,
"tokenizer_class": "Qwen2Tokenizer",
"unk_token": null
}