Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/actions/model-card-generator/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

name: Model Card Generator
description: Auto-generate MODEL_CARD.md for TinyLlama checkpoints.

inputs:
model_path:
description: Path to model dir
required: true
default: checkpoints/TinyLlama-1.1B
output:
description: Output markdown file
required: false
default: MODEL_CARD.md

runs:
using: composite
steps:
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install deps
run: pip install --quiet transformers
- shell: bash
run: |
python "$GITHUB_ACTION_PATH/model_card_generator.py" --model_path "${{ inputs.model_path }}" --output "${{ inputs.output }}"
38 changes: 38 additions & 0 deletions .github/actions/model-card-generator/model_card_generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

#!/usr/bin/env python3
"""TinyLlama Model Card Generator."""
import argparse, datetime
from pathlib import Path
try:
from transformers import AutoConfig
except ImportError:
AutoConfig = None

TEMPLATE = """# {name}
**Generated on {date}**

- **Architecture**: {arch}
- **Parameters**: {params}
- **License**: {license}
"""

def generate(model_path, output):
meta = dict(name=Path(model_path).name, date=datetime.date.today(), arch='Unknown', params='N/A', license='N/A')
if AutoConfig and Path(model_path).exists():
try:
cfg = AutoConfig.from_pretrained(model_path)
meta.update(arch=(cfg.architectures[0] if getattr(cfg,'architectures',[]) else 'Unknown'),
params=getattr(cfg,'num_parameters','N/A'),
license=getattr(cfg,'license','N/A'),
name=cfg.name_or_path)
except Exception as e:
print('Warn:', e)
Path(output).write_text(TEMPLATE.format(**meta))
print('Wrote', output)

if __name__ == '__main__':
p=argparse.ArgumentParser()
p.add_argument('--model_path', required=True)
p.add_argument('--output', default='MODEL_CARD.md')
args=p.parse_args()
generate(args.model_path, args.output)
1 change: 1 addition & 0 deletions .github/actions/model-card-generator/s
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ss
Binary file added .github/tinyllama-modelcard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions .github/workflows/generate-model-card.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

name: Generate TinyLlama Model Card
on:
push:
paths:
- 'checkpoints/**'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/model-card-generator
with:
model_path: 'checkpoints/TinyLlama-1.1B'
output: 'MODEL_CARD.md'
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 'docs: update MODEL_CARD.md'
file_pattern: 'MODEL_CARD.md'
1 change: 1 addition & 0 deletions .github/workflows/t
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ English | [中文](README_zh-CN.md)
The TinyLlama project aims to **pretrain** a **1.1B Llama model on 3 trillion tokens**. With some proper optimization, we can achieve this within a span of "just" 90 days using 16 A100-40G GPUs 🚀🚀. The training has started on 2023-09-01.

<div align="center">
<img src=".github/TinyLlama_logo.png" width="300"/>
<img src=".github/tinyllama-modelcard.png" width="300"/>
</div>

We adopted exactly the same architecture and tokenizer as Llama 2. This means TinyLlama can be plugged and played in many open-source projects built upon Llama. Besides, TinyLlama is compact with only 1.1B parameters. This compactness allows it to cater to a multitude of applications demanding a restricted computation and memory footprint.
Expand Down