{"id":13754198,"url":"https://github.com/aiwaves-cn/RecurrentGPT","last_synced_at":"2025-05-09T22:31:31.110Z","repository":{"id":168321207,"uuid":"644001706","full_name":"aiwaves-cn/RecurrentGPT","owner":"aiwaves-cn","description":"Official Code for Paper: RecurrentGPT: Interactive Generation of (Arbitrarily) Long Text","archived":false,"fork":false,"pushed_at":"2024-05-15T03:35:35.000Z","size":2526,"stargazers_count":992,"open_issues_count":13,"forks_count":157,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-04-09T11:08:53.689Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aiwaves-cn.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-05-22T15:43:19.000Z","updated_at":"2025-04-09T01:43:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"1e9b695c-be01-4396-bb7b-95f832437dc4","html_url":"https://github.com/aiwaves-cn/RecurrentGPT","commit_stats":null,"previous_names":["aiwaves-cn/recurrentgpt"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aiwaves-cn%2FRecurrentGPT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aiwaves-cn%2FRecurrentGPT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aiwaves-cn%2FRecurrentGPT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aiwaves-cn%2FRecurrentGPT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aiwaves-cn","download_url":"https://codeload.github.com/aiwaves-cn/RecurrentGPT/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253335678,"owners_count":21892713,"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":[],"created_at":"2024-08-03T09:01:49.297Z","updated_at":"2025-05-09T22:31:28.830Z","avatar_url":"https://github.com/aiwaves-cn.png","language":"Python","funding_links":[],"categories":["A01_文本生成_文本对话","Python"],"sub_categories":["大语言对话模型及数据"],"readme":"# RecurrentGPT\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://arxiv.org/pdf/2305.13304.pdf\"\u003e[📄 Paper]\u003c/a\u003e | \u003ca href=\"https://www.aiwaves.org/recurrentgpt\"\u003e[🤗 Demo - Writing Assistant]\u003c/a\u003e | \u003ca href=\"https://www.aiwaves.org/interactivefiction\"\u003e[🤗 Demo - Interactive Fiction]\u003c/a\u003e |  \u003ca href=\"https://www.youtube.com/watch?v=rMnw3ljCibc\"\u003e[📺 Video]\u003c/a\u003e | \u003ca href=\"https://discord.gg/aNznfrYPeR\"\u003e[🔥 Discord]\u003c/a\u003e \u003c/p\u003e\n\u003chr\u003e\n\n## Framework Illustration\n\u003cdiv align=center\u003e\n\u003cimg src=\"resources/recurGPT-structure.png\" width = \"640\" alt=\"struct\" align=center /\u003e\n\u003c/div\u003e\n\n\u003e RecurrentGPT replaces the vectorized elements (i.e., cell state, hidden state, input, and output) in a Long-short Term Memory RNN (LSTM) with natural language (i.e., paragraphs of texts), and simulates the recurrence mechanism with prompt engineering. \n\n\u003e At each timestep t, RecurrentGPT receives a paragraph of text and a brief plan of the next paragraph, which are both generated in step t − 1. It then attends to the long-term memory, which contains the summaries of all previously generated paragraphs and can be stored on hard drives, and relevant paragraphs can be retrieved with semantic search.\n\n\u003e RecurrentGPT also maintains a short-term memory that summarizes key information within recent timesteps in natural language and is updated at each time step. RecurrentGPT combines all aforementioned inputs in a prompt and asks the backbone LLM to generate a new paragraph, a short plan for the next paragraph, and updates the long-short term memory by rewriting the short-term memory and appending the summary of the output paragraph to the long-term memory. \n\n### Example\n\u003cdiv align=center\u003e\n\u003cimg src=\"resources/recurGPT-illu.png\" width = \"640\" alt=\"struct\" align=center /\u003e\n\u003c/div\u003e\n\n\n\n## Deployment\nYou can change the configurations given in the `recurrent.sh` script\n```yaml\niteration: 10                       #(int) the number of rounds you would like it to roll.\noutfile: response.txt               #(str) the output file path.\ninit_prompt: init_prompt.json       #(str) the path to the prompt used for initialization.\ntopic: Aliens                       #(str) the topic that you wish your novel is about.\ntype: science-fiction               #(str) the type of novel you would like to write.\n\n```\n\nThen after specify your `OPENAI_API_KEY` in the `recurrent.sh` file, you can run\n```\nsh recurrent.sh\n```\nNOTE: If your local internet is not allowed to access OpenAI's API, you might need to first export your HTTP proxy in the `recurrent.sh` file as well.\n```\nexport http_proxy='your_proxy'\n```\n\n## Showcases\n\n### Prompt Engineering\n\u003cdiv align=center\u003e\n\u003cimg src=\"resources/recurGPT-prompt.png\" width = \"640\" alt=\"struct\" align=center /\u003e\n\u003c/div\u003e\n\n### Iterations\n\n\u003cdiv align=center\u003e\n\u003cimg src=\"resources/recurGPT-case.png\" width = \"640\" alt=\"struct\" align=center /\u003e\n\u003c/div\u003e\n\n\u003e Human writer starts by choosing the topic he/she wants to write and writes a short paragraph describing the background and the outline of the book. Then RECURRENTGPT automatically generates the first paragraphs and provides a few possible options for the writer to continue the story. The writer may select one from them and edit it if needed. He or she can also write a short plan for the next few paragraphs by him/herself if generated plans are all inappropriate, which makes human-AI co-writing process more flexible\n\n## Web demo\nYou can directly use our online demo at:\nhttps://www.aiwaves.org/recurrentgpt  and https://www.aiwaves.org/interactivefiction\n\nOr you can run it on your local machine by editing the OPENAI_API_KEY and OPENAI_Proxy in utils.py and then run:\n```\npython gradio_server.py\n```\n\n![web-demo](resources/web_demo.png)\n\n## Use customized LLMs for local deployment\nPlease refer to https://github.com/jackaduma/Recurrent-LLM to use opensource LLMs for local deployment. Many thanks to @jackaduma \n\n## Citation\n```angular2\n@misc{zhou2023recurrentgpt,\n      title={RecurrentGPT: Interactive Generation of (Arbitrarily) Long Text}, \n      author={Wangchunshu Zhou and Yuchen Eleanor Jiang and Peng Cui and Tiannan Wang and Zhenxin Xiao and Yifan Hou and Ryan Cotterell and Mrinmaya Sachan},\n      year={2023},\n      eprint={2305.13304},\n      archivePrefix={arXiv},\n      primaryClass={cs.CL}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faiwaves-cn%2FRecurrentGPT","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faiwaves-cn%2FRecurrentGPT","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faiwaves-cn%2FRecurrentGPT/lists"}