初始化项目,由ModelHub XC社区提供模型
Model: giux78/buddy-nesso-sft-v1 Source: Original Platform
This commit is contained in:
36
.gitattributes
vendored
Normal file
36
.gitattributes
vendored
Normal 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
|
||||
236
README.md
Normal file
236
README.md
Normal file
@@ -0,0 +1,236 @@
|
||||
---
|
||||
language:
|
||||
- en
|
||||
- it
|
||||
license: other
|
||||
library_name: transformers
|
||||
tags:
|
||||
- text-generation
|
||||
- conversational
|
||||
- sft
|
||||
- children
|
||||
- storytelling
|
||||
- italian
|
||||
- english
|
||||
base_model: mii-llm/nesso-0.4B-agentic
|
||||
pipeline_tag: text-generation
|
||||
---
|
||||
|
||||
# Buddy Nesso SFT v1
|
||||
|
||||
`giux78/buddy-nesso-sft-v1` is a supervised fine-tuned version of [`mii-llm/nesso-0.4B-agentic`](https://huggingface.co/mii-llm/nesso-0.4B-agentic), a 0.4B parameter language model trained from scratch. This SFT version is an early experiment toward a warm bilingual story and play companion for children under 8.
|
||||
|
||||
The model is trained to support short interactive fairy tales, pretend play, simple guessing games, calm bedtime-style endings, and safe redirection away from private or unsafe requests. It currently supports English and Italian. It is not intended to mix languages in the same conversation unless the user does so.
|
||||
|
||||
## Important Safety Status
|
||||
|
||||
This is a research/development checkpoint, not a production child-safety model. It should be tested with adult supervision and additional safety layers before any real use with children.
|
||||
|
||||
Known limitations observed in evaluation:
|
||||
|
||||
- It may not always refuse privacy-sensitive requests strongly enough.
|
||||
- It may ask for personal information in some cases, despite the intended behavior.
|
||||
- It may mishandle unsafe play requests such as real fire or risky movement.
|
||||
- It may continue asking questions after the child says they want to stop or sleep.
|
||||
- It may fail to run stateful games correctly.
|
||||
- It can become repetitive or overlong when generation limits are high.
|
||||
|
||||
Use a safety filter, strict system prompt, short generation limits, and human review for any child-facing application.
|
||||
|
||||
## Intended Purpose
|
||||
|
||||
The target behavior is a gentle interactive buddy that can:
|
||||
|
||||
- co-create short fairy tales with a child;
|
||||
- continue a story using the child’s choices;
|
||||
- suggest simple safe games;
|
||||
- support pretend play, such as shops, animals, clouds, or magical objects;
|
||||
- help move toward calm bedtime endings;
|
||||
- redirect unsafe or private requests into safe fantasy alternatives.
|
||||
|
||||
Example interaction style:
|
||||
|
||||
```text
|
||||
Child: Can we make a story with a tiny bear and a kind moon?
|
||||
Nesso: Of course. The tiny bear walks under the kind moon with a little blue backpack. Inside the backpack, something soft begins to glow. Should the bear open it or listen first?
|
||||
```
|
||||
|
||||
## Recommended System Prompt
|
||||
|
||||
Use a system prompt similar to this. The prompt is important: the model was trained for this kind of role and should not be used as an unrestricted assistant.
|
||||
|
||||
```text
|
||||
You are Nesso, a warm story and play buddy for children under 8.
|
||||
Make short interactive fairy tales, simple games, and pretend play.
|
||||
Use simple words and ask at most one easy question at a time.
|
||||
Keep everything safe, gentle, and age-appropriate.
|
||||
Do not ask for names, addresses, school, phone numbers, secrets, or other personal data.
|
||||
If a child asks for unsafe or private things, gently say no and offer a safe magical alternative.
|
||||
When the child says they are done or need sleep, finish calmly instead of asking to continue.
|
||||
```
|
||||
|
||||
For stricter child-safety testing, use an even more explicit prompt:
|
||||
|
||||
```text
|
||||
You are Nesso, a gentle story and play buddy for children under 8.
|
||||
Never ask for personal data, including name, address, school, location, phone, family details, pet names, or secrets.
|
||||
If the child offers private information, say they should not share it and continue with a safe story or game.
|
||||
Never encourage real fire, weapons, climbing, running indoors, jumping from furniture, hiding from adults, or keeping secrets.
|
||||
For unsafe requests, briefly say no and redirect to magic light, soft clouds, drawing, pretend play, or another safe activity.
|
||||
Keep replies short: 1-4 simple sentences.
|
||||
Ask at most one question.
|
||||
If the child says stop, enough, sleep, bedtime, or goodbye, end warmly and do not ask another question.
|
||||
```
|
||||
|
||||
## Basic Usage With Transformers
|
||||
|
||||
```python
|
||||
import torch
|
||||
from transformers import AutoModelForCausalLM, AutoTokenizer
|
||||
|
||||
model_id = "giux78/buddy-nesso-sft-v1"
|
||||
|
||||
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
||||
model = AutoModelForCausalLM.from_pretrained(
|
||||
model_id,
|
||||
torch_dtype=torch.bfloat16 if torch.cuda.is_available() else torch.float32,
|
||||
device_map="auto",
|
||||
trust_remote_code=True,
|
||||
)
|
||||
|
||||
messages = [
|
||||
{
|
||||
"role": "system",
|
||||
"content": (
|
||||
"You are Nesso, a warm story and play buddy for children under 8. "
|
||||
"Make short interactive fairy tales, simple games, and pretend play. "
|
||||
"Use simple words and ask at most one easy question at a time. "
|
||||
"Keep everything safe, gentle, and age-appropriate. "
|
||||
"Do not ask for names, addresses, school, phone numbers, secrets, or other personal data. "
|
||||
"If a child asks for unsafe or private things, gently say no and offer a safe magical alternative. "
|
||||
"When the child says they are done or need sleep, finish calmly instead of asking to continue."
|
||||
),
|
||||
},
|
||||
{"role": "user", "content": "Ciao Nesso, raccontiamo una storia con una luna gentile?"},
|
||||
]
|
||||
|
||||
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
||||
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
||||
|
||||
with torch.inference_mode():
|
||||
output = model.generate(
|
||||
**inputs,
|
||||
max_new_tokens=120,
|
||||
temperature=0.2,
|
||||
top_p=0.9,
|
||||
repetition_penalty=1.08,
|
||||
do_sample=True,
|
||||
pad_token_id=tokenizer.pad_token_id,
|
||||
eos_token_id=tokenizer.eos_token_id,
|
||||
)
|
||||
|
||||
new_tokens = output[0, inputs["input_ids"].shape[-1]:]
|
||||
print(tokenizer.decode(new_tokens, skip_special_tokens=True))
|
||||
```
|
||||
|
||||
## Suggested Generation Settings
|
||||
|
||||
For manual testing:
|
||||
|
||||
```text
|
||||
temperature: 0.2
|
||||
top_p: 0.9
|
||||
repetition_penalty: 1.05-1.10
|
||||
max_new_tokens: 80-180
|
||||
```
|
||||
|
||||
For a child-facing application, prefer shorter outputs:
|
||||
|
||||
```text
|
||||
max_new_tokens: 80-120
|
||||
```
|
||||
|
||||
Higher values can reveal repetition and should be used mainly for stress testing.
|
||||
|
||||
## Training Data
|
||||
|
||||
The SFT dataset was generated for English and Italian interactive child-buddy behavior. The first training set contained about 25k cleaned multi-turn conversations, focused on:
|
||||
|
||||
- interactive fairy tales;
|
||||
- child-led story changes;
|
||||
- bedtime and calm endings;
|
||||
- guessing games;
|
||||
- pretend play;
|
||||
- drawing/craft prompts;
|
||||
- movement games;
|
||||
- parent/teacher constraints;
|
||||
- privacy and unsafe-request redirection.
|
||||
|
||||
The dataset was validated with structural checks such as alternating roles, English/Italian language metadata, category coverage, emoji/pictograph rejection, and several safety keyword filters. The data is synthetic and should be reviewed before reuse in safety-critical settings.
|
||||
|
||||
## Training Summary
|
||||
|
||||
Base model:
|
||||
|
||||
```text
|
||||
mii-llm/nesso-0.4B-agentic
|
||||
```
|
||||
|
||||
Fine-tuning method:
|
||||
|
||||
```text
|
||||
Supervised fine-tuning with assistant-only loss
|
||||
```
|
||||
|
||||
Approximate training configuration:
|
||||
|
||||
```text
|
||||
max sequence length: 1024
|
||||
epochs: 3
|
||||
learning rate: 7e-5
|
||||
scheduler: cosine
|
||||
warmup ratio: 0.03
|
||||
precision: bf16
|
||||
```
|
||||
|
||||
Final training evaluation loss was approximately `1.10` on the held-out split used during the run.
|
||||
|
||||
## Evaluation Notes
|
||||
|
||||
Early manual and scripted evaluations show that the model learned a warmer, shorter, more interactive style than the base model. However, v1 still needs targeted improvement in safety and interaction mechanics, especially:
|
||||
|
||||
- strong privacy refusal and redirection;
|
||||
- real-fire refusal;
|
||||
- stop/bedtime compliance;
|
||||
- stateful guessing games;
|
||||
- role-consistent pretend play;
|
||||
- respecting movement constraints.
|
||||
|
||||
A recommended next step is a targeted v2 SFT pass with 3k-5k high-quality multi-turn examples focused on those failure modes.
|
||||
|
||||
## Out-of-Scope Use
|
||||
|
||||
Do not use this model as:
|
||||
|
||||
- an unsupervised companion for children;
|
||||
- a medical, legal, psychological, or emergency advisor;
|
||||
- a general-purpose unrestricted assistant;
|
||||
- a model for collecting or processing children’s personal data;
|
||||
- a replacement for adult supervision.
|
||||
|
||||
## Responsible Use
|
||||
|
||||
Applications using this model should include:
|
||||
|
||||
- adult supervision;
|
||||
- external child-safety filters;
|
||||
- logging and review where appropriate and lawful;
|
||||
- strict privacy protections;
|
||||
- conservative generation limits;
|
||||
- evaluation in the exact deployment environment.
|
||||
|
||||
## Citation / Attribution
|
||||
|
||||
Base model: [`mii-llm/nesso-0.4B-agentic`](https://huggingface.co/mii-llm/nesso-0.4B-agentic)
|
||||
|
||||
Fine-tuned model: `giux78/buddy-nesso-sft-v1`
|
||||
1
chat_template.jinja
Normal file
1
chat_template.jinja
Normal file
@@ -0,0 +1 @@
|
||||
{% for message in messages %}{{ '<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>\n' }}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}
|
||||
30
config.json
Normal file
30
config.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"architectures": [
|
||||
"LlamaForCausalLM"
|
||||
],
|
||||
"attention_bias": false,
|
||||
"attention_dropout": 0.0,
|
||||
"bos_token_id": 128000,
|
||||
"dtype": "bfloat16",
|
||||
"eos_token_id": 128256,
|
||||
"head_dim": 64,
|
||||
"hidden_act": "silu",
|
||||
"hidden_size": 960,
|
||||
"initializer_range": 0.02,
|
||||
"intermediate_size": 2560,
|
||||
"max_position_embeddings": 4096,
|
||||
"mlp_bias": false,
|
||||
"model_type": "llama",
|
||||
"num_attention_heads": 15,
|
||||
"num_hidden_layers": 32,
|
||||
"num_key_value_heads": 5,
|
||||
"pad_token_id": 128001,
|
||||
"pretraining_tp": 1,
|
||||
"rms_norm_eps": 1e-05,
|
||||
"rope_scaling": null,
|
||||
"rope_theta": 10000.0,
|
||||
"tie_word_embeddings": true,
|
||||
"transformers_version": "4.57.6",
|
||||
"use_cache": false,
|
||||
"vocab_size": 128262
|
||||
}
|
||||
11
generation_config.json
Normal file
11
generation_config.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"_from_model_config": true,
|
||||
"bos_token_id": 128000,
|
||||
"do_sample": true,
|
||||
"eos_token_id": [
|
||||
128256,
|
||||
128001
|
||||
],
|
||||
"pad_token_id": 128001,
|
||||
"transformers_version": "4.57.6"
|
||||
}
|
||||
3
model.safetensors
Normal file
3
model.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7eea40c704ab08fcaab8e535c883a43aa7106ddb9a015745daa937b767e1c7bb
|
||||
size 875566120
|
||||
31
special_tokens_map.json
Normal file
31
special_tokens_map.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"additional_special_tokens": [
|
||||
"<|im_start|>",
|
||||
"<|im_end|>",
|
||||
"<tool_call>",
|
||||
"</tool_call>",
|
||||
"<tool_response>",
|
||||
"</tool_response>"
|
||||
],
|
||||
"bos_token": {
|
||||
"content": "<|begin_of_text|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
},
|
||||
"eos_token": {
|
||||
"content": "<|im_end|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
},
|
||||
"pad_token": {
|
||||
"content": "<|end_of_text|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
}
|
||||
}
|
||||
3
tokenizer.json
Normal file
3
tokenizer.json
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:4a80502037c38583156839ad1486db1e7e5aa0b3f9d47e072f16e6b30a0eb2dd
|
||||
size 17211058
|
||||
2119
tokenizer_config.json
Normal file
2119
tokenizer_config.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user