| # Hugging Face 上传指南 | |
| 本指南说明如何将 EasyTemporalPointProcess-main 上传到 Hugging Face。 | |
| ## 📋 准备工作 | |
| ### 1. 运行清理脚本 | |
| ```bash | |
| cd /Users/chenshuyi/Downloads/EasyTemporalPointProcess-main | |
| python cleanup_for_hf.py | |
| ``` | |
| 这会自动: | |
| - 删除 `__pycache__/`、`.pyc` 等临时文件 | |
| - 检查大文件 | |
| - 创建上传检查清单 | |
| ### 2. 数据文件说明 ⚠️ | |
| **重要**: `data/cascades/` 目录包含大文件(约 1.6GB),**不会上传到 Hugging Face**。 | |
| 这些文件已通过 `.gitignore` 排除: | |
| - `information_cascade.json` (606MB) | |
| - `information_cascade_original_posts.json` (980MB) | |
| **在云电脑上获取数据文件的方法**: | |
| - 方法1: 使用 scp 直接传输(推荐) | |
| - 方法2: 上传到云存储后下载 | |
| - 方法3: 使用 Git LFS(如果配置) | |
| - 方法4: 单独上传到 Hugging Face Dataset Hub | |
| 详细说明请参考 `DATA_FILES_NOTICE.md` | |
| ### 3. 手动检查 | |
| - [ ] 检查是否有敏感信息(API密钥、密码等) | |
| - [ ] 确认大文件已正确排除(通过 .gitignore) | |
| - [ ] 确保 `requirements.txt` 是最新的 | |
| - [ ] 检查 README.md 是否完整 | |
| ## 🚀 上传方法 | |
| ### 方法1: 使用 Hugging Face CLI(推荐) | |
| ```bash | |
| # 1. 安装 Hugging Face CLI | |
| pip install huggingface_hub | |
| # 2. 登录 | |
| huggingface-cli login | |
| # 输入你的 Hugging Face token(在 https://huggingface.co/settings/tokens 获取) | |
| # 3. 创建仓库(在网页上创建,或使用 CLI) | |
| # 访问 https://huggingface.co/new 创建新仓库 | |
| # 选择 "Dataset" 类型,命名为例如:easytpp-cascade-metrics | |
| # 4. 上传文件 | |
| cd /Users/chenshuyi/Downloads/EasyTemporalPointProcess-main | |
| huggingface-cli upload <your-username>/easytpp-cascade-metrics . --repo-type dataset | |
| ``` | |
| ### 方法2: 使用 Git | |
| ```bash | |
| # 1. 初始化 Git(如果还没有) | |
| cd /Users/chenshuyi/Downloads/EasyTemporalPointProcess-main | |
| git init | |
| # 2. 添加文件 | |
| git add . | |
| git commit -m "Add EasyTPP with cascade metrics computation" | |
| # 3. 添加 Hugging Face 远程仓库 | |
| # 先在 https://huggingface.co/new 创建仓库 | |
| git remote add origin https://huggingface.co/<your-username>/<repo-name> | |
| # 4. 推送 | |
| git push origin main | |
| ``` | |
| ### 方法3: 使用 Web 界面上传 | |
| 1. 访问 https://huggingface.co/new | |
| 2. 创建新的 Dataset 仓库 | |
| 3. 点击 "Add file" → "Upload files" | |
| 4. 拖拽或选择文件夹上传 | |
| ## 📦 在云电脑上下载 | |
| 上传完成后,在云电脑上下载: | |
| ```bash | |
| # 方法1: 使用 Hugging Face CLI | |
| pip install huggingface_hub | |
| huggingface-cli download <your-username>/<repo-name> --local-dir ./EasyTPP | |
| # 方法2: 使用 Git | |
| git clone https://huggingface.co/datasets/<your-username>/<repo-name> | |
| cd <repo-name> | |
| # 方法3: 使用 Python | |
| from huggingface_hub import snapshot_download | |
| snapshot_download(repo_id="<your-username>/<repo-name>", repo_type="dataset", local_dir="./EasyTPP") | |
| ``` | |
| ### 📥 下载数据文件 | |
| **重要**: 代码仓库不包含数据文件(已通过 .gitignore 排除)。 | |
| 数据文件需要单独获取: | |
| ```bash | |
| # 方法1: 使用 scp 从本地传输(推荐) | |
| mkdir -p data/cascades | |
| scp user@local-machine:/path/to/information_cascade*.json ./data/cascades/ | |
| # 方法2: 如果已上传到 Hugging Face Dataset Hub | |
| huggingface-cli download <username>/cascade-data --local-dir ./data/cascades | |
| # 方法3: 从云存储下载 | |
| # (根据你使用的云存储服务) | |
| ``` | |
| 详细说明请参考 `DATA_FILES_NOTICE.md` | |
| ## 📝 新增功能说明 | |
| 本仓库在原始 EasyTPP 基础上新增了以下功能: | |
| ### 1. 级联指标计算 (`compute_cascade_metrics.py`) | |
| 用于计算信息级联数据的指标: | |
| - **情感得分** (Sentiment Score) | |
| - **情感偏差** (Sentiment Deviation) | |
| - **语境偏差** (Contextual Deviation) | |
| - **困惑度** (Perplexity) | |
| 详细说明请参考 `COMPUTE_METRICS_README.md` | |
| ### 2. 相关文件 | |
| - `compute_cascade_metrics.py`: 主计算脚本 | |
| - `COMPUTE_METRICS_README.md`: 使用说明 | |
| - `requirements_compute_metrics.txt`: 额外依赖 | |
| - `example_compute_metrics.sh`: 示例脚本 | |
| - `cleanup_for_hf.py`: 清理脚本 | |
| ## ⚠️ 注意事项 | |
| 1. **大文件处理** | |
| - 如果文件 >50MB,考虑使用 Git LFS | |
| - 或排除数据文件,使用外部链接 | |
| 2. **敏感信息** | |
| - 不要上传包含 API 密钥、密码的文件 | |
| - 检查配置文件中的敏感数据 | |
| 3. **许可证** | |
| - 确保所有代码都有适当的许可证 | |
| - 原始 EasyTPP 使用 Apache 2.0 许可证 | |
| 4. **版本控制** | |
| - 建议使用 Git 进行版本控制 | |
| - 每次更新后提交并推送 | |
| ## 🔍 验证上传 | |
| 上传后检查: | |
| - [ ] 所有文件都已上传 | |
| - [ ] README 显示正确 | |
| - [ ] 代码可以正常下载 | |
| - [ ] 依赖可以正常安装 | |
| ## 📞 问题反馈 | |
| 如有问题,请检查: | |
| 1. Hugging Face 仓库设置是否正确 | |
| 2. 文件大小是否超过限制 | |
| 3. 是否有权限问题 | |