diff --git a/openseek/competition/LongContext-ICL-Annotation/src/README.md b/openseek/competition/LongContext-ICL-Annotation/src/README.md new file mode 100644 index 00000000..d3ec761a --- /dev/null +++ b/openseek/competition/LongContext-ICL-Annotation/src/README.md @@ -0,0 +1,159 @@ +# 长上下文ICL自动数据标注方案 + +本方案基于Qwen3-4B大语言模型,采用In-Context Learning (ICL) 范式完成8个数据集的自动标注任务。 + +## 环境要求 + +- Python >= 3.8 +- Huawei Ascend 910C GPU +- vLLM推理引擎 (支持Ascend) + +## 安装依赖 + +```bash +pip install -r requirements.txt +``` + +## 模型准备 + +下载Qwen3-4B模型到指定路径(默认为 `/root/Qwen3-4B`): + +- HuggingFace: https://huggingface.co/Qwen/Qwen3-4B +- ModelScope: https://modelscope.cn/models/Qwen/Qwen3-4B + +## 启动vLLM服务 + +在使用本方案前,需要先启动vLLM推理服务: + +```bash +# 使用vLLM Ascend版本启动服务 +vllm serve /root/Qwen3-4B \ + --port 9010 \ + --dtype auto \ + --max-model-len 131072 \ + --tensor-parallel-size 1 \ + --gpu-memory-utilization 0.95 \ + --block-size 16 \ + --trust-remote-code +``` + +服务启动后,API地址为:`http://localhost:9010/v1/` + +## 数据准备 + +确保数据集已放置在正确路径: + +``` +/root/OpenSeek/openseek/competition/LongContext-ICL-Annotation/data/ +``` + +## 运行标注任务 + +### 单个任务运行 + +```bash +python3 main.py \ + --task_id 1 \ + --tokenizer_path /root/Qwen3-4B \ + --log_path_prefix ./outputs/ \ + --max_input_length 128000 +``` + +参数说明: +- `--task_id`: 任务ID (1-8) +- `--tokenizer_path`: Qwen3-4B模型路径 +- `log_path_prefix`: 输出文件路径前缀 +- `--max_input_length`: 最大输入长度(默认128000) + +### 批量运行所有任务 + +```bash +#!/bin/bash +OUTPUT_DIR="./outputs" +TOKENIZER_PATH="/root/Qwen3-4B" + +for task_id in 1 2 3 4 5 6 7 8; do + python3 main.py \ + --task_id $task_id \ + --log_path_prefix $OUTPUT_DIR/ \ + --tokenizer_path $TOKENIZER_PATH +done +``` + +### 并行运行(4个任务同时) + +```bash +#!/bin/bash +OUTPUT_DIR="./outputs" +TOKENIZER_PATH="/root/Qwen3-4B" +CONCURRENT=4 + +for task_id in 1 2 3 4 5 6 7 8; do + python3 main.py \ + --task_id $task_id \ + --log_path_prefix $OUTPUT_DIR/ \ + --tokenizer_path $TOKENIZER_PATH > task${task_id}.log 2>&1 & + + if [ $((task_id % $CONCURRENT)) -eq 0 ]; then + wait + fi +done +wait +``` + +## 输出结果 + +每个任务会生成一个 `.jsonl` 文件,格式如下: + +```json +{"test_sample_id": "1", "prediction": "Good Review"} +{"test_sample_id": "2", "prediction": "Bad Review"} +``` + +## 方案特点 + +1. **长上下文支持**:使用50个ICL示例,通过YARN RoPE scaling支持最长131,072 tokens +2. **提示工程**:优化的prompt设计,确保输出格式准确(使用