{"id":18809950,"url":"https://github.com/anchen1011/fireact","last_synced_at":"2025-04-09T13:09:56.558Z","repository":{"id":199398194,"uuid":"701868592","full_name":"anchen1011/FireAct","owner":"anchen1011","description":"FireAct: Toward Language Agent Fine-tuning","archived":false,"fork":false,"pushed_at":"2023-10-22T17:05:17.000Z","size":14023,"stargazers_count":275,"open_issues_count":2,"forks_count":20,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-02T11:08:26.754Z","etag":null,"topics":["agent","fine-tuning","large-language-models","llm","reasoning"],"latest_commit_sha":null,"homepage":"https://fireact-agent.github.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anchen1011.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-07T19:53:16.000Z","updated_at":"2025-04-01T03:13:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"3038bfe4-1398-48d0-a439-3d6452feaceb","html_url":"https://github.com/anchen1011/FireAct","commit_stats":null,"previous_names":["anchen1011/fireact"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anchen1011%2FFireAct","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anchen1011%2FFireAct/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anchen1011%2FFireAct/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anchen1011%2FFireAct/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anchen1011","download_url":"https://codeload.github.com/anchen1011/FireAct/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248045245,"owners_count":21038554,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent","fine-tuning","large-language-models","llm","reasoning"],"created_at":"2024-11-07T23:18:19.163Z","updated_at":"2025-04-09T13:09:56.539Z","avatar_url":"https://github.com/anchen1011.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FireAct: Toward Language Agent Fine-tuning\n\n\u003cp\u003e\n    \u003ca href=\"https://www.python.org/\"\u003e\n        \u003cimg alt=\"Build\" src=\"https://img.shields.io/badge/Python-3.7+-1f425f.svg?color=blue\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/anchen1011/FireAct/blob/main/LICENSE\"\u003e\n        \u003cimg alt=\"License\" src=\"https://img.shields.io/badge/License-MIT-blue\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://huggingface.co/forestai/fireact_llama_2_7b\" target=\"_blank\"\u003e\n        \u003cimg alt=\"Hugging Face\" src=\"https://img.shields.io/badge/%F0%9F%A4%97%20-Hugging%20Face-blue?color=blue\u0026logoColor=white\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n![teaser](teaser.png)\n\n\nThis repository is based on our publication *FireAct: Toward Language Agent Fine-tuning* ([PDF](https://browse.arxiv.org/pdf/2310.05915.pdf)). It contains prompts, demo code and fine-tuning data we generated. It also includes the description and directory for the model family we fine-tuned. If you use this code or data in your work, please cite:\n\n```\n@misc{chen2023fireact,\n      title={FireAct: Toward Language Agent Fine-tuning}, \n      author={Baian Chen and Chang Shu and Ehsan Shareghi and Nigel Collier and Karthik Narasimhan and Shunyu Yao},\n      year={2023},\n      eprint={2310.05915},\n      archivePrefix={arXiv},\n      primaryClass={cs.CL}\n}\n```\n\n## Overview\n- Define tools in `tools/`\n- Define tasks in `tasks/`\n- Collect data \u0026 run experiments via `generation.py` \n- Results will be saved in `trajs/`\n\n\n## Data \u0026 Prompts\n- Data to generate training data and run experiments in `data/`. We also include samples of training data for both Alpaca format and GPT format. See details [here](https://github.com/anchen1011/FireAct/tree/main/data).\n- Prompts to generate training data and run experiments in `prompts/`\n\n## Setup\n\nSet up OpenAI API key and store in environment variable  (see [here](https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety))\n\n```\nexport OPENAI_API_KEY=\u003cYOUR_KEY\u003e\n```\n \nSet up SERP API key and store in environment variable (see [here](https://serpapi.com))\n\n```\nexport SERPAPI_API_KEY=\u003cYOUR_KEY\u003e\n```\n\nCreate virtual env, for example with conda\n\n```\nconda create -n fireact python=3.9\nconda activate fireact\n```\n\nClone this repo and install dependencies\n\n```\ngit clone https://github.com/anchen1011/FireAct.git\npip install -r requirements.txt\n```\n\n## Run Demo\n\n#### Data Generation\n\nExample:\n\n```\npython generation.py \\\n    --task hotpotqa \\\n    --backend gpt-4 \\\n    --promptpath default \\\n    --evaluate \\\n    --random \\\n    --task_split val \\\n    --temperature 0 \\\n    --task_end_index 5\n```\n\nSee details with command `python generation.py -h`\n\nYou need to set a high number (thousands) of `--task_end_index` to get sufficient good data samples. **[WARNING] This is costly with gpt-4 and serpapi.**\n\nYou need to convert trajectories into [alpaca format](https://github.com/tatsu-lab/stanford_alpaca#data-release) or [gpt format](https://platform.openai.com/docs/guides/fine-tuning/preparing-your-dataset) for training. See our examples [here](https://github.com/anchen1011/FireAct/tree/main/data/finetune).\n\n#### Supervised Fine-tuning\n\nExample:\n\n```\ncd finetune/llama_lora\npython finetune.py \\\n    --base_model meta-llama/Llama-2-13b-chat-hf \\\n    --data_path ../../data/finetune/alpaca_format/hotpotqa.json \\\n    --micro_batch_size 8 \\\n    --num_epochs 30 \\\n    --output_dir ../../models/lora/fireact-llama-2-13b \\\n    --val_set_size 0.01 \\\n    --cutoff_len 512 \\\n```\n\nSee details [here](https://github.com/anchen1011/FireAct/tree/main/finetune).\n\n#### Inference\n\nExample (FireAct Llama):\n\n```\npython generation.py \\\n    --task hotpotqa \\\n    --backend llama \\\n    --evaluate \\\n    --random \\\n    --task_split dev \\\n    --task_end_index 5 \\\n    --modelpath meta-llama/Llama-2-7b-chat \\\n    --add_lora \\\n    --alpaca_format \\\n    --peftpath forestai/fireact_llama_2_7b_lora \n```\n\nExample (FireAct GPT):\n\n```\npython generation.py \\\n    --task hotpotqa \\\n    --backend ft:gpt-3.5-turbo-0613:\u003cYOUR_MODEL\u003e \\\n    --evaluate \\\n    --random \\\n    --task_split dev \\\n    --temperature 0 \\\n    --chatgpt_format \\\n    --task_end_index 5\n```\n\nSee details with command `python generation.py -h`\n\nSet `--task_end_index 500` for quantitative evaluations. See our examples [here](https://github.com/anchen1011/FireAct/tree/main/trajs).\n\n## Model Zoo\n\nWe release a selected set of multitask models based on Llama family. Details can be found in their model cards. \n\n| Base Model    | Training Method | Hugging Face                                               |\n|---------------|-----------------|------------------------------------------------------------|\n| Llama2-7B     | LoRA            | [forestai/fireact\\_llama\\_2\\_7b\\_lora](https://huggingface.co/forestai/fireact_llama_2_7b_lora)    |\n| Llama2-13B    | LoRA            | [forestai/fireact\\_llama\\_2\\_13b\\_lora](https://huggingface.co/forestai/fireact_llama_2_13b_lora)   |\n| CodeLlama-7B  | LoRA            | [forestai/fireact\\_codellama\\_7b\\_lora](https://huggingface.co/forestai/fireact\\_codellama\\_7b\\_lora)  |\n| CodeLlama-13B | LoRA            | [forestai/fireact\\_codellama\\_13b\\_lora](https://huggingface.co/forestai/fireact\\_codellama\\_13b\\_lora) |\n| CodeLlama-34B | LoRA            | [forestai/fireact\\_codellama\\_34b\\_lora](https://huggingface.co/forestai/fireact\\_codellama\\_34b\\_lora) |\n| Llama2-7B     | Full Model      | [forestai/fireact\\_llama\\_2\\_7b](https://huggingface.co/forestai/fireact_llama_2_7b)         |\n\n\n\n## References\n1. Our generation code is based on [ysymyth/ReAct](https://github.com/ysymyth/ReAct)\n2. Our Llama full model training code is based on [tatsu-lab/stanford_alpaca](https://github.com/tatsu-lab/stanford_alpaca)\n3. Our Llama LoRA training code is based on [tloen/alpaca-lora](https://github.com/tloen/alpaca-lora)\n4. Our GPT fine-tuning code is based on [anchen1011/chatgpt-finetune-ui](https://github.com/anchen1011/chatgpt-finetune-ui/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanchen1011%2Ffireact","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanchen1011%2Ffireact","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanchen1011%2Ffireact/lists"}