├── .gitignore ├── AFM ├── data │ ├── README.md │ ├── code_agent │ │ ├── code_math_benchmarks │ │ │ ├── OlympiadBench.parquet │ │ │ ├── README.md │ │ │ ├── aime24.parquet │ │ │ ├── aime25.parquet │ │ │ ├── amc23.parquet │ │ │ ├── codecontest.parquet │ │ │ ├── livecodebench_v4.parquet │ │ │ ├── livecodebench_v5.parquet │ │ │ └── math500.parquet │ │ ├── download.py │ │ └── livecodebench_testcases │ │ │ └── download_and_process.py │ ├── mhqa_agent │ │ ├── download.py │ │ ├── prepare.sh │ │ ├── prepare_data.py │ │ ├── sys_prompts.py │ │ └── test_benchmarks │ │ │ └── nq_full.jsonl │ ├── prepare_data.py │ ├── sys_prompts.py │ └── web_agent │ │ ├── download.py │ │ └── test_benchmarks │ │ ├── browsecomp.json │ │ ├── gaia_dev_103.json │ │ ├── hle_test.json │ │ └── webwalker_main.json ├── evaluation │ ├── code_agent │ │ └── eval_code_agent.sh │ ├── mhqa_agent │ │ └── eval_mhqa_agent.sh │ └── web_agent │ │ ├── inference_web_agent.py │ │ ├── prompts.py │ │ ├── run_qwen.sh │ │ ├── utils.py │ │ └── web_tools.py ├── models │ ├── code_agent │ │ └── download.py │ ├── mhqa_agent │ │ └── download.py │ └── web_agent │ │ └── download.py ├── tool_servers │ ├── README.md │ ├── web_server │ │ ├── server_tests │ │ │ ├── test_crawl_page_simple_v2.py │ │ │ └── test_wiki_rag_simple.py │ │ ├── start_servers.sh │ │ └── v2 │ │ │ ├── cache_serper_server_v2.py │ │ │ ├── crawl_page_server_v2.py │ │ │ └── keys.py │ └── wiki_server │ │ ├── download.py │ │ ├── launch_rag_server.sh │ │ └── wiki_rag_server.py └── train │ ├── code_agent │ ├── rl │ │ └── train_dapo_code_agent.sh │ └── sft │ │ ├── sft_qwen2.5_32b.sh │ │ └── sft_qwen2.5_7b.sh │ ├── mhqa_agent │ ├── rl │ │ └── train_ppo_mhqa_agent.sh │ └── sft │ │ ├── sft_qwen2.5_3b.sh │ │ └── sft_qwen2.5_7b.sh │ └── web_agent │ ├── rl │ └── train_dapo_web_agent.sh │ └── sft │ ├── sft_qwen2.5_32b.sh │ └── sft_qwen2.5_7b.sh ├── LICENSE ├── LLaMA-Factory ├── .dockerignore ├── .env.local ├── .gitattributes ├── .github │ ├── CODE_OF_CONDUCT.md │ ├── CONTRIBUTING.md │ ├── ISSUE_TEMPLATE │ │ ├── 1-bug-report.yml │ │ ├── 2-feature-request.yml │ │ └── config.yml │ ├── PULL_REQUEST_TEMPLATE.md │ ├── SECURITY.md │ └── workflows │ │ ├── label_issue.yml │ │ ├── publish.yml │ │ └── tests.yml ├── .gitignore ├── .pre-commit-config.yaml ├── AFM_changeLog.md ├── CITATION.cff ├── LICENSE ├── MANIFEST.in ├── Makefile ├── README.md ├── README_zh.md ├── assets │ ├── benchmark.svg │ ├── logo.png │ ├── wechat.jpg │ └── wechat_npu.jpg ├── data │ ├── README.md │ ├── README_zh.md │ ├── alpaca_en_demo.json │ ├── alpaca_zh_demo.json │ ├── belle_multiturn │ │ └── belle_multiturn.py │ ├── c4_demo.jsonl │ ├── dataset_info.json │ ├── dpo_en_demo.json │ ├── dpo_zh_demo.json │ ├── glaive_toolcall_en_demo.json │ ├── glaive_toolcall_zh_demo.json │ ├── hh_rlhf_en │ │ └── hh_rlhf_en.py │ ├── identity.json │ ├── kto_en_demo.json │ ├── mllm_audio_demo.json │ ├── mllm_demo.json │ ├── mllm_demo_data │ │ ├── 1.jpg │ │ ├── 1.mp3 │ │ ├── 1.mp4 │ │ ├── 2.avi │ │ ├── 2.jpg │ │ ├── 2.wav │ │ ├── 3.flac │ │ ├── 3.jpg │ │ ├── 3.mp4 │ │ ├── 4.mp3 │ │ └── 4.mp4 │ ├── mllm_video_audio_demo.json │ ├── mllm_video_demo.json │ ├── ultra_chat │ │ └── ultra_chat.py │ └── wiki_demo.txt ├── docker │ ├── docker-cuda │ │ ├── Dockerfile │ │ └── docker-compose.yml │ ├── docker-npu │ │ ├── Dockerfile │ │ └── docker-compose.yml │ └── docker-rocm │ │ ├── Dockerfile │ │ └── docker-compose.yml ├── evaluation │ ├── ceval │ │ ├── ceval.py │ │ ├── ceval.zip │ │ └── mapping.json │ ├── cmmlu │ │ ├── cmmlu.py │ │ ├── cmmlu.zip │ │ └── mapping.json │ └── mmlu │ │ ├── mapping.json │ │ ├── mmlu.py │ │ └── mmlu.zip ├── examples │ ├── README.md │ ├── README_zh.md │ ├── accelerate │ │ ├── fsdp_config.yaml │ │ └── fsdp_config_offload.yaml │ ├── deepspeed │ │ ├── ds_z0_config.json │ │ ├── ds_z2_config.json │ │ ├── ds_z2_offload_config.json │ │ ├── ds_z3_config.json │ │ └── ds_z3_offload_config.json │ ├── extras │ │ ├── adam_mini │ │ │ └── qwen2_full_sft.yaml │ │ ├── apollo │ │ │ └── llama3_full_sft.yaml │ │ ├── badam │ │ │ └── llama3_full_sft.yaml │ │ ├── fsdp_qlora │ │ │ ├── llama3_lora_sft.yaml │ │ │ └── train.sh │ │ ├── galore │ │ │ └── llama3_full_sft.yaml │ │ ├── llama_pro │ │ │ ├── expand.sh │ │ │ └── llama3_freeze_sft.yaml │ │ ├── loraplus │ │ │ └── llama3_lora_sft.yaml │ │ ├── mod │ │ │ └── llama3_full_sft.yaml │ │ ├── muon │ │ │ └── qwen2_full_sft.yaml │ │ ├── nlg_eval │ │ │ └── llama3_lora_predict.yaml │ │ └── pissa │ │ │ ├── init.sh │ │ │ └── llama3_lora_sft.yaml │ ├── inference │ │ ├── llama3.yaml │ │ ├── llama3_full_sft.yaml │ │ ├── llama3_lora_sft.yaml │ │ └── qwen2_5vl.yaml │ ├── merge_lora │ │ ├── llama3_full_sft.yaml │ │ ├── llama3_gptq.yaml │ │ ├── llama3_lora_sft.yaml │ │ └── qwen2_5vl_lora_sft.yaml │ ├── train_full │ │ ├── llama3_full_sft.yaml │ │ └── qwen2_5vl_full_sft.yaml │ ├── train_lora │ │ ├── llama3_lora_dpo.yaml │ │ ├── llama3_lora_eval.yaml │ │ ├── llama3_lora_kto.yaml │ │ ├── llama3_lora_ppo.yaml │ │ ├── llama3_lora_pretrain.yaml │ │ ├── llama3_lora_reward.yaml │ │ ├── llama3_lora_sft.sh │ │ ├── llama3_lora_sft.yaml │ │ ├── llama3_lora_sft_ds3.yaml │ │ ├── llama3_lora_sft_ray.yaml │ │ ├── llama3_preprocess.yaml │ │ ├── llama4_lora_sft_ds3.yaml │ │ ├── qwen2_5vl_lora_dpo.yaml │ │ └── qwen2_5vl_lora_sft.yaml │ └── train_qlora │ │ ├── llama3_lora_sft_aqlm.yaml │ │ ├── llama3_lora_sft_awq.yaml │ │ ├── llama3_lora_sft_bnb_npu.yaml │ │ ├── llama3_lora_sft_gptq.yaml │ │ └── llama3_lora_sft_otfq.yaml ├── pyproject.toml ├── requirements.txt ├── scripts │ ├── api_example │ │ ├── test_image.py │ │ └── test_toolcall.py │ ├── convert_ckpt │ │ ├── llamafy_baichuan2.py │ │ ├── llamafy_qwen.py │ │ └── tiny_llama4.py │ ├── eval_bleu_rouge.py │ ├── llama_pro.py │ ├── loftq_init.py │ ├── pissa_init.py │ ├── qwen_omni_merge.py │ ├── stat_utils │ │ ├── cal_flops.py │ │ ├── cal_lr.py │ │ ├── cal_mfu.py │ │ ├── cal_ppl.py │ │ └── length_cdf.py │ └── vllm_infer.py ├── setup.py ├── src │ ├── api.py │ ├── llamafactory │ │ ├── __init__.py │ │ ├── api │ │ │ ├── __init__.py │ │ │ ├── app.py │ │ │ ├── chat.py │ │ │ ├── common.py │ │ │ └── protocol.py │ │ ├── chat │ │ │ ├── __init__.py │ │ │ ├── base_engine.py │ │ │ ├── chat_model.py │ │ │ ├── hf_engine.py │ │ │ ├── sglang_engine.py │ │ │ └── vllm_engine.py │ │ ├── cli.py │ │ ├── data │ │ │ ├── __init__.py │ │ │ ├── collator.py │ │ │ ├── converter.py │ │ │ ├── data_utils.py │ │ │ ├── formatter.py │ │ │ ├── loader.py │ │ │ ├── mm_plugin.py │ │ │ ├── parser.py │ │ │ ├── processor │ │ │ │ ├── __init__.py │ │ │ │ ├── feedback.py │ │ │ │ ├── pairwise.py │ │ │ │ ├── pretrain.py │ │ │ │ ├── processor_utils.py │ │ │ │ ├── supervised.py │ │ │ │ └── unsupervised.py │ │ │ ├── template.py │ │ │ └── tool_utils.py │ │ ├── eval │ │ │ ├── __init__.py │ │ │ ├── evaluator.py │ │ │ └── template.py │ │ ├── extras │ │ │ ├── __init__.py │ │ │ ├── constants.py │ │ │ ├── env.py │ │ │ ├── logging.py │ │ │ ├── misc.py │ │ │ ├── packages.py │ │ │ └── ploting.py │ │ ├── hparams │ │ │ ├── __init__.py │ │ │ ├── data_args.py │ │ │ ├── evaluation_args.py │ │ │ ├── finetuning_args.py │ │ │ ├── generating_args.py │ │ │ ├── model_args.py │ │ │ ├── parser.py │ │ │ └── training_args.py │ │ ├── launcher.py │ │ ├── model │ │ │ ├── __init__.py │ │ │ ├── adapter.py │ │ │ ├── loader.py │ │ │ ├── model_utils │ │ │ │ ├── __init__.py │ │ │ │ ├── attention.py │ │ │ │ ├── checkpointing.py │ │ │ │ ├── embedding.py │ │ │ │ ├── kv_cache.py │ │ │ │ ├── liger_kernel.py │ │ │ │ ├── longlora.py │ │ │ │ ├── misc.py │ │ │ │ ├── mod.py │ │ │ │ ├── moe.py │ │ │ │ ├── packing.py │ │ │ │ ├── quantization.py │ │ │ │ ├── rope.py │ │ │ │ ├── unsloth.py │ │ │ │ ├── valuehead.py │ │ │ │ └── visual.py │ │ │ └── patcher.py │ │ ├── third_party │ │ │ ├── __init__.py │ │ │ └── muon │ │ │ │ ├── __init__.py │ │ │ │ └── muon.py │ │ ├── train │ │ │ ├── __init__.py │ │ │ ├── callbacks.py │ │ │ ├── dpo │ │ │ │ ├── __init__.py │ │ │ │ ├── trainer.py │ │ │ │ └── workflow.py │ │ │ ├── kto │ │ │ │ ├── __init__.py │ │ │ │ ├── trainer.py │ │ │ │ └── workflow.py │ │ │ ├── ppo │ │ │ │ ├── __init__.py │ │ │ │ ├── ppo_utils.py │ │ │ │ ├── trainer.py │ │ │ │ └── workflow.py │ │ │ ├── pt │ │ │ │ ├── __init__.py │ │ │ │ ├── trainer.py │ │ │ │ └── workflow.py │ │ │ ├── rm │ │ │ │ ├── __init__.py │ │ │ │ ├── metric.py │ │ │ │ ├── trainer.py │ │ │ │ └── workflow.py │ │ │ ├── sft │ │ │ │ ├── __init__.py │ │ │ │ ├── metric.py │ │ │ │ ├── trainer.py │ │ │ │ └── workflow.py │ │ │ ├── test_utils.py │ │ │ ├── trainer_utils.py │ │ │ └── tuner.py │ │ └── webui │ │ │ ├── __init__.py │ │ │ ├── chatter.py │ │ │ ├── common.py │ │ │ ├── components │ │ │ ├── __init__.py │ │ │ ├── chatbot.py │ │ │ ├── data.py │ │ │ ├── eval.py │ │ │ ├── export.py │ │ │ ├── infer.py │ │ │ ├── top.py │ │ │ └── train.py │ │ │ ├── control.py │ │ │ ├── css.py │ │ │ ├── engine.py │ │ │ ├── interface.py │ │ │ ├── locales.py │ │ │ ├── manager.py │ │ │ └── runner.py │ ├── train.py │ └── webui.py └── tests │ ├── check_license.py │ ├── data │ ├── processor │ │ ├── test_feedback.py │ │ ├── test_pairwise.py │ │ ├── test_processor_utils.py │ │ ├── test_supervised.py │ │ └── test_unsupervised.py │ ├── test_collator.py │ ├── test_converter.py │ ├── test_formatter.py │ ├── test_loader.py │ ├── test_mm_plugin.py │ └── test_template.py │ ├── e2e │ ├── test_chat.py │ ├── test_sglang.py │ └── test_train.py │ ├── eval │ └── test_eval_template.py │ ├── model │ ├── model_utils │ │ ├── test_add_tokens.py │ │ ├── test_attention.py │ │ ├── test_checkpointing.py │ │ ├── test_misc.py │ │ ├── test_packing.py │ │ └── test_visual.py │ ├── test_base.py │ ├── test_freeze.py │ ├── test_full.py │ ├── test_lora.py │ └── test_pissa.py │ ├── train │ └── test_sft_trainer.py │ └── version.txt ├── NOTICE ├── README.md ├── assets ├── AFM.pdf ├── afm.png ├── performance.png ├── tts.png └── tts_1.png ├── environment.sh └── verl ├── .gitignore ├── .pre-commit-config.yaml ├── .readthedocs.yaml ├── AFM_changeLog.md ├── LICENSE ├── docker ├── Apptainerfile.rocm ├── Dockerfile.awsefa ├── Dockerfile.ngc.vllm ├── Dockerfile.ngc.vllm0.8 ├── Dockerfile.ngc.vllm0.8.sagemaker ├── Dockerfile.rocm ├── Dockerfile.sglang ├── Dockerfile.vemlp.vllm.te ├── Dockerfile.vllm.sglang.megatron └── Dockerfile.vllm.sglang.megatron.deepseek ├── docs ├── Makefile ├── README.md ├── README_vllm0.7.md ├── README_vllm0.8.md ├── _static │ ├── js │ │ └── runllm-widget.js │ └── logo.png ├── advance │ ├── checkpoint.rst │ ├── dpo_extension.rst │ ├── fsdp_extension.rst │ ├── megatron_extension.rst │ ├── placement.rst │ ├── ppo_lora.rst │ └── rope.rst ├── algo │ ├── baseline.md │ ├── dapo.md │ ├── grpo.md │ ├── opo.md │ ├── ppo.md │ ├── spin.md │ └── sppo.md ├── amd_tutorial │ ├── amd_build_dockerfile_page.rst │ └── amd_vllm_page.rst ├── api │ ├── data.rst │ ├── single_controller.rst │ ├── trainer.rst │ └── utils.rst ├── ascend_tutorial │ └── ascend_quick_start.rst ├── conf.py ├── examples │ ├── config.rst │ ├── gsm8k_example.rst │ ├── multi_modal_example.rst │ ├── ppo_code_architecture.rst │ └── sandbox_fusion_example.rst ├── faq │ └── faq.rst ├── hybrid_flow.rst ├── index.rst ├── perf │ ├── device_tuning.rst │ ├── dpsk.md │ ├── nsight_profiling.md │ └── perf_tuning.rst ├── preparation │ ├── prepare_data.rst │ └── reward_function.rst ├── requirements-docs.txt ├── sglang_multiturn │ ├── multiturn.rst │ ├── sandbox_fusion.rst │ └── search_tool_example.rst ├── single_controller.rst ├── start │ ├── install.rst │ ├── multinode.rst │ ├── quickstart.rst │ └── ray_debug_tutorial.rst └── workers │ ├── fsdp_workers.rst │ ├── megatron_workers.rst │ ├── ray_trainer.rst │ └── sglang_worker.rst ├── examples ├── data_preprocess │ ├── aime2024_multiturn_w_tool.py │ ├── dapo_multiturn_w_tool.py │ ├── full_hh_rlhf.py │ ├── geo3k.py │ ├── gsm8k.py │ ├── gsm8k_multiturn_w_tool.py │ ├── hellaswag.py │ ├── math_dataset.py │ ├── multiturn.py │ └── preprocess_search_r1_dataset.py ├── generation │ ├── run_deepseek7b_mutli_node.sh │ └── run_deepseek_v2_lite_math.sh ├── grpo_trainer │ ├── README.md │ ├── run_deepseek671b_math_megatron.sh │ ├── run_deepseek7b_llm.sh │ ├── run_deepseek7b_llm_math.sh │ ├── run_deepseek7b_llm_math_megatron.sh │ ├── run_deepseek7b_llm_seq_balance.sh │ ├── run_moonlight16b_math_megatron.sh │ ├── run_qwen2-7b.sh │ ├── run_qwen2-7b_math.sh │ ├── run_qwen2-7b_math_megatron.sh │ ├── run_qwen2-7b_seq_balance.sh │ ├── run_qwen2-7b_seq_balance_math_megatron.sh │ ├── run_qwen2-7b_sgl_megatron.sh │ ├── run_qwen2_5-3b_gsm8k_grpo_lora.sh │ ├── run_qwen2_5-7b_math_megatron_diff_tp.sh │ ├── run_qwen2_5_32b_grpo_npu.sh │ ├── run_qwen2_5_7b_grpo_npu.sh │ ├── run_qwen2_5_vl-7b-megatron.sh │ ├── run_qwen2_5_vl-7b.sh │ ├── run_qwen2_5_vl_32b_npu.sh │ ├── run_qwen2_5_vl_3b_npu.sh │ ├── run_qwen2_5_vl_7b_npu.sh │ ├── run_qwen3-236b_megatron.sh │ ├── run_qwen3-8b.sh │ └── run_qwen3moe-30b_megatron.sh ├── ppo_trainer │ ├── README.md │ ├── run_deepseek7b_llm.sh │ ├── run_deepseek7b_llm_modelscope.sh │ ├── run_deepseek7b_llm_pfppo.sh │ ├── run_deepseek7b_llm_sandbox_fusion.sh │ ├── run_deepseek7b_llm_sp2.sh │ ├── run_deepseek_full_hh_rlhf.sh │ ├── run_deepseek_math_gsm8k_megatron.sh │ ├── run_deepseek_math_gsm8k_megatron_nsys.sh │ ├── run_gemma.sh │ ├── run_moonlight16b_a3b_gsm8k_megatron.sh │ ├── run_qwen1.5_moe_a2.7b-gsm8k_megatron.sh │ ├── run_qwen2-7b_math_gsm8k_megatron.sh │ ├── run_qwen2-7b_rm.sh │ ├── run_qwen2-7b_rm_seq_balance.sh │ ├── run_qwen2-7b_rm_seq_balance_fused_kernels.sh │ ├── run_qwen2-7b_rm_seq_balance_nsys.sh │ ├── run_qwen2-7b_seq_balance.sh │ ├── run_qwen2-7b_sglang_seq_balance.sh │ └── run_qwen2.5-32b.sh ├── reinforce_plus_plus_trainer │ ├── run_qwen2-7b_math_rf.sh │ └── run_qwen2-7b_math_rf_baseline.sh ├── remax_trainer │ ├── run_qwen2.5-3b_seq_balance.sh │ └── run_qwen2.5-7b_seq_balance.sh ├── rloo_trainer │ └── run_qwen2-7b.sh ├── sft │ ├── gsm8k │ │ ├── run_deepseek_6b7.sh │ │ ├── run_gemma_2b.sh │ │ ├── run_gemma_7b.sh │ │ ├── run_qwen_05_peft.sh │ │ ├── run_qwen_05_sp2.sh │ │ └── run_qwen_05_sp2_liger.sh │ └── multiturn │ │ └── run_qwen_05_sp2.sh ├── sglang_multiturn │ ├── README.md │ ├── config │ │ ├── gsm8k_multiturn_grpo.yaml │ │ ├── gsm8k_multiturn_megatron_grpo.yaml │ │ ├── retool_multiturn_grpo.yaml │ │ ├── search_multiturn_grpo.yaml │ │ └── tool_config │ │ │ ├── gsm8k_tool_config.yaml │ │ │ ├── sandbox_fusion_tool_config.yaml │ │ │ └── search_tool_config.yaml │ ├── run_qwen2.5-3b_gsm8k_multiturn.sh │ ├── run_qwen2.5-3b_gsm8k_multiturn_4xgpu.sh │ ├── run_qwen2.5-3b_megatron_gsm8k_multiturn.sh │ ├── run_qwen3-4b_gsm8k_multiturn.sh │ └── search_r1_like │ │ ├── local_dense_retriever │ │ ├── download.py │ │ └── retrieval_server.py │ │ └── run_qwen2.5-3b_instruct_search_multiturn.sh ├── slurm │ └── ray_on_slurm.slurm ├── split_placement │ ├── README.md │ ├── config │ │ └── ppo_trainer_split.yaml │ ├── main_ppo_split.py │ ├── run_deepseek7b_llm.sh │ └── split_monkey_patch.py └── tuning │ ├── 0.5b │ └── qwen2-0.5b_grpo-lora_1_h100_fsdp_vllm.sh │ ├── 1.5b │ └── qwen2-1.5b_grpo-lora_1_h100_fsdp_vllm.sh │ ├── 14b │ ├── qwen2-14b_grpo-lora_2_h100_fsdp_vllm.sh │ └── qwen2_14b_grpo_4_h800_fsdp_vllm.sh │ ├── 32b │ ├── qwen2-32b_grpo-lora_4_h100_fsdp_vllm.sh │ └── qwen2_32B_grpo_8_h20_megatron_vllm.sh │ ├── 3b │ └── qwen2-3b_grpo-lora_1_h100_fsdp_vllm.sh │ ├── 70b │ ├── qwen2-70b_grpo_32_h20_fsdp_vllm.sh │ ├── qwen2-70b_grpo_32_h800_fsdp_vllm.sh │ └── qwen2-72b_grpo-lora_8_h100_fsdp_vllm.sh │ └── 7b │ ├── qwen2-7b_grpo-lora_1_h100_fsdp_vllm.sh │ └── qwen2-7b_grpo_2_h800_fsdp_vllm.sh ├── inference └── inference.sh ├── pyproject.toml ├── recipe ├── README.md ├── char_count │ ├── README.md │ ├── create_dataset.py │ ├── reward_function.py │ ├── train_grpo.sh │ └── train_sft.sh ├── dapo │ ├── README.md │ ├── config │ │ └── dapo_trainer.yaml │ ├── dapo_ray_trainer.py │ ├── main_dapo.py │ ├── prepare_dapo_data.sh │ ├── run_dapo_early_qwen2.5_32b.sh │ ├── run_dapo_qwen2.5_32b.sh │ ├── run_dapo_wo_ds_qwen2.5_32b.sh │ ├── test_dapo_7b.sh │ ├── test_dapo_7b_math.sh │ ├── test_dapo_7b_math_lora.sh │ ├── test_dapo_7b_math_megatron.sh │ ├── test_dapo_dspk_671b_megatron.sh │ └── test_dapo_qwen3_30b_math.sh ├── prime │ ├── __init__.py │ ├── config │ │ └── prime_trainer.yaml │ ├── main_prime.py │ ├── prime_core_algos.py │ ├── prime_dp_rm.py │ ├── prime_fsdp_workers.py │ ├── prime_ray_trainer.py │ ├── run_prime_qwen.sh │ └── run_prime_qwen_code.sh ├── r1 │ ├── README.md │ ├── __init__.py │ ├── config │ │ └── evaluation.yaml │ ├── data_process.py │ ├── main_eval.py │ ├── reward_score.py │ ├── run_r1_distill_qwen.sh │ └── tasks │ │ ├── __init__.py │ │ ├── gpqa.py │ │ ├── livecodebench.py │ │ └── math.py ├── retool │ ├── retool_multi_turn_sft_preprocess.py │ ├── run_qwen2.5_32b_sp8.sh │ ├── run_qwen2.5_7b_sp4.sh │ ├── run_qwen3_4b_sp4.sh │ └── run_sft.sh ├── spin │ ├── README.md │ ├── config │ │ └── spin_trainer.yaml │ ├── core_algos.py │ ├── dp_actor.py │ ├── fsdp_workers.py │ ├── main_spin.py │ ├── run_spin.sh │ └── spin_trainer.py └── sppo │ ├── README.md │ ├── __init__.py │ ├── config │ └── sppo_trainer.yaml │ ├── dp_actor.py │ ├── main_sppo.py │ ├── run_qwen2.5-7b_rm.sh │ ├── sppo_ray_trainer.py │ └── sppo_worker.py ├── requirements-npu.txt ├── requirements.txt ├── requirements_sglang.txt ├── scripts ├── converter_hf_to_mcore.py ├── diagnose.py ├── init_random_model.py ├── install_vllm_sglang_mcore.sh └── model_merger.py ├── setup.py ├── tests ├── README.md ├── __init__.py ├── kill_github_tests.sh ├── models │ ├── test_transformer.py │ └── test_transformers_ulysses.py ├── single_controller │ ├── __init__.py │ ├── base │ │ └── test_decorator.py │ ├── check_worker_alive │ │ └── main.py │ ├── detached_worker │ │ ├── README.md │ │ ├── client.py │ │ ├── run.sh │ │ └── server.py │ ├── test_auto_padding_on_cpu.py │ ├── test_colocated_workers.py │ ├── test_colocated_workers_fused.py │ ├── test_data_transfer.py │ ├── test_decorator_on_cpu.py │ ├── test_driverfunc_to_worker.py │ ├── test_fused_workers_on_cpu.py │ ├── test_high_level_scheduling_api.py │ ├── test_ray_local_envs_on_cpu.py │ ├── test_ray_utils_on_cpu.py │ ├── test_rvdz.py │ ├── test_worker_group_basics.py │ └── test_worker_group_torch.py ├── special_distributed │ ├── README.md │ ├── run_all.sh │ ├── test_fsdp_ckpt.py │ └── test_tensor_dict.py ├── special_e2e │ ├── README.md │ ├── __init__.py │ ├── check_custom_rwd_fn.py │ ├── check_results.py │ ├── envs │ │ ├── __init__.py │ │ └── digit_completion │ │ │ ├── __init__.py │ │ │ ├── task.py │ │ │ └── tokenizer.py │ ├── generation │ │ └── run_gen_qwen05.sh │ ├── ppo_trainer │ │ ├── run_function_reward.sh │ │ └── run_model_reward.sh │ ├── run_dapo.sh │ ├── run_grpo_lora_with_merge.sh │ ├── run_gsm8k_fsdp_sgl_multiturn_sf_tool.sh │ ├── run_gsm8k_fsdp_sgl_multiturn_w_tool.sh │ ├── run_ppo_trainer_megatron.sh │ ├── run_prime.sh │ ├── run_r1_distill_qwen_aime24_eval.sh │ ├── run_spin.sh │ ├── run_sppo.sh │ ├── run_test.sh │ └── sft │ │ ├── run_sft.sh │ │ └── test_sp_loss_match.py ├── special_npu │ ├── run_qwen2_5_05b_dapo.sh │ ├── run_qwen2_5_05b_grpo.sh │ └── run_qwen2_5_vl_3b_npu.sh ├── special_sanity │ ├── check_device_api_usage.py │ ├── check_license.py │ ├── check_pr_title.py │ ├── test_config_docs.py │ ├── test_import.py │ ├── type_coverage_check.py │ ├── validate_imported_docs.py │ └── validate_structure.py ├── special_standalone │ ├── README.md │ └── test_memory_buffers.py ├── test_protocol_on_cpu.py ├── tools │ └── test_base_tool_on_cpu.py ├── trainer │ ├── __init__.py │ └── ppo │ │ ├── __init__.py │ │ ├── test_core_algos_on_cpu.py │ │ └── test_metric_utils_on_cpu.py ├── utils │ ├── _test_module.py │ ├── dataset │ │ ├── test_multiturn_sft_dataset_on_cpu.py │ │ ├── test_rl_dataset_on_cpu.py │ │ └── test_sft_dataset_on_cpu.py │ ├── megatron │ │ └── test_pipeline_parallel.py │ ├── reward_score │ │ ├── reward_score │ │ │ └── test_sandbox_fusion_on_cpu.py │ │ └── test_sandbox_on_cpu.py │ ├── test_activation_offload.py │ ├── test_flops_counter.py │ ├── test_fs_on_cpu.py │ ├── test_import_utils_on_cpu.py │ ├── test_linear_cross_entropy.py │ ├── test_linear_cross_entropy_tp.py │ ├── test_model_on_cpu.py │ ├── test_seqlen_balancing.py │ ├── test_timeout_decorator_cpu.py │ └── test_torch_functional.py └── workers │ ├── reward_manager │ └── test_registry_on_cpu.py │ └── rollout │ ├── async_rollout_utils.py │ ├── perf │ └── vllm_async_rollout.py │ ├── resource │ └── tool_configs │ │ ├── sandbox_fusion_tool_config │ │ └── search_tool_config │ ├── rollout_vllm │ ├── run_fsdp_vllm.py │ ├── test_vllm_chat_scheduler.py │ ├── test_vllm_hf_loader.py │ └── test_vllm_spmd.py │ ├── test_async_sglang_server.py │ ├── test_custom_completion_callback.py │ ├── test_hf_rollout.py │ ├── test_sglang_async_rollout_search_tools.py │ ├── test_sglang_async_rollout_sf_tools.py │ ├── test_sglang_async_rollout_w_tools.py │ ├── test_sglang_spmd.py │ └── utils_sglang.py └── verl ├── __init__.py ├── models ├── README.md ├── __init__.py ├── llama │ ├── __init__.py │ └── megatron │ │ ├── __init__.py │ │ ├── checkpoint_utils │ │ ├── __init__.py │ │ ├── llama_loader.py │ │ ├── llama_loader_depracated.py │ │ └── llama_saver.py │ │ ├── layers │ │ ├── __init__.py │ │ ├── parallel_attention.py │ │ ├── parallel_decoder.py │ │ ├── parallel_linear.py │ │ ├── parallel_mlp.py │ │ └── parallel_rmsnorm.py │ │ └── modeling_llama_megatron.py ├── mcore │ ├── __init__.py │ ├── config_converter.py │ ├── loader.py │ ├── model_forward.py │ ├── model_initializer.py │ ├── patch_v012.py │ ├── qwen2_5_vl │ │ ├── __init__.py │ │ ├── attention.py │ │ ├── model.py │ │ ├── rope_utils.py │ │ ├── vision_config.py │ │ ├── vision_model.py │ │ └── vision_transformer_block.py │ ├── readme.md │ ├── registry.py │ ├── saver.py │ ├── util.py │ └── weight_converter.py ├── qwen2 │ ├── __init__.py │ └── megatron │ │ ├── __init__.py │ │ ├── checkpoint_utils │ │ ├── __init__.py │ │ ├── qwen2_loader.py │ │ ├── qwen2_loader_depracated.py │ │ └── qwen2_saver.py │ │ ├── layers │ │ ├── __init__.py │ │ ├── parallel_attention.py │ │ ├── parallel_decoder.py │ │ ├── parallel_linear.py │ │ ├── parallel_mlp.py │ │ └── parallel_rmsnorm.py │ │ └── modeling_qwen2_megatron.py ├── registry.py ├── transformers │ ├── __init__.py │ ├── dense_common.py │ ├── kimi_vl.py │ ├── llama.py │ ├── monkey_patch.py │ ├── npu_patch.py │ ├── qwen2.py │ ├── qwen2_5_vl.py │ └── qwen2_vl.py └── weight_loader_registry.py ├── protocol.py ├── single_controller ├── __init__.py ├── base │ ├── __init__.py │ ├── decorator.py │ ├── megatron │ │ ├── __init__.py │ │ ├── worker.py │ │ └── worker_group.py │ ├── register_center │ │ ├── __init__.py │ │ └── ray.py │ ├── worker.py │ └── worker_group.py └── ray │ ├── __init__.py │ ├── base.py │ └── megatron.py ├── third_party ├── __init__.py ├── sglang │ ├── __init__.py │ └── parallel_state.py └── vllm │ ├── __init__.py │ ├── vllm_v_0_5_4 │ ├── __init__.py │ ├── arg_utils.py │ ├── config.py │ ├── dtensor_weight_loaders.py │ ├── hf_weight_loader.py │ ├── llm.py │ ├── llm_engine_sp.py │ ├── megatron_weight_loaders.py │ ├── model_loader.py │ ├── model_runner.py │ ├── parallel_state.py │ ├── spmd_gpu_executor.py │ ├── tokenizer.py │ └── worker.py │ └── vllm_v_0_6_3 │ ├── __init__.py │ ├── arg_utils.py │ ├── config.py │ ├── dtensor_weight_loaders.py │ ├── hf_weight_loader.py │ ├── llm.py │ ├── llm_engine_sp.py │ ├── megatron_weight_loaders.py │ ├── model_loader.py │ ├── model_runner.py │ ├── parallel_state.py │ ├── spmd_gpu_executor.py │ ├── tokenizer.py │ └── worker.py ├── tools ├── README.md ├── __init__.py ├── base_tool.py ├── code_executor.py ├── config │ ├── afm_tool_config │ │ └── afm_tool_config.yaml │ ├── code_tool_config │ │ └── code_executor.yaml │ ├── mm_tool_config │ │ └── visual_inspector.yaml │ └── search_tool_config │ │ ├── training_servers_config.yaml │ │ └── wiki_rag_config.yaml ├── crawl_page_v2.py ├── gsm8k_tool.py ├── sandbox_fusion_tools.py ├── schemas.py ├── search_tool.py ├── utils │ ├── __init__.py │ ├── code_executors │ │ ├── __init__.py │ │ ├── nsjail_executor_codeforces.py │ │ ├── nsjail_sandbox.py │ │ └── utils.py │ └── search_r1_like_utils.py ├── visual_inspector.py ├── web_search_v2.py ├── wiki_search_r1.py └── xml_tool_parser.py ├── trainer ├── __init__.py ├── config │ ├── evaluation.yaml │ ├── generation.yaml │ ├── ppo_megatron_trainer.yaml │ ├── ppo_trainer.yaml │ └── sft_trainer.yaml ├── fsdp_sft_trainer.py ├── main_eval.py ├── main_generation.py ├── main_ppo.py ├── ppo │ ├── __init__.py │ ├── core_algos.py │ ├── metric_utils.py │ ├── ray_trainer.py │ └── reward.py └── runtime_env.yaml ├── utils ├── __init__.py ├── activation_offload.py ├── checkpoint │ ├── __init__.py │ ├── checkpoint_manager.py │ ├── fsdp_checkpoint_manager.py │ └── megatron_checkpoint_manager.py ├── config.py ├── dataset │ ├── README.md │ ├── __init__.py │ ├── multiturn_sft_dataset.py │ ├── rl_dataset.py │ ├── rm_dataset.py │ ├── sft_dataset.py │ └── vision_utils.py ├── debug │ ├── __init__.py │ ├── empty_annotations.py │ ├── nvtx_profile.py │ ├── performance.py │ ├── profile.py │ └── trajectory_tracker.py ├── device.py ├── distributed.py ├── experimental │ ├── __init__.py │ └── torch_functional.py ├── flops_counter.py ├── fs.py ├── fsdp_utils.py ├── hdfs_io.py ├── import_utils.py ├── kernel │ ├── __init__.py │ ├── kernels.py │ └── linear_cross_entropy.py ├── logger │ ├── __init__.py │ └── aggregate_logger.py ├── logging_utils.py ├── megatron │ ├── __init__.py │ ├── memory.py │ ├── optimizer.py │ ├── pipeline_parallel.py │ ├── sequence_parallel.py │ └── tensor_parallel.py ├── megatron_utils.py ├── memory_buffer.py ├── metric │ ├── __init__.py │ └── utils.py ├── model.py ├── net_utils.py ├── py_functional.py ├── ray_utils.py ├── rendezvous │ ├── __init__.py │ └── ray_backend.py ├── reward_score │ ├── __init__.py │ ├── codeforces.py │ ├── format_reward.py │ ├── format_verifier.py │ ├── geo3k.py │ ├── grm_simple.py │ ├── gsm8k.py │ ├── lcb.py │ ├── length_penalty.py │ ├── livecodebench │ │ ├── __init__.py │ │ ├── lcb_runner │ │ │ ├── __init__.py │ │ │ ├── benchmarks │ │ │ │ ├── __init__.py │ │ │ │ ├── code_execution.py │ │ │ │ ├── code_generation.py │ │ │ │ └── test_output_prediction.py │ │ │ ├── evaluation │ │ │ │ ├── __init__.py │ │ │ │ ├── compute_code_execution_metrics.py │ │ │ │ ├── compute_code_generation_metrics.py │ │ │ │ ├── compute_scores.py │ │ │ │ ├── compute_test_output_prediction_metrics.py │ │ │ │ ├── old_results_check.py │ │ │ │ ├── pass_k_utils.py │ │ │ │ ├── testing_util.py │ │ │ │ └── utils_execute.py │ │ │ ├── lm_styles.py │ │ │ ├── prompts │ │ │ │ ├── __init__.py │ │ │ │ ├── code_execution.py │ │ │ │ ├── code_generation.py │ │ │ │ ├── self_repair.py │ │ │ │ └── test_output_prediction.py │ │ │ ├── runner │ │ │ │ ├── base_runner.py │ │ │ │ ├── claude3_runner.py │ │ │ │ ├── claude_runner.py │ │ │ │ ├── cohere_runner.py │ │ │ │ ├── custom_evaluator.py │ │ │ │ ├── deepseek_runner.py │ │ │ │ ├── fireworks_runner.py │ │ │ │ ├── gemini_runner.py │ │ │ │ ├── main.py │ │ │ │ ├── mistral_runner.py │ │ │ │ ├── oai_runner.py │ │ │ │ ├── parser.py │ │ │ │ ├── runner_utils.py │ │ │ │ ├── scenario_router.py │ │ │ │ └── vllm_runner.py │ │ │ └── utils │ │ │ │ ├── extraction_utils.py │ │ │ │ ├── multiprocess.py │ │ │ │ ├── path_utils.py │ │ │ │ └── scenarios.py │ │ ├── skywork.py │ │ └── unit_test.py │ ├── llm_judge.py │ ├── math_1.py │ ├── math_batch.py │ ├── math_dapo.py │ ├── math_verify.py │ ├── mathverify.py │ ├── mbpp.py │ ├── mhqa_eval.py │ ├── mhqa_train.py │ ├── multiply.py │ ├── prime_code │ │ ├── __init__.py │ │ ├── testing_util.py │ │ └── utils.py │ ├── prime_math │ │ ├── __init__.py │ │ ├── grader.py │ │ └── math_normalize.py │ ├── qa_em.py │ ├── sandbox_fusion │ │ ├── __init__.py │ │ └── utils.py │ ├── search_r1_like_qa_em.py │ └── utils.py ├── seqlen_balancing.py ├── tokenizer.py ├── torch_dtypes.py ├── torch_functional.py ├── tracking.py ├── ulysses.py └── vllm_utils.py ├── version └── version └── workers ├── __init__.py ├── actor ├── __init__.py ├── base.py ├── dp_actor.py └── megatron_actor.py ├── critic ├── __init__.py ├── base.py ├── dp_critic.py └── megatron_critic.py ├── fsdp_workers.py ├── megatron_workers.py ├── reward_manager ├── __init__.py ├── afm.py ├── batch.py ├── dapo.py ├── naive.py ├── prime.py ├── registry.py └── search.py ├── reward_model ├── __init__.py ├── base.py └── megatron │ ├── __init__.py │ └── reward_model.py ├── rollout ├── __init__.py ├── async_server.py ├── base.py ├── chat_scheduler.py ├── hf_rollout.py ├── naive │ ├── __init__.py │ └── naive_rollout.py ├── schemas.py ├── sglang_rollout │ ├── __init__.py │ ├── async_sglang_server.py │ ├── sglang_rollout.py │ └── utils.py ├── tokenizer.py └── vllm_rollout │ ├── __init__.py │ ├── fire_vllm_rollout.py │ ├── vllm_async_server.py │ ├── vllm_rollout.py │ └── vllm_rollout_spmd.py └── sharding_manager ├── __init__.py ├── base.py ├── fsdp_sglang.py ├── fsdp_ulysses.py ├── fsdp_vllm.py ├── megatron_sglang.py └── megatron_vllm.py /AFM/data/code_agent/code_math_benchmarks/OlympiadBench.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OPPO-PersonalAI/Agent_Foundation_Models/9a6594d4661fa994f189074ecfdfd259eea87c6d/AFM/data/code_agent/code_math_benchmarks/OlympiadBench.parquet -------------------------------------------------------------------------------- /AFM/data/code_agent/code_math_benchmarks/aime24.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OPPO-PersonalAI/Agent_Foundation_Models/9a6594d4661fa994f189074ecfdfd259eea87c6d/AFM/data/code_agent/code_math_benchmarks/aime24.parquet -------------------------------------------------------------------------------- /AFM/data/code_agent/code_math_benchmarks/aime25.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OPPO-PersonalAI/Agent_Foundation_Models/9a6594d4661fa994f189074ecfdfd259eea87c6d/AFM/data/code_agent/code_math_benchmarks/aime25.parquet -------------------------------------------------------------------------------- /AFM/data/code_agent/code_math_benchmarks/amc23.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OPPO-PersonalAI/Agent_Foundation_Models/9a6594d4661fa994f189074ecfdfd259eea87c6d/AFM/data/code_agent/code_math_benchmarks/amc23.parquet -------------------------------------------------------------------------------- /AFM/data/code_agent/code_math_benchmarks/codecontest.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OPPO-PersonalAI/Agent_Foundation_Models/9a6594d4661fa994f189074ecfdfd259eea87c6d/AFM/data/code_agent/code_math_benchmarks/codecontest.parquet -------------------------------------------------------------------------------- /AFM/data/code_agent/code_math_benchmarks/livecodebench_v4.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OPPO-PersonalAI/Agent_Foundation_Models/9a6594d4661fa994f189074ecfdfd259eea87c6d/AFM/data/code_agent/code_math_benchmarks/livecodebench_v4.parquet -------------------------------------------------------------------------------- /AFM/data/code_agent/code_math_benchmarks/livecodebench_v5.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OPPO-PersonalAI/Agent_Foundation_Models/9a6594d4661fa994f189074ecfdfd259eea87c6d/AFM/data/code_agent/code_math_benchmarks/livecodebench_v5.parquet -------------------------------------------------------------------------------- /AFM/data/code_agent/code_math_benchmarks/math500.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OPPO-PersonalAI/Agent_Foundation_Models/9a6594d4661fa994f189074ecfdfd259eea87c6d/AFM/data/code_agent/code_math_benchmarks/math500.parquet -------------------------------------------------------------------------------- /AFM/data/code_agent/download.py: -------------------------------------------------------------------------------- 1 | from datasets import load_dataset 2 | 3 | # Login using e.g. `huggingface-cli login` to access this dataset 4 | ds_sft = load_dataset("PersonalAILab/AFM-CodeAgent-SFT-Dataset") 5 | ds_sft.save_to_disk("./AFM-CodeAgent-SFT-Dataset") 6 | 7 | ds_rl = load_dataset("PersonalAILab/AFM-CodeAgent-RL-Dataset") 8 | ds_rl.save_to_disk("./AFM-CodeAgent-RL-Dataset") -------------------------------------------------------------------------------- /AFM/data/code_agent/livecodebench_testcases/download_and_process.py: -------------------------------------------------------------------------------- 1 | """ 2 | Generate single pkl file of livecodebench testcases for dynamic loading during training. 3 | You can specify release_version, start_date and end_date to generate lcb v5 or lcb v6, etc. 4 | """ 5 | 6 | import sys 7 | from pathlib import Path 8 | 9 | project_root = Path(__file__).resolve().parent.parent.parent 10 | sys.path.insert(0, str(project_root)) 11 | 12 | from verl.utils.reward_score.livecodebench.lcb_runner.benchmarks import code_generation 13 | 14 | dataset = load_code_generation_dataset() 15 | output_dir = "data/livecodebench_testcases" 16 | save_dataset_as_individual_pkl(dataset, output_dir) 17 | 18 | 19 | -------------------------------------------------------------------------------- /AFM/data/mhqa_agent/download.py: -------------------------------------------------------------------------------- 1 | from datasets import load_dataset 2 | 3 | # Login using e.g. `huggingface-cli login` to access this dataset 4 | ds_sft = load_dataset("PersonalAILab/AFM-MHQA-Agent-SFT-Dataset") 5 | ds_sft.save_to_disk("./AFM-MHQA-Agent-SFT-Dataset") 6 | 7 | ds_rl = load_dataset("PersonalAILab/AFM-MHQA-RL-Dataset") 8 | ds_rl.save_to_disk("./AFM-MHQA-Agent-RL-Dataset") -------------------------------------------------------------------------------- /AFM/data/mhqa_agent/prepare.sh: -------------------------------------------------------------------------------- 1 | python prepare_data.py ./test_benchmarks/nq_full.jsonl \ 2 | -o ./test_benchmarks \ 3 | --tool-type single \ 4 | --sys-prompt-key MHQA_PROMPT -------------------------------------------------------------------------------- /AFM/data/web_agent/download.py: -------------------------------------------------------------------------------- 1 | from datasets import load_dataset 2 | 3 | # Login using e.g. `huggingface-cli login` to access this dataset 4 | ds_sft = load_dataset("PersonalAILab/AFM-WebAgent-SFT-Dataset") 5 | ds_sft.save_to_disk("./AFM-WebAgent-SFT-Dataset") 6 | 7 | ds_rl = load_dataset("PersonalAILab/AFM-WebAgent-RL-Dataset") 8 | ds_rl.save_to_disk("./AFM-WebAgent-RL-Dataset") -------------------------------------------------------------------------------- /AFM/models/code_agent/download.py: -------------------------------------------------------------------------------- 1 | from huggingface_hub import snapshot_download 2 | 3 | # you can change to our other models in "https://huggingface.co/PersonalAILab/models" 4 | snapshot_download( 5 | repo_id="PersonalAILab/AFM-CodeAgent-32B-rl", 6 | local_dir="./AFM-CodeAgent-32B-rl", 7 | local_dir_use_symlinks=False, 8 | resume_download=True 9 | ) -------------------------------------------------------------------------------- /AFM/models/mhqa_agent/download.py: -------------------------------------------------------------------------------- 1 | from huggingface_hub import snapshot_download 2 | 3 | # you can change to our other models in "https://huggingface.co/PersonalAILab/models" 4 | snapshot_download( 5 | repo_id="PersonalAILab/AFM-MHQA-Agent-7B-rl", 6 | local_dir="./AFM-MHQA-Agent-7B-rl", 7 | local_dir_use_symlinks=False, 8 | resume_download=True 9 | ) -------------------------------------------------------------------------------- /AFM/models/web_agent/download.py: -------------------------------------------------------------------------------- 1 | from huggingface_hub import snapshot_download 2 | 3 | # you can change to our other models in "https://huggingface.co/PersonalAILab/models" 4 | snapshot_download( 5 | repo_id="PersonalAILab/AFM-WebAgent-32B-rl", 6 | local_dir="./AFM-WebAgent-32B-rl", 7 | local_dir_use_symlinks=False, 8 | resume_download=True 9 | ) -------------------------------------------------------------------------------- /AFM/tool_servers/web_server/v2/keys.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | serper_key_pool = [ 4 | { 5 | "url": "https://google.serper.dev/search", 6 | "key": os.environ.get("WEB_SEARCH_SERPER_API_KEY") 7 | } 8 | ] 9 | 10 | qwen_api_pool = [ 11 | { 12 | "url": "https://api.uniapi.vip/v1", 13 | "key": os.environ.get("UNI_API_KEY"), 14 | "model": "qwen2.5-72b-instruct", 15 | }, 16 | # other qwen api provider ... 17 | ] 18 | 19 | 20 | jina_api_pool = [ 21 | { 22 | "key": os.environ.get("JINA_API_KEY") 23 | } 24 | ] 25 | 26 | 27 | def get_serper_api() -> dict: 28 | """ 29 | Returns a random Serper API from the pool. 30 | """ 31 | import random 32 | return random.choice(serper_key_pool) 33 | 34 | def get_qwen_api() -> dict: 35 | """ 36 | Returns a random Qwen API from the pool. 37 | """ 38 | import random 39 | return random.choice(qwen_api_pool) 40 | 41 | 42 | def get_jina_api() -> dict: 43 | """ 44 | Returns a random Jina API from the pool. 45 | """ 46 | import random 47 | return random.choice(jina_api_pool) -------------------------------------------------------------------------------- /AFM/tool_servers/wiki_server/download.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | from huggingface_hub import hf_hub_download 3 | 4 | parser = argparse.ArgumentParser(description="Download files from a Hugging Face dataset repository.") 5 | parser.add_argument("--repo_id", type=str, default="PeterJinGo/wiki-18-e5-index", help="Hugging Face repository ID") 6 | parser.add_argument("--save_path", type=str, required=True, help="Local directory to save files") 7 | 8 | args = parser.parse_args() 9 | 10 | repo_id = "PeterJinGo/wiki-18-e5-index" 11 | for file in ["part_aa", "part_ab"]: 12 | hf_hub_download( 13 | repo_id=repo_id, 14 | filename=file, # e.g., "e5_Flat.index" 15 | repo_type="dataset", 16 | local_dir=args.save_path, 17 | ) 18 | 19 | repo_id = "PeterJinGo/wiki-18-corpus" 20 | hf_hub_download( 21 | repo_id=repo_id, 22 | filename="wiki-18.jsonl.gz", 23 | repo_type="dataset", 24 | local_dir=args.save_path, 25 | ) 26 | -------------------------------------------------------------------------------- /AFM/tool_servers/wiki_server/launch_rag_server.sh: -------------------------------------------------------------------------------- 1 | # nohup bash launch_rag_server.sh > launch_rag_server_8000.log 2>&1 & 2 | 3 | file_path=path_to_your_index_data_dir 4 | index_file=$file_path/e5_Flat.index 5 | corpus_file=$file_path/wiki-18.jsonl 6 | retriever_name=e5 7 | retriever_path=path_to_your_embedding_file 8 | port=8000 9 | 10 | python server/wiki_rag_server.py --index_path $index_file \ 11 | --corpus_path $corpus_file \ 12 | --topk 3 \ 13 | --retriever_name $retriever_name \ 14 | --retriever_model $retriever_path \ 15 | --faiss_gpu \ 16 | --port $port 17 | -------------------------------------------------------------------------------- /LLaMA-Factory/.dockerignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | .git 3 | .github 4 | .venv 5 | cache 6 | data 7 | docker 8 | saves 9 | hf_cache 10 | ms_cache 11 | om_cache 12 | output 13 | .dockerignore 14 | .gitattributes 15 | .gitignore 16 | -------------------------------------------------------------------------------- /LLaMA-Factory/.env.local: -------------------------------------------------------------------------------- 1 | # Note: actually we do not support .env, just for reference 2 | # api 3 | API_HOST= 4 | API_PORT= 5 | API_KEY= 6 | API_MODEL_NAME= 7 | API_VERBOSE= 8 | FASTAPI_ROOT_PATH= 9 | MAX_CONCURRENT= 10 | # general 11 | DISABLE_VERSION_CHECK= 12 | FORCE_CHECK_IMPORTS= 13 | ALLOW_EXTRA_ARGS= 14 | LLAMAFACTORY_VERBOSITY= 15 | USE_MODELSCOPE_HUB= 16 | USE_OPENMIND_HUB= 17 | USE_RAY= 18 | RECORD_VRAM= 19 | OPTIM_TORCH= 20 | NPU_JIT_COMPILE= 21 | # torchrun 22 | FORCE_TORCHRUN= 23 | MASTER_ADDR= 24 | MASTER_PORT= 25 | NNODES= 26 | NODE_RANK= 27 | NPROC_PER_NODE= 28 | # wandb 29 | WANDB_DISABLED= 30 | WANDB_PROJECT= 31 | WANDB_API_KEY= 32 | # gradio ui 33 | GRADIO_SHARE= 34 | GRADIO_SERVER_NAME= 35 | GRADIO_SERVER_PORT= 36 | GRADIO_ROOT_PATH= 37 | GRADIO_IPV6= 38 | # setup 39 | ENABLE_SHORT_CONSOLE= 40 | # reserved (do not use) 41 | LLAMABOARD_ENABLED= 42 | LLAMABOARD_WORKDIR= 43 | -------------------------------------------------------------------------------- /LLaMA-Factory/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /LLaMA-Factory/.github/ISSUE_TEMPLATE/2-feature-request.yml: -------------------------------------------------------------------------------- 1 | name: "\U0001F680 Feature request" 2 | description: Submit a request for a new feature 3 | labels: ["enhancement", "pending"] 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | Please do not create issues that are not related to new features under this category. 9 | 请勿在此分类下创建和新特性无关的 issues。 10 | 11 | - type: checkboxes 12 | id: reminder 13 | attributes: 14 | label: Reminder 15 | description: | 16 | Please ensure you have read the above rules carefully and searched the existing issues. 17 | 请确保您已经认真阅读了上述规则并且搜索过现有的 issues。 18 | 19 | options: 20 | - label: I have read the above rules and searched the existing issues. 21 | required: true 22 | 23 | - type: textarea 24 | id: description 25 | validations: 26 | required: true 27 | attributes: 28 | label: Description 29 | description: | 30 | A clear and concise description of the feature proposal. 31 | 请详细描述您希望加入的新功能特性。 32 | 33 | - type: textarea 34 | id: contribution 35 | validations: 36 | required: false 37 | attributes: 38 | label: Pull Request 39 | description: | 40 | Have you already created the relevant PR and submitted the code? 41 | 您是否已经创建了相关 PR 并提交了代码? 42 | -------------------------------------------------------------------------------- /LLaMA-Factory/.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | -------------------------------------------------------------------------------- /LLaMA-Factory/.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # What does this PR do? 2 | 3 | Fixes # (issue) 4 | 5 | ## Before submitting 6 | 7 | - [ ] Did you read the [contributor guideline](https://github.com/hiyouga/LLaMA-Factory/blob/main/.github/CONTRIBUTING.md)? 8 | - [ ] Did you write any new necessary tests? 9 | -------------------------------------------------------------------------------- /LLaMA-Factory/.github/SECURITY.md: -------------------------------------------------------------------------------- 1 | # Reporting Security Issues 2 | 3 | To report a security issue, please use the GitHub Security Advisory ["Report a Vulnerability"](https://github.com/hiyouga/LLaMA-Factory/security/advisories/new) tab. 4 | 5 | We will send a response indicating the next steps in handling your report. After the initial reply to your report, the security team will keep you informed of the progress towards a fix and full announcement, and may ask for additional information or guidance. 6 | 7 | Report security bugs in third-party modules to the person or team maintaining the module. 8 | -------------------------------------------------------------------------------- /LLaMA-Factory/.github/workflows/label_issue.yml: -------------------------------------------------------------------------------- 1 | name: label_issue 2 | 3 | on: 4 | issues: 5 | types: 6 | - opened 7 | 8 | jobs: 9 | label_issue: 10 | runs-on: ubuntu-latest 11 | 12 | permissions: 13 | issues: write 14 | 15 | steps: 16 | - env: 17 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 18 | ISSUE_URL: ${{ github.event.issue.html_url }} 19 | ISSUE_TITLE: ${{ github.event.issue.title }} 20 | run: | 21 | LABEL="" 22 | NPU_KEYWORDS=(npu huawei ascend 华为 昇腾) 23 | ISSUE_TITLE_LOWER=$(echo $ISSUE_TITLE | tr '[:upper:]' '[:lower:]') 24 | for KEYWORD in ${NPU_KEYWORDS[@]}; do 25 | if [[ $ISSUE_TITLE_LOWER == *$KEYWORD* ]] && [[ $ISSUE_TITLE_LOWER != *input* ]]; then 26 | LABEL="npu" 27 | break 28 | fi 29 | done 30 | if [ -n "$LABEL" ]; then 31 | gh issue edit $ISSUE_URL --add-label $LABEL 32 | fi 33 | -------------------------------------------------------------------------------- /LLaMA-Factory/.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: publish 2 | 3 | on: 4 | workflow_dispatch: 5 | release: 6 | types: 7 | - published 8 | 9 | jobs: 10 | publish: 11 | name: Upload release to PyPI 12 | 13 | runs-on: ubuntu-latest 14 | 15 | environment: 16 | name: release 17 | url: https://pypi.org/p/llamafactory 18 | 19 | permissions: 20 | id-token: write 21 | 22 | steps: 23 | - name: Checkout 24 | uses: actions/checkout@v4 25 | 26 | - name: Set up Python 27 | uses: actions/setup-python@v5 28 | with: 29 | python-version: "3.9" 30 | 31 | - name: Build package 32 | run: | 33 | make build 34 | 35 | - name: Publish package 36 | uses: pypa/gh-action-pypi-publish@release/v1 37 | -------------------------------------------------------------------------------- /LLaMA-Factory/.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/pre-commit/pre-commit-hooks 3 | rev: v5.0.0 4 | hooks: 5 | - id: check-ast 6 | - id: check-added-large-files 7 | args: ['--maxkb=25000'] 8 | - id: check-merge-conflict 9 | - id: check-yaml 10 | - id: debug-statements 11 | - id: end-of-file-fixer 12 | - id: trailing-whitespace 13 | args: [--markdown-linebreak-ext=md] 14 | - id: no-commit-to-branch 15 | args: ['--branch', 'main'] 16 | 17 | - repo: https://github.com/asottile/pyupgrade 18 | rev: v3.17.0 19 | hooks: 20 | - id: pyupgrade 21 | args: [--py38-plus] 22 | 23 | - repo: https://github.com/astral-sh/ruff-pre-commit 24 | rev: v0.6.9 25 | hooks: 26 | - id: ruff 27 | args: [--fix] 28 | - id: ruff-format 29 | -------------------------------------------------------------------------------- /LLaMA-Factory/AFM_changeLog.md: -------------------------------------------------------------------------------- 1 | ## Modified Features 2 | - Modified SFT training to support masked token modeling 3 | - Implemented DPO (Direct Preference Optimization) training functionality 4 | 5 | ## Modified Files 6 | The following files were updated to support these features: 7 | - M src/llamafactory/data/loader.py 8 | - M src/llamafactory/data/processor/__init__.py 9 | - M src/llamafactory/data/processor/supervised.py 10 | - M src/llamafactory/data/processor/pairwise.py 11 | - M src/llamafactory/hparams/data_args.py 12 | -------------------------------------------------------------------------------- /LLaMA-Factory/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include LICENSE requirements.txt 2 | -------------------------------------------------------------------------------- /LLaMA-Factory/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: build commit license quality style test 2 | 3 | check_dirs := scripts src tests setup.py 4 | 5 | build: 6 | pip3 install build && python3 -m build 7 | 8 | commit: 9 | pre-commit install 10 | pre-commit run --all-files 11 | 12 | license: 13 | python3 tests/check_license.py $(check_dirs) 14 | 15 | quality: 16 | ruff check $(check_dirs) 17 | ruff format --check $(check_dirs) 18 | 19 | style: 20 | ruff check $(check_dirs) --fix 21 | ruff format $(check_dirs) 22 | 23 | test: 24 | CUDA_VISIBLE_DEVICES= WANDB_DISABLED=true pytest -vv tests/ 25 | -------------------------------------------------------------------------------- /LLaMA-Factory/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OPPO-PersonalAI/Agent_Foundation_Models/9a6594d4661fa994f189074ecfdfd259eea87c6d/LLaMA-Factory/assets/logo.png -------------------------------------------------------------------------------- /LLaMA-Factory/assets/wechat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OPPO-PersonalAI/Agent_Foundation_Models/9a6594d4661fa994f189074ecfdfd259eea87c6d/LLaMA-Factory/assets/wechat.jpg -------------------------------------------------------------------------------- /LLaMA-Factory/assets/wechat_npu.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OPPO-PersonalAI/Agent_Foundation_Models/9a6594d4661fa994f189074ecfdfd259eea87c6d/LLaMA-Factory/assets/wechat_npu.jpg -------------------------------------------------------------------------------- /LLaMA-Factory/data/mllm_audio_demo.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "messages": [ 4 | { 5 | "content": "