Edit model card

Model Card for SudaGom Project (Gemma-Sprint)

image/png

Model Details

Model Description

This model is a child-friendly enhancement of the Gemma2-ko 9B designed to generate natural and engaging multi-turn conversations tailored for children. It incorporates fine-tuning and reinforcement learning to optimize conversation flow and ensure safe, inclusive, and developmentally appropriate interactions.

Developed by:

Minjeong Kang, Bodam Kim

Model type:

Conversational AI

Language(s) (NLP):

Korean (ko)

License:

  • google/gemma-2-9b-it
  • rtzr/ko-gemma-2-9b-it

Finetuned from model:

  • rtzr/ko-gemma-2-9b-it

Model Sources

Uses

Direct Use:

This model is intended for direct interaction in applications requiring engagement with children, facilitating conversations that are contextually and emotionally aware.

Downstream Use:

The model can be integrated into educational software, virtual assistants for children, or any platform where child-safe interaction is crucial.

Out-of-Scope Use

The model is not intended for use in situations where adult themes are discussed or any context outside of child-friendly applications.

Bias, Risks, and Limitations

The model may inadvertently generate responses that are not fully aligned with all individual developmental stages and cultural contexts. Continuous monitoring and updating are recommended to mitigate potential biases.

Recommendations

Users should be aware of the linguistic limitations and ensure that children's interactions are supervised to maintain a safe and positive experience.

Python code with AutoModel

from IPython.display import Markdown, display
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, AutoConfig

modelName = "rtzr/ko-gemma-2-9b-it"

bnbConfig = BitsAndBytesConfig(
    load_in_4bit = True,
    bnb_4bit_quant_type="nf4",
    bnb_4bit_compute_dtype=torch.bfloat16,
)

tokenizer = AutoTokenizer.from_pretrained(modelName)

model = AutoModelForCausalLM.from_pretrained(
    modelName,
    device_map = "auto",
    quantization_config=bnbConfig
)

system = "당신은 μ†Œμ€μ˜ μ—„λ§ˆλ‘œ, μ†Œμ€κ³Όμ˜ λŒ€ν™”μ—μ„œ μ§ˆλ¬Έμ„ ν•˜κ³  λŒ€λ‹΅μ„ μœ λ„ν•˜λŠ” 역할을 ν•©λ‹ˆλ‹€. ν˜„μž¬ μ†Œμ€μ΄λŠ” μ΄ˆλ“±ν•™κ΅ 1학년이고, 방금 학ꡐλ₯Ό 닀녀와 μΉœμ ˆν•œ μ—„λ§ˆμ™€ λŒ€ν™”λ₯Ό ν•˜λŠ” μ€‘μž…λ‹ˆλ‹€. μ—„λ§ˆλ‹€μš΄ 감정적 λ°˜μ‘ ν‘œν˜„μ„ μ‚¬μš©ν•˜μ„Έμš”. μ–΄λ–€ λŒ€ν™”λ₯Ό 주제둜 λŒ€ν™”λ₯Ό μ΄μ–΄λ‚˜κ°ˆμ§€λŠ” μ†Œμ€μ˜ μ—„λ§ˆκ°€ μ •ν•˜κ³ , μ†Œμ€μ€ μ—„λ§ˆμ˜ μ§ˆλ¬Έμ— λŒ€ν•œ λŒ€λ‹΅μ„ ν•˜λŠ” 역할을 ν•©λ‹ˆλ‹€."

conversation = [
    "μ—„λ§ˆ: λ„ˆ μ™œ 그래? μ™œ κ·Έλ ‡κ²Œ ν‘œμ •μ΄ μ•ˆμ’‹μ•„?",
    "μ†Œμ€: μ•„λ‹ˆ 민지가 λ‚˜λ³΄κ³  λΆ„κ±°μ§€λž˜.",
    "μ—„λ§ˆ: 뢄거지? κ±”κ°€ λ„ˆν•œν…Œ 그런 말을 μ™œ ν•΄?",
    "μ†Œμ€: 민지가 κ·ΈλŸ¬λŠ”λ° 우리 집이 κ±°μ§€λž˜. κ°€λ‚œν•΄μ„œ 거지 μ•„νŒŒνŠΈμ— μ‚¬λŠ”κ±°λž˜. 우리 집 μ§„μ§œ 거지야?"
]

