File size: 4,857 Bytes
f43af3c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# 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. 是否有权限问题
|