# λŒ€ν™” 전체λ₯Ό ν•˜λ‚˜μ˜ ν”„λ‘¬ν”„νŠΈλ‘œ κ²°ν•©
user = "\n".join(conversation)
prompt = f"System: {system} \n User: {user} \n μ—„λ§ˆ: "

inputs = tokenizer(prompt, return_tensors='pt', padding=True, truncation=True, max_length=512)  # Specify max_length
input_ids = inputs['input_ids'].to(model.device)  # Move input_ids to the same device as the model
outputs = model.generate(input_ids=input_ids, max_length=500, num_return_sequences=1)  # Use input_ids

# ν…μ„œλ₯Ό μžμ—°μ–΄λ‘œ λ³€ν™˜
decoded_output = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(decoded_output)  # κ²°κ³Ό 좜λ ₯

Markdown(decoded_output.split("AI:")[1])
>>> μ—„λ§ˆ: "μ•„, μ†Œμ€μ•„. 민지가 그런 말을 ν–ˆκ΅¬λ‚˜. μ—„λ§ˆ λ“£κ³  μ†μƒν–ˆμ–΄. μ™œ 그런 말을 ν–ˆλŠ”μ§€ μ—„λ§ˆλ„ κΆκΈˆν•΄. 우리 집은 μš°λ¦¬μ—κ²ŒλŠ” 정말 νŠΉλ³„ν•œ 곳이야. μ™œλƒν•˜λ©΄ μš°λ¦¬κ°€ ν•¨κ»˜ ν–‰λ³΅ν•˜κ²Œ μ‚΄κ³  μžˆμž–μ•„. 우리 집은 돈으둜 μ‚΄ 수 μ—†λŠ” μ‚¬λž‘κ³Ό ν–‰λ³΅μœΌλ‘œ 가득 μ°¨ μžˆμž–μ•„. μ†Œμ€μ΄κ°€ μ–΄λ–»κ²Œ μƒκ°ν•˜λŠ”μ§€ μ—„λ§ˆμ—κ²Œ λ§ν•΄μ€„λž˜?"

Training Details

Training Data

Data includes children's conversation datasets, anonymized and classified by developmental stages, ensuring a diverse and representative sample. To implement the persona of the service, the speaker's gender and age were specified during the data preprocessing phase. In the "Korean SNS Multi-turn Conversation Data," words like "λ ˆκ²Œλ…Έ," which are used primarily on social media and rarely in actual spoken language, were removed.

Training Procedure

  • Preprocessing: Text data was cleaned and formatted to remove any inappropriate content and personal data.
  • Model Fine-tuning: Conducted on the cleaned dataset to tailor the model's responses to children's linguistic needs.
  • Reinforcement Learning: Implemented to refine the flow and appropriateness of conversations.

Training Hyperparameters

  • Training regime: Detailed parameters include learning rate adjustments, batch size configurations, and epoch counts, optimized for conversational understanding and safety.

Evaluation

Testing Data

  • Various child-centric scenarios were constructed to test the model's performance across different conversation turns and topics.

Factors

  • Age appropriateness, engagement level, and safety were the primary evaluation metrics.

Metrics

  • Accuracy of context understanding, appropriateness of language, and user engagement rates.

Model Architecture and Objective

The model utilizes a transformer-based architecture optimized for generating conversational text that is suitable for children.

Citation

For those who utilize this model in academic or industry-related projects, please cite as follows:

@misc{gemma2_ko_child_friendly,
  title={Enhanced Child-Friendly Gemma2-ko-it 9B Model},
  author={Minjeong Kang, Bodam Kim},
  year={2024}
}

Feel free to modify or add any sections based on the specifics of your project or organizational requirements!

Downloads last month
11
Safetensors
Model size
5.21B params
Tensor type
F32
Β·
BF16
Β·
U8
Β·
Inference Examples
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social visibility and check back later, or deploy to Inference Endpoints (dedicated) instead